--- trunk/configure 2007/10/08 16:18:27 10 +++ trunk/configure 2007/10/08 16:20:40 30 @@ -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.140 2005/06/27 17:31:50 debug Exp $ +# $Id: configure,v 1.228 2006/07/25 21:49:14 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,106 +47,63 @@ # 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. # ############################################################################### -ENABLEARM=YES -ENABLEMIPS=YES -ENABLEPPC=YES -ENABLEURISC=YES -ENABLEX86=NO -STABLE=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: + ENABLEALPHA=YES + ENABLEARM=YES + ENABLEMIPS=YES + ENABLEPPC=YES +else + # 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 + ENABLETRANSPUTER=YES + ENABLEX86=YES +fi + +if [ z"$UNSTABLE" = zYES ]; then + printf "###\n### DEVELOPMENT (UNSTABLE)\n###\n\n" +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--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-arm ]; then - ENABLEARM=NO - else if [ z$a = z--enable-arm ]; then - ENABLEARM=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-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-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--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 " --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" - echo " --disable-arm disable ARM CPU emulation" - echo " --disable-mips disable MIPS CPU emulation" - echo " --disable-ppc disable PPC CPU emulation" - echo " --disable-urisc disable URISC CPU emulation" - if [ z$STABLE = zNO ]; then - printf " --enable-x86 " - printf "enable x86 CPU emulation" - printf " (NOT YET)\n" - fi - printf "\nMIPS-specific options:\n" - printf " --enable-mips16 enable MIPS16 instruction" - printf " support (NOT YET)\n\n" + printf "usage: $0 [options]\n\n" + echo " --disable-x don't include X11 support,"\ + "even if the host supports it" + 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 done fi @@ -176,76 +133,92 @@ 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 +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$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" 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" 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$ENABLEURISC = zYES ]; then - printf "#define ENABLE_URISC\n" >> config.h +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" + CPU_TOOLS="$CPU_TOOLS generate_sparc_loadstore" +fi +if [ z$ENABLETRANSPUTER = zYES ]; then + printf "#define ENABLE_TRANSPUTER\n" >> config.h + CPU_ARCHS="$CPU_ARCHS cpu_transputer.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 -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 -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 + CPU_ARCHS="$CPU_ARCHS cpu_x86.o" 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 - 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 - printf "\nNOTE: Cache emulation enabled, but right now it triggers " printf "weird bugs in the\n emulator. You have been warned.\n\n" fi @@ -325,15 +298,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 @@ -448,8 +421,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\"); @@ -479,39 +452,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\"); @@ -543,7 +485,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\"); @@ -575,7 +517,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\"); @@ -618,6 +560,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 @@ -625,7 +579,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 @@ -640,9 +594,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 @@ -730,6 +684,25 @@ rm -f _testprog _testprog.error _testprog.stdout +# -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 + + # -lrt for nanosleep? printf "checking whether -lrt is required for nanosleep... " printf "#include \n#include @@ -864,12 +837,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 @@ -926,6 +907,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 @@ -961,6 +983,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\", @@ -982,110 +1006,70 @@ 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 - -############################################################################### -# -# 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 - - if [ z$BINTRANS = zNO ]; then - printf "not supported yet on this arch\n" +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 ############################################################################### -# 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" +# 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* ############################################################################### INCLUDE=-Iinclude/ DINCLUDE=-I../include/ +rm -f _testprog.c + echo C compiler flags: $CFLAGS $CWARNINGS echo Linker flags: $OTHERLIBS echo "CWARNINGS=$CWARNINGS" >> _Makefile.header @@ -1094,128 +1078,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 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/machines src/promemul doc" +for a in $D; do echo "creating $a/Makefile" touch $a/Makefile cat _Makefile.header > $a/Makefile