--- trunk/configure 2007/10/08 16:19:56 24 +++ trunk/configure 2007/10/08 16:22:11 40 @@ -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.224 2006/06/23 08:54:56 debug Exp $ +# $Id: configure,v 1.254 2007/04/19 15:18:15 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,6 +49,7 @@ # 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 @@ -60,30 +61,11 @@ # 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: - ENABLEALPHA=YES - ENABLEARM=YES - ENABLEMIPS=YES - ENABLEPPC=YES + # Stable. + : else - # Development: + # Development. UNSTABLE=YES - ENABLEALPHA=YES - ENABLEARM=YES - ENABLEAVR=YES - ENABLEHPPA=YES - ENABLEI960=YES - ENABLEIA64=YES - ENABLEM68K=YES - ENABLEMIPS=YES - ENABLEPPC=YES - ENABLESH=YES - ENABLESPARC=YES - ENABLEX86=YES -fi - -if [ z"$UNSTABLE" = zYES ]; then - printf "###\n### DEVELOPMENT (UNSTABLE)\n###\n\n" fi if [ z"$*" != z ]; then @@ -91,10 +73,16 @@ for a in $*; do if [ z$a = z--disable-x ]; then NOX11=YES + else if [ z$a = z--debug ]; then + DEBUG=YES else if [ z$a = z--help ]; then 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 @@ -102,11 +90,28 @@ echo "Run $0 --help to get a list of" \ "available options." exit - 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 + ENABLEM88K=YES + ENABLESPARC=YES +fi + + ############################################################################### # # Configure options: @@ -167,27 +172,16 @@ 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" +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 @@ -196,25 +190,12 @@ 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 - - -# Cache emulation: -if [ z$CACHES = zYES ]; then - echo 'Enabling Cache emulation. (EXPERIMENTAL and BUGGY)' - printf "#define ENABLE_CACHE_EMULATION\n" >> config.h - - printf "\nNOTE: Cache emulation enabled, but right now it triggers " - printf "weird bugs in the\n emulator. You have been warned.\n\n" + CPU_ARCHS="$CPU_ARCHS cpu_sparc.o memory_sparc.o" + CPU_TOOLS="$CPU_TOOLS generate_sparc_loadstore" fi @@ -362,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 \ @@ -574,25 +569,32 @@ if [ z"$COMPAQCC" = zYES ]; then # -O4 is possible, but sometimes -O3 is better? - CFLAGS="-O4 $CFLAGS" + 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 -O3 2> /dev/null + if [ ! z"$DEBUG" = zYES ]; then + $CC $CFLAGS _testprog.c -o _testprog -O 2> /dev/null if [ -x _testprog ]; then - CFLAGS="-O3 $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 @@ -602,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 @@ -640,59 +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 # -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" - else +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 -# -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? @@ -748,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 @@ -1055,6 +1064,43 @@ fi rm -f _test_end* + +############################################################################### +# +# 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/ @@ -1077,7 +1123,7 @@ # Create the Makefiles: D=". src src/include src/cpus src/debugger src/devices src/devices/fonts" -D="$D src/machines src/promemul doc" +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