1 |
#!/bin/sh |
#!/bin/sh |
2 |
############################################################################### |
############################################################################### |
3 |
# |
# |
4 |
# Copyright (C) 2003-2005 Anders Gavare. All rights reserved. |
# Copyright (C) 2003-2006 Anders Gavare. All rights reserved. |
5 |
# |
# |
6 |
# Redistribution and use in source and binary forms, with or without |
# Redistribution and use in source and binary forms, with or without |
7 |
# modification, are permitted provided that the following conditions are met: |
# modification, are permitted provided that the following conditions are met: |
27 |
# SUCH DAMAGE. |
# SUCH DAMAGE. |
28 |
# |
# |
29 |
# |
# |
30 |
# $Id: configure,v 1.140 2005/06/27 17:31:50 debug Exp $ |
# $Id: configure,v 1.235 2006/10/28 13:04:37 debug Exp $ |
31 |
# |
# |
32 |
# This is a minimal configure script, hardcoded for GXemul. This script |
# This is a minimal configure script, hardcoded for GXemul. This script |
33 |
# figures out which compiler flags will work, and creates Makefiles in |
# figures out which compiler flags will work, and creates Makefiles in |
47 |
# o) special hacks for some OSes |
# o) special hacks for some OSes |
48 |
# o) which compiler to use (overridden by setting CC) |
# o) which compiler to use (overridden by setting CC) |
49 |
# o) which compiler flags to use (overridden by setting CFLAGS) |
# o) which compiler flags to use (overridden by setting CFLAGS) |
50 |
# o) X11 flags and libraries (TODO: should be possible to override) |
# o) X11 flags and libraries (TODO: should be possible to override |
51 |
# o) binary translation (on supported platforms) |
# via command line options?) |
52 |
# o) prefetch capability (TODO: this is assumed on Alpha, but not all |
# |
53 |
# Alphas have it...) |
# |
54 |
# |
# The general philosophy regarding command line switches is that anything |
55 |
# TODO: |
# which can be incorporated into the program as a runtime command line option |
56 |
# o) do not enable prefetch on Alpha ev4 or ev5, only on pca56 and newer |
# should be, instead of requiring a recompile. |
|
# o) X11 libs and includes via command line options? |
|
57 |
# |
# |
58 |
############################################################################### |
############################################################################### |
59 |
|
|
60 |
ENABLEARM=YES |
# Figure out if this is a stable version (0.x.x). |
61 |
ENABLEMIPS=YES |
X=`basename \`pwd\`|cut -d \- -f 2-|cut -c1-2` |
62 |
ENABLEPPC=YES |
if [ z"$X" = z0. ]; then |
63 |
ENABLEURISC=YES |
# Stable: |
64 |
ENABLEX86=NO |
ENABLEALPHA=YES |
65 |
STABLE=NO |
ENABLEARM=YES |
66 |
|
ENABLEMIPS=YES |
67 |
|
ENABLEPPC=YES |
68 |
|
ENABLESH=YES |
69 |
|
else |
70 |
|
# Development: |
71 |
|
UNSTABLE=YES |
72 |
|
ENABLEALPHA=YES |
73 |
|
ENABLEARM=YES |
74 |
|
ENABLEAVR=YES |
75 |
|
ENABLEAVR32=YES |
76 |
|
ENABLEHPPA=YES |
77 |
|
ENABLEI960=YES |
78 |
|
ENABLEIA64=YES |
79 |
|
ENABLEM68K=YES |
80 |
|
ENABLEMIPS=YES |
81 |
|
ENABLEPPC=YES |
82 |
|
ENABLERCA180X=YES |
83 |
|
ENABLESH=YES |
84 |
|
ENABLESPARC=YES |
85 |
|
ENABLETRANSPUTER=YES |
86 |
|
ENABLEX86=YES |
87 |
|
fi |
88 |
|
|
89 |
|
if [ z"$UNSTABLE" = zYES ]; then |
90 |
|
printf "###\n### DEVELOPMENT (UNSTABLE)\n###\n\n" |
91 |
|
fi |
92 |
|
|
93 |
if [ z"$*" != z ]; then |
if [ z"$*" != z ]; then |
94 |
# Parse command line options: |
# Parse command line options: |
95 |
for a in $*; do |
for a in $*; do |
96 |
if [ z$a = z--disable-x ]; then |
if [ z$a = z--disable-x ]; then |
97 |
NOX11=YES |
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 |
|
98 |
else if [ z$a = z--help ]; then |
else if [ z$a = z--help ]; then |
99 |
echo "usage: $0 [options]" |
printf "usage: $0 [options]\n\n" |
100 |
printf "\nDevelopment (debug) options:\n" |
echo " --disable-x don't include X11 support,"\ |
101 |
echo " --always32 enable" \ |
"even if the host supports it" |
102 |
"ALWAYS_SIGNEXTEND_32 (for hunting down" |
echo |
|
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" |
|
103 |
exit |
exit |
104 |
else |
else |
105 |
echo "Invalid option: $a" |
echo "Invalid option: $a" |
106 |
echo "Run $0 --help to get a list of" \ |
echo "Run $0 --help to get a list of" \ |
107 |
"available options." |
"available options." |
108 |
exit |
exit |
109 |
fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi; fi |
fi; fi |
|
fi; fi; fi; fi; fi; fi; fi |
|
110 |
done |
done |
111 |
fi |
fi |
112 |
|
|
136 |
fi |
fi |
137 |
|
|
138 |
|
|
139 |
|
if [ z"$UNSTABLE" = zYES ]; then |
140 |
|
printf "#define UNSTABLE_DEVEL\n" >> config.h |
141 |
|
fi |
142 |
|
|
143 |
|
|
144 |
ZZ=`echo compiled on \`uname\`/\`uname -m\`, \`date\`` |
ZZ=`echo compiled on \`uname\`/\`uname -m\`, \`date\`` |
145 |
printf "#define COMPILE_DATE \"$ZZ\"\n" >> config.h |
printf "#define COMPILE_DATE \"$ZZ\"\n" >> config.h |
146 |
|
|
147 |
|
|
148 |
|
|
149 |
# Support for various CPU types: |
# Support for various CPU types: |
150 |
if [ z$MIPS16 = zYES ]; then |
if [ z$ENABLEALPHA = zYES ]; then |
151 |
printf 'Enabling MIPS16 support. ' |
printf "#define ENABLE_ALPHA\n" >> config.h |
152 |
printf 'NOTE: MIPS16 support is not really working yet.\n' |
CPU_ARCHS="$CPU_ARCHS cpu_alpha.o cpu_alpha_palcode.o memory_alpha.o" |
153 |
printf "#define ENABLE_MIPS16\n" >> config.h |
CPU_TOOLS="$CPU_TOOLS generate_alpha_misc" |
154 |
fi |
fi |
155 |
if [ z$ENABLEARM = zYES ]; then |
if [ z$ENABLEARM = zYES ]; then |
156 |
printf "#define ENABLE_ARM\n" >> config.h |
printf "#define ENABLE_ARM\n" >> config.h |
157 |
|
CPU_ARCHS="$CPU_ARCHS cpu_arm.o cpu_arm_coproc.o memory_arm.o " |
158 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_dpi.o tmp_arm_loadstore.o tmp_arm_r.o" |
159 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_r0.o tmp_arm_r1.o" |
160 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_r2.o tmp_arm_r3.o" |
161 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_r4.o tmp_arm_r5.o" |
162 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_r6.o tmp_arm_r7.o" |
163 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_r8.o tmp_arm_r9.o" |
164 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_ra.o tmp_arm_rb.o" |
165 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_rc.o tmp_arm_rd.o" |
166 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_re.o tmp_arm_rf.o tmp_arm_multi.o" |
167 |
|
CPU_TOOLS="$CPU_TOOLS generate_arm_dpi generate_arm_r" |
168 |
|
CPU_TOOLS="$CPU_TOOLS generate_arm_loadstore generate_arm_multi" |
169 |
|
fi |
170 |
|
if [ z$ENABLEAVR = zYES ]; then |
171 |
|
printf "#define ENABLE_AVR\n" >> config.h |
172 |
|
CPU_ARCHS="$CPU_ARCHS cpu_avr.o" |
173 |
|
fi |
174 |
|
if [ z$ENABLEAVR32 = zYES ]; then |
175 |
|
printf "#define ENABLE_AVR32\n" >> config.h |
176 |
|
CPU_ARCHS="$CPU_ARCHS cpu_avr32.o" |
177 |
|
fi |
178 |
|
if [ z$ENABLEHPPA = zYES ]; then |
179 |
|
printf "#define ENABLE_HPPA\n" >> config.h |
180 |
|
CPU_ARCHS="$CPU_ARCHS cpu_hppa.o" |
181 |
|
fi |
182 |
|
if [ z$ENABLEI960 = zYES ]; then |
183 |
|
printf "#define ENABLE_I960\n" >> config.h |
184 |
|
CPU_ARCHS="$CPU_ARCHS cpu_i960.o" |
185 |
|
fi |
186 |
|
if [ z$ENABLEIA64 = zYES ]; then |
187 |
|
printf "#define ENABLE_IA64\n" >> config.h |
188 |
|
CPU_ARCHS="$CPU_ARCHS cpu_ia64.o" |
189 |
|
fi |
190 |
|
if [ z$ENABLEM68K = zYES ]; then |
191 |
|
printf "#define ENABLE_M68K\n" >> config.h |
192 |
|
CPU_ARCHS="$CPU_ARCHS cpu_m68k.o" |
193 |
fi |
fi |
194 |
if [ z$ENABLEMIPS = zYES ]; then |
if [ z$ENABLEMIPS = zYES ]; then |
195 |
printf "#define ENABLE_MIPS\n" >> config.h |
printf "#define ENABLE_MIPS\n" >> config.h |
196 |
|
CPU_ARCHS="$CPU_ARCHS cpu_mips.o cpu_mips_coproc.o " |
197 |
|
CPU_ARCHS="$CPU_ARCHS cpu_mips_instr_unaligned.o" |
198 |
|
CPU_TOOLS="$CPU_TOOLS generate_mips_loadstore" |
199 |
fi |
fi |
200 |
if [ z$ENABLEPPC = zYES ]; then |
if [ z$ENABLEPPC = zYES ]; then |
201 |
printf "#define ENABLE_PPC\n" >> config.h |
printf "#define ENABLE_PPC\n" >> config.h |
202 |
|
CPU_ARCHS="$CPU_ARCHS cpu_ppc.o" |
203 |
|
CPU_TOOLS="$CPU_TOOLS generate_ppc_loadstore" |
204 |
fi |
fi |
205 |
if [ z$ENABLEURISC = zYES ]; then |
if [ z$ENABLERCA180X = zYES ]; then |
206 |
printf "#define ENABLE_URISC\n" >> config.h |
printf "#define ENABLE_RCA180X\n" >> config.h |
207 |
|
CPU_ARCHS="$CPU_ARCHS cpu_rca180x.o" |
208 |
|
fi |
209 |
|
if [ z$ENABLESH = zYES ]; then |
210 |
|
printf "#define ENABLE_SH\n" >> config.h |
211 |
|
CPU_ARCHS="$CPU_ARCHS cpu_sh.o memory_sh.o" |
212 |
|
fi |
213 |
|
if [ z$ENABLESPARC = zYES ]; then |
214 |
|
printf "#define ENABLE_SPARC\n" >> config.h |
215 |
|
CPU_ARCHS="$CPU_ARCHS cpu_sparc.o memory_sparc.o" |
216 |
|
CPU_TOOLS="$CPU_TOOLS generate_sparc_loadstore" |
217 |
|
fi |
218 |
|
if [ z$ENABLETRANSPUTER = zYES ]; then |
219 |
|
printf "#define ENABLE_TRANSPUTER\n" >> config.h |
220 |
|
CPU_ARCHS="$CPU_ARCHS cpu_transputer.o" |
221 |
fi |
fi |
222 |
if [ z$ENABLEX86 = zYES ]; then |
if [ z$ENABLEX86 = zYES ]; then |
223 |
printf "#define ENABLE_X86\n" >> config.h |
printf "#define ENABLE_X86\n" >> config.h |
224 |
if [ z$STABLE = zNO ]; then |
CPU_ARCHS="$CPU_ARCHS cpu_x86.o" |
|
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 |
|
|
fi |
|
|
|
|
|
|
|
|
# Cache emulation: |
|
|
if [ z$CACHES = zYES ]; then |
|
|
echo 'Enabling Cache emulation. (EXPERIMENTAL)' |
|
|
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" |
|
225 |
fi |
fi |
226 |
|
|
227 |
|
|
299 |
fi |
fi |
300 |
rm -f _testprog |
rm -f _testprog |
301 |
|
|
302 |
# Try ccc (FreeBSD/Alpha): |
# # Try ccc (FreeBSD/Alpha): |
303 |
printf "#!/bin/sh\nccc _testprog.c -o _testprog >" > _test.sh |
# printf "#!/bin/sh\nccc _testprog.c -o _testprog >" > _test.sh |
304 |
printf " /dev/null 2> /dev/null\n" >> _test.sh |
# printf " /dev/null 2> /dev/null\n" >> _test.sh |
305 |
chmod 755 _test.sh |
# chmod 755 _test.sh |
306 |
./_test.sh > /dev/null 2> /dev/null |
# ./_test.sh > /dev/null 2> /dev/null |
307 |
if [ -x _testprog ]; then |
# if [ -x _testprog ]; then |
308 |
CC="ccc" |
# CC="ccc" |
309 |
fi |
# fi |
310 |
rm -f _testprog |
# rm -f _testprog |
311 |
|
|
312 |
rm -f _test.sh |
rm -f _test.sh |
313 |
fi |
fi |
422 |
fi |
fi |
423 |
|
|
424 |
|
|
425 |
# Check for weird 'alpha' define. |
# Check for 'alpha' define. |
426 |
printf "checking for weird 'alpha' define... " |
printf "checking for 'alpha' define... " |
427 |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
428 |
#ifdef alpha |
#ifdef alpha |
429 |
printf(\"1\"); |
printf(\"1\"); |
453 |
rm -f _testm* |
rm -f _testm* |
454 |
|
|
455 |
|
|
|
# Check for weird 'hppa' define. |
|
|
printf "checking for weird 'hppa' define... " |
|
|
printf "#include <stdio.h>\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* |
|
|
|
|
|
|
|
456 |
# Some OSes on MIPS seems to define 'mips' to 1. (eg OpenBSD/arc) |
# Some OSes on MIPS seems to define 'mips' to 1. (eg OpenBSD/arc) |
457 |
printf "checking for weird 'mips' define... " |
printf "checking for 'mips' define... " |
458 |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
459 |
#ifdef mips |
#ifdef mips |
460 |
printf(\"1\"); |
printf(\"1\"); |
486 |
|
|
487 |
# Similar to the mips define check above, although I don't know if |
# Similar to the mips define check above, although I don't know if |
488 |
# any OS actually defined ppc like this. |
# any OS actually defined ppc like this. |
489 |
printf "checking for weird 'ppc' define... " |
printf "checking for 'ppc' define... " |
490 |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
491 |
#ifdef ppc |
#ifdef ppc |
492 |
printf(\"1\"); |
printf(\"1\"); |
518 |
|
|
519 |
# Similar to the mips define check above, although I don't know if |
# Similar to the mips define check above, although I don't know if |
520 |
# any OS actually defined sparc like this. |
# any OS actually defined sparc like this. |
521 |
printf "checking for weird 'sparc' define... " |
printf "checking for 'sparc' define... " |
522 |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
523 |
#ifdef sparc |
#ifdef sparc |
524 |
printf(\"1\"); |
printf(\"1\"); |
561 |
if [ z"$COMPAQCC" = zYES ]; then |
if [ z"$COMPAQCC" = zYES ]; then |
562 |
CWARNINGS="$CWARNINGS -msg_disable longlongtype,unusedtop" |
CWARNINGS="$CWARNINGS -msg_disable longlongtype,unusedtop" |
563 |
fi |
fi |
564 |
|
|
565 |
|
if [ z"$UNSTABLE" = zYES ]; then |
566 |
|
printf "checking whether -Werror can be used... " |
567 |
|
rm -f _testprog |
568 |
|
$CC $CFLAGS $CWARNINGS _testprog.c -o _testprog -Werror 2> /dev/null |
569 |
|
if [ -x _testprog ]; then |
570 |
|
printf "yes\n" |
571 |
|
CWARNINGS="$CWARNINGS -Werror" |
572 |
|
else |
573 |
|
printf "no\n" |
574 |
|
fi |
575 |
|
fi |
576 |
else |
else |
577 |
printf "no\n" |
printf "no\n" |
578 |
fi |
fi |
580 |
|
|
581 |
|
|
582 |
if [ z"$COMPAQCC" = zYES ]; then |
if [ z"$COMPAQCC" = zYES ]; then |
583 |
# -O4 is possible, but is -O3 better? |
# -O4 is possible, but sometimes -O3 is better? |
584 |
CFLAGS="-O4 $CFLAGS" |
CFLAGS="-O4 $CFLAGS" |
585 |
else |
else |
586 |
if [ z"`uname`" = zSunOS ]; then |
if [ z"`uname`" = zSunOS ]; then |
595 |
$CC $CFLAGS _testprog.c -o _testprog -O 2> /dev/null |
$CC $CFLAGS _testprog.c -o _testprog -O 2> /dev/null |
596 |
if [ -x _testprog ]; then |
if [ -x _testprog ]; then |
597 |
rm -f _testprog |
rm -f _testprog |
598 |
$CC $CFLAGS _testprog.c -o _testprog -O2 2> /dev/null |
$CC $CFLAGS _testprog.c -o _testprog -O3 2> /dev/null |
599 |
if [ -x _testprog ]; then |
if [ -x _testprog ]; then |
600 |
CFLAGS="-O2 $CFLAGS" |
CFLAGS="-O3 $CFLAGS" |
601 |
else |
else |
602 |
CFLAGS="-O $CFLAGS" |
CFLAGS="-O $CFLAGS" |
603 |
fi |
fi |
685 |
rm -f _testprog _testprog.error _testprog.stdout |
rm -f _testprog _testprog.error _testprog.stdout |
686 |
|
|
687 |
|
|
688 |
|
# -g, for development builds |
689 |
|
if [ z"$UNSTABLE" = zYES ]; then |
690 |
|
printf "checking whether -g can be used... " |
691 |
|
if [ z"$COMPAQCC" = zYES ]; then |
692 |
|
printf "skipping\n" |
693 |
|
else |
694 |
|
$CC $CFLAGS -g _testprog.c -o _testprog > _testprog.stdout 2>&1 |
695 |
|
cat _testprog.stdout >> _testprog.error |
696 |
|
if [ -x _testprog ]; then |
697 |
|
CFLAGS="-g $CFLAGS" |
698 |
|
printf "yes\n" |
699 |
|
else |
700 |
|
printf "no\n" |
701 |
|
fi |
702 |
|
fi |
703 |
|
rm -f _testprog _testprog.error _testprog.stdout |
704 |
|
fi |
705 |
|
|
706 |
|
|
707 |
# -lrt for nanosleep? |
# -lrt for nanosleep? |
708 |
printf "checking whether -lrt is required for nanosleep... " |
printf "checking whether -lrt is required for nanosleep... " |
709 |
printf "#include <time.h>\n#include <stdio.h> |
printf "#include <time.h>\n#include <stdio.h> |
838 |
#include <stdio.h> |
#include <stdio.h> |
839 |
#include <sys/types.h> |
#include <sys/types.h> |
840 |
int main(int argc, char *argv[]) { fseeko(NULL, 0, 0); return 0;}\n" > _tests.c |
int main(int argc, char *argv[]) { fseeko(NULL, 0, 0); return 0;}\n" > _tests.c |
841 |
$CC $CFLAGS _tests.c -o _tests 2> /dev/null |
$CC $CFLAGS $CWARNINGS _tests.c -o _tests 2> /dev/null |
842 |
if [ ! -x _tests ]; then |
if [ ! -x _tests ]; then |
843 |
printf "missing\n" |
# Try with _LARGEFILE_SOURCE (hack to make fseeko |
844 |
printf "WARNING! fseeko missing from libc. Using a hack, " |
# work on 64-bit Linux): |
845 |
printf "which probably doesn't work.\n" |
$CC $CFLAGS -D_LARGEFILE_SOURCE $CWARNINGS _tests.c -o _tests 2> /dev/null |
846 |
printf "#define HACK_FSEEKO\n" >> config.h |
if [ ! -x _tests ]; then |
847 |
|
printf "missing\n" |
848 |
|
printf "WARNING! fseeko missing from libc. Using a hack, " |
849 |
|
printf "which probably doesn't work.\n" |
850 |
|
printf "#define HACK_FSEEKO\n" >> config.h |
851 |
|
else |
852 |
|
printf "using -D_LARGEFILE_SOURCE hack\n" |
853 |
|
CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE" |
854 |
|
fi |
855 |
else |
else |
856 |
printf "found\n" |
printf "found\n" |
857 |
fi |
fi |
908 |
rm -f _tests.[co] _tests |
rm -f _tests.[co] _tests |
909 |
|
|
910 |
|
|
911 |
|
# Check for PRIx64 in inttypes.h: |
912 |
|
printf "checking for PRIx64 in inttypes.h... " |
913 |
|
printf "#include <inttypes.h>\nint main(int argc, char *argv[])\n |
914 |
|
{\n#ifdef PRIx64\nreturn 0;\n#else\nreturn 1;\n#endif\n}\n" > _testpri.c |
915 |
|
$CC $CFLAGS _testpri.c -o _testpri 2> /dev/null |
916 |
|
if [ ! -x _testpri ]; then |
917 |
|
printf "\nERROR! COULD NOT COMPILE PRIx64 TEST PROGRAM AT ALL!\n" |
918 |
|
exit |
919 |
|
else |
920 |
|
if ./_testpri; then |
921 |
|
printf "yes\n" |
922 |
|
else |
923 |
|
printf "no, using an ugly hack instead, " |
924 |
|
printf "#define NO_C99_PRINTF_DEFINES\n" >> config.h |
925 |
|
|
926 |
|
# Try llx first: |
927 |
|
printf "#include <stdio.h>\n#include <inttypes.h>\nint main(int argc, char *argv[]){ |
928 |
|
printf(\"%%llx\\\n\", (int64_t)128);return 0;}\n" > _testpri.c |
929 |
|
rm -f _testpri |
930 |
|
$CC $CFLAGS $CWARNINGS _testpri.c -o _testpri 2> /dev/null |
931 |
|
if [ z`./_testpri` = z80 ]; then |
932 |
|
printf "PRIx64=llx\n" |
933 |
|
printf "#define NO_C99_64BIT_LONGLONG\n" >> config.h |
934 |
|
else |
935 |
|
# Try lx too: |
936 |
|
printf "#include <stdio.h>\n#include <inttypes.h>\nint main(int argc, char *argv[]){ |
937 |
|
printf(\"%%lx\\\n\", (int64_t)128);return 0;}\n" > _testpri.c |
938 |
|
rm -f _testpri |
939 |
|
$CC $CFLAGS $CWARNINGS _testpri.c -o _testpri 2> /dev/null |
940 |
|
if [ z`./_testpri` = z80 ]; then |
941 |
|
printf "PRIx64=lx\n" |
942 |
|
else |
943 |
|
printf "\nFailed, neither lx nor llx worked!\n" |
944 |
|
exit |
945 |
|
fi |
946 |
|
fi |
947 |
|
fi |
948 |
|
fi |
949 |
|
rm -f _testpri.c _testpri |
950 |
|
|
951 |
|
|
952 |
# Check for 64-bit off_t: |
# Check for 64-bit off_t: |
953 |
printf "checking for 64-bit off_t... " |
printf "checking for 64-bit off_t... " |
954 |
printf "#include <stdio.h>\n#include <inttypes.h>\n#include <sys/types.h>\n |
printf "#include <stdio.h>\n#include <inttypes.h>\n#include <sys/types.h>\n |
984 |
|
|
985 |
|
|
986 |
# Check for u_int8_t etc: |
# Check for u_int8_t etc: |
987 |
|
# These are needed because some header files in src/include/ use u_int* |
988 |
|
# instead of uint*, and I don't have time to rewrite them all. |
989 |
printf "checking for u_int8_t... " |
printf "checking for u_int8_t... " |
990 |
printf "#include <stdio.h>\n#include <inttypes.h>\n#include <sys/types.h>\n |
printf "#include <stdio.h>\n#include <inttypes.h>\n#include <sys/types.h>\n |
991 |
int main(int argc, char *argv[]){printf(\"%%i\\\n\", |
int main(int argc, char *argv[]){printf(\"%%i\\\n\", |
1007 |
printf "typedef uint8_t u_int8_t;\n" >> config.h |
printf "typedef uint8_t u_int8_t;\n" >> config.h |
1008 |
printf "typedef uint16_t u_int16_t;\n" >> config.h |
printf "typedef uint16_t u_int16_t;\n" >> config.h |
1009 |
printf "typedef uint32_t u_int32_t;\n" >> config.h |
printf "typedef uint32_t u_int32_t;\n" >> config.h |
|
printf "typedef uint64_t u_int64_t;\n" >> config.h |
|
1010 |
printf "uint8_t\n" |
printf "uint8_t\n" |
1011 |
else |
else |
1012 |
printf "yes\n" |
printf "yes\n" |
1013 |
fi |
fi |
1014 |
rm -f _testuint.c _testuint |
rm -f _testuint.c _testuint |
1015 |
|
|
1016 |
|
printf "checking for u_int64_t... " |
1017 |
############################################################################### |
printf "#include <stdio.h>\n#include <inttypes.h>\n#include <sys/types.h>\n |
1018 |
# |
int main(int argc, char *argv[]){printf(\"%%i\\\n\", |
1019 |
# Dynamic binary translation (BINTRANS): |
(int)sizeof(u_int64_t));return 0;}\n" > _testuint.c |
1020 |
# |
$CC $CFLAGS _testuint.c -o _testuint 2> /dev/null |
1021 |
############################################################################### |
if [ ! -x _testuint ]; then |
1022 |
|
rm -f _testuint* |
1023 |
printf "checking for bintrans backend... " |
printf "#include <stdio.h>\n#include <inttypes.h> |
1024 |
|
\n#include <sys/types.h>\nint main(int argc, char *argv[]) |
1025 |
BINTRANS=NO |
{printf(\"%%i\\\n\", (int)sizeof(uint64_t));return 0;}\n" > _testuint.c |
1026 |
|
$CC $CFLAGS _testuint.c -o _testuint 2> /dev/null |
1027 |
if [ z$ENABLEMIPS = zNO ]; then |
if [ ! -x _testuint ]; then |
1028 |
printf "NO!\nTEMPORARY HACK/PROBLEM: Disabling bintrans for now,\n" |
printf "no\n\nERROR: No u_int64_t or uint64_t. Aborting\n" |
1029 |
printf "until things have stabilized.\n" |
# TODO: Automagically detect using various combinations |
1030 |
NOBINTRANS=YES |
# of char, int, short, long etc. |
1031 |
fi |
exit |
|
|
|
|
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" |
|
1032 |
fi |
fi |
1033 |
|
|
1034 |
|
printf "typedef uint64_t u_int64_t;\n" >> config.h |
1035 |
|
printf "uint64_t\n" |
1036 |
|
else |
1037 |
|
printf "yes\n" |
1038 |
fi |
fi |
1039 |
|
rm -f _testuint.c _testuint |
1040 |
|
|
1041 |
|
|
1042 |
############################################################################### |
############################################################################### |
1043 |
|
|
1044 |
# Prefetch support? |
# Host byte order? |
1045 |
printf "checking for asm prefetch support... " |
printf "checking host endianness... " |
1046 |
if [ z"`uname -m`" = zalpha ]; then |
rm -f _test_end* |
1047 |
rm -f _alpha_asm_test.c _alpha_asm_test |
printf '#include <stdio.h> |
1048 |
printf 'int main(int argc, char *argv[]) |
int main(int argc, char *argv[]) |
1049 |
{ int x; int *y = &x; asm ("ldl $31,0(%%0)" : : "g" (y)); |
{ int x = 1; void *xp = (void *)&x; char *p = (char *)xp; |
1050 |
return 0; }\n' > _alpha_asm_test.c |
if (*p) printf("little\\\n"); else printf("big\\\n"); } |
1051 |
$CC $CFLAGS -O2 _alpha_asm_test.c -o _alpha_asm_test \ |
' > _test_end.c |
1052 |
> /dev/null 2> /dev/null |
$CC $CFLAGS _test_end.c -o _test_end 2> /dev/null |
1053 |
if [ -x _alpha_asm_test ]; then |
X=`./_test_end` |
1054 |
# printf "#define HAVE_PREFETCH\n" >> config.h |
echo $X |
1055 |
printf "#define PREFETCH(x) asm(\"ldl" >> config.h |
if [ z$X = zlittle ]; then |
1056 |
printf " \$31,0(%%0)\" : : \"g\" (x))\n" >> config.h |
printf "#define HOST_LITTLE_ENDIAN\n" >> config.h |
1057 |
echo "yes" |
else |
1058 |
PREFSUP=YES |
if [ z$X = zbig ]; then |
1059 |
fi |
printf "#define HOST_BIG_ENDIAN\n" >> config.h |
1060 |
rm -f _alpha_asm_test.c _alpha_asm_test |
else |
1061 |
fi |
echo "Error! Could not determine host's endianness." |
1062 |
if [ z$PREFSUP = z ]; then |
exit |
1063 |
printf "#define PREFETCH(x) { }\n" >> config.h |
fi |
|
echo "no" |
|
1064 |
fi |
fi |
1065 |
|
rm -f _test_end* |
1066 |
|
|
1067 |
############################################################################### |
############################################################################### |
1068 |
|
|
1069 |
INCLUDE=-Iinclude/ |
INCLUDE=-Iinclude/ |
1070 |
DINCLUDE=-I../include/ |
DINCLUDE=-I../include/ |
1071 |
|
|
1072 |
|
rm -f _testprog.c |
1073 |
|
|
1074 |
echo C compiler flags: $CFLAGS $CWARNINGS |
echo C compiler flags: $CFLAGS $CWARNINGS |
1075 |
echo Linker flags: $OTHERLIBS |
echo Linker flags: $OTHERLIBS |
1076 |
echo "CWARNINGS=$CWARNINGS" >> _Makefile.header |
echo "CWARNINGS=$CWARNINGS" >> _Makefile.header |
1079 |
echo "DINCLUDE=$DINCLUDE" >> _Makefile.header |
echo "DINCLUDE=$DINCLUDE" >> _Makefile.header |
1080 |
echo "CC=$CC" >> _Makefile.header |
echo "CC=$CC" >> _Makefile.header |
1081 |
echo "OTHERLIBS=$OTHERLIBS" >> _Makefile.header |
echo "OTHERLIBS=$OTHERLIBS" >> _Makefile.header |
1082 |
|
echo "CPU_ARCHS=$CPU_ARCHS" >> _Makefile.header |
1083 |
|
echo "CPU_TOOLS=$CPU_TOOLS" >> _Makefile.header |
1084 |
echo "" >> _Makefile.header |
echo "" >> _Makefile.header |
1085 |
|
|
1086 |
|
|
|
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 |
|
|
|
|
|
|
|
1087 |
# Create the Makefiles: |
# Create the Makefiles: |
1088 |
|
D=". src src/include src/cpus src/debugger src/devices src/devices/fonts" |
1089 |
for a in . src src/devices src/devices/fonts tests; do |
D="$D src/machines src/net src/promemul" |
1090 |
|
for a in $D; do |
1091 |
echo "creating $a/Makefile" |
echo "creating $a/Makefile" |
1092 |
touch $a/Makefile |
touch $a/Makefile |
1093 |
cat _Makefile.header > $a/Makefile |
cat _Makefile.header > $a/Makefile |