--- trunk/configure 2007/10/08 16:18:19 8 +++ trunk/configure 2007/10/08 16:19:37 22 @@ -1,7 +1,7 @@ #!/bin/sh ############################################################################### # -# Copyright (C) 2003-2005 Anders Gavare. All rights reserved. +# Copyright (C) 2003-2006 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.134 2005/06/11 20:59:10 debug Exp $ +# $Id: configure,v 1.198 2006/02/18 13:15:20 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,20 +49,41 @@ # 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) X11 libs and includes via command line options? # ############################################################################### -ENABLEALPHA=NO -ENABLEARM=NO -ENABLEHPPA=NO -ENABLEMIPS=YES -ENABLEPPC=YES -ENABLESPARC=NO -ENABLEURISC=YES -ENABLEX86=NO -STABLE=YES +# 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: + ENABLEARM=YES + ENABLEMIPS=YES + ENABLEPPC=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 + ENABLESH=YES + ENABLESPARC=YES + ENABLEX86=YES +fi + +if [ z"$UNSTABLE" = zYES ]; then + printf "### DEVELOPMENT (UNSTABLE)\n\n" +fi if [ z"$*" != z ]; then # Parse command line options: @@ -81,38 +102,10 @@ 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-hppa ]; then - ENABLEHPPA=NO - 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--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-urisc ]; then - ENABLEURISC=NO - else if [ z$a = z--enable-urisc ]; then - ENABLEURISC=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-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 @@ -121,58 +114,58 @@ 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 "\nDevelopment (debug) options:\n" - echo " --always32 enable" \ - "ALWAYS_SIGNEXTEND_32 (for hunting down" - echo " 32/64-bit bugs)" - echo " --tracenull enable" \ - "TRACE_NULL_CRASHES (for bug hunting)" - printf "\nGeneral options:\n" - echo " --disable-bintrans configure without" \ - "bintrans, even if the host supports it" + + 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" - echo " --disable-x don't include X11 support" - printf "\nCPU selection options:\n" - if [ z$STABLE = zNO ]; then - printf " --enable-alpha " - printf "enable Alpha CPU emulation" - printf " (NOT YET)\n" - printf " --enable-arm " - printf "enable ARM CPU emulation" - printf " (NOT YET)\n" - printf " --enable-hppa " - printf "enable HPPA CPU emulation" - printf " (NOT YET)\n" - fi - echo " --disable-mips disable MIPS CPU emulation" - echo " --disable-ppc disable PPC CPU emulation" - if [ z$STABLE = zNO ]; then - printf " --enable-sparc " - printf "enable SPARC CPU emulation" - printf " (NOT YET)\n" - fi - echo " --disable-urisc disable URISC CPU emulation" - if [ z$STABLE = zNO ]; then - printf " --enable-x86 " - printf "enable x86 CPU emulation" - printf " (NOT YET)\n" + + if [ z$DYNTRANSBACKEND = zYES ]; then + printf " --disable-dyntransbackend disable " + else + printf " --enable-dyntransbackend enable" fi - printf "\nMIPS-specific options:\n" - printf " --enable-mips16 enable MIPS16 instruction" - printf " support (NOT YET)\n\n" + 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" 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; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi + fi; fi done fi @@ -196,7 +189,7 @@ # 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 @@ -215,62 +208,67 @@ fi if [ z$ENABLEALPHA = zYES ]; then printf "#define ENABLE_ALPHA\n" >> config.h - if [ z$STABLE = zNO ]; then - printf "\nWARNING: Alpha emulation enabled, but it isn't really" - printf " implemented yet.\n\n" - else - printf "Not in the stable release.\n" - exit - fi + CPU_ARCHS="$CPU_ARCHS cpu_alpha.o cpu_alpha_palcode.o" + CPU_TOOLS="$CPU_TOOLS generate_alpha_misc" fi if [ z$ENABLEARM = zYES ]; then printf "#define ENABLE_ARM\n" >> config.h - if [ z$STABLE = zNO ]; then - printf "\nWARNING: ARM emulation enabled, but it isn't really" - printf " implemented yet.\n\n" - else - printf "Not in the stable release.\n" - exit - fi + 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$ENABLEHPPA = zYES ]; then printf "#define ENABLE_HPPA\n" >> config.h - if [ z$STABLE = zNO ]; then - printf "\nWARNING: HPPA emulation enabled, but it isn't really" - printf " implemented yet.\n\n" - else - printf "Not in the stable release.\n" - exit - fi + 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 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" fi if [ z$ENABLESPARC = zYES ]; then printf "#define ENABLE_SPARC\n" >> config.h - if [ z$STABLE = zNO ]; then - printf "\nWARNING: SPARC emulation enabled, but it isn't really" - printf " implemented yet.\n\n" - else - printf "Not in the stable release.\n" - exit - fi -fi -if [ z$ENABLEURISC = zYES ]; then - printf "#define ENABLE_URISC\n" >> config.h + CPU_ARCHS="$CPU_ARCHS cpu_sparc.o" fi if [ z$ENABLEX86 = zYES ]; then printf "#define ENABLE_X86\n" >> config.h - if [ z$STABLE = zNO ]; then - printf "\nWARNING: X86 emulation enabled, but it isn't really" - printf " working yet.\n\n" - else - printf "Not in the stable release.\n" - exit - fi + CPU_ARCHS="$CPU_ARCHS cpu_x86.o" fi @@ -289,17 +287,19 @@ 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 +# 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)' + echo 'Enabling Cache emulation. (EXPERIMENTAL and BUGGY)' printf "#define ENABLE_CACHE_EMULATION\n" >> config.h if [ z$DELAYS != zYES ]; then @@ -388,15 +388,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 @@ -511,8 +511,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\"); @@ -542,39 +542,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\"); @@ -606,7 +575,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\"); @@ -638,7 +607,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\"); @@ -681,6 +650,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 @@ -688,7 +669,7 @@ if [ z"$COMPAQCC" = zYES ]; then - # -O4 is possible, but is -O3 better? + # -O4 is possible, but sometimes -O3 is better? CFLAGS="-O4 $CFLAGS" else if [ z"`uname`" = zSunOS ]; then @@ -703,9 +684,9 @@ $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 + $CC $CFLAGS _testprog.c -o _testprog -O3 2> /dev/null if [ -x _testprog ]; then - CFLAGS="-O2 $CFLAGS" + CFLAGS="-O3 $CFLAGS" else CFLAGS="-O $CFLAGS" fi @@ -793,6 +774,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" + else + printf "no\n" + fi +fi +rm -f _testprog _testprog.error _testprog.stdout + + # -lrt for nanosleep? printf "checking whether -lrt is required for nanosleep... " printf "#include \n#include @@ -871,6 +869,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 @@ -1007,6 +1022,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\", @@ -1028,17 +1045,41 @@ 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 + ############################################################################### # -# Dynamic binary translation (BINTRANS): +# OLD binary translation (BINTRANS): # ############################################################################### @@ -1063,8 +1104,8 @@ BINTRANS=YES fi - # x86: (all machines ending in "86" are treated as i386) - if [ z"`uname -m|rev|cut -c1-2`" = z68 ]; then + # 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" @@ -1102,203 +1143,111 @@ ############################################################################### - -# 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 - - +# +# Dyntrans recompilation (native backend) support: +# ############################################################################### -INCLUDE=-Iinclude/ -DINCLUDE=-I../include/ - -echo C compiler flags: $CFLAGS $CWARNINGS -echo Linker flags: $OTHERLIBS -echo "CWARNINGS=$CWARNINGS" >> _Makefile.header -echo "COPTIM=$CFLAGS" >> _Makefile.header -echo "INCLUDE=$INCLUDE" >> _Makefile.header -echo "DINCLUDE=$DINCLUDE" >> _Makefile.header -echo "CC=$CC" >> _Makefile.header -echo "OTHERLIBS=$OTHERLIBS" >> _Makefile.header -echo "" >> _Makefile.header +if [ z$DYNTRANSBACKEND = zYES ]; then + printf "Dyntrans: Not yet.\n" + exit + printf "checking for dyntrans backend... " + DBFOUND=NO -printf "Regression test setup: (not really needed to build gxemul)\n" + # 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 -## 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" +# # 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 -#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 + # 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 -# 64-bit MIPS cross-compiler: + 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 -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" +# 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 $MIPS"-gcc" + echo "Error! Could not determine host's endianness." + exit fi fi -rm -f _testprog* _test.sh +rm -f _test_end* -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 +############################################################################### +INCLUDE=-Iinclude/ +DINCLUDE=-I../include/ -## 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 +rm -f _testprog.c +echo C compiler flags: $CFLAGS $CWARNINGS +echo Linker flags: $OTHERLIBS +echo "CWARNINGS=$CWARNINGS" >> _Makefile.header +echo "COPTIM=$CFLAGS" >> _Makefile.header +echo "INCLUDE=$INCLUDE" >> _Makefile.header +echo "DINCLUDE=$DINCLUDE" >> _Makefile.header +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: -for a in . src src/devices src/devices/fonts tests; do +# Create the Makefiles: +D=". src src/include src/cpus src/devices src/devices/fonts" +D="$D src/machines src/promemul" +for a in $D; do echo "creating $a/Makefile" touch $a/Makefile cat _Makefile.header > $a/Makefile