1 |
#!/bin/sh |
#!/bin/sh |
2 |
############################################################################### |
############################################################################### |
3 |
# |
# |
4 |
# Copyright (C) 2003-2005 Anders Gavare. All rights reserved. |
# Copyright (C) 2003-2007 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.132 2005/06/04 12:05:50 debug Exp $ |
# $Id: configure,v 1.270 2007/06/15 17:13:40 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...) |
# The general philosophy regarding command line switches is that anything |
54 |
|
# which can be incorporated into the program as a runtime command line option |
55 |
|
# should be, instead of requiring a recompile. |
56 |
# |
# |
57 |
############################################################################### |
############################################################################### |
58 |
|
|
59 |
ENABLEALPHA=NO |
# Figure out if this is a stable version (0.x.x). |
60 |
ENABLEARM=NO |
X=`basename \`pwd\`|cut -d \- -f 2-|cut -c1-2` |
61 |
ENABLEHPPA=NO |
if [ z"$X" = z0. ]; then |
62 |
ENABLEMIPS=YES |
# Stable. |
63 |
ENABLEPPC=YES |
: |
64 |
ENABLESPARC=NO |
else |
65 |
ENABLEURISC=YES |
# Development. |
66 |
ENABLEX86=NO |
UNSTABLE=YES |
67 |
STABLE=YES |
fi |
68 |
|
|
69 |
if [ z"$*" != z ]; then |
if [ z"$*" != z ]; then |
70 |
# Parse command line options: |
# Parse command line options: |
71 |
for a in $*; do |
for a in $*; do |
72 |
if [ z$a = z--disable-x ]; then |
if [ z$a = z--disable-x ]; then |
73 |
NOX11=YES |
NOX11=YES |
74 |
else if [ z$a = z--always32 ]; then |
else if [ z$a = z--debug ]; then |
75 |
ALWAYS32=YES |
DEBUG=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-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-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 |
|
76 |
else if [ z$a = z--help ]; then |
else if [ z$a = z--help ]; then |
77 |
echo "usage: $0 [options]" |
printf "usage: $0 [options]\n\n" |
78 |
printf "\nDevelopment (debug) options:\n" |
echo " --disable-x don't include X11 support,"\ |
79 |
echo " --always32 enable" \ |
"even if the host supports it" |
80 |
"ALWAYS_SIGNEXTEND_32 (for hunting down" |
if [ z"$UNSTABLE" = zYES ]; then |
81 |
echo " 32/64-bit bugs)" |
echo " --debug configure" \ |
82 |
printf "\nGeneral options:\n" |
"for a debug build" |
|
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" |
|
|
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" |
|
83 |
fi |
fi |
84 |
printf "\nMIPS-specific options:\n" |
echo |
|
printf " --enable-mips16 enable MIPS16 instruction" |
|
|
printf " support (NOT YET)\n\n" |
|
85 |
exit |
exit |
86 |
else |
else |
87 |
echo "Invalid option: $a" |
echo "Invalid option: $a" |
88 |
echo "Run $0 --help to get a list of" \ |
echo "Run $0 --help to get a list of" \ |
89 |
"available options." |
"available options." |
90 |
exit |
exit |
91 |
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 |
|
92 |
done |
done |
93 |
fi |
fi |
94 |
|
|
112 |
# Figure out if VERSION should be defined. |
# Figure out if VERSION should be defined. |
113 |
X=`basename \`pwd\`|cut -d \- -f 2-` |
X=`basename \`pwd\`|cut -d \- -f 2-` |
114 |
if [ z"$X" = zgxemul ]; then |
if [ z"$X" = zgxemul ]; then |
115 |
echo '# No VERSION defined.' >> _Makefile.header |
echo '/* No VERSION defined. */' >> config.h |
116 |
else |
else |
117 |
printf "#define VERSION \"$X\"\n" >> config.h |
printf "#define VERSION \"$X\"\n" >> config.h |
118 |
fi |
fi |
119 |
|
|
120 |
|
|
121 |
ZZ=`echo compiled on \`uname\`/\`uname -m\`, \`date\`` |
if [ z"$UNSTABLE" = zYES ]; then |
122 |
printf "#define COMPILE_DATE \"$ZZ\"\n" >> config.h |
printf "#define UNSTABLE_DEVEL\n" >> config.h |
123 |
|
else |
124 |
|
CFLAGS="-DNDEBUG $CFLAGS" |
|
|
|
|
# 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 |
|
|
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 |
|
|
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 |
|
|
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 |
|
|
fi |
|
|
if [ z$ENABLEMIPS = zYES ]; then |
|
|
printf "#define ENABLE_MIPS\n" >> config.h |
|
|
fi |
|
|
if [ z$ENABLEPPC = zYES ]; then |
|
|
printf "#define ENABLE_PPC\n" >> config.h |
|
|
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 |
|
|
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 |
|
125 |
fi |
fi |
126 |
|
|
127 |
|
|
128 |
# Instruction delay/latency emulation: |
ZZ=`echo compiled on \`uname\`/\`uname -m\`, \`date\`` |
129 |
if [ z$ALWAYS32 = zYES ]; then |
printf "#define COMPILE_DATE \"$ZZ\"\n" >> config.h |
|
echo 'Enabling ALWAYS_SIGNEXTEND_32. (NOTE:' \ |
|
|
'This slows down everything.)' |
|
|
printf "#define ALWAYS_SIGNEXTEND_32\n" >> config.h |
|
|
fi |
|
130 |
|
|
131 |
|
|
132 |
# Cache emulation: |
# Include support for all CPU types: |
133 |
if [ z$CACHES = zYES ]; then |
printf "#define ADD_ALL_CPU_FAMILIES " >> config.h |
|
echo 'Enabling Cache emulation. (EXPERIMENTAL)' |
|
|
printf "#define ENABLE_CACHE_EMULATION\n" >> config.h |
|
134 |
|
|
135 |
if [ z$DELAYS != zYES ]; then |
# Alpha |
136 |
printf 'WARNING: Cache emulation without instruction ' |
printf " add_cpu_family(alpha_cpu_family_init, ARCH_ALPHA);" >> config.h |
137 |
printf 'delay/latency emulation\n' |
CPU_ARCHS="$CPU_ARCHS cpu_alpha.o cpu_alpha_palcode.o memory_alpha.o" |
138 |
printf ' (--delays) will not produce correct ' |
CPU_TOOLS="$CPU_TOOLS generate_alpha_misc" |
139 |
printf 'cache miss penalties and such.\n' |
|
140 |
fi |
# ARM |
141 |
|
printf " add_cpu_family(arm_cpu_family_init, ARCH_ARM);" >> config.h |
142 |
|
CPU_ARCHS="$CPU_ARCHS cpu_arm.o cpu_arm_coproc.o memory_arm.o " |
143 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_loadstore.o" |
144 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_loadstore_p0_u0_w0.o" |
145 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_loadstore_p0_u0_w1.o" |
146 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_loadstore_p0_u1_w0.o" |
147 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_loadstore_p0_u1_w1.o" |
148 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_loadstore_p1_u0_w0.o" |
149 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_loadstore_p1_u0_w1.o" |
150 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_loadstore_p1_u1_w0.o" |
151 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_loadstore_p1_u1_w1.o" |
152 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_dpi.o tmp_arm_r.o" |
153 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_r0.o tmp_arm_r1.o" |
154 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_r2.o tmp_arm_r3.o" |
155 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_r4.o tmp_arm_r5.o" |
156 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_r6.o tmp_arm_r7.o" |
157 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_r8.o tmp_arm_r9.o" |
158 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_ra.o tmp_arm_rb.o" |
159 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_rc.o tmp_arm_rd.o" |
160 |
|
CPU_ARCHS="$CPU_ARCHS tmp_arm_re.o tmp_arm_rf.o tmp_arm_multi.o" |
161 |
|
CPU_TOOLS="$CPU_TOOLS generate_arm_dpi generate_arm_r" |
162 |
|
CPU_TOOLS="$CPU_TOOLS generate_arm_loadstore generate_arm_multi" |
163 |
|
|
164 |
|
# M88K |
165 |
|
printf " add_cpu_family(m88k_cpu_family_init, ARCH_M88K);" >> config.h |
166 |
|
CPU_ARCHS="$CPU_ARCHS cpu_m88k.o memory_m88k.o" |
167 |
|
CPU_TOOLS="$CPU_TOOLS generate_m88k_bcnd" |
168 |
|
CPU_TOOLS="$CPU_TOOLS generate_m88k_loadstore" |
169 |
|
|
170 |
|
# MIPS |
171 |
|
printf " add_cpu_family(mips_cpu_family_init, ARCH_MIPS);" >> config.h |
172 |
|
CPU_ARCHS="$CPU_ARCHS cpu_mips.o cpu_mips_coproc.o " |
173 |
|
CPU_ARCHS="$CPU_ARCHS cpu_mips_instr_unaligned.o" |
174 |
|
CPU_TOOLS="$CPU_TOOLS generate_mips_loadstore" |
175 |
|
CPU_TOOLS="$CPU_TOOLS generate_mips_loadstore_multi" |
176 |
|
|
177 |
|
# POWER/PowerPC |
178 |
|
printf " add_cpu_family(ppc_cpu_family_init, ARCH_PPC);" >> config.h |
179 |
|
CPU_ARCHS="$CPU_ARCHS cpu_ppc.o" |
180 |
|
CPU_TOOLS="$CPU_TOOLS generate_ppc_loadstore" |
181 |
|
|
182 |
|
# SuperH |
183 |
|
printf " add_cpu_family(sh_cpu_family_init, ARCH_SH);" >> config.h |
184 |
|
CPU_ARCHS="$CPU_ARCHS cpu_sh.o memory_sh.o" |
185 |
|
|
186 |
|
# SPARC |
187 |
|
printf " add_cpu_family(sparc_cpu_family_init, ARCH_SPARC);" >> config.h |
188 |
|
CPU_ARCHS="$CPU_ARCHS cpu_sparc.o memory_sparc.o" |
189 |
|
CPU_TOOLS="$CPU_TOOLS generate_sparc_loadstore" |
190 |
|
|
191 |
printf "\nNOTE: Cache emulation enabled, but right now it triggers " |
printf "\n" >> config.h |
|
printf "weird bugs in the\n emulator. You have been warned.\n\n" |
|
|
fi |
|
192 |
|
|
193 |
|
|
194 |
############################################################################### |
############################################################################### |
235 |
#\n\n" >> _Makefile.header |
#\n\n" >> _Makefile.header |
236 |
|
|
237 |
|
|
238 |
echo 'int main(int argc, char *argv[]) { return 0; }' > _testprog.c |
# Try with the simplest possible test program. Actually, test static variables |
239 |
|
# as well, because GXemul uses things like NULL-initialized global pointers, |
240 |
|
# and it is important that they work. (GCC on Solaris is known to be completely |
241 |
|
# broken, for instance.) |
242 |
|
|
243 |
|
echo '#include <stdio.h> |
244 |
|
|
245 |
|
int main(int argc, char *argv[]) |
246 |
|
{ |
247 |
|
static int x = 0; |
248 |
|
static int y = 1; |
249 |
|
printf("%i,%i", x, y); |
250 |
|
return 0; |
251 |
|
} |
252 |
|
' > _testprog.c |
253 |
|
|
254 |
|
|
255 |
# Try to detect which C compiler to use, if CC is not set: |
# Try to detect which C compiler to use, if CC is not set: |
256 |
printf "checking which C compiler to use... " |
printf "checking which C compiler to use... " |
257 |
|
rm -f _testprog |
258 |
if [ z"$CC" = z ]; then |
if [ z"$CC" = z ]; then |
|
CC=cc |
|
|
|
|
259 |
# Try gcc first: |
# Try gcc first: |
260 |
printf "#!/bin/sh\ngcc _testprog.c -o _testprog >" > _test.sh |
printf "#!/bin/sh\ngcc $CFLAGS _testprog.c -o _testprog >" > _test.sh |
261 |
printf " /dev/null 2> /dev/null\n" >> _test.sh |
printf " /dev/null 2> /dev/null\n" >> _test.sh |
262 |
chmod 755 _test.sh |
chmod 755 _test.sh |
263 |
./_test.sh > /dev/null 2> /dev/null |
./_test.sh > /dev/null 2> /dev/null |
264 |
if [ -x _testprog ]; then |
if [ -x _testprog ]; then |
265 |
CC=gcc |
if [ z`./_testprog` = z0,1 ]; then |
266 |
|
CC=gcc |
267 |
|
else |
268 |
|
printf "broken gcc detected\n" |
269 |
|
printf "The test program:\n\n" |
270 |
|
cat _testprog.c |
271 |
|
printf "\nshould have resulted in 0,1, but the" |
272 |
|
printf " result was: " |
273 |
|
./_testprog |
274 |
|
printf "\n\nchecking for other C compilers... " |
275 |
|
fi |
276 |
fi |
fi |
277 |
rm -f _testprog |
rm -f _testprog |
278 |
|
|
279 |
# If both gcc and cc exist, then cc might be a vendor specific |
# If both gcc and cc exist, then cc might be a vendor specific |
280 |
# compiler which produces faster code than gcc (eg on Solaris): |
# compiler which produces faster code than gcc (eg on Solaris): |
281 |
printf "#!/bin/sh\ncc _testprog.c -o _testprog >" > _test.sh |
printf "#!/bin/sh\ncc $CFLAGS _testprog.c -o _testprog >" > _test.sh |
282 |
printf " /dev/null 2> /dev/null\n" >> _test.sh |
printf " /dev/null 2> /dev/null\n" >> _test.sh |
283 |
chmod 755 _test.sh |
chmod 755 _test.sh |
284 |
./_test.sh > /dev/null 2> /dev/null |
./_test.sh > /dev/null 2> /dev/null |
285 |
if [ -x _testprog ]; then |
if [ -x _testprog ]; then |
286 |
CC=cc |
if [ z`./_testprog` = z0,1 ]; then |
287 |
|
CC=cc |
288 |
|
else |
289 |
|
printf "broken cc detected\n" |
290 |
|
printf "checking for other C compilers... " |
291 |
|
fi |
292 |
fi |
fi |
293 |
rm -f _testprog |
rm -f _testprog |
294 |
|
|
295 |
# Try ccc (FreeBSD/Alpha): |
# Actually, don't try ccc on Alpha. ccc generates broken code :( |
296 |
printf "#!/bin/sh\nccc _testprog.c -o _testprog >" > _test.sh |
|
297 |
printf " /dev/null 2> /dev/null\n" >> _test.sh |
# # Try ccc (FreeBSD/Alpha): |
298 |
chmod 755 _test.sh |
# printf "#!/bin/sh\nccc $CFLAGS _testprog.c -o _testprog >" > _test.sh |
299 |
./_test.sh > /dev/null 2> /dev/null |
# printf " /dev/null 2> /dev/null\n" >> _test.sh |
300 |
if [ -x _testprog ]; then |
# chmod 755 _test.sh |
301 |
CC="ccc" |
# ./_test.sh > /dev/null 2> /dev/null |
302 |
fi |
# if [ -x _testprog ]; then |
303 |
rm -f _testprog |
# CC="ccc" |
304 |
|
# fi |
305 |
|
# rm -f _testprog |
306 |
|
|
307 |
rm -f _test.sh |
rm -f _test.sh |
308 |
fi |
fi |
309 |
|
|
310 |
|
|
311 |
rm -f _testprog |
rm -f _testprog |
312 |
|
|
313 |
|
if [ z$CC = z ]; then |
314 |
|
printf "no working compiler detected\n" |
315 |
|
printf "\nPlease set the CC environment variable to a working C " |
316 |
|
printf "compiler before running\nthe configure script, and make" |
317 |
|
printf " sure that the CFLAGS environment variable is\nalso valid" |
318 |
|
printf " for that compiler.\n" |
319 |
|
exit |
320 |
|
fi |
321 |
|
|
322 |
printf "$CC $CFLAGS" |
printf "$CC $CFLAGS" |
323 |
|
|
324 |
|
|
374 |
|
|
375 |
rm -f _test_x11 _test_x11.o |
rm -f _test_x11 _test_x11.o |
376 |
|
|
377 |
|
# Special case for some 64-bit Linux/x86_64 systems: |
378 |
|
if [ z$XOK = z0 ]; then |
379 |
|
$CC $CFLAGS _test_x11.c -c -o _test_x11.o \ |
380 |
|
$XINCLUDE 2> /dev/null |
381 |
|
|
382 |
|
XLIB="-L/usr/X11R6/lib64 -lX11" |
383 |
|
$CC $CFLAGS _test_x11.o -o _test_x11 $XLIB 2> /dev/null |
384 |
|
|
385 |
|
if [ -x _test_x11 ]; then |
386 |
|
XOK=1 |
387 |
|
fi |
388 |
|
fi |
389 |
|
rm -f _test_x11 _test_x11.o |
390 |
|
|
391 |
if [ z$XOK = z0 ]; then |
if [ z$XOK = z0 ]; then |
392 |
XINCLUDE="" |
XINCLUDE="" |
393 |
$CC $CFLAGS _test_x11.c -c -o _test_x11.o \ |
$CC $CFLAGS _test_x11.c -c -o _test_x11.o \ |
441 |
fi |
fi |
442 |
|
|
443 |
|
|
444 |
# Check for weird 'alpha' define. |
# Check for 'alpha' define. |
445 |
printf "checking for weird 'alpha' define... " |
printf "checking for 'alpha' define... " |
446 |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
447 |
#ifdef alpha |
#ifdef alpha |
448 |
printf(\"1\"); |
printf(\"1\"); |
472 |
rm -f _testm* |
rm -f _testm* |
473 |
|
|
474 |
|
|
|
# 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* |
|
|
|
|
|
|
|
475 |
# 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) |
476 |
printf "checking for weird 'mips' define... " |
printf "checking for 'mips' define... " |
477 |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
478 |
#ifdef mips |
#ifdef mips |
479 |
printf(\"1\"); |
printf(\"1\"); |
505 |
|
|
506 |
# 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 |
507 |
# any OS actually defined ppc like this. |
# any OS actually defined ppc like this. |
508 |
printf "checking for weird 'ppc' define... " |
printf "checking for 'ppc' define... " |
509 |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
510 |
#ifdef ppc |
#ifdef ppc |
511 |
printf(\"1\"); |
printf(\"1\"); |
537 |
|
|
538 |
# 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 |
539 |
# any OS actually defined sparc like this. |
# any OS actually defined sparc like this. |
540 |
printf "checking for weird 'sparc' define... " |
printf "checking for 'sparc' define... " |
541 |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
542 |
#ifdef sparc |
#ifdef sparc |
543 |
printf(\"1\"); |
printf(\"1\"); |
580 |
if [ z"$COMPAQCC" = zYES ]; then |
if [ z"$COMPAQCC" = zYES ]; then |
581 |
CWARNINGS="$CWARNINGS -msg_disable longlongtype,unusedtop" |
CWARNINGS="$CWARNINGS -msg_disable longlongtype,unusedtop" |
582 |
fi |
fi |
583 |
|
|
584 |
|
if [ z"$UNSTABLE" = zYES ]; then |
585 |
|
printf "checking whether -Werror can be used... " |
586 |
|
rm -f _testprog |
587 |
|
$CC $CFLAGS $CWARNINGS _testprog.c -o _testprog -Werror 2> /dev/null |
588 |
|
if [ -x _testprog ]; then |
589 |
|
printf "yes\n" |
590 |
|
CWARNINGS="$CWARNINGS -Werror" |
591 |
|
else |
592 |
|
printf "no\n" |
593 |
|
fi |
594 |
|
fi |
595 |
else |
else |
596 |
printf "no\n" |
printf "no\n" |
597 |
fi |
fi |
598 |
rm -f _testprog |
rm -f _testprog |
599 |
|
|
600 |
|
|
601 |
|
# -Wstrict-aliasing |
602 |
|
if [ ! z"$DEBUG" = zYES ]; then |
603 |
|
printf "checking whether -Wstrict-aliasing can be used... " |
604 |
|
$CC $CFLAGS -Wstrict-aliasing _testprog.c -o \ |
605 |
|
_testprog 1> _testprog.stdout 2>&1 |
606 |
|
cat _testprog.stdout >> _testprog.error |
607 |
|
if grep frame _testprog.error > /dev/null 2>&1; then |
608 |
|
printf "no\n" |
609 |
|
else |
610 |
|
if [ -x _testprog ]; then |
611 |
|
CWARNINGS="-Wstrict-aliasing $CWARNINGS" |
612 |
|
printf "yes\n" |
613 |
|
else |
614 |
|
printf "no\n" |
615 |
|
fi |
616 |
|
fi |
617 |
|
rm -f _testprog _testprog.error _testprog.stdout |
618 |
|
fi |
619 |
|
|
620 |
|
|
621 |
if [ z"$COMPAQCC" = zYES ]; then |
if [ z"$COMPAQCC" = zYES ]; then |
622 |
# -O4 is possible, but is -O3 better? |
# -O4 is possible, but sometimes -O3 is better? |
623 |
CFLAGS="-O4 $CFLAGS" |
if [ ! z"$DEBUG" = zYES ]; then |
624 |
|
CFLAGS="-O4 $CFLAGS" |
625 |
|
fi |
626 |
else |
else |
627 |
if [ z"`uname`" = zSunOS ]; then |
if [ z"`uname`" = zSunOS ]; then |
628 |
# "cc", the system's default compiler: |
# "cc", the system's default compiler: |
629 |
if [ z"$SUNCC" = zYES ]; then |
if [ ! z"$DEBUG" = zYES ]; then |
630 |
CFLAGS="-xO5 -xdepend $CFLAGS" |
if [ z"$SUNCC" = zYES ]; then |
631 |
|
CFLAGS="-xO5 -xdepend $CFLAGS" |
632 |
|
fi |
633 |
fi |
fi |
634 |
printf "#define SOLARIS\n" >> config.h |
printf "#define SOLARIS\n" >> config.h |
635 |
OTHERLIBS="-lsocket $OTHERLIBS" |
OTHERLIBS="-lsocket $OTHERLIBS" |
636 |
else |
else |
637 |
# gcc or something else: |
# gcc or something else: |
638 |
$CC $CFLAGS _testprog.c -o _testprog -O 2> /dev/null |
if [ ! z"$DEBUG" = zYES ]; then |
639 |
if [ -x _testprog ]; then |
$CC $CFLAGS _testprog.c -o _testprog -O 2> /dev/null |
|
rm -f _testprog |
|
|
$CC $CFLAGS _testprog.c -o _testprog -O2 2> /dev/null |
|
640 |
if [ -x _testprog ]; then |
if [ -x _testprog ]; then |
641 |
CFLAGS="-O2 $CFLAGS" |
rm -f _testprog |
642 |
else |
$CC $CFLAGS _testprog.c -o _testprog \ |
643 |
CFLAGS="-O $CFLAGS" |
-O3 2> /dev/null |
644 |
|
if [ -x _testprog ]; then |
645 |
|
CFLAGS="-O3 $CFLAGS" |
646 |
|
else |
647 |
|
CFLAGS="-O $CFLAGS" |
648 |
|
fi |
649 |
fi |
fi |
650 |
fi |
fi |
651 |
fi |
fi |
655 |
|
|
656 |
# -fschedule-insns causes bugs on i386 with gcc, |
# -fschedule-insns causes bugs on i386 with gcc, |
657 |
# but works OK on my alpha with ccc (compaq's cc). |
# but works OK on my alpha with ccc (compaq's cc). |
658 |
if [ z"$COMPAQCC" = zYES ]; then |
if [ ! z"$DEBUG" = zYES ]; then |
659 |
|
if [ z"$COMPAQCC" = zYES ]; then |
660 |
printf "checking whether -fschedule-insns2 can be used... " |
printf "checking whether -fschedule-insns2 can be used... " |
661 |
$CC $CFLAGS _testprog.c -o _testprog -fschedule-insns2 2> /dev/null |
$CC $CFLAGS _testprog.c -o _testprog -fschedule-insns2 2> /dev/null |
662 |
if [ -x _testprog ]; then |
if [ -x _testprog ]; then |
677 |
fi |
fi |
678 |
rm -f _testprog |
rm -f _testprog |
679 |
|
|
680 |
# # -intrinsics |
# -intrinsics |
681 |
# $CC $CFLAGS _testprog.c -o _testprog -intrinsics 2> /dev/null |
printf "checking whether -intrinsics can be used... " |
682 |
# if [ -x _testprog ]; then |
$CC $CFLAGS _testprog.c -o _testprog -intrinsics 2> /dev/null |
683 |
# CFLAGS="-intrinsics $CFLAGS" |
if [ -x _testprog ]; then |
684 |
# fi |
CFLAGS="-intrinsics $CFLAGS" |
685 |
# rm -f _testprog |
printf "yes\n" |
686 |
|
else |
687 |
|
printf "no\n" |
688 |
|
fi |
689 |
|
rm -f _testprog |
690 |
|
|
691 |
# -fast |
# -fast |
692 |
printf "checking whether -fast can be used... " |
printf "checking whether -fast can be used... " |
698 |
printf "no\n" |
printf "no\n" |
699 |
fi |
fi |
700 |
rm -f _testprog |
rm -f _testprog |
701 |
fi |
fi; fi |
702 |
|
|
703 |
|
|
704 |
# -fpeephole |
# -fpeephole |
705 |
printf "checking whether -fpeephole can be used... " |
if [ ! z"$DEBUG" = zYES ]; then |
706 |
$CC $CFLAGS -fpeephole _testprog.c -o _testprog > _testprog.stdout 2>&1 |
printf "checking whether -fpeephole can be used... " |
707 |
cat _testprog.stdout >> _testprog.error |
$CC $CFLAGS -fpeephole _testprog.c -o _testprog > _testprog.stdout 2>&1 |
708 |
if grep peephole _testprog.error > /dev/null 2>&1; then |
cat _testprog.stdout >> _testprog.error |
709 |
printf "no\n" |
if grep peephole _testprog.error > /dev/null 2>&1; then |
|
else |
|
|
if [ -x _testprog ]; then |
|
|
CFLAGS="-fpeephole $CFLAGS" |
|
|
printf "yes\n" |
|
|
else |
|
710 |
printf "no\n" |
printf "no\n" |
711 |
|
else |
712 |
|
if [ -x _testprog ]; then |
713 |
|
CFLAGS="-fpeephole $CFLAGS" |
714 |
|
printf "yes\n" |
715 |
|
else |
716 |
|
printf "no\n" |
717 |
|
fi |
718 |
fi |
fi |
719 |
|
rm -f _testprog _testprog.error _testprog.stdout |
720 |
fi |
fi |
|
rm -f _testprog _testprog.error _testprog.stdout |
|
721 |
|
|
722 |
|
|
723 |
# -fomit-frame-pointer |
# -fomit-frame-pointer |
724 |
printf "checking whether -fomit-frame-pointer can be used... " |
if [ ! z"$DEBUG" = zYES ]; then |
725 |
$CC $CFLAGS -fomit-frame-pointer _testprog.c -o \ |
printf "checking whether -fomit-frame-pointer can be used... " |
726 |
_testprog 1> _testprog.stdout 2>&1 |
$CC $CFLAGS -fomit-frame-pointer _testprog.c -o \ |
727 |
cat _testprog.stdout >> _testprog.error |
_testprog 1> _testprog.stdout 2>&1 |
728 |
if grep frame _testprog.error > /dev/null 2>&1; then |
cat _testprog.stdout >> _testprog.error |
729 |
printf "no\n" |
if grep frame _testprog.error > /dev/null 2>&1; then |
730 |
else |
printf "no\n" |
|
if [ -x _testprog ]; then |
|
|
CFLAGS="-fomit-frame-pointer $CFLAGS" |
|
|
printf "yes\n" |
|
731 |
else |
else |
732 |
|
if [ -x _testprog ]; then |
733 |
|
CFLAGS="-fomit-frame-pointer $CFLAGS" |
734 |
|
printf "yes\n" |
735 |
|
else |
736 |
|
printf "no\n" |
737 |
|
fi |
738 |
|
fi |
739 |
|
rm -f _testprog _testprog.error _testprog.stdout |
740 |
|
fi |
741 |
|
|
742 |
|
|
743 |
|
# -fstrict-aliasing |
744 |
|
if [ ! z"$DEBUG" = zYES ]; then |
745 |
|
printf "checking whether -fstrict-aliasing can be used... " |
746 |
|
$CC $CFLAGS -fstrict-aliasing _testprog.c -o \ |
747 |
|
_testprog 1> _testprog.stdout 2>&1 |
748 |
|
cat _testprog.stdout >> _testprog.error |
749 |
|
if grep frame _testprog.error > /dev/null 2>&1; then |
750 |
printf "no\n" |
printf "no\n" |
751 |
|
else |
752 |
|
if [ -x _testprog ]; then |
753 |
|
CFLAGS="-fstrict-aliasing $CFLAGS" |
754 |
|
printf "yes\n" |
755 |
|
else |
756 |
|
printf "no\n" |
757 |
|
fi |
758 |
fi |
fi |
759 |
|
rm -f _testprog _testprog.error _testprog.stdout |
760 |
|
fi |
761 |
|
|
762 |
|
|
763 |
|
# -g, for development builds |
764 |
|
if [ z"$UNSTABLE" = zYES ]; then |
765 |
|
printf "checking whether -g can be used... " |
766 |
|
if [ z"$COMPAQCC" = zYES ]; then |
767 |
|
$CC $CFLAGS -g3 _testprog.c -o _testprog > _testprog.stdout 2>&1 |
768 |
|
cat _testprog.stdout >> _testprog.error |
769 |
|
if [ -x _testprog ]; then |
770 |
|
CFLAGS="-g3 $CFLAGS" |
771 |
|
printf "yes (-g3)\n" |
772 |
|
else |
773 |
|
printf "no\n" |
774 |
|
fi |
775 |
|
else |
776 |
|
$CC $CFLAGS -g _testprog.c -o _testprog > _testprog.stdout 2>&1 |
777 |
|
cat _testprog.stdout >> _testprog.error |
778 |
|
if [ -x _testprog ]; then |
779 |
|
CFLAGS="-g $CFLAGS" |
780 |
|
printf "yes\n" |
781 |
|
else |
782 |
|
printf "no\n" |
783 |
|
fi |
784 |
|
fi |
785 |
|
rm -f _testprog _testprog.error _testprog.stdout |
786 |
fi |
fi |
|
rm -f _testprog _testprog.error _testprog.stdout |
|
787 |
|
|
788 |
|
|
789 |
# -lrt for nanosleep? |
# -lrt for nanosleep? |
839 |
# -lm? |
# -lm? |
840 |
printf "checking for math libs..." |
printf "checking for math libs..." |
841 |
printf "#include <math.h>\nint main(int argc, char *argv[]) { " > _testr.c |
printf "#include <math.h>\nint main(int argc, char *argv[]) { " > _testr.c |
842 |
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 |
843 |
$CC $CFLAGS _testr.c -o _testr 2> /dev/null |
$CC $CFLAGS _testr.c -o _testr 2> /dev/null |
844 |
if [ ! -x _testr ]; then |
if [ ! -x _testr ]; then |
845 |
$CC $CFLAGS _testr.c -lm -o _testr 2> /dev/null |
$CC $CFLAGS _testr.c -lm -o _testr 2> /dev/null |
864 |
rm -f _testr.[co] _testr |
rm -f _testr.[co] _testr |
865 |
|
|
866 |
|
|
867 |
|
# strlcpy missing? |
868 |
|
printf "checking for strlcpy... " |
869 |
|
printf "#include <string.h> |
870 |
|
int main(int argc, char *argv[]) { char *p; char *q; size_t x; |
871 |
|
x = strlcpy(p, q, 50); return 0;}\n" > _tests.c |
872 |
|
$CC $CFLAGS _tests.c -o _tests 2> /dev/null |
873 |
|
if [ ! -x _tests ]; then |
874 |
|
printf "missing, using mystrlcpy\n" |
875 |
|
printf "#define strlcpy mystrlcpy\n" >> config.h |
876 |
|
printf "#define strlcat mystrlcat\n" >> config.h |
877 |
|
printf "#define USE_STRLCPY_REPLACEMENTS\n" >> config.h |
878 |
|
else |
879 |
|
printf "found\n" |
880 |
|
fi |
881 |
|
rm -f _tests.[co] _tests |
882 |
|
|
883 |
|
|
884 |
# strtoull missing? |
# strtoull missing? |
885 |
printf "checking for strtoull... " |
printf "checking for strtoull... " |
886 |
printf "#include <stdlib.h> |
printf "#include <stdlib.h> |
920 |
#include <stdio.h> |
#include <stdio.h> |
921 |
#include <sys/types.h> |
#include <sys/types.h> |
922 |
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 |
923 |
$CC $CFLAGS _tests.c -o _tests 2> /dev/null |
$CC $CFLAGS $CWARNINGS _tests.c -o _tests 2> /dev/null |
924 |
if [ ! -x _tests ]; then |
if [ ! -x _tests ]; then |
925 |
printf "missing\n" |
# Try with _LARGEFILE_SOURCE (hack to make fseeko |
926 |
printf "WARNING! fseeko missing from libc. Using a hack, " |
# work on 64-bit Linux): |
927 |
printf "which probably doesn't work.\n" |
$CC $CFLAGS -D_LARGEFILE_SOURCE $CWARNINGS _tests.c -o _tests 2> /dev/null |
928 |
printf "#define HACK_FSEEKO\n" >> config.h |
if [ ! -x _tests ]; then |
929 |
|
printf "missing\n" |
930 |
|
printf "WARNING! fseeko missing from libc. Using a hack, " |
931 |
|
printf "which probably doesn't work.\n" |
932 |
|
printf "#define HACK_FSEEKO\n" >> config.h |
933 |
|
else |
934 |
|
printf "using -D_LARGEFILE_SOURCE hack\n" |
935 |
|
CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE" |
936 |
|
fi |
937 |
else |
else |
938 |
printf "found\n" |
printf "found\n" |
939 |
fi |
fi |
990 |
rm -f _tests.[co] _tests |
rm -f _tests.[co] _tests |
991 |
|
|
992 |
|
|
993 |
|
# Check for PRIx64 in inttypes.h: |
994 |
|
printf "checking for PRIx64 in inttypes.h... " |
995 |
|
printf "#include <inttypes.h>\nint main(int argc, char *argv[])\n |
996 |
|
{\n#ifdef PRIx64\nreturn 0;\n#else\nreturn 1;\n#endif\n}\n" > _testpri.c |
997 |
|
$CC $CFLAGS _testpri.c -o _testpri 2> /dev/null |
998 |
|
if [ ! -x _testpri ]; then |
999 |
|
printf "\nERROR! COULD NOT COMPILE PRIx64 TEST PROGRAM AT ALL!\n" |
1000 |
|
exit |
1001 |
|
else |
1002 |
|
if ./_testpri; then |
1003 |
|
printf "yes\n" |
1004 |
|
else |
1005 |
|
printf "no, using an ugly hack instead, " |
1006 |
|
printf "#define NO_C99_PRINTF_DEFINES\n" >> config.h |
1007 |
|
|
1008 |
|
# Try llx first: |
1009 |
|
printf "#include <stdio.h>\n#include <inttypes.h>\nint main(int argc, char *argv[]){ |
1010 |
|
printf(\"%%llx\\\n\", (int64_t)128);return 0;}\n" > _testpri.c |
1011 |
|
rm -f _testpri |
1012 |
|
$CC $CFLAGS $CWARNINGS _testpri.c -o _testpri 2> /dev/null |
1013 |
|
if [ z`./_testpri` = z80 ]; then |
1014 |
|
printf "PRIx64=llx\n" |
1015 |
|
printf "#define NO_C99_64BIT_LONGLONG\n" >> config.h |
1016 |
|
else |
1017 |
|
# Try lx too: |
1018 |
|
printf "#include <stdio.h>\n#include <inttypes.h>\nint main(int argc, char *argv[]){ |
1019 |
|
printf(\"%%lx\\\n\", (int64_t)128);return 0;}\n" > _testpri.c |
1020 |
|
rm -f _testpri |
1021 |
|
$CC $CFLAGS $CWARNINGS _testpri.c -o _testpri 2> _testpri.result |
1022 |
|
if [ z`./_testpri` = z80 ]; then |
1023 |
|
printf "PRIx64=lx\n" |
1024 |
|
else |
1025 |
|
printf "\nFailed, neither lx nor llx worked!\n" |
1026 |
|
exit |
1027 |
|
fi |
1028 |
|
fi |
1029 |
|
fi |
1030 |
|
fi |
1031 |
|
rm -f _testpri.c _testpri _testpri.result |
1032 |
|
|
1033 |
|
|
1034 |
# Check for 64-bit off_t: |
# Check for 64-bit off_t: |
1035 |
printf "checking for 64-bit off_t... " |
printf "checking for 64-bit off_t... " |
1036 |
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 |
1066 |
|
|
1067 |
|
|
1068 |
# Check for u_int8_t etc: |
# Check for u_int8_t etc: |
1069 |
|
# These are needed because some header files in src/include/ use u_int* |
1070 |
|
# instead of uint*, and I don't have time to rewrite them all. |
1071 |
printf "checking for u_int8_t... " |
printf "checking for u_int8_t... " |
1072 |
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 |
1073 |
int main(int argc, char *argv[]){printf(\"%%i\\\n\", |
int main(int argc, char *argv[]){printf(\"%%i\\\n\", |
1089 |
printf "typedef uint8_t u_int8_t;\n" >> config.h |
printf "typedef uint8_t u_int8_t;\n" >> config.h |
1090 |
printf "typedef uint16_t u_int16_t;\n" >> config.h |
printf "typedef uint16_t u_int16_t;\n" >> config.h |
1091 |
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 |
|
1092 |
printf "uint8_t\n" |
printf "uint8_t\n" |
1093 |
else |
else |
1094 |
printf "yes\n" |
printf "yes\n" |
1095 |
fi |
fi |
1096 |
rm -f _testuint.c _testuint |
rm -f _testuint.c _testuint |
1097 |
|
|
1098 |
|
printf "checking for u_int64_t... " |
1099 |
|
printf "#include <stdio.h>\n#include <inttypes.h>\n#include <sys/types.h>\n |
1100 |
|
int main(int argc, char *argv[]){printf(\"%%i\\\n\", |
1101 |
|
(int)sizeof(u_int64_t));return 0;}\n" > _testuint.c |
1102 |
|
$CC $CFLAGS _testuint.c -o _testuint 2> /dev/null |
1103 |
|
if [ ! -x _testuint ]; then |
1104 |
|
rm -f _testuint* |
1105 |
|
printf "#include <stdio.h>\n#include <inttypes.h> |
1106 |
|
\n#include <sys/types.h>\nint main(int argc, char *argv[]) |
1107 |
|
{printf(\"%%i\\\n\", (int)sizeof(uint64_t));return 0;}\n" > _testuint.c |
1108 |
|
$CC $CFLAGS _testuint.c -o _testuint 2> /dev/null |
1109 |
|
if [ ! -x _testuint ]; then |
1110 |
|
printf "no\n\nERROR: No u_int64_t or uint64_t. Aborting\n" |
1111 |
|
# TODO: Automagically detect using various combinations |
1112 |
|
# of char, int, short, long etc. |
1113 |
|
exit |
1114 |
|
fi |
1115 |
|
|
1116 |
############################################################################### |
printf "typedef uint64_t u_int64_t;\n" >> config.h |
1117 |
# |
printf "uint64_t\n" |
1118 |
# Dynamic binary translation (BINTRANS): |
else |
1119 |
# |
printf "yes\n" |
1120 |
############################################################################### |
fi |
1121 |
|
rm -f _testuint* |
|
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 |
|
1122 |
|
|
1123 |
if [ z$BINTRANS = zNO ]; then |
printf "checking for __FUNCTION__... " |
1124 |
printf "not supported yet on this arch\n" |
printf "#include <stdio.h>\n\nint main(int argc, char *argv[]) { |
1125 |
|
if (__FUNCTION__) printf(__FUNCTION__);\n return 0;\n}\n" > _testfunction.c |
1126 |
|
$CC $CFLAGS _testfunction.c -o _testfunction 2> /dev/null |
1127 |
|
if [ ! -x _testfunction ]; then |
1128 |
|
printf "no\n" |
1129 |
|
else |
1130 |
|
if [ z`./_testfunction` = zmain ]; then |
1131 |
|
printf "yes\n" |
1132 |
|
printf "#define HAVE___FUNCTION__\n" >> config.h |
1133 |
|
else |
1134 |
|
printf "no\n" |
1135 |
fi |
fi |
1136 |
fi |
fi |
1137 |
|
rm -f _testfunction* |
1138 |
|
|
1139 |
|
|
1140 |
############################################################################### |
############################################################################### |
1141 |
|
|
1142 |
# Prefetch support? |
# Host byte order? |
1143 |
printf "checking for asm prefetch support... " |
printf "checking host endianness... " |
1144 |
if [ z"`uname -m`" = zalpha ]; then |
rm -f _test_end* |
1145 |
rm -f _alpha_asm_test.c _alpha_asm_test |
printf '#include <stdio.h> |
1146 |
printf 'int main(int argc, char *argv[]) |
int main(int argc, char *argv[]) |
1147 |
{ int x; int *y = &x; asm ("ldl $31,0(%%0)" : : "g" (y)); |
{ int x = 1; void *xp = (void *)&x; char *p = (char *)xp; |
1148 |
return 0; }\n' > _alpha_asm_test.c |
if (*p) printf("little\\\n"); else printf("big\\\n"); } |
1149 |
$CC $CFLAGS -O2 _alpha_asm_test.c -o _alpha_asm_test \ |
' > _test_end.c |
1150 |
> /dev/null 2> /dev/null |
$CC $CFLAGS _test_end.c -o _test_end 2> /dev/null |
1151 |
if [ -x _alpha_asm_test ]; then |
X=`./_test_end` |
1152 |
# printf "#define HAVE_PREFETCH\n" >> config.h |
echo $X |
1153 |
printf "#define PREFETCH(x) asm(\"ldl" >> config.h |
if [ z$X = zlittle ]; then |
1154 |
printf " \$31,0(%%0)\" : : \"g\" (x))\n" >> config.h |
printf "#define HOST_LITTLE_ENDIAN\n" >> config.h |
1155 |
echo "yes" |
else |
1156 |
PREFSUP=YES |
if [ z$X = zbig ]; then |
1157 |
fi |
printf "#define HOST_BIG_ENDIAN\n" >> config.h |
1158 |
rm -f _alpha_asm_test.c _alpha_asm_test |
else |
1159 |
fi |
echo "Error! Could not determine host's endianness." |
1160 |
if [ z$PREFSUP = z ]; then |
exit |
1161 |
printf "#define PREFETCH(x) { }\n" >> config.h |
fi |
|
echo "no" |
|
1162 |
fi |
fi |
1163 |
|
rm -f _test_end* |
1164 |
|
|
1165 |
|
|
1166 |
############################################################################### |
############################################################################### |
1168 |
INCLUDE=-Iinclude/ |
INCLUDE=-Iinclude/ |
1169 |
DINCLUDE=-I../include/ |
DINCLUDE=-I../include/ |
1170 |
|
|
1171 |
|
rm -f _testprog.c |
1172 |
|
|
1173 |
echo C compiler flags: $CFLAGS $CWARNINGS |
echo C compiler flags: $CFLAGS $CWARNINGS |
1174 |
echo Linker flags: $OTHERLIBS |
echo Linker flags: $OTHERLIBS |
1175 |
echo "CWARNINGS=$CWARNINGS" >> _Makefile.header |
echo "CWARNINGS=$CWARNINGS" >> _Makefile.header |
1178 |
echo "DINCLUDE=$DINCLUDE" >> _Makefile.header |
echo "DINCLUDE=$DINCLUDE" >> _Makefile.header |
1179 |
echo "CC=$CC" >> _Makefile.header |
echo "CC=$CC" >> _Makefile.header |
1180 |
echo "OTHERLIBS=$OTHERLIBS" >> _Makefile.header |
echo "OTHERLIBS=$OTHERLIBS" >> _Makefile.header |
1181 |
|
echo "CPU_ARCHS=$CPU_ARCHS" >> _Makefile.header |
1182 |
|
echo "CPU_TOOLS=$CPU_TOOLS" >> _Makefile.header |
1183 |
echo "" >> _Makefile.header |
echo "" >> _Makefile.header |
1184 |
|
|
1185 |
|
|
|
printf "Regression test setup: (not really needed to build gxemul)\n" |
|
|
|
|
|
|
|
|
## 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" |
|
|
# 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 |
|
|
|
|
|
|
|
|
# 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 |
|
|
|
|
|
|
|
1186 |
# Create the Makefiles: |
# Create the Makefiles: |
1187 |
|
D=". src src/include src/cpus src/debugger src/devices src/devices/fonts" |
1188 |
for a in . src src/devices src/devices/fonts tests; do |
D="$D src/disk src/file src/machines src/native src/net src/promemul" |
1189 |
|
D="$D src/useremul" |
1190 |
|
for a in $D; do |
1191 |
echo "creating $a/Makefile" |
echo "creating $a/Makefile" |
1192 |
touch $a/Makefile |
touch $a/Makefile |
1193 |
cat _Makefile.header > $a/Makefile |
cat _Makefile.header > $a/Makefile |
1201 |
rm -f _Makefile.header |
rm -f _Makefile.header |
1202 |
|
|
1203 |
echo Configured. You may now run make to build gxemul. |
echo Configured. You may now run make to build gxemul. |
1204 |
|
|