Menu

#7 Minimal autoconfiscation

open
nobody
None
5
2002-01-19
2002-01-19
Anonymous
No

The ToDo file for Riscose says, "Also, autoconf sounds like a good idea."
Since I've been trying to get Riscose running on NetBSD, I agree.

The attached patch adds minimal autoconfiscation to Riscose, such that it'll
compile on NetBSD (admittedly using GNU Make). There are lots of aspects
that could do with more cleaning up, but it's a start.

Note that the patch also needs src/Makefile and src/rom/Makefile to be removed,
since they're generated by configure, and that the patch doesn't include the
results of running autoconf and autoheader. Oh, and the added files are
included separately because cvs diff -N needs cvs add to work, which it doesn't
for anoncvs users.

Discussion

  • Nobody/Anonymous

    Logged In: NO

    Hrmph. The file attachment doofer didn't work...

    Index: src/kernel/osmisc.c

    RCS file: /cvsroot/riscose/riscose/src/kernel/osmisc.c,v
    retrieving revision 1.5
    diff -u -u -r1.5 osmisc.c
    --- src/kernel/osmisc.c 2001/10/26 22:29:28 1.5
    +++ src/kernel/osmisc.c 2002/01/19 18:16:48
    @@ -12,6 +12,8 @@
    ** $Revision: 1.5 $
    ** $Date: 2001/10/26 22:29:28 $
    */
    +#include "config.h"
    +
    #include <stdio.h>
    #include <stdlib.h>

    @@ -22,7 +24,11 @@
    #include "vdu.h"
    #include "map.h"

    +#ifdef HAVE_READLINE_READLINE_H
    #include <readline/readline.h>
    +#elif defined(HAVE_READLINE_H)
    +#include <readline.h>
    +#endif

    /* FIXME: this should be in a header file, osmodule.h? */
    void osmodule(void);
    Index: src/kernel/vdu.c
    ===================================================================
    RCS file: /cvsroot/riscose/riscose/src/kernel/vdu.c,v
    retrieving revision 1.1
    diff -u -u -r1.1 vdu.c
    --- src/kernel/vdu.c 2001/07/30 22:22:23 1.1
    +++ src/kernel/vdu.c 2002/01/19 18:16:48
    @@ -9,7 +9,7 @@
    */

    #include <stdio.h>
    -#include <ncurses.h>
    +#include <curses.h>

    #include "vdu.h"

    Index: src/modules/SharedCLibrary.c

    RCS file: /cvsroot/riscose/riscose/src/modules/SharedCLibrary.c,v
    retrieving revision 1.9
    diff -u -u -r1.9 SharedCLibrary.c
    --- src/modules/SharedCLibrary.c 2001/12/12 18:59:00 1.9
    +++ src/modules/SharedCLibrary.c 2002/01/19 18:16:49
    @@ -12,6 +12,8 @@
    ** $Revision: 1.9 $
    ** $Date: 2001/12/12 18:59:00 $
    */
    +#include "config.h"
    +
    #include <stdio.h>
    #include <string.h>
    #include <ctype.h>
    @@ -126,6 +128,7 @@
    }
    }

    +#ifdef SIMPLE_VA_LIST
    static
    int countpercents(char *str)
    {
    @@ -167,6 +170,7 @@
    arm_va_list[arg] = 0;
    return arm_va_list;
    }
    +#endif SIMPLE_VA_LIST

    #if defined(NATIVE) && defined(NATIVE_FASTCALL)
    static void
    @@ -255,8 +259,10 @@
    WORD
    swih_sharedclibrary_entry(WORD num)
    {
    +#ifdef SIMPLE_VA_LIST
    char **arm_va_list;
    -
    +#endif
    +
    switch(SWI_NUM(num))
    {

    @@ -482,6 +488,7 @@
    clib_file_real(ARM_R3)));
    return 0;

    +#ifdef SIMPLE_VA_LIST
    case CLIB_CLIB__SPRINTF:
    case CLIB_CLIB_SPRINTF:
    arm_va_list = prepare_arm_va_list(MEM_TOHOST(ARM_R1), 2, 0);
    @@ -527,6 +534,7 @@
    arm_va_list));
    free(arm_va_list);
    return 0;
    +#endif /* SIMPLE_VA_LIST */

    case CLIB_CLIB_FPUTC: /* FIXME: 4-31? */
    ARM_SET_R0(fputc(ARM_R0, clib_file_real(ARM_R1)));
    Index: src/modules/UtilityModule.c
    ===================================================================
    RCS file: /cvsroot/riscose/riscose/src/modules/UtilityModule.c,v
    retrieving revision 1.3
    diff -u -u -r1.3 UtilityModule.c
    --- src/modules/UtilityModule.c 2001/10/25 10:23:26 1.3
    +++ src/modules/UtilityModule.c 2002/01/19 18:16:50
    @@ -10,12 +10,20 @@
    ** $Revision: 1.3 $
    ** $Date: 2001/10/25 10:23:26 $
    */
    +#include "config.h"
    +
    #include <sys/stat.h>
    #include <sys/types.h>
    #include <unistd.h>
    #include <stdio.h>
    +#ifdef HAVE_READLINE_READLINE_H
    #include <readline/readline.h>
    +#elif defined(HAVE_READLINE_H)
    +#include <readline.h>
    +#endif
    +#ifdef HAVE_GDBM_H
    #include <gdbm.h>
    +#endif
    #include <getopt.h>
    #include <stdlib.h>

    @@ -23,11 +31,14 @@
    # define TEMPDIR "/tmp"
    #endif

    +#ifdef HAVE_GDBM_H
    GDBM_FILE cmds;
    +#endif

    void
    cli_init(void)
    {
    +#ifdef HAVE_GDBM_H
    char filename[256] = TEMPDIR;

    sprintf(filename, "%s/riscose.cli.%d", TEMPDIR, getppid());
    @@ -40,6 +51,7 @@
    exit(1);
    }
    unlink(filename);
    +#endif
    }

    void
    --- /dev/null Sat Jan 19 18:05:06 2002
    +++ configure.in Sat Jan 19 17:19:11 2002
    @@ -0,0 +1,37 @@
    +dnl This file is processed by autoconf to produce the configure script.
    +AC_INIT(src/swi.c)
    +AC_CONFIG_HEADER(src/include/config.h)
    +
    +ARM_SELECT=armul
    +AC_ARG_ENABLE(arm,
    +[ --enable-arm=ARM Set the ARM emulation to use. Choose one of armul,
    + sleeve or native [armul]],
    +ARM_SELECT=$enableval)
    +AC_SUBST(ARM_SELECT)
    +dnl checks for programs
    +AC_CHECK_PROGS(PERL, perl, no)
    +
    +dnl checks for libraries
    +AC_SEARCH_LIBS(initscr, ncurses curses)
    +AC_SEARCH_LIBS(readline, readline edit)
    +
    +dnl checks for header files
    +AC_CHECK_HEADERS(readline/readline.h readline.h gdbm.h)
    +
    +dnl checks for typedefs
    +dnl checks for structures
    +
    +AC_CACHE_CHECK([whether va_list is char **], riscose_cv_type_simple_va_list,
    + [AC_TRY_COMPILE([#include <stdio.h>],
    + [char **arm_va_list; vprintf("", arm_va_list);],
    + riscose_cv_type_simple_va_list=yes,
    + riscose_cv_type_simple_va_list=no)
    + ])
    +if test "$riscose_cv_type_simple_va_list" = yes; then
    + AC_DEFINE(SIMPLE_VA_LIST)
    +fi
    +
    +dnl checks for compiler characteristics
    +dnl checks for library functions
    +dnl checks for system services
    +AC_OUTPUT(Makefile src/Makefile src/rom/Makefile)
    --- /dev/null Sat Jan 19 18:05:06 2002
    +++ Makefile.in Sat Jan 19 16:20:02 2002
    @@ -0,0 +1,6 @@
    +
    +all:
    + cd src && $(MAKE) all
    +
    +clean:
    + cd src && $(MAKE) clean
    --- /dev/null Sat Jan 19 18:05:06 2002
    +++ acconfig.h Sat Jan 19 16:57:51 2002
    @@ -0,0 +1,2 @@
    +/* Define if it's safe to treat a char ** as a va_list */
    +#undef SIMPLE_VA_LIST
    --- /dev/null Sat Jan 19 18:05:06 2002
    +++ src/Makefile.in Sat Jan 19 17:14:29 2002
    @@ -0,0 +1,99 @@
    +#! /bin/make -f
    +
    + ############################
    + ######## Riscose Makefile ########
    + ############################
    +
    +######## Feature switches
    +
    +# One-to-one memory mapping?
    +#DEFS += -DCONFIG_MEM_ONE2ONE
    +
    +# Which ARM to use? Either armul, sleeve or native.
    +ARM_SELECT = @ARM_SELECT@
    +
    +# Which traces to turn on? (debugging use only)
    +#DEFS += -DCONFIG_TRACE_INSTRUCTIONS
    +#DEFS += -DCONFIG_TRACE_SWIS
    +#DEFS += -DCONFIG_TRACE_BRANCHES
    +#DEFS += -DCONFIG_TRACE_HEAP
    +
    +######## Code / environment switches
    +
    +include $(ARM_SELECT)/Make-defs
    +
    +SRCDIR = $(CURDIR)
    +CC = gcc
    +CFLAGS = -O2 -g3 -Wall \ + -I$(SRCDIR) -I$(SRCDIR)/include -I$(SRCDIR)/$(ARM_SELECT) $(DEFS)
    +LDFLAGS = @LIBS@
    +PREFIX = /usr/local
    +
    +######## Everything else
    +
    +export CC CFLAGS SRCDIR LDFLAGS
    +
    +CORE = heap.o mem.o swi.o swichunk.o util.o
    +
    +OBJS = $(CORE) modules/libmodules.a kernel/libkernel.a \ + $(ARM_SELECT)/lib$(ARM_SELECT).a monty/libmonty.a
    +
    +%.o: %.c mem.h arm.h
    + $(CC) $(CFLAGS) -c -o $@ $<
    +
    +# ----------------------------------------------------------------------
    +
    +all: subs riscose heaptest
    +
    +# ----------------------------------------------------------------------
    +
    +subs:
    + cd monty && $(MAKE)
    + cd rom && $(MAKE)
    + cd kernel && $(MAKE)
    + cd modules && $(MAKE)
    + cd $(ARM_SELECT) && $(MAKE)
    +
    +clean::
    + cd monty && $(MAKE) $@
    + cd rom && $(MAKE) $@
    + cd kernel && $(MAKE) $@
    + cd modules && $(MAKE) $@
    + cd $(ARM_SELECT) && $(MAKE) $@
    +
    +# ----------------------------------------------------------------------
    +
    +riscose: main.o $(OBJS)
    + $(CC) -o $@ main.o $(OBJS) $(LDFLAGS) $(EXTRA_LDFLAGS)
    +
    +clean::
    + rm -f $(CORE)
    + rm -f riscose main.o
    +
    +# ----------------------------------------------------------------------
    +
    +# FIXME: produce a new swichunk.c only if it would be different to the
    +# existing one. this stops swichunk.o being rebuilt and riscose being
    +# re-linked. a `make' following a `make' shouldn't really do anything.
    +swichunk.c::
    + ./mkswichunk.sh
    +
    +clean::
    + rm -f swichunk.c
    +
    +# ----------------------------------------------------------------------
    +
    +heaptest: heaptest.o $(OBJS)
    + $(CC) -o $@ heaptest.o $(OBJS) $(LDFLAGS)
    +
    +clean::
    + rm -f heaptest heaptest.o
    +
    +######## Utility targets
    +
    +# So you can run RISC OS binaries as if they're native
    +
    +# FIXME: not useful unless you're mattbee.
    +
    +binfmt:
    + echo ':riscos_aif:M:16:\x11\x00\x00\xEF::/home/mattbee/Projects/riscose/riscose/src/riscose:' >/proc/sys/fs/binfmt_misc/register
    --- /dev/null Sat Jan 19 18:05:06 2002
    +++ src/rom/Makefile.in Sat Jan 19 16:21:16 2002
    @@ -0,0 +1,11 @@
    +#! /bin/make -f
    +
    +PERL=@PERL@
    +
    +all: ROMimage rom.h
    +
    +ROMimage rom.h: error.list
    + $(PERL) compilerom.pl
    +
    +clean::
    + rm -f ROMimage rom.h

     
  • Nobody/Anonymous

    Logged In: NO

    Hrmph. Getting the actual patch attached is difficult.
    <URL:http://www.chiark.greenend.org.uk/~bjharris/autoconf.patch>, for a
    limited period only.

     

Log in to post a comment.