--- trunk/configure 2007/10/08 16:18:38 12 +++ trunk/configure 2007/10/08 16:22:32 42 @@ -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.155 2005/08/16 05:37:08 debug Exp $ +# $Id: configure,v 1.270 2007/06/15 17:13:40 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,32 +47,23 @@ # 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...) -# -# TODO: -# o) do not enable prefetch on Alpha ev4 or ev5, only on pca56 and newer -# o) X11 libs and includes via command line options? +# o) X11 flags and libraries (TODO: should be possible to override +# 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. # ############################################################################### # 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: - ENABLEMIPS=YES + # Stable. + : else - # Development: - ENABLEALPHA=YES - ENABLEARM=YES - ENABLEIA64=YES - ENABLEM68K=YES - ENABLEMIPS=YES - ENABLEPPC=YES - ENABLESPARC=YES - ENABLEX86=YES + # Development. + UNSTABLE=YES fi if [ z"$*" != z ]; then @@ -80,150 +71,24 @@ 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-alpha ]; then - ENABLEALPHA=NO - else if [ z$a = z--enable-alpha ]; then - ENABLEALPHA=YES - else if [ z$a = z--disable-arm ]; then - ENABLEARM=NO - else if [ z$a = z--enable-arm ]; then - ENABLEARM=YES - else if [ z$a = z--disable-ia64 ]; then - ENABLEIA64=NO - else if [ z$a = z--enable-ia64 ]; then - ENABLEIA64=YES - else if [ z$a = z--disable-m68k ]; then - ENABLEM68K=NO - else if [ z$a = z--enable-m68k ]; then - ENABLEM86K=YES - else if [ z$a = z--disable-mips ]; then - ENABLEMIPS=NO - else if [ z$a = z--enable-mips ]; then - ENABLEMIPS=YES - else if [ z$a = z--disable-ppc ]; then - ENABLEPPC=NO - else if [ z$a = z--enable-ppc ]; then - ENABLEPPC=YES - else if [ z$a = z--disable-sparc ]; then - ENABLESPARC=NO - else if [ z$a = z--enable-sparc ]; then - ENABLESPARC=YES - else if [ z$a = z--disable-x86 ]; then - ENABLEX86=NO - else if [ z$a = z--enable-x86 ]; then - ENABLEX86=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--debug ]; then + DEBUG=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)" - echo " --tracenull enable" \ - "TRACE_NULL_CRASHES (for bug hunting)" - printf " --enable-caches enable cache emulation" - printf " (BUGGY)\n" - echo " --enable-delays enable instruction" \ - "latency/delay emulation" - - if [ z$ENABLEALPHA = zYES ]; then - printf " --disable-alpha disable " - else - printf " --enable-alpha enable " - fi - printf "Alpha CPU emulation\n" - - if [ z$ENABLEARM = zYES ]; then - printf " --disable-arm disable " - else - printf " --enable-arm enable " - fi - printf "ARM CPU emulation\n" - - if [ z$ENABLEIA64 = zYES ]; then - printf " --disable-ia64 disable " - else - printf " --enable-ia64 enable " - fi - printf "IA64 CPU emulation\n" - - if [ z$ENABLEM68K = zYES ]; then - printf " --disable-m68k disable " - else - printf " --enable-m68k enable " + 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 - printf "M68K CPU emulation\n" - - if [ z$ENABLEMIPS = zYES ]; then - printf " --disable-mips disable " - else - printf " --enable-mips enable " - fi - printf "MIPS CPU emulation\n" - - if [ z$ENABLEPPC = zYES ]; then - printf " --disable-ppc disable " - else - printf " --enable-ppc enable " - fi - printf "POWER/PPC CPU emulation\n" - - if [ z$ENABLESPARC = zYES ]; then - printf " --disable-sparc disable " - else - printf " --enable-sparc enable " - fi - printf "SPARC CPU emulation\n" - - if [ z$ENABLEX86 = zYES ]; then - printf " --disable-x86 disable " - else - printf " --enable-x86 enable " - fi - printf "x86 CPU emulation\n" - - echo " --enable-mips16 enable MIPS16 support" - - 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" + 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; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi + fi; fi; fi done fi @@ -253,88 +118,77 @@ 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" -fi -if [ z$ENABLEARM = zYES ]; then - printf "#define ENABLE_ARM\n" >> config.h - CPU_ARCHS="$CPU_ARCHS cpu_arm.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 -fi -if [ z$ENABLEPPC = zYES ]; then - printf "#define ENABLE_PPC\n" >> config.h - CPU_ARCHS="$CPU_ARCHS cpu_ppc.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 -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 +if [ z"$UNSTABLE" = zYES ]; then + printf "#define UNSTABLE_DEVEL\n" >> config.h +else + CFLAGS="-DNDEBUG $CFLAGS" fi -# Development option: TRACE_NULL_CRASHES -if [ z$TRACENULL = zYES ]; then - echo 'Enabling TRACE_NULL_CRASHES. (NOTE:' \ - 'This slows down the emulator.)' - printf "#define TRACE_NULL_CRASHES\n" >> config.h -fi +ZZ=`echo compiled on \`uname\`/\`uname -m\`, \`date\`` +printf "#define COMPILE_DATE \"$ZZ\"\n" >> config.h -# Cache emulation: -if [ z$CACHES = zYES ]; then - echo 'Enabling Cache emulation. (EXPERIMENTAL)' - printf "#define ENABLE_CACHE_EMULATION\n" >> config.h +# Include support for all CPU types: +printf "#define ADD_ALL_CPU_FAMILIES " >> 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 +# Alpha +printf " add_cpu_family(alpha_cpu_family_init, ARCH_ALPHA);" >> config.h +CPU_ARCHS="$CPU_ARCHS cpu_alpha.o cpu_alpha_palcode.o memory_alpha.o" +CPU_TOOLS="$CPU_TOOLS generate_alpha_misc" + +# ARM +printf " add_cpu_family(arm_cpu_family_init, ARCH_ARM);" >> config.h +CPU_ARCHS="$CPU_ARCHS cpu_arm.o cpu_arm_coproc.o memory_arm.o " +CPU_ARCHS="$CPU_ARCHS tmp_arm_loadstore.o" +CPU_ARCHS="$CPU_ARCHS tmp_arm_loadstore_p0_u0_w0.o" +CPU_ARCHS="$CPU_ARCHS tmp_arm_loadstore_p0_u0_w1.o" +CPU_ARCHS="$CPU_ARCHS tmp_arm_loadstore_p0_u1_w0.o" +CPU_ARCHS="$CPU_ARCHS tmp_arm_loadstore_p0_u1_w1.o" +CPU_ARCHS="$CPU_ARCHS tmp_arm_loadstore_p1_u0_w0.o" +CPU_ARCHS="$CPU_ARCHS tmp_arm_loadstore_p1_u0_w1.o" +CPU_ARCHS="$CPU_ARCHS tmp_arm_loadstore_p1_u1_w0.o" +CPU_ARCHS="$CPU_ARCHS tmp_arm_loadstore_p1_u1_w1.o" +CPU_ARCHS="$CPU_ARCHS tmp_arm_dpi.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" + +# M88K +printf " add_cpu_family(m88k_cpu_family_init, ARCH_M88K);" >> config.h +CPU_ARCHS="$CPU_ARCHS cpu_m88k.o memory_m88k.o" +CPU_TOOLS="$CPU_TOOLS generate_m88k_bcnd" +CPU_TOOLS="$CPU_TOOLS generate_m88k_loadstore" + +# MIPS +printf " add_cpu_family(mips_cpu_family_init, ARCH_MIPS);" >> 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" + +# POWER/PowerPC +printf " add_cpu_family(ppc_cpu_family_init, ARCH_PPC);" >> config.h +CPU_ARCHS="$CPU_ARCHS cpu_ppc.o" +CPU_TOOLS="$CPU_TOOLS generate_ppc_loadstore" + +# SuperH +printf " add_cpu_family(sh_cpu_family_init, ARCH_SH);" >> config.h +CPU_ARCHS="$CPU_ARCHS cpu_sh.o memory_sh.o" + +# SPARC +printf " add_cpu_family(sparc_cpu_family_init, ARCH_SPARC);" >> config.h +CPU_ARCHS="$CPU_ARCHS cpu_sparc.o memory_sparc.o" +CPU_TOOLS="$CPU_TOOLS generate_sparc_loadstore" - printf "\nNOTE: Cache emulation enabled, but right now it triggers " - printf "weird bugs in the\n emulator. You have been warned.\n\n" -fi +printf "\n" >> config.h ############################################################################### @@ -381,51 +235,90 @@ #\n\n" >> _Makefile.header -echo 'int main(int argc, char *argv[]) { return 0; }' > _testprog.c +# Try with the simplest possible test program. Actually, test static variables +# as well, because GXemul uses things like NULL-initialized global pointers, +# and it is important that they work. (GCC on Solaris is known to be completely +# broken, for instance.) + +echo '#include + +int main(int argc, char *argv[]) +{ + static int x = 0; + static int y = 1; + printf("%i,%i", x, y); + return 0; +} +' > _testprog.c # Try to detect which C compiler to use, if CC is not set: printf "checking which C compiler to use... " - +rm -f _testprog if [ z"$CC" = z ]; then - CC=cc - # Try gcc first: - printf "#!/bin/sh\ngcc _testprog.c -o _testprog >" > _test.sh + printf "#!/bin/sh\ngcc $CFLAGS _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=gcc + if [ z`./_testprog` = z0,1 ]; then + CC=gcc + else + printf "broken gcc detected\n" + printf "The test program:\n\n" + cat _testprog.c + printf "\nshould have resulted in 0,1, but the" + printf " result was: " + ./_testprog + printf "\n\nchecking for other C compilers... " + fi fi rm -f _testprog # If both gcc and cc exist, then cc might be a vendor specific # compiler which produces faster code than gcc (eg on Solaris): - printf "#!/bin/sh\ncc _testprog.c -o _testprog >" > _test.sh + printf "#!/bin/sh\ncc $CFLAGS _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=cc + if [ z`./_testprog` = z0,1 ]; then + CC=cc + else + printf "broken cc detected\n" + printf "checking for other C compilers... " + fi 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 +# Actually, don't try ccc on Alpha. ccc generates broken code :( + +# # Try ccc (FreeBSD/Alpha): +# printf "#!/bin/sh\nccc $CFLAGS _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 rm -f _testprog + +if [ z$CC = z ]; then + printf "no working compiler detected\n" + printf "\nPlease set the CC environment variable to a working C " + printf "compiler before running\nthe configure script, and make" + printf " sure that the CFLAGS environment variable is\nalso valid" + printf " for that compiler.\n" + exit +fi + printf "$CC $CFLAGS" @@ -481,6 +374,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 \ @@ -673,33 +580,72 @@ 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 rm -f _testprog +# -Wstrict-aliasing +if [ ! z"$DEBUG" = zYES ]; then + printf "checking whether -Wstrict-aliasing can be used... " + $CC $CFLAGS -Wstrict-aliasing _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 + CWARNINGS="-Wstrict-aliasing $CWARNINGS" + printf "yes\n" + else + printf "no\n" + fi + fi + rm -f _testprog _testprog.error _testprog.stdout +fi + + 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 @@ -709,7 +655,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 @@ -730,12 +677,16 @@ fi rm -f _testprog -# # -intrinsics -# $CC $CFLAGS _testprog.c -o _testprog -intrinsics 2> /dev/null -# if [ -x _testprog ]; then -# CFLAGS="-intrinsics $CFLAGS" -# fi -# rm -f _testprog + # -intrinsics + printf "checking whether -intrinsics can be used... " + $CC $CFLAGS _testprog.c -o _testprog -intrinsics 2> /dev/null + if [ -x _testprog ]; then + CFLAGS="-intrinsics $CFLAGS" + printf "yes\n" + else + printf "no\n" + fi + rm -f _testprog # -fast printf "checking whether -fast can be used... " @@ -747,42 +698,92 @@ 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 # -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" +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 + + +# -fstrict-aliasing +if [ ! z"$DEBUG" = zYES ]; then + printf "checking whether -fstrict-aliasing can be used... " + $CC $CFLAGS -fstrict-aliasing _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="-fstrict-aliasing $CFLAGS" + printf "yes\n" + else + printf "no\n" + fi fi + rm -f _testprog _testprog.error _testprog.stdout +fi + + +# -g, for development builds +if [ z"$UNSTABLE" = zYES ]; then + printf "checking whether -g can be used... " + if [ z"$COMPAQCC" = zYES ]; then + $CC $CFLAGS -g3 _testprog.c -o _testprog > _testprog.stdout 2>&1 + cat _testprog.stdout >> _testprog.error + if [ -x _testprog ]; then + CFLAGS="-g3 $CFLAGS" + printf "yes (-g3)\n" + else + printf "no\n" + fi + 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? @@ -838,7 +839,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 @@ -919,12 +920,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 @@ -981,6 +990,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> _testpri.result + 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 _testpri.result + + # Check for 64-bit off_t: printf "checking for 64-bit off_t... " printf "#include \n#include \n#include \n @@ -1016,6 +1066,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\", @@ -1037,77 +1089,52 @@ 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 -############################################################################### -# -# Dynamic 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: (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 + printf "typedef uint64_t u_int64_t;\n" >> config.h + printf "uint64_t\n" +else + printf "yes\n" +fi +rm -f _testuint* - if [ z$BINTRANS = zNO ]; then - printf "not supported yet on this arch\n" +printf "checking for __FUNCTION__... " +printf "#include \n\nint main(int argc, char *argv[]) { + if (__FUNCTION__) printf(__FUNCTION__);\n return 0;\n}\n" > _testfunction.c +$CC $CFLAGS _testfunction.c -o _testfunction 2> /dev/null +if [ ! -x _testfunction ]; then + printf "no\n" +else + if [ z`./_testfunction` = zmain ]; then + printf "yes\n" + printf "#define HAVE___FUNCTION__\n" >> config.h + else + printf "no\n" fi fi +rm -f _testfunction* ############################################################################### @@ -1135,31 +1162,6 @@ fi rm -f _test_end* -############################################################################### - -# 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" -fi - ############################################################################### @@ -1177,12 +1179,15 @@ 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 # Create the Makefiles: - -for a in . src src/devices src/devices/fonts; 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" +D="$D src/useremul" +for a in $D; do echo "creating $a/Makefile" touch $a/Makefile cat _Makefile.header > $a/Makefile @@ -1196,3 +1201,4 @@ rm -f _Makefile.header echo Configured. You may now run make to build gxemul. +