--- trunk/configure 2007/10/08 16:18:00 4 +++ trunk/configure 2007/10/08 16:21:53 38 @@ -1,7 +1,7 @@ #!/bin/sh ############################################################################### # -# Copyright (C) 2003-2005 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.123 2005/04/17 01:42:21 debug Exp $ +# $Id: configure,v 1.252 2007/04/10 17:52:27 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,88 +47,71 @@ # 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) prefetch capability (TODO: this is assumed on Alpha, but not all -# Alphas have it...) +# o) X11 flags and libraries (TODO: should be possible to override +# via command line options?) +# o) native code generation backend (i.e. detect host ABI) +# +# +# 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. # ############################################################################### -ENABLEALPHA=NO -ENABLEHPPA=NO -ENABLEMIPS=YES -ENABLEPPC=YES -ENABLESPARC=NO -ENABLEURISC=YES -ENABLEX86=NO +# Figure out if this is a stable version (0.x.x). +X=`basename \`pwd\`|cut -d \- -f 2-|cut -c1-2` +if [ z"$X" = z0. ]; then + # Stable. + : +else + # Development. + UNSTABLE=YES +fi if [ z"$*" != z ]; then # Parse command line options: 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--disable-bintrans ]; then - NOBINTRANS=YES - else if [ z$a = z--enable-mips16 ]; then - MIPS16=YES - else if [ z$a = z--enable-alpha ]; then - ENABLEALPHA=YES - else if [ z$a = z--enable-hppa ]; then - ENABLEHPPA=YES - else if [ z$a = z--disable-mips ]; then - ENABLEMIPS=NO - else if [ z$a = z--disable-ppc ]; then - ENABLEPPC=NO - else if [ z$a = z--enable-sparc ]; then - ENABLESPARC=YES - else if [ z$a = z--disable-urisc ]; then - ENABLEURISC=NO - else if [ z$a = z--enable-x86 ]; then - ENABLEX86=YES - else if [ z$a = z--enable-delays ]; then - DELAYS=YES - else if [ z$a = z--enable-caches ]; then - CACHES=YES + else if [ z$a = z--debug ]; then + DEBUG=YES else if [ z$a = z--help ]; then - echo "usage: $0 [options]" - printf "\nDevelopment (debug) options:\n" - echo " --always32 enable" \ - "ALWAYS_SIGNEXTEND_32 (for hunting down" - echo " 32/64-bit bugs)" - printf "\nGeneral options:\n" - echo " --disable-bintrans configure without" \ - "bintrans, even if the host supports it" - echo " --enable-caches enable cache emulation" \ - "(experimental)" - echo " --enable-delays enable instruction" \ - "latency/delay emulation" - echo " --disable-x don't include X11 support" - printf "\nCPU selection options: (most of these" - printf " are experimental)\n" - echo " --enable-alpha enable Alpha CPU emulation" - echo " --enable-hppa enable HPPA CPU emulation" - echo " --disable-mips disable MIPS CPU emulation" - echo " --disable-ppc disable PPC CPU emulation" - echo " --enable-sparc enable SPARC CPU emulation" - echo " --disable-urisc disable URISC CPU emulation" - echo " --enable-x86 enable x86 CPU emulation" - printf "\nMIPS-specific options:\n" - echo " --enable-mips16 enable MIPS16 instruction" \ - "support (experimental)" - printf "\n" + printf "usage: $0 [options]\n\n" + echo " --disable-x don't include X11 support,"\ + "even if the host supports it" + if [ z"$UNSTABLE" = zYES ]; then + echo " --debug configure" \ + "for a debug build" + fi + 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 done fi +# Stable releases: +ENABLEARM=YES +ENABLEMIPS=YES +ENABLEPPC=YES +ENABLESH=YES + +if [ z"$UNSTABLE" = zYES ]; then + # Development: + printf "###\n### DEVELOPMENT (UNSTABLE)\n###\n### " + printf "(Enabling some archs that are not working yet.)\n###\n\n" + ENABLEALPHA=YES + ENABLEAVR=YES + ENABLEM68K=YES + ENABLESPARC=YES +fi + + ############################################################################### # # Configure options: @@ -148,72 +131,71 @@ # Figure out if VERSION should be defined. X=`basename \`pwd\`|cut -d \- -f 2-` if [ z"$X" = zgxemul ]; then - echo '# No VERSION defined.' >> _Makefile.header + echo '/* No VERSION defined. */' >> config.h else printf "#define VERSION \"$X\"\n" >> config.h 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 memory_alpha.o" + CPU_TOOLS="$CPU_TOOLS generate_alpha_misc" fi -if [ z$ENABLEHPPA = zYES ]; then - printf "#define ENABLE_HPPA\n" >> config.h +if [ z$ENABLEARM = zYES ]; then + printf "#define ENABLE_ARM\n" >> config.h + CPU_ARCHS="$CPU_ARCHS cpu_arm.o cpu_arm_coproc.o memory_arm.o " + CPU_ARCHS="$CPU_ARCHS tmp_arm_dpi.o tmp_arm_loadstore.o tmp_arm_r.o" + CPU_ARCHS="$CPU_ARCHS tmp_arm_r0.o tmp_arm_r1.o" + CPU_ARCHS="$CPU_ARCHS tmp_arm_r2.o tmp_arm_r3.o" + CPU_ARCHS="$CPU_ARCHS tmp_arm_r4.o tmp_arm_r5.o" + CPU_ARCHS="$CPU_ARCHS tmp_arm_r6.o tmp_arm_r7.o" + CPU_ARCHS="$CPU_ARCHS tmp_arm_r8.o tmp_arm_r9.o" + CPU_ARCHS="$CPU_ARCHS tmp_arm_ra.o tmp_arm_rb.o" + CPU_ARCHS="$CPU_ARCHS tmp_arm_rc.o tmp_arm_rd.o" + CPU_ARCHS="$CPU_ARCHS tmp_arm_re.o tmp_arm_rf.o tmp_arm_multi.o" + CPU_TOOLS="$CPU_TOOLS generate_arm_dpi generate_arm_r" + CPU_TOOLS="$CPU_TOOLS generate_arm_loadstore generate_arm_multi" +fi +if [ z$ENABLEAVR = zYES ]; then + printf "#define ENABLE_AVR\n" >> config.h + CPU_ARCHS="$CPU_ARCHS cpu_avr.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 + 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$ENABLESH = zYES ]; then + printf "#define ENABLE_SH\n" >> config.h + CPU_ARCHS="$CPU_ARCHS cpu_sh.o memory_sh.o" fi if [ z$ENABLESPARC = zYES ]; then printf "#define ENABLE_SPARC\n" >> config.h -fi -if [ z$ENABLEURISC = zYES ]; then - printf "#define ENABLE_URISC\n" >> config.h -fi -if [ z$ENABLEX86 = zYES ]; then - printf "#define ENABLE_X86\n" >> config.h -fi - - -# Instruction delay/latency emulation: -if [ z$DELAYS = zYES ]; then - echo 'Enabling Instruction delay/latency emulation.' - printf "#define ENABLE_INSTRUCTION_DELAYS\n" >> config.h -fi - - -# Instruction delay/latency emulation: -if [ z$ALWAYS32 = zYES ]; then - echo 'Enabling ALWAYS_SIGNEXTEND_32. (NOTE:' \ - 'This slows down everything.)' - printf "#define ALWAYS_SIGNEXTEND_32\n" >> config.h -fi - - -# Cache emulation: -if [ z$CACHES = zYES ]; then - echo 'Enabling Cache emulation. (EXPERIMENTAL)' - 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 + CPU_ARCHS="$CPU_ARCHS cpu_sparc.o memory_sparc.o" + CPU_TOOLS="$CPU_TOOLS generate_sparc_loadstore" fi @@ -291,15 +273,15 @@ fi rm -f _testprog - # Try ccc (FreeBSD/Alpha): - printf "#!/bin/sh\nccc _testprog.c -o _testprog >" > _test.sh - printf " /dev/null 2> /dev/null\n" >> _test.sh - chmod 755 _test.sh - ./_test.sh > /dev/null 2> /dev/null - if [ -x _testprog ]; then - CC="ccc" - fi - rm -f _testprog +# # Try ccc (FreeBSD/Alpha): +# printf "#!/bin/sh\nccc _testprog.c -o _testprog >" > _test.sh +# printf " /dev/null 2> /dev/null\n" >> _test.sh +# chmod 755 _test.sh +# ./_test.sh > /dev/null 2> /dev/null +# if [ -x _testprog ]; then +# CC="ccc" +# fi +# rm -f _testprog rm -f _test.sh fi @@ -361,6 +343,20 @@ rm -f _test_x11 _test_x11.o + # Special case for some 64-bit Linux/x86_64 systems: + if [ z$XOK = z0 ]; then + $CC $CFLAGS _test_x11.c -c -o _test_x11.o \ + $XINCLUDE 2> /dev/null + + 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 \ @@ -414,8 +410,8 @@ fi -# Check for weird 'alpha' define. -printf "checking for weird 'alpha' define... " +# Check for 'alpha' define. +printf "checking for 'alpha' define... " printf "#include \nint main(int argc, char *argv[]){ #ifdef alpha printf(\"1\"); @@ -445,39 +441,8 @@ rm -f _testm* -# Check for weird 'hppa' define. -printf "checking for weird 'hppa' define... " -printf "#include \nint main(int argc, char *argv[]){ -#ifdef hppa -printf(\"1\"); -#undef hppa -#ifdef hppa -printf(\"2\"); -#endif -#endif -printf(\"\\\n\");return 0;}\n" > _testm.c -$CC $CFLAGS _testm.c -o _testm 2> /dev/null -if [ ! -x _testm ]; then - printf "\nWARNING! COULD NOT COMPILE hppa define TEST" - printf " PROGRAM AT ALL!\n" -else - if [ z`./_testm` = z1 ]; then - printf "yes, workaround applied\n" - echo "#undef hppa" >> config.h - else - if [ z`./_testm` = z12 ]; then - printf "yes, but workaround not possible\n" - exit - else - printf "no\n" - fi - fi -fi -rm -f _testm* - - # Some OSes on MIPS seems to define 'mips' to 1. (eg OpenBSD/arc) -printf "checking for weird 'mips' define... " +printf "checking for 'mips' define... " printf "#include \nint main(int argc, char *argv[]){ #ifdef mips printf(\"1\"); @@ -509,7 +474,7 @@ # Similar to the mips define check above, although I don't know if # any OS actually defined ppc like this. -printf "checking for weird 'ppc' define... " +printf "checking for 'ppc' define... " printf "#include \nint main(int argc, char *argv[]){ #ifdef ppc printf(\"1\"); @@ -541,7 +506,7 @@ # Similar to the mips define check above, although I don't know if # any OS actually defined sparc like this. -printf "checking for weird 'sparc' define... " +printf "checking for 'sparc' define... " printf "#include \nint main(int argc, char *argv[]){ #ifdef sparc printf(\"1\"); @@ -584,6 +549,18 @@ if [ z"$COMPAQCC" = zYES ]; then CWARNINGS="$CWARNINGS -msg_disable longlongtype,unusedtop" fi + + if [ z"$UNSTABLE" = zYES ]; then + printf "checking whether -Werror can be used... " + rm -f _testprog + $CC $CFLAGS $CWARNINGS _testprog.c -o _testprog -Werror 2> /dev/null + if [ -x _testprog ]; then + printf "yes\n" + CWARNINGS="$CWARNINGS -Werror" + else + printf "no\n" + fi + fi else printf "no\n" fi @@ -591,26 +568,33 @@ if [ z"$COMPAQCC" = zYES ]; then - # -O4 is possible, but is -O3 better? - CFLAGS="-O4 $CFLAGS" + # -O4 is possible, but sometimes -O3 is better? + if [ ! z"$DEBUG" = zYES ]; then + CFLAGS="-O4 $CFLAGS" + fi else if [ z"`uname`" = zSunOS ]; then # "cc", the system's default compiler: - if [ z"$SUNCC" = zYES ]; then - CFLAGS="-xO5 -xdepend $CFLAGS" + if [ ! z"$DEBUG" = zYES ]; then + if [ z"$SUNCC" = zYES ]; then + CFLAGS="-xO5 -xdepend $CFLAGS" + fi fi printf "#define SOLARIS\n" >> config.h OTHERLIBS="-lsocket $OTHERLIBS" else # gcc or something else: - $CC $CFLAGS _testprog.c -o _testprog -O 2> /dev/null - if [ -x _testprog ]; then - rm -f _testprog - $CC $CFLAGS _testprog.c -o _testprog -O2 2> /dev/null + if [ ! z"$DEBUG" = zYES ]; then + $CC $CFLAGS _testprog.c -o _testprog -O 2> /dev/null if [ -x _testprog ]; then - CFLAGS="-O2 $CFLAGS" - else - CFLAGS="-O $CFLAGS" + rm -f _testprog + $CC $CFLAGS _testprog.c -o _testprog \ + -O3 2> /dev/null + if [ -x _testprog ]; then + CFLAGS="-O3 $CFLAGS" + else + CFLAGS="-O $CFLAGS" + fi fi fi fi @@ -620,7 +604,8 @@ # -fschedule-insns causes bugs on i386 with gcc, # but works OK on my alpha with ccc (compaq's cc). -if [ z"$COMPAQCC" = zYES ]; then +if [ ! z"$DEBUG" = zYES ]; then + if [ z"$COMPAQCC" = zYES ]; then printf "checking whether -fschedule-insns2 can be used... " $CC $CFLAGS _testprog.c -o _testprog -fschedule-insns2 2> /dev/null if [ -x _testprog ]; then @@ -658,60 +643,65 @@ printf "no\n" fi rm -f _testprog -fi +fi; fi # -fpeephole -printf "checking whether -fpeephole can be used... " -$CC $CFLAGS -fpeephole _testprog.c -o _testprog > _testprog.stdout 2>&1 -cat _testprog.stdout >> _testprog.error -if grep peephole _testprog.error > /dev/null 2>&1; then - printf "no\n" -else - if [ -x _testprog ]; then - CFLAGS="-fpeephole $CFLAGS" - printf "yes\n" - else +if [ ! z"$DEBUG" = zYES ]; then + printf "checking whether -fpeephole can be used... " + $CC $CFLAGS -fpeephole _testprog.c -o _testprog > _testprog.stdout 2>&1 + cat _testprog.stdout >> _testprog.error + if grep peephole _testprog.error > /dev/null 2>&1; then printf "no\n" + else + if [ -x _testprog ]; then + CFLAGS="-fpeephole $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 -# -fmove-all-movables -printf "checking whether -fmove-all-movables can be used... " -$CC $CFLAGS -fmove-all-movables _testprog.c -o \ - _testprog > _testprog.stdout 2>&1 -cat _testprog.stdout >> _testprog.error -if grep movables _testprog.error > /dev/null 2>&1; then - printf "no\n" -else - if [ -x _testprog ]; then - CFLAGS="-fmove-all-movables $CFLAGS" - printf "yes\n" - else +# -fomit-frame-pointer +if [ ! z"$DEBUG" = zYES ]; then + printf "checking whether -fomit-frame-pointer can be used... " + $CC $CFLAGS -fomit-frame-pointer _testprog.c -o \ + _testprog 1> _testprog.stdout 2>&1 + cat _testprog.stdout >> _testprog.error + if grep frame _testprog.error > /dev/null 2>&1; then printf "no\n" + else + if [ -x _testprog ]; then + CFLAGS="-fomit-frame-pointer $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 -# -fomit-frame-pointer -printf "checking whether -fomit-frame-pointer can be used... " -$CC $CFLAGS -fomit-frame-pointer _testprog.c -o \ - _testprog 1> _testprog.stdout 2>&1 -cat _testprog.stdout >> _testprog.error -if grep frame _testprog.error > /dev/null 2>&1; then - printf "no\n" -else - if [ -x _testprog ]; then - CFLAGS="-fomit-frame-pointer $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? @@ -767,7 +757,7 @@ # -lm? printf "checking for math libs..." printf "#include \nint main(int argc, char *argv[]) { " > _testr.c -printf "double x = sqrt((double)argc); return (int)x; }\n" >> _testr.c +printf "double x = sqrt(sin((double)argc)); return (int)x; }\n" >> _testr.c $CC $CFLAGS _testr.c -o _testr 2> /dev/null if [ ! -x _testr ]; then $CC $CFLAGS _testr.c -lm -o _testr 2> /dev/null @@ -792,6 +782,23 @@ rm -f _testr.[co] _testr +# strlcpy missing? +printf "checking for strlcpy... " +printf "#include +int main(int argc, char *argv[]) { char *p; char *q; size_t x; + x = strlcpy(p, q, 50); return 0;}\n" > _tests.c +$CC $CFLAGS _tests.c -o _tests 2> /dev/null +if [ ! -x _tests ]; then + printf "missing, using mystrlcpy\n" + printf "#define strlcpy mystrlcpy\n" >> config.h + printf "#define strlcat mystrlcat\n" >> config.h + printf "#define USE_STRLCPY_REPLACEMENTS\n" >> config.h +else + printf "found\n" +fi +rm -f _tests.[co] _tests + + # strtoull missing? printf "checking for strtoull... " printf "#include @@ -804,9 +811,24 @@ printf "missing, using mystrtoull\n" printf "#define strtoull mystrtoull\n" >> config.h else - printf "yes\n" + printf "found\n" fi -rm -f _testlong* _tests.[co] _tests +rm -f _tests.[co] _tests + + +# mkstemp missing? +printf "checking for mkstemp... " +printf "#include +int main(int argc, char *argv[]) { int x; char *y = \"abc\"; +x = mkstemp(y); return 0;}\n" > _tests.c +$CC $CFLAGS _tests.c -o _tests 2> /dev/null +if [ ! -x _tests ]; then + printf "missing, using workaround\n" + printf "#define mkstemp mymkstemp\n" >> config.h +else + printf "found\n" +fi +rm -f _tests.[co] _tests # fseeko missing? @@ -816,14 +838,22 @@ #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 "no\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 "yes\n" + printf "found\n" fi rm -f _tests.[co] _tests @@ -841,7 +871,7 @@ printf "no, using int\n" CFLAGS="$CFLAGS -Dsocklen_t=int" else - printf "yes\n" + printf "socklen_t\n" fi rm -f _tests.[co] _tests @@ -878,6 +908,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 @@ -913,6 +984,8 @@ # Check for u_int8_t etc: +# These are needed because some header files in src/include/ use u_int* +# instead of uint*, and I don't have time to rewrite them all. printf "checking for u_int8_t... " printf "#include \n#include \n#include \n int main(int argc, char *argv[]){printf(\"%%i\\\n\", @@ -934,102 +1007,97 @@ printf "typedef uint8_t u_int8_t;\n" >> config.h printf "typedef uint16_t u_int16_t;\n" >> config.h printf "typedef uint32_t u_int32_t;\n" >> config.h - printf "typedef uint64_t u_int64_t;\n" >> config.h printf "uint8_t\n" else printf "yes\n" fi rm -f _testuint.c _testuint +printf "checking for u_int64_t... " +printf "#include \n#include \n#include \n +int main(int argc, char *argv[]){printf(\"%%i\\\n\", + (int)sizeof(u_int64_t));return 0;}\n" > _testuint.c +$CC $CFLAGS _testuint.c -o _testuint 2> /dev/null +if [ ! -x _testuint ]; then + rm -f _testuint* + printf "#include \n#include + \n#include \nint main(int argc, char *argv[]) + {printf(\"%%i\\\n\", (int)sizeof(uint64_t));return 0;}\n" > _testuint.c + $CC $CFLAGS _testuint.c -o _testuint 2> /dev/null + if [ ! -x _testuint ]; then + printf "no\n\nERROR: No u_int64_t or uint64_t. Aborting\n" + # TODO: Automagically detect using various combinations + # of char, int, short, long etc. + exit + fi + + printf "typedef uint64_t u_int64_t;\n" >> config.h + printf "uint64_t\n" +else + printf "yes\n" +fi +rm -f _testuint.c _testuint + + +############################################################################### + +# Host byte order? +printf "checking host endianness... " +rm -f _test_end* +printf '#include +int main(int argc, char *argv[]) +{ int x = 1; void *xp = (void *)&x; char *p = (char *)xp; +if (*p) printf("little\\\n"); else printf("big\\\n"); } +' > _test_end.c +$CC $CFLAGS _test_end.c -o _test_end 2> /dev/null +X=`./_test_end` +echo $X +if [ z$X = zlittle ]; then + printf "#define HOST_LITTLE_ENDIAN\n" >> config.h +else + if [ z$X = zbig ]; then + printf "#define HOST_BIG_ENDIAN\n" >> config.h + else + echo "Error! Could not determine host's endianness." + exit + fi +fi +rm -f _test_end* + ############################################################################### # -# Dynamic binary translation (BINTRANS): +# Native code generation backend: (Detect host ABI.) # ############################################################################### -printf "checking for bintrans backend... " +if [ z$UNSTABLE = zYES ]; then + printf "detecting native code generation ABI... " -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 + NATIVE_CODE_GENERATION=YES printf "Alpha\n" - BINTRANS=YES + printf "#define NATIVE_CODE_GENERATION\n" >> config.h + printf "#define HOST_ARCH_ALPHA\n" >> config.h fi - # x86: (all machines ending in "86" are treated as i386) - if [ z"`uname -m|rev|cut -c1-2`" = z68 ]; 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" + 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 -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 -############################################################################### - -# Prefetch support? -printf "checking for asm prefetch support... " -if [ z"`uname -m`" = zalpha ]; then - rm -f _alpha_asm_test.c _alpha_asm_test - printf 'int main(int argc, char *argv[]) - { int x; int *y = &x; asm ("ldl $31,0(%%0)" : : "g" (y)); - return 0; }\n' > _alpha_asm_test.c - $CC $CFLAGS -O2 _alpha_asm_test.c -o _alpha_asm_test \ - > /dev/null 2> /dev/null - if [ -x _alpha_asm_test ]; then -# printf "#define HAVE_PREFETCH\n" >> config.h - printf "#define PREFETCH(x) asm(\"ldl" >> config.h - printf " \$31,0(%%0)\" : : \"g\" (x))\n" >> config.h - echo "yes" - PREFSUP=YES - fi - rm -f _alpha_asm_test.c _alpha_asm_test -fi -if [ z$PREFSUP = z ]; then - printf "#define PREFETCH(x) { }\n" >> config.h - echo "no" + if [ z$NATIVE_CODE_GENERATION = z ]; then + printf "not supported yet for this host platform\n" + fi fi @@ -1038,6 +1106,8 @@ INCLUDE=-Iinclude/ DINCLUDE=-I../include/ +rm -f _testprog.c + echo C compiler flags: $CFLAGS $CWARNINGS echo Linker flags: $OTHERLIBS echo "CWARNINGS=$CWARNINGS" >> _Makefile.header @@ -1046,165 +1116,15 @@ echo "DINCLUDE=$DINCLUDE" >> _Makefile.header echo "CC=$CC" >> _Makefile.header echo "OTHERLIBS=$OTHERLIBS" >> _Makefile.header +echo "CPU_ARCHS=$CPU_ARCHS" >> _Makefile.header +echo "CPU_TOOLS=$CPU_TOOLS" >> _Makefile.header echo "" >> _Makefile.header -printf "Regression test setup: (not really needed to build gxemul)\n" - - -## 64-bit HPPA cross-assembler: -# -#HPPA='' -#if [ z$ENABLEHPPA = zYES ]; then -# printf "Checking for a GNU cross-assembler for 64-bit HPPA... " -# echo 'nop' > _testprog.s -# -# for HPPA_TRY in hppa64-unknown-elf hppa64-elf; do -# printf '#!/bin/sh\n'$HPPA_TRY'-as _testprog.s' > _test.sh -# printf ' -o _testprog.o\n' >> _test.sh -# chmod 755 _test.sh -# rm -f _testprog.o -# ./_test.sh > /dev/null 2> /dev/null -# if [ -f _testprog.o ]; then -# HPPA=$HPPA_TRY -# break -# fi -# rm -f _testprog.o -# done -# -# if [ z$HPPA = z ]; then -# echo "none" -# else -# echo $HPPA"-gcc" -# fi -#fi -#rm -f _testprog* _test.sh -# -## TODO: are these ok? 64-bit mode! -##echo "HPPA_CC="$HPPA"-gcc -g -O2 -fno-builtin -fschedule-insns" \ -## >> _Makefile.header -#echo "HPPA_AS="$HPPA"-as " >> _Makefile.header -#echo "HPPA_LD="$HPPA"-ld -Ttext 0xa800000000030000 -e main" \ -# "--oformat=elf64-bigmips" >> _Makefile.header -#echo "" >> _Makefile.header - - -# 64-bit MIPS cross-compiler: - -MIPS='' -if [ z$ENABLEMIPS = zYES ]; then - printf "Checking for a GNU cross-compiler for 64-bit MIPS... " - echo 'int f(int x) { return x; }' > _testprog.c - - for MIPS_TRY in mips64-unknown-elf mips64-elf mips-unknown-elf64; do - printf '#!/bin/sh\n'$MIPS_TRY'-gcc _testprog.c -c\n' > _test.sh - chmod 755 _test.sh - rm -f _testprog.o - ./_test.sh > /dev/null 2> /dev/null - if [ -f _testprog.o ]; then - MIPS=$MIPS_TRY - break - fi - rm -f _testprog.o - done - - if [ z$MIPS = z ]; then - echo "none" - else - echo $MIPS"-gcc" - fi -fi -rm -f _testprog* _test.sh - -echo "MIPS_CC="$MIPS"-gcc -g -O2 -fno-builtin -fschedule-insns" \ - "-mips64 -mabi=64" >> _Makefile.header -echo "MIPS_AS="$MIPS"-as -mabi=64 -mips64" >> _Makefile.header -echo "MIPS_LD="$MIPS"-ld -Ttext 0xa800000000030000 -e main" \ - "--oformat=elf64-bigmips" >> _Makefile.header -echo "" >> _Makefile.header - - -## PPC64 cross-assembler: -# -#PPC='' -#if [ z$ENABLEPPC = zYES ]; then -# printf "Checking for a GNU cross-assembler for 64-bit PPC... " -# echo 'nop' > _testprog.s -# -# for a in ppc64 powerpc64; do -# for b in unknown; do -# for c in elf elf64 linux linux64 aix aix5; do -# PPC_TRY=$a-$b-$c -# printf '#!/bin/sh\n'$PPC_TRY'-as _testprog.s' > _test.sh -# printf ' -o _testprog.o\n' >> _test.sh -# chmod 755 _test.sh -# rm -f _testprog.o -# ./_test.sh > /dev/null 2> /dev/null -# if [ -f _testprog.o ]; then -# PPC=$PPC_TRY -# break -# fi -# rm -f _testprog.o -# done -# done -# done -# -# if [ z$PPC = z ]; then -# echo "none" -# else -# echo $PPC"-as" -# fi -#fi -#rm -f _testprog* _test.sh -# -##echo "PPC_CC="$PPC"-gcc -g -O2 -fno-builtin" >> _Makefile.header -#echo "PPC_AS="$PPC"-as" >> _Makefile.header -#echo "PPC_LD="$PPC"-ld -e main" >> _Makefile.header -#echo "" >> _Makefile.header - - -## SPARC64 cross-compiler: -# -#SPARC='' -#if [ z$ENABLESPARC = zYES ]; then -# printf "Checking for a GNU cross-compiler for 64-bit SPARC... " -# echo 'int f(int x) { return x; }' > _testprog.c -# -# for a in sparc64; do -# for b in unknown; do -# for c in elf elf64; do -# SPARC_TRY=$a-$b-$c -# printf '#!/bin/sh\n'$SPARC_TRY'-gcc _testprog.c -c' > _test.sh -# printf ' -o _testprog.o\n' >> _test.sh -# chmod 755 _test.sh -# rm -f _testprog.o -# ./_test.sh > /dev/null 2> /dev/null -# if [ -f _testprog.o ]; then -# SPARC=$SPARC_TRY -# break -# fi -# rm -f _testprog.o -# done -# done -# done -# -# if [ z$SPARC = z ]; then -# echo "none" -# else -# echo $SPARC"-gcc" -# fi -#fi -#rm -f _testprog* _test.sh -# -#echo "SPARC_CC="$SPARC"-gcc -g -O2 -fno-builtin" >> _Makefile.header -#echo "SPARC_AS="$SPARC"-as" >> _Makefile.header -#echo "SPARC_LD="$SPARC"-ld -e main" >> _Makefile.header -#echo "" >> _Makefile.header - - # Create the Makefiles: - -for a in . src src/devices src/devices/fonts tests; do +D=". src src/include src/cpus src/debugger src/devices src/devices/fonts" +D="$D src/disk src/file src/machines src/native src/net src/promemul" +for a in $D; do echo "creating $a/Makefile" touch $a/Makefile cat _Makefile.header > $a/Makefile