--- trunk/configure 2007/10/08 16:19:37 22 +++ trunk/configure 2007/10/08 16:21:17 34 @@ -1,7 +1,7 @@ #!/bin/sh ############################################################################### # -# Copyright (C) 2003-2006 Anders Gavare. All rights reserved. +# Copyright (C) 2003-2007 Anders Gavare. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -27,7 +27,7 @@ # SUCH DAMAGE. # # -# $Id: configure,v 1.198 2006/02/18 13:15:20 debug Exp $ +# $Id: configure,v 1.243 2007/02/10 14:29:54 debug Exp $ # # This is a minimal configure script, hardcoded for GXemul. This script # figures out which compiler flags will work, and creates Makefiles in @@ -47,11 +47,14 @@ # o) special hacks for some OSes # o) which compiler to use (overridden by setting CC) # o) which compiler flags to use (overridden by setting CFLAGS) -# o) X11 flags and libraries (TODO: should be possible to override) -# o) binary translation (on supported platforms) +# o) X11 flags and libraries (TODO: should be possible to override +# via command line options?) +# o) native code generation backend (i.e. detect host architecture) # -# TODO: -# o) X11 libs and includes via command line options? +# +# The general philosophy regarding command line switches is that anything +# which can be incorporated into the program as a runtime command line option +# should be, instead of requiring a recompile. # ############################################################################### @@ -59,30 +62,28 @@ X=`basename \`pwd\`|cut -d \- -f 2-|cut -c1-2` if [ z"$X" = z0. ]; then # Stable: + ENABLEALPHA=YES ENABLEARM=YES ENABLEMIPS=YES ENABLEPPC=YES + ENABLESH=YES else # Development: UNSTABLE=YES - DYNTRANSBACKEND=NO #YES ENABLEALPHA=YES ENABLEARM=YES ENABLEAVR=YES - ENABLEHPPA=YES - ENABLEI960=YES - ENABLEIA64=YES ENABLEM68K=YES ENABLEMIPS=YES - NEWMIPS=NO ENABLEPPC=YES + ENABLERCA180X=YES ENABLESH=YES ENABLESPARC=YES - ENABLEX86=YES + ENABLETRANSPUTER=YES fi if [ z"$UNSTABLE" = zYES ]; then - printf "### DEVELOPMENT (UNSTABLE)\n\n" + printf "###\n### DEVELOPMENT (UNSTABLE)\n###\n\n" fi if [ z"$*" != z ]; then @@ -90,81 +91,17 @@ for a in $*; do if [ z$a = z--disable-x ]; then NOX11=YES - else if [ z$a = z--always32 ]; then - ALWAYS32=YES - else if [ z$a = z--tracenull ]; then - TRACENULL=YES - else if [ z$a = z--disable-bintrans ]; then - NOBINTRANS=YES - else if [ z$a = z--enable-bintrans ]; then - NOBINTRANS=NO - else if [ z$a = z--disable-mips16 ]; then - MIPS16=NO - else if [ z$a = z--enable-mips16 ]; then - MIPS16=YES - else if [ z$a = z--disable-dyntransbackend ]; then - DYNTRANSBACKEND=NO - else if [ z$a = z--enable-dyntransbackend ]; then - DYNTRANSBACKEND=YES - else if [ z$a = z--disable-delays ]; then - DELAYS=NO - else if [ z$a = z--enable-delays ]; then - DELAYS=YES - else if [ z$a = z--disable-caches ]; then - CACHES=NO - else if [ z$a = z--enable-caches ]; then - CACHES=YES - else if [ z$a = z--disable-newmips ]; then - NEWMIPS=NO - else if [ z$a = z--enable-newmips ]; then - NEWMIPS=YES - else if [ z$a = z--disable-1k-pages ]; then - ONEKPAGE=NO - else if [ z$a = z--enable-1k-pages ]; then - ONEKPAGE=YES else if [ z$a = z--help ]; then - echo "usage: $0 [options]" - - printf "\nGeneral options:\n\n" - - echo " --disable-bintrans configure without the" \ - "old binary translation subsystem," - echo " even if the host" \ - "supports it" - echo " --disable-x don't include X11 support" - - printf "\nDevelopment (debug) options:\n\n" - - echo " --always32 enable ALWAYS_SIGNEXTEND_32"\ - "(for hunting down 32-bit bugs)" - printf " --enable-caches enable cache emulation" - printf " (BUGGY)\n" - echo " --enable-delays enable instruction" \ - "latency/delay emulation" - - if [ z$DYNTRANSBACKEND = zYES ]; then - printf " --disable-dyntransbackend disable " - else - printf " --enable-dyntransbackend enable" - fi - printf "dyntrans backend\n" - - echo " --enable-mips16 enable MIPS16 support" - echo " --enable-newmips use new MIPS dyntrans code" - #printf " --enable-1k-pages allow 1KB dyntrans pages" - #printf " (default: 4KB)\n" - - printf "\n(Pretty much all of these options are only" - printf " meaningful during the development of\nthe" - printf " emulator, and should not be used when " - printf "compiling a stable version.)\n" + printf "usage: $0 [options]\n\n" + echo " --disable-x don't include X11 support,"\ + "even if the host supports it" + echo exit else echo "Invalid option: $a" echo "Run $0 --help to get a list of" \ "available options." exit - fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi fi; fi done fi @@ -195,20 +132,20 @@ fi +if [ z"$UNSTABLE" = zYES ]; then + printf "#define UNSTABLE_DEVEL\n" >> config.h +fi + + ZZ=`echo compiled on \`uname\`/\`uname -m\`, \`date\`` printf "#define COMPILE_DATE \"$ZZ\"\n" >> config.h # Support for various CPU types: -if [ z$MIPS16 = zYES ]; then - printf 'Enabling MIPS16 support. ' - printf 'NOTE: MIPS16 support is not really working yet.\n' - printf "#define ENABLE_MIPS16\n" >> config.h -fi if [ z$ENABLEALPHA = zYES ]; then printf "#define ENABLE_ALPHA\n" >> config.h - CPU_ARCHS="$CPU_ARCHS cpu_alpha.o cpu_alpha_palcode.o" + CPU_ARCHS="$CPU_ARCHS cpu_alpha.o cpu_alpha_palcode.o memory_alpha.o" CPU_TOOLS="$CPU_TOOLS generate_alpha_misc" fi if [ z$ENABLEARM = zYES ]; then @@ -230,87 +167,38 @@ printf "#define ENABLE_AVR\n" >> config.h CPU_ARCHS="$CPU_ARCHS cpu_avr.o" fi -if [ z$ENABLEHPPA = zYES ]; then - printf "#define ENABLE_HPPA\n" >> config.h - CPU_ARCHS="$CPU_ARCHS cpu_hppa.o" -fi -if [ z$ENABLEI960 = zYES ]; then - printf "#define ENABLE_I960\n" >> config.h - CPU_ARCHS="$CPU_ARCHS cpu_i960.o" -fi -if [ z$ENABLEIA64 = zYES ]; then - printf "#define ENABLE_IA64\n" >> config.h - CPU_ARCHS="$CPU_ARCHS cpu_ia64.o" -fi if [ z$ENABLEM68K = zYES ]; then printf "#define ENABLE_M68K\n" >> config.h CPU_ARCHS="$CPU_ARCHS cpu_m68k.o" fi if [ z$ENABLEMIPS = zYES ]; then printf "#define ENABLE_MIPS\n" >> config.h - if [ z$NEWMIPS = zYES ]; then - echo 'Enabling the _EXPERIMENTAL_ MIPS dyntrans code.' - printf "#define EXPERIMENTAL_NEWMIPS\n" >> config.h - fi + CPU_ARCHS="$CPU_ARCHS cpu_mips.o cpu_mips_coproc.o " + CPU_ARCHS="$CPU_ARCHS cpu_mips_instr_unaligned.o" + CPU_TOOLS="$CPU_TOOLS generate_mips_loadstore" + CPU_TOOLS="$CPU_TOOLS generate_mips_loadstore_multi" fi if [ z$ENABLEPPC = zYES ]; then printf "#define ENABLE_PPC\n" >> config.h CPU_ARCHS="$CPU_ARCHS cpu_ppc.o" CPU_TOOLS="$CPU_TOOLS generate_ppc_loadstore" fi +if [ z$ENABLERCA180X = zYES ]; then + printf "#define ENABLE_RCA180X\n" >> config.h + CPU_ARCHS="$CPU_ARCHS cpu_rca180x.o" +fi if [ z$ENABLESH = zYES ]; then printf "#define ENABLE_SH\n" >> config.h - CPU_ARCHS="$CPU_ARCHS cpu_sh.o" + CPU_ARCHS="$CPU_ARCHS cpu_sh.o memory_sh.o" fi if [ z$ENABLESPARC = zYES ]; then printf "#define ENABLE_SPARC\n" >> config.h - CPU_ARCHS="$CPU_ARCHS cpu_sparc.o" -fi -if [ z$ENABLEX86 = zYES ]; then - printf "#define ENABLE_X86\n" >> config.h - CPU_ARCHS="$CPU_ARCHS cpu_x86.o" -fi - - -# Instruction delay/latency emulation: -if [ z$DELAYS = zYES ]; then - echo 'Enabling Instruction delay/latency emulation.' - printf "#define ENABLE_INSTRUCTION_DELAYS\n" >> config.h + CPU_ARCHS="$CPU_ARCHS cpu_sparc.o memory_sparc.o" + CPU_TOOLS="$CPU_TOOLS generate_sparc_loadstore" fi - - -# Development option: ALWAYS_SIGNEXTEND_32 -if [ z$ALWAYS32 = zYES ]; then - echo 'Enabling ALWAYS_SIGNEXTEND_32. (NOTE:' \ - 'This slows down everything.)' - printf "#define ALWAYS_SIGNEXTEND_32\n" >> config.h -fi - - -# 1KB page emulation: -if [ z$ONEKPAGE = zYES ]; then - echo '1 KB pages: not yet.' - exit - echo 'Enabling 1 KB page dyntrans support. (NOTE:' \ - 'This slows down everything.)' - printf "#define ONEKPAGE\n" >> config.h -fi - - -# Cache emulation: -if [ z$CACHES = zYES ]; then - echo 'Enabling Cache emulation. (EXPERIMENTAL and BUGGY)' - printf "#define ENABLE_CACHE_EMULATION\n" >> config.h - - if [ z$DELAYS != zYES ]; then - printf 'WARNING: Cache emulation without instruction ' - printf 'delay/latency emulation\n' - printf ' (--delays) will not produce correct ' - printf 'cache miss penalties and such.\n' - fi - - printf "\nNOTE: Cache emulation enabled, but right now it triggers " - printf "weird bugs in the\n emulator. You have been warned.\n\n" +if [ z$ENABLETRANSPUTER = zYES ]; then + printf "#define ENABLE_TRANSPUTER\n" >> config.h + CPU_ARCHS="$CPU_ARCHS cpu_transputer.o" fi @@ -458,6 +346,17 @@ rm -f _test_x11 _test_x11.o + # Special case for some 64-bit Linux/x86_64 systems: + if [ z$XOK = z0 ]; then + XLIB="-L/usr/X11R6/lib64 -lX11" + $CC $CFLAGS _test_x11.o -o _test_x11 $XLIB 2> /dev/null + + if [ -x _test_x11 ]; then + XOK=1 + fi + fi + rm -f _test_x11 _test_x11.o + if [ z$XOK = z0 ]; then XINCLUDE="" $CC $CFLAGS _test_x11.c -c -o _test_x11.o \ @@ -774,21 +673,23 @@ rm -f _testprog _testprog.error _testprog.stdout -# -g -printf "checking whether -g can be used... " -if [ z"$COMPAQCC" = zYES ]; then - printf "skipping\n" -else - $CC $CFLAGS -g _testprog.c -o _testprog > _testprog.stdout 2>&1 - cat _testprog.stdout >> _testprog.error - if [ -x _testprog ]; then - CFLAGS="-g $CFLAGS" - printf "yes\n" +# -g, for development builds +if [ z"$UNSTABLE" = zYES ]; then + printf "checking whether -g can be used... " + if [ z"$COMPAQCC" = zYES ]; then + printf "skipping\n" else + $CC $CFLAGS -g _testprog.c -o _testprog > _testprog.stdout 2>&1 + cat _testprog.stdout >> _testprog.error + if [ -x _testprog ]; then + CFLAGS="-g $CFLAGS" + printf "yes\n" + else printf "no\n" + fi fi + rm -f _testprog _testprog.error _testprog.stdout fi -rm -f _testprog _testprog.error _testprog.stdout # -lrt for nanosleep? @@ -925,12 +826,20 @@ #include #include int main(int argc, char *argv[]) { fseeko(NULL, 0, 0); return 0;}\n" > _tests.c -$CC $CFLAGS _tests.c -o _tests 2> /dev/null +$CC $CFLAGS $CWARNINGS _tests.c -o _tests 2> /dev/null if [ ! -x _tests ]; then - printf "missing\n" - printf "WARNING! fseeko missing from libc. Using a hack, " - printf "which probably doesn't work.\n" - printf "#define HACK_FSEEKO\n" >> config.h + # Try with _LARGEFILE_SOURCE (hack to make fseeko + # work on 64-bit Linux): + $CC $CFLAGS -D_LARGEFILE_SOURCE $CWARNINGS _tests.c -o _tests 2> /dev/null + if [ ! -x _tests ]; then + printf "missing\n" + printf "WARNING! fseeko missing from libc. Using a hack, " + printf "which probably doesn't work.\n" + printf "#define HACK_FSEEKO\n" >> config.h + else + printf "using -D_LARGEFILE_SOURCE hack\n" + CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE" + fi else printf "found\n" fi @@ -987,6 +896,47 @@ rm -f _tests.[co] _tests +# Check for PRIx64 in inttypes.h: +printf "checking for PRIx64 in inttypes.h... " +printf "#include \nint main(int argc, char *argv[])\n +{\n#ifdef PRIx64\nreturn 0;\n#else\nreturn 1;\n#endif\n}\n" > _testpri.c +$CC $CFLAGS _testpri.c -o _testpri 2> /dev/null +if [ ! -x _testpri ]; then + printf "\nERROR! COULD NOT COMPILE PRIx64 TEST PROGRAM AT ALL!\n" + exit +else + if ./_testpri; then + printf "yes\n" + else + printf "no, using an ugly hack instead, " + printf "#define NO_C99_PRINTF_DEFINES\n" >> config.h + + # Try llx first: + printf "#include \n#include \nint main(int argc, char *argv[]){ + printf(\"%%llx\\\n\", (int64_t)128);return 0;}\n" > _testpri.c + rm -f _testpri + $CC $CFLAGS $CWARNINGS _testpri.c -o _testpri 2> /dev/null + if [ z`./_testpri` = z80 ]; then + printf "PRIx64=llx\n" + printf "#define NO_C99_64BIT_LONGLONG\n" >> config.h + else + # Try lx too: + printf "#include \n#include \nint main(int argc, char *argv[]){ + printf(\"%%lx\\\n\", (int64_t)128);return 0;}\n" > _testpri.c + rm -f _testpri + $CC $CFLAGS $CWARNINGS _testpri.c -o _testpri 2> /dev/null + if [ z`./_testpri` = z80 ]; then + printf "PRIx64=lx\n" + else + printf "\nFailed, neither lx nor llx worked!\n" + exit + fi + fi + fi +fi +rm -f _testpri.c _testpri + + # Check for 64-bit off_t: printf "checking for 64-bit off_t... " printf "#include \n#include \n#include \n @@ -1078,127 +1028,6 @@ ############################################################################### -# -# OLD binary translation (BINTRANS): -# -############################################################################### - -printf "checking for bintrans backend... " - -BINTRANS=NO - -if [ z$ENABLEMIPS = zNO ]; then - printf "NO!\nTEMPORARY HACK/PROBLEM: Disabling bintrans for now,\n" - printf "until things have stabilized.\n" - NOBINTRANS=YES -fi - -if [ z$NOBINTRANS = zYES ]; then - printf "disabled\n" -else - # Alpha: - if [ z"`uname -m`" = zalpha ]; then - printf "#define ALPHA\n" >> config.h - printf "#define BINTRANS\n" >> config.h - printf "Alpha\n" - BINTRANS=YES - fi - - # x86: - if `uname -m|grep -v 64|grep -q 86`; then - printf "#define I386\n" >> config.h - printf "#define BINTRANS\n" >> config.h - printf "i386\n" - BINTRANS=YES - fi - -# MIPS not yet -# # MIPS: -# if [ z"`uname -m`" = zmips ]; then -# printf "#define MIPS\n" >> config.h -# printf "#define BINTRANS\n" >> config.h -# printf "MIPS\n" -# BINTRANS=YES -# fi - -# # UltraSPARC: -# if [ z"`uname -m`" = zsun4u ]; then -# printf "#define SPARCV9\n" >> config.h -# printf "#define BINTRANS\n" >> config.h -# printf "SPARC V9\n" -# BINTRANS=YES -# else -# if [ z"`uname -m`" = zsparc64 ]; then -# printf "#define SPARCV9\n" >> config.h -# printf "#define BINTRANS\n" >> config.h -# printf "SPARC V9\n" -# BINTRANS=YES -# fi -# fi - - if [ z$BINTRANS = zNO ]; then - printf "not supported yet on this arch\n" - fi -fi - - -############################################################################### -# -# Dyntrans recompilation (native backend) support: -# -############################################################################### - -if [ z$DYNTRANSBACKEND = zYES ]; then - printf "Dyntrans: Not yet.\n" - exit - - printf "checking for dyntrans backend... " - DBFOUND=NO - - # Alpha: - if [ z"`uname -m`" = zalpha ]; then - printf "#define DYNTRANS_BACKEND_ALPHA\n" >> config.h - printf "Alpha\n" - CPU_BACKENDS="$CPU_BACKENDS backend_alpha.o" - DBFOUND=YES - fi - - # AMD64: - # TODO - -# # UltraSPARC: -# if [ z"`uname -m`" = zsun4u ]; then -# printf "#define DYNTRANS_BACKEND_SPARC64\n" >> config.h -# printf "UltraSPARC\n" -# CPU_BACKENDS="$CPU_BACKENDS backend_sparc.o" -# DBFOUND=YES -# fi -# if [ z"`uname -m`" = zsparc64 ]; then -# printf "#define DYNTRANS_BACKEND_SPARC64\n" >> config.h -# printf "UltraSPARC\n" -# CPU_BACKENDS="$CPU_BACKENDS backend_sparc.o" -# DBFOUND=YES -# fi - - # x86: - if `uname -m|grep -q -v 64|grep -q 86`; then - printf "#define DYNTRANS_BACKEND_I386\n" >> config.h - printf "i386\n" - CPU_BACKENDS="$CPU_BACKENDS backend_i386.o" - DBFOUND=YES - fi - - if [ z$DBFOUND = zYES ]; then - printf "#define DYNTRANS_BACKEND\n" >> config.h - else - printf "not supported yet on this arch (" - printf `uname -m` - printf ")\n" - fi -fi - - -############################################################################### # Host byte order? printf "checking host endianness... " @@ -1223,6 +1052,36 @@ fi rm -f _test_end* + +############################################################################### +# +# Native code generation backend: (Detect host architecture.) +# +############################################################################### + +if [ z$UNSTABLE = zYES ]; then + printf "native code generation backend... " + + if [ z"`uname -m`" = zamd64 ]; then + NATIVE_CODE_GENERATION=YES + printf "amd64\n" + printf "#define NATIVE_CODE_GENERATION\n" >> config.h + printf "#define HOST_ARCH_AMD64\n" >> config.h + fi + + if [ z"`uname -m`" = zx86_64 ]; then + NATIVE_CODE_GENERATION=YES + printf "amd64\n" + printf "#define NATIVE_CODE_GENERATION\n" >> config.h + printf "#define HOST_ARCH_AMD64\n" >> config.h + fi + + if [ z$NATIVE_CODE_GENERATION = z ]; then + printf "not yet for this host platform\n" + fi +fi + + ############################################################################### INCLUDE=-Iinclude/ @@ -1239,14 +1098,13 @@ echo "CC=$CC" >> _Makefile.header echo "OTHERLIBS=$OTHERLIBS" >> _Makefile.header echo "CPU_ARCHS=$CPU_ARCHS" >> _Makefile.header -echo "CPU_BACKENDS=$CPU_BACKENDS" >> _Makefile.header echo "CPU_TOOLS=$CPU_TOOLS" >> _Makefile.header echo "" >> _Makefile.header # Create the Makefiles: -D=". src src/include src/cpus src/devices src/devices/fonts" -D="$D src/machines src/promemul" +D=". src src/include src/cpus src/debugger src/devices src/devices/fonts" +D="$D src/machines src/native src/net src/promemul" for a in $D; do echo "creating $a/Makefile" touch $a/Makefile