--- trunk/configure 2007/10/08 16:22:11 40 +++ trunk/configure 2007/10/08 16:22:32 42 @@ -27,7 +27,7 @@ # SUCH DAMAGE. # # -# $Id: configure,v 1.254 2007/04/19 15:18:15 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 @@ -49,8 +49,6 @@ # o) which compiler flags to use (overridden by setting CFLAGS) # 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 @@ -95,23 +93,6 @@ 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 - ENABLEM88K=YES - ENABLESPARC=YES -fi - - ############################################################################### # # Configure options: @@ -139,6 +120,8 @@ if [ z"$UNSTABLE" = zYES ]; then printf "#define UNSTABLE_DEVEL\n" >> config.h +else + CFLAGS="-DNDEBUG $CFLAGS" fi @@ -146,57 +129,66 @@ printf "#define COMPILE_DATE \"$ZZ\"\n" >> config.h +# Include support for all CPU types: +printf "#define ADD_ALL_CPU_FAMILIES " >> config.h -# Support for various CPU types: -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$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$ENABLEM88K = zYES ]; then - printf "#define ENABLE_M88K\n" >> config.h - CPU_ARCHS="$CPU_ARCHS cpu_m88k.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 - CPU_ARCHS="$CPU_ARCHS cpu_sparc.o memory_sparc.o" - CPU_TOOLS="$CPU_TOOLS generate_sparc_loadstore" -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 "\n" >> config.h ############################################################################### @@ -243,38 +235,67 @@ #\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 +# Actually, don't try ccc on Alpha. ccc generates broken code :( + # # Try ccc (FreeBSD/Alpha): -# printf "#!/bin/sh\nccc _testprog.c -o _testprog >" > _test.sh +# 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 @@ -288,6 +309,16 @@ 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" @@ -567,6 +598,26 @@ 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 sometimes -O3 is better? if [ ! z"$DEBUG" = zYES ]; then @@ -626,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... " @@ -685,11 +740,38 @@ 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 - printf "skipping\n" + $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 @@ -697,8 +779,8 @@ CFLAGS="-g $CFLAGS" printf "yes\n" else - printf "no\n" - fi + printf "no\n" + fi fi rm -f _testprog _testprog.error _testprog.stdout fi @@ -936,7 +1018,7 @@ 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 + $CC $CFLAGS $CWARNINGS _testpri.c -o _testpri 2> _testpri.result if [ z`./_testpri` = z80 ]; then printf "PRIx64=lx\n" else @@ -946,7 +1028,7 @@ fi fi fi -rm -f _testpri.c _testpri +rm -f _testpri.c _testpri _testpri.result # Check for 64-bit off_t: @@ -1036,7 +1118,23 @@ else printf "yes\n" fi -rm -f _testuint.c _testuint +rm -f _testuint* + +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* ############################################################################### @@ -1066,42 +1164,6 @@ ############################################################################### -# -# Native code generation backend: (Detect host ABI.) -# -############################################################################### - -if [ z$UNSTABLE = zYES ]; then - printf "detecting native code generation ABI... " - - if [ z"`uname -m`" = zalpha ]; then - NATIVE_CODE_GENERATION=YES - printf "Alpha\n" - printf "#define NATIVE_CODE_GENERATION\n" >> config.h - printf "#define HOST_ARCH_ALPHA\n" >> config.h - fi - - 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 supported yet for this host platform\n" - fi -fi - - -############################################################################### INCLUDE=-Iinclude/ DINCLUDE=-I../include/ @@ -1124,6 +1186,7 @@ # Create the Makefiles: 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 @@ -1138,3 +1201,4 @@ rm -f _Makefile.header echo Configured. You may now run make to build gxemul. +