1 |
#!/bin/sh |
2 |
############################################################################### |
3 |
# |
4 |
# Copyright (C) 2003-2006 Anders Gavare. All rights reserved. |
5 |
# |
6 |
# Redistribution and use in source and binary forms, with or without |
7 |
# modification, are permitted provided that the following conditions are met: |
8 |
# |
9 |
# 1. Redistributions of source code must retain the above copyright |
10 |
# notice, this list of conditions and the following disclaimer. |
11 |
# 2. Redistributions in binary form must reproduce the above copyright |
12 |
# notice, this list of conditions and the following disclaimer in the |
13 |
# documentation and/or other materials provided with the distribution. |
14 |
# 3. The name of the author may not be used to endorse or promote products |
15 |
# derived from this software without specific prior written permission. |
16 |
# |
17 |
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
18 |
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
19 |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
20 |
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
21 |
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
22 |
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
23 |
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
24 |
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
25 |
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
26 |
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
27 |
# SUCH DAMAGE. |
28 |
# |
29 |
# |
30 |
# $Id: configure,v 1.224 2006/06/23 08:54:56 debug Exp $ |
31 |
# |
32 |
# This is a minimal configure script, hardcoded for GXemul. This script |
33 |
# figures out which compiler flags will work, and creates Makefiles in |
34 |
# sub-directories. A config.h file is also created. |
35 |
# |
36 |
# |
37 |
# ---> FOR NORMAL USE, JUST RUN ./configure WITHOUT OPTIONS! |
38 |
# |
39 |
# |
40 |
# To compile the emulator with profiling (during development), use |
41 |
# CFLAGS="-pg", run the emulator, and then run 'gprof gxemul' and study |
42 |
# the results. |
43 |
# |
44 |
# |
45 |
# The main things that are detected by this script: |
46 |
# |
47 |
# o) special hacks for some OSes |
48 |
# o) which compiler to use (overridden by setting CC) |
49 |
# o) which compiler flags to use (overridden by setting CFLAGS) |
50 |
# o) X11 flags and libraries (TODO: should be possible to override |
51 |
# via command line options?) |
52 |
# |
53 |
# |
54 |
# The general philosophy regarding command line switches is that anything |
55 |
# which can be incorporated into the program as a runtime command line option |
56 |
# should be, instead of requiring a recompile. |
57 |
# |
58 |
############################################################################### |
59 |
|
60 |
# Figure out if this is a stable version (0.x.x). |
61 |
X=`basename \`pwd\`|cut -d \- -f 2-|cut -c1-2` |
62 |
if [ z"$X" = z0. ]; then |
63 |
# Stable: |
64 |
ENABLEALPHA=YES |
65 |
ENABLEARM=YES |
66 |
ENABLEMIPS=YES |
67 |
ENABLEPPC=YES |
68 |
else |
69 |
# Development: |
70 |
UNSTABLE=YES |
71 |
ENABLEALPHA=YES |
72 |
ENABLEARM=YES |
73 |
ENABLEAVR=YES |
74 |
ENABLEHPPA=YES |
75 |
ENABLEI960=YES |
76 |
ENABLEIA64=YES |
77 |
ENABLEM68K=YES |
78 |
ENABLEMIPS=YES |
79 |
ENABLEPPC=YES |
80 |
ENABLESH=YES |
81 |
ENABLESPARC=YES |
82 |
ENABLEX86=YES |
83 |
fi |
84 |
|
85 |
if [ z"$UNSTABLE" = zYES ]; then |
86 |
printf "###\n### DEVELOPMENT (UNSTABLE)\n###\n\n" |
87 |
fi |
88 |
|
89 |
if [ z"$*" != z ]; then |
90 |
# Parse command line options: |
91 |
for a in $*; do |
92 |
if [ z$a = z--disable-x ]; then |
93 |
NOX11=YES |
94 |
else if [ z$a = z--help ]; then |
95 |
printf "usage: $0 [options]\n\n" |
96 |
echo " --disable-x don't include X11 support,"\ |
97 |
"even if the host supports it" |
98 |
echo |
99 |
exit |
100 |
else |
101 |
echo "Invalid option: $a" |
102 |
echo "Run $0 --help to get a list of" \ |
103 |
"available options." |
104 |
exit |
105 |
fi; fi |
106 |
done |
107 |
fi |
108 |
|
109 |
|
110 |
############################################################################### |
111 |
# |
112 |
# Configure options: |
113 |
# |
114 |
# This creates a config.h file, which is then included from include/misc.h. |
115 |
# |
116 |
############################################################################### |
117 |
|
118 |
# Head of config.h: |
119 |
printf "/* |
120 |
* THIS FILE IS AUTOMATICALLY CREATED BY configure! |
121 |
* DON'T EDIT THIS FILE MANUALLY, IT WILL BE OVERWRITTEN. |
122 |
*/ |
123 |
\n#ifndef CONFIG_H\n#define CONFIG_H\n\n" > config.h |
124 |
|
125 |
|
126 |
# Figure out if VERSION should be defined. |
127 |
X=`basename \`pwd\`|cut -d \- -f 2-` |
128 |
if [ z"$X" = zgxemul ]; then |
129 |
echo '/* No VERSION defined. */' >> config.h |
130 |
else |
131 |
printf "#define VERSION \"$X\"\n" >> config.h |
132 |
fi |
133 |
|
134 |
|
135 |
if [ z"$UNSTABLE" = zYES ]; then |
136 |
printf "#define UNSTABLE_DEVEL\n" >> config.h |
137 |
fi |
138 |
|
139 |
|
140 |
ZZ=`echo compiled on \`uname\`/\`uname -m\`, \`date\`` |
141 |
printf "#define COMPILE_DATE \"$ZZ\"\n" >> config.h |
142 |
|
143 |
|
144 |
|
145 |
# Support for various CPU types: |
146 |
if [ z$ENABLEALPHA = zYES ]; then |
147 |
printf "#define ENABLE_ALPHA\n" >> config.h |
148 |
CPU_ARCHS="$CPU_ARCHS cpu_alpha.o cpu_alpha_palcode.o memory_alpha.o" |
149 |
CPU_TOOLS="$CPU_TOOLS generate_alpha_misc" |
150 |
fi |
151 |
if [ z$ENABLEARM = zYES ]; then |
152 |
printf "#define ENABLE_ARM\n" >> config.h |
153 |
CPU_ARCHS="$CPU_ARCHS cpu_arm.o cpu_arm_coproc.o memory_arm.o " |
154 |
CPU_ARCHS="$CPU_ARCHS tmp_arm_dpi.o tmp_arm_loadstore.o tmp_arm_r.o" |
155 |
CPU_ARCHS="$CPU_ARCHS tmp_arm_r0.o tmp_arm_r1.o" |
156 |
CPU_ARCHS="$CPU_ARCHS tmp_arm_r2.o tmp_arm_r3.o" |
157 |
CPU_ARCHS="$CPU_ARCHS tmp_arm_r4.o tmp_arm_r5.o" |
158 |
CPU_ARCHS="$CPU_ARCHS tmp_arm_r6.o tmp_arm_r7.o" |
159 |
CPU_ARCHS="$CPU_ARCHS tmp_arm_r8.o tmp_arm_r9.o" |
160 |
CPU_ARCHS="$CPU_ARCHS tmp_arm_ra.o tmp_arm_rb.o" |
161 |
CPU_ARCHS="$CPU_ARCHS tmp_arm_rc.o tmp_arm_rd.o" |
162 |
CPU_ARCHS="$CPU_ARCHS tmp_arm_re.o tmp_arm_rf.o tmp_arm_multi.o" |
163 |
CPU_TOOLS="$CPU_TOOLS generate_arm_dpi generate_arm_r" |
164 |
CPU_TOOLS="$CPU_TOOLS generate_arm_loadstore generate_arm_multi" |
165 |
fi |
166 |
if [ z$ENABLEAVR = zYES ]; then |
167 |
printf "#define ENABLE_AVR\n" >> config.h |
168 |
CPU_ARCHS="$CPU_ARCHS cpu_avr.o" |
169 |
fi |
170 |
if [ z$ENABLEHPPA = zYES ]; then |
171 |
printf "#define ENABLE_HPPA\n" >> config.h |
172 |
CPU_ARCHS="$CPU_ARCHS cpu_hppa.o" |
173 |
fi |
174 |
if [ z$ENABLEI960 = zYES ]; then |
175 |
printf "#define ENABLE_I960\n" >> config.h |
176 |
CPU_ARCHS="$CPU_ARCHS cpu_i960.o" |
177 |
fi |
178 |
if [ z$ENABLEIA64 = zYES ]; then |
179 |
printf "#define ENABLE_IA64\n" >> config.h |
180 |
CPU_ARCHS="$CPU_ARCHS cpu_ia64.o" |
181 |
fi |
182 |
if [ z$ENABLEM68K = zYES ]; then |
183 |
printf "#define ENABLE_M68K\n" >> config.h |
184 |
CPU_ARCHS="$CPU_ARCHS cpu_m68k.o" |
185 |
fi |
186 |
if [ z$ENABLEMIPS = zYES ]; then |
187 |
printf "#define ENABLE_MIPS\n" >> config.h |
188 |
CPU_ARCHS="$CPU_ARCHS cpu_mips.o cpu_mips_coproc.o " |
189 |
CPU_ARCHS="$CPU_ARCHS cpu_mips_instr_unaligned.o" |
190 |
CPU_TOOLS="$CPU_TOOLS generate_mips_loadstore" |
191 |
fi |
192 |
if [ z$ENABLEPPC = zYES ]; then |
193 |
printf "#define ENABLE_PPC\n" >> config.h |
194 |
CPU_ARCHS="$CPU_ARCHS cpu_ppc.o" |
195 |
CPU_TOOLS="$CPU_TOOLS generate_ppc_loadstore" |
196 |
fi |
197 |
if [ z$ENABLESH = zYES ]; then |
198 |
printf "#define ENABLE_SH\n" >> config.h |
199 |
CPU_ARCHS="$CPU_ARCHS cpu_sh.o" |
200 |
fi |
201 |
if [ z$ENABLESPARC = zYES ]; then |
202 |
printf "#define ENABLE_SPARC\n" >> config.h |
203 |
CPU_ARCHS="$CPU_ARCHS cpu_sparc.o" |
204 |
fi |
205 |
if [ z$ENABLEX86 = zYES ]; then |
206 |
printf "#define ENABLE_X86\n" >> config.h |
207 |
CPU_ARCHS="$CPU_ARCHS cpu_x86.o" |
208 |
fi |
209 |
|
210 |
|
211 |
# Cache emulation: |
212 |
if [ z$CACHES = zYES ]; then |
213 |
echo 'Enabling Cache emulation. (EXPERIMENTAL and BUGGY)' |
214 |
printf "#define ENABLE_CACHE_EMULATION\n" >> config.h |
215 |
|
216 |
printf "\nNOTE: Cache emulation enabled, but right now it triggers " |
217 |
printf "weird bugs in the\n emulator. You have been warned.\n\n" |
218 |
fi |
219 |
|
220 |
|
221 |
############################################################################### |
222 |
# |
223 |
# Special hacks for some host OSes: |
224 |
# |
225 |
############################################################################### |
226 |
|
227 |
if [ z"`uname|cut -c 1-6`" = zCYGWIN ]; then |
228 |
CYGWIN=YES |
229 |
|
230 |
if [ z"$CC" = z ]; then |
231 |
# Assume gcc on Cygwin (Windows) systems. |
232 |
CC=gcc |
233 |
fi |
234 |
fi |
235 |
|
236 |
if [ z"`uname`" = zHP-UX ]; then |
237 |
HPUX=YES |
238 |
|
239 |
if [ z$CC = z ]; then |
240 |
if [ -f /usr/local/pa64/bin/gcc ]; then |
241 |
CC=/usr/local/pa64/bin/gcc |
242 |
fi |
243 |
fi |
244 |
fi |
245 |
|
246 |
if [ z"`uname`" = zOSF1 ]; then |
247 |
OSF1=YES |
248 |
fi |
249 |
|
250 |
|
251 |
############################################################################### |
252 |
# |
253 |
# Create the Makefile header: |
254 |
# |
255 |
############################################################################### |
256 |
|
257 |
rm -f _Makefile.header |
258 |
|
259 |
printf "# |
260 |
# DO NOT EDIT THIS FILE! It is automagically created by |
261 |
# the configure script, based on Makefile.skel. |
262 |
#\n\n" >> _Makefile.header |
263 |
|
264 |
|
265 |
echo 'int main(int argc, char *argv[]) { return 0; }' > _testprog.c |
266 |
|
267 |
|
268 |
# Try to detect which C compiler to use, if CC is not set: |
269 |
printf "checking which C compiler to use... " |
270 |
|
271 |
if [ z"$CC" = z ]; then |
272 |
CC=cc |
273 |
|
274 |
# Try gcc first: |
275 |
printf "#!/bin/sh\ngcc _testprog.c -o _testprog >" > _test.sh |
276 |
printf " /dev/null 2> /dev/null\n" >> _test.sh |
277 |
chmod 755 _test.sh |
278 |
./_test.sh > /dev/null 2> /dev/null |
279 |
if [ -x _testprog ]; then |
280 |
CC=gcc |
281 |
fi |
282 |
rm -f _testprog |
283 |
|
284 |
# If both gcc and cc exist, then cc might be a vendor specific |
285 |
# compiler which produces faster code than gcc (eg on Solaris): |
286 |
printf "#!/bin/sh\ncc _testprog.c -o _testprog >" > _test.sh |
287 |
printf " /dev/null 2> /dev/null\n" >> _test.sh |
288 |
chmod 755 _test.sh |
289 |
./_test.sh > /dev/null 2> /dev/null |
290 |
if [ -x _testprog ]; then |
291 |
CC=cc |
292 |
fi |
293 |
rm -f _testprog |
294 |
|
295 |
# # Try ccc (FreeBSD/Alpha): |
296 |
# printf "#!/bin/sh\nccc _testprog.c -o _testprog >" > _test.sh |
297 |
# printf " /dev/null 2> /dev/null\n" >> _test.sh |
298 |
# chmod 755 _test.sh |
299 |
# ./_test.sh > /dev/null 2> /dev/null |
300 |
# if [ -x _testprog ]; then |
301 |
# CC="ccc" |
302 |
# fi |
303 |
# rm -f _testprog |
304 |
|
305 |
rm -f _test.sh |
306 |
fi |
307 |
|
308 |
|
309 |
rm -f _testprog |
310 |
printf "$CC $CFLAGS" |
311 |
|
312 |
|
313 |
CCTYPE="generic" |
314 |
|
315 |
if $CC $CFLAGS -V 2> /dev/null | grep ompaq 1> /dev/null 2> /dev/null; then |
316 |
COMPAQCC=YES |
317 |
CCTYPE="Compaq CC" |
318 |
fi |
319 |
|
320 |
if $CC $CFLAGS -V 2>&1 | grep Sun 1> /dev/null 2> /dev/null; then |
321 |
SUNCC=YES |
322 |
CCTYPE="Solaris CC" |
323 |
fi |
324 |
|
325 |
if $CC $CFLAGS -v 2>&1 | grep gcc 1> /dev/null 2> /dev/null; then |
326 |
GCCCC=YES |
327 |
CCTYPE="GNU CC" |
328 |
fi |
329 |
|
330 |
if [ z$CYGWIN = zYES ]; then |
331 |
CCTYPE="$CCTYPE (Cygwin)" |
332 |
fi |
333 |
|
334 |
echo " ($CCTYPE)" |
335 |
|
336 |
|
337 |
if [ z$NOX11 = z ]; then |
338 |
printf "checking for X11 headers and libs\n" |
339 |
|
340 |
# Try to compile a small X11 test program: |
341 |
printf "#include <X11/Xlib.h> |
342 |
#include <stdio.h> |
343 |
Display *dis; |
344 |
void f(void) { |
345 |
dis = XOpenDisplay(NULL); |
346 |
} |
347 |
int main(int argc, char *argv[]) |
348 |
{ return 0; } |
349 |
" > _test_x11.c |
350 |
|
351 |
XOK=0 |
352 |
|
353 |
XINCLUDE=-I/usr/X11R6/include |
354 |
$CC $CFLAGS _test_x11.c -c -o _test_x11.o $XINCLUDE 2> /dev/null |
355 |
|
356 |
XLIB="-L/usr/X11R6/lib -lX11" |
357 |
$CC $CFLAGS _test_x11.o -o _test_x11 $XLIB 2> /dev/null |
358 |
|
359 |
if [ -x _test_x11 ]; then |
360 |
XOK=1 |
361 |
fi |
362 |
|
363 |
rm -f _test_x11 _test_x11.o |
364 |
|
365 |
if [ z$XOK = z0 ]; then |
366 |
XINCLUDE="" |
367 |
$CC $CFLAGS _test_x11.c -c -o _test_x11.o \ |
368 |
$XINCLUDE 2> /dev/null |
369 |
|
370 |
# -lsocket for Solaris |
371 |
XLIB="-lX11 -lsocket" |
372 |
$CC $CFLAGS _test_x11.o -o _test_x11 $XLIB 2> /dev/null |
373 |
|
374 |
if [ -x _test_x11 ]; then |
375 |
XOK=1 |
376 |
fi |
377 |
rm -f _test_x11 _test_x11.o |
378 |
fi |
379 |
|
380 |
if [ z`uname` = zNetBSD ]; then |
381 |
echo "Using NetBSD hack for X11 libs..." |
382 |
XLIB="$XLIB -Wl,-rpath,/usr/X11R6/lib" |
383 |
fi |
384 |
|
385 |
if [ z`uname` = zOpenBSD ]; then |
386 |
if [ z`uname -m` = zarc ]; then |
387 |
echo "Using old OpenBSD/arc hack for X11 libs..." |
388 |
XLIB="$XLIB -Wl,-rpath,/usr/X11R6/lib" |
389 |
fi |
390 |
fi |
391 |
|
392 |
if [ z$XOK = z0 ]; then |
393 |
echo "Failed to compile X11 test program." \ |
394 |
"Configuring without X11." |
395 |
else |
396 |
printf "X11 headers: $XINCLUDE\n" |
397 |
printf "X11 libraries: $XLIB\n" |
398 |
echo "XINCLUDE=$XINCLUDE" >> _Makefile.header |
399 |
echo "XLIB=$XLIB" >> _Makefile.header |
400 |
printf "#define WITH_X11\n" >> config.h |
401 |
fi |
402 |
|
403 |
rm -f _test_x11.c |
404 |
fi |
405 |
|
406 |
|
407 |
if [ z$HPUX = zYES ]; then |
408 |
CFLAGS="-D_XOPEN_SOURCE_EXTENDED $CFLAGS" |
409 |
printf "#define HPUX\n" >> config.h |
410 |
fi |
411 |
|
412 |
|
413 |
if [ z$OSF1 = zYES ]; then |
414 |
CFLAGS="-D_XOPEN_SOURCE=500 -D_OSF_SOURCE -D_POSIX_PII_SOCKET $CFLAGS" |
415 |
fi |
416 |
|
417 |
|
418 |
# Check for 'alpha' define. |
419 |
printf "checking for 'alpha' define... " |
420 |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
421 |
#ifdef alpha |
422 |
printf(\"1\"); |
423 |
#undef alpha |
424 |
#ifdef alpha |
425 |
printf(\"2\"); |
426 |
#endif |
427 |
#endif |
428 |
printf(\"\\\n\");return 0;}\n" > _testm.c |
429 |
$CC $CFLAGS _testm.c -o _testm 2> /dev/null |
430 |
if [ ! -x _testm ]; then |
431 |
printf "\nWARNING! COULD NOT COMPILE alpha define TEST" |
432 |
printf " PROGRAM AT ALL!\n" |
433 |
else |
434 |
if [ z`./_testm` = z1 ]; then |
435 |
printf "yes, workaround applied\n" |
436 |
echo "#undef alpha" >> config.h |
437 |
else |
438 |
if [ z`./_testm` = z12 ]; then |
439 |
printf "yes, but workaround not possible\n" |
440 |
exit |
441 |
else |
442 |
printf "no\n" |
443 |
fi |
444 |
fi |
445 |
fi |
446 |
rm -f _testm* |
447 |
|
448 |
|
449 |
# Some OSes on MIPS seems to define 'mips' to 1. (eg OpenBSD/arc) |
450 |
printf "checking for 'mips' define... " |
451 |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
452 |
#ifdef mips |
453 |
printf(\"1\"); |
454 |
#undef mips |
455 |
#ifdef mips |
456 |
printf(\"2\"); |
457 |
#endif |
458 |
#endif |
459 |
printf(\"\\\n\");return 0;}\n" > _testm.c |
460 |
$CC $CFLAGS _testm.c -o _testm 2> /dev/null |
461 |
if [ ! -x _testm ]; then |
462 |
printf "\nWARNING! COULD NOT COMPILE mips define TEST" |
463 |
printf " PROGRAM AT ALL!\n" |
464 |
else |
465 |
if [ z`./_testm` = z1 ]; then |
466 |
printf "yes, workaround applied\n" |
467 |
echo "#undef mips" >> config.h |
468 |
else |
469 |
if [ z`./_testm` = z12 ]; then |
470 |
printf "yes, but workaround not possible\n" |
471 |
exit |
472 |
else |
473 |
printf "no\n" |
474 |
fi |
475 |
fi |
476 |
fi |
477 |
rm -f _testm* |
478 |
|
479 |
|
480 |
# Similar to the mips define check above, although I don't know if |
481 |
# any OS actually defined ppc like this. |
482 |
printf "checking for 'ppc' define... " |
483 |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
484 |
#ifdef ppc |
485 |
printf(\"1\"); |
486 |
#undef ppc |
487 |
#ifdef ppc |
488 |
printf(\"2\"); |
489 |
#endif |
490 |
#endif |
491 |
printf(\"\\\n\");return 0;}\n" > _testm.c |
492 |
$CC $CFLAGS _testm.c -o _testm 2> /dev/null |
493 |
if [ ! -x _testm ]; then |
494 |
printf "\nWARNING! COULD NOT COMPILE ppc define TEST" |
495 |
printf " PROGRAM AT ALL!\n" |
496 |
else |
497 |
if [ z`./_testm` = z1 ]; then |
498 |
printf "yes, workaround applied\n" |
499 |
echo "#undef ppc" >> config.h |
500 |
else |
501 |
if [ z`./_testm` = z12 ]; then |
502 |
printf "yes, but workaround not possible\n" |
503 |
exit |
504 |
else |
505 |
printf "no\n" |
506 |
fi |
507 |
fi |
508 |
fi |
509 |
rm -f _testm* |
510 |
|
511 |
|
512 |
# Similar to the mips define check above, although I don't know if |
513 |
# any OS actually defined sparc like this. |
514 |
printf "checking for 'sparc' define... " |
515 |
printf "#include <stdio.h>\nint main(int argc, char *argv[]){ |
516 |
#ifdef sparc |
517 |
printf(\"1\"); |
518 |
#undef sparc |
519 |
#ifdef sparc |
520 |
printf(\"2\"); |
521 |
#endif |
522 |
#endif |
523 |
printf(\"\\\n\");return 0;}\n" > _testm.c |
524 |
$CC $CFLAGS _testm.c -o _testm 2> /dev/null |
525 |
if [ ! -x _testm ]; then |
526 |
printf "\nWARNING! COULD NOT COMPILE sparc define TEST " |
527 |
printf "PROGRAM AT ALL!\n" |
528 |
else |
529 |
if [ z`./_testm` = z1 ]; then |
530 |
printf "yes, workaround applied\n" |
531 |
echo "#undef sparc" >> config.h |
532 |
else |
533 |
if [ z`./_testm` = z12 ]; then |
534 |
printf "yes, but workaround not possible\n" |
535 |
exit |
536 |
else |
537 |
printf "no\n" |
538 |
fi |
539 |
fi |
540 |
fi |
541 |
rm -f _testm* |
542 |
|
543 |
|
544 |
# CWARNINGS: |
545 |
printf "checking whether -Wall can be used... " |
546 |
$CC $CFLAGS _testprog.c -o _testprog -Wall 2> /dev/null |
547 |
if [ -x _testprog ]; then |
548 |
printf "yes\n" |
549 |
CWARNINGS="-Wall $CWARNINGS" |
550 |
|
551 |
# Compaq's compiler always seems to warn about the long long type, |
552 |
# and unusedtop suppresses warnings about include files being |
553 |
# included more than once. |
554 |
if [ z"$COMPAQCC" = zYES ]; then |
555 |
CWARNINGS="$CWARNINGS -msg_disable longlongtype,unusedtop" |
556 |
fi |
557 |
|
558 |
if [ z"$UNSTABLE" = zYES ]; then |
559 |
printf "checking whether -Werror can be used... " |
560 |
rm -f _testprog |
561 |
$CC $CFLAGS $CWARNINGS _testprog.c -o _testprog -Werror 2> /dev/null |
562 |
if [ -x _testprog ]; then |
563 |
printf "yes\n" |
564 |
CWARNINGS="$CWARNINGS -Werror" |
565 |
else |
566 |
printf "no\n" |
567 |
fi |
568 |
fi |
569 |
else |
570 |
printf "no\n" |
571 |
fi |
572 |
rm -f _testprog |
573 |
|
574 |
|
575 |
if [ z"$COMPAQCC" = zYES ]; then |
576 |
# -O4 is possible, but sometimes -O3 is better? |
577 |
CFLAGS="-O4 $CFLAGS" |
578 |
else |
579 |
if [ z"`uname`" = zSunOS ]; then |
580 |
# "cc", the system's default compiler: |
581 |
if [ z"$SUNCC" = zYES ]; then |
582 |
CFLAGS="-xO5 -xdepend $CFLAGS" |
583 |
fi |
584 |
printf "#define SOLARIS\n" >> config.h |
585 |
OTHERLIBS="-lsocket $OTHERLIBS" |
586 |
else |
587 |
# gcc or something else: |
588 |
$CC $CFLAGS _testprog.c -o _testprog -O 2> /dev/null |
589 |
if [ -x _testprog ]; then |
590 |
rm -f _testprog |
591 |
$CC $CFLAGS _testprog.c -o _testprog -O3 2> /dev/null |
592 |
if [ -x _testprog ]; then |
593 |
CFLAGS="-O3 $CFLAGS" |
594 |
else |
595 |
CFLAGS="-O $CFLAGS" |
596 |
fi |
597 |
fi |
598 |
fi |
599 |
fi |
600 |
rm -f _testprog |
601 |
|
602 |
|
603 |
# -fschedule-insns causes bugs on i386 with gcc, |
604 |
# but works OK on my alpha with ccc (compaq's cc). |
605 |
if [ z"$COMPAQCC" = zYES ]; then |
606 |
printf "checking whether -fschedule-insns2 can be used... " |
607 |
$CC $CFLAGS _testprog.c -o _testprog -fschedule-insns2 2> /dev/null |
608 |
if [ -x _testprog ]; then |
609 |
CFLAGS="-fschedule-insns2 $CFLAGS" |
610 |
printf "yes\n" |
611 |
else |
612 |
printf "no\n" |
613 |
fi |
614 |
rm -f _testprog |
615 |
|
616 |
printf "checking whether -fschedule-insns can be used... " |
617 |
$CC $CFLAGS _testprog.c -o _testprog -fschedule-insns 2> /dev/null |
618 |
if [ -x _testprog ]; then |
619 |
CFLAGS="-fschedule-insns $CFLAGS" |
620 |
printf "yes\n" |
621 |
else |
622 |
printf "no\n" |
623 |
fi |
624 |
rm -f _testprog |
625 |
|
626 |
# # -intrinsics |
627 |
# $CC $CFLAGS _testprog.c -o _testprog -intrinsics 2> /dev/null |
628 |
# if [ -x _testprog ]; then |
629 |
# CFLAGS="-intrinsics $CFLAGS" |
630 |
# fi |
631 |
# rm -f _testprog |
632 |
|
633 |
# -fast |
634 |
printf "checking whether -fast can be used... " |
635 |
$CC $CFLAGS _testprog.c -o _testprog -fast 2> /dev/null |
636 |
if [ -x _testprog ]; then |
637 |
CFLAGS="-fast $CFLAGS" |
638 |
printf "yes\n" |
639 |
else |
640 |
printf "no\n" |
641 |
fi |
642 |
rm -f _testprog |
643 |
fi |
644 |
|
645 |
|
646 |
# -fpeephole |
647 |
printf "checking whether -fpeephole can be used... " |
648 |
$CC $CFLAGS -fpeephole _testprog.c -o _testprog > _testprog.stdout 2>&1 |
649 |
cat _testprog.stdout >> _testprog.error |
650 |
if grep peephole _testprog.error > /dev/null 2>&1; then |
651 |
printf "no\n" |
652 |
else |
653 |
if [ -x _testprog ]; then |
654 |
CFLAGS="-fpeephole $CFLAGS" |
655 |
printf "yes\n" |
656 |
else |
657 |
printf "no\n" |
658 |
fi |
659 |
fi |
660 |
rm -f _testprog _testprog.error _testprog.stdout |
661 |
|
662 |
|
663 |
# -fomit-frame-pointer |
664 |
printf "checking whether -fomit-frame-pointer can be used... " |
665 |
$CC $CFLAGS -fomit-frame-pointer _testprog.c -o \ |
666 |
_testprog 1> _testprog.stdout 2>&1 |
667 |
cat _testprog.stdout >> _testprog.error |
668 |
if grep frame _testprog.error > /dev/null 2>&1; then |
669 |
printf "no\n" |
670 |
else |
671 |
if [ -x _testprog ]; then |
672 |
CFLAGS="-fomit-frame-pointer $CFLAGS" |
673 |
printf "yes\n" |
674 |
else |
675 |
printf "no\n" |
676 |
fi |
677 |
fi |
678 |
rm -f _testprog _testprog.error _testprog.stdout |
679 |
|
680 |
|
681 |
# -g |
682 |
printf "checking whether -g can be used... " |
683 |
if [ z"$COMPAQCC" = zYES ]; then |
684 |
printf "skipping\n" |
685 |
else |
686 |
$CC $CFLAGS -g _testprog.c -o _testprog > _testprog.stdout 2>&1 |
687 |
cat _testprog.stdout >> _testprog.error |
688 |
if [ -x _testprog ]; then |
689 |
CFLAGS="-g $CFLAGS" |
690 |
printf "yes\n" |
691 |
else |
692 |
printf "no\n" |
693 |
fi |
694 |
fi |
695 |
rm -f _testprog _testprog.error _testprog.stdout |
696 |
|
697 |
|
698 |
# -lrt for nanosleep? |
699 |
printf "checking whether -lrt is required for nanosleep... " |
700 |
printf "#include <time.h>\n#include <stdio.h> |
701 |
int main(int argc, char *argv[]){nanosleep(NULL,NULL);return 0;}\n" > _testns.c |
702 |
$CC $CFLAGS _testns.c -o _testns 2> /dev/null |
703 |
if [ ! -x _testns ]; then |
704 |
$CC $CFLAGS -lrt _testns.c -o _testns 2> /dev/null |
705 |
if [ ! -x _testns ]; then |
706 |
printf "WARNING! COULD NOT COMPILE WITH nanosleep AT ALL!\n" |
707 |
else |
708 |
# -lrt for nanosleep |
709 |
OTHERLIBS="-lrt $OTHERLIBS" |
710 |
printf "yes\n" |
711 |
fi |
712 |
else |
713 |
printf "no\n" |
714 |
fi |
715 |
rm -f _testns.c _testns |
716 |
|
717 |
|
718 |
# -lresolv for inet_pton? |
719 |
printf "checking whether -lresolv is required for inet_pton... " |
720 |
printf "int inet_pton(void); int main(int argc, " > _testr.c |
721 |
printf "char *argv[]) { return inet_pton(); }\n" >> _testr.c |
722 |
$CC $CFLAGS _testr.c -o _testr 2> /dev/null |
723 |
if [ ! -x _testr ]; then |
724 |
$CC $CFLAGS _testr.c -lresolv -o _testr 2> /dev/null |
725 |
if [ ! -x _testr ]; then |
726 |
$CC $CFLAGS _testr.c -lresolv -lnsl -o _testr 2> /dev/null |
727 |
if [ ! -x _testr ]; then |
728 |
printf "no, using inet_aton\n" |
729 |
else |
730 |
# -lresolv -lnsl for inet_pton |
731 |
OTHERLIBS="-lresolv -lnsl $OTHERLIBS" |
732 |
printf "yes (and -lnsl)\n" |
733 |
printf "#define HAVE_INET_PTON\n" >> config.h |
734 |
fi |
735 |
else |
736 |
# -lresolv for inet_pton |
737 |
OTHERLIBS="-lresolv $OTHERLIBS" |
738 |
printf "yes\n" |
739 |
printf "#define HAVE_INET_PTON\n" >> config.h |
740 |
fi |
741 |
else |
742 |
printf "no\n" |
743 |
printf "#define HAVE_INET_PTON\n" >> config.h |
744 |
fi |
745 |
rm -f _testr.[co] _testr |
746 |
|
747 |
|
748 |
# -lm? |
749 |
printf "checking for math libs..." |
750 |
printf "#include <math.h>\nint main(int argc, char *argv[]) { " > _testr.c |
751 |
printf "double x = sqrt((double)argc); return (int)x; }\n" >> _testr.c |
752 |
$CC $CFLAGS _testr.c -o _testr 2> /dev/null |
753 |
if [ ! -x _testr ]; then |
754 |
$CC $CFLAGS _testr.c -lm -o _testr 2> /dev/null |
755 |
if [ ! -x _testr ]; then |
756 |
$CC $CFLAGS _testr.c -lm -lcpml -o _testr 2> /dev/null |
757 |
if [ ! -x _testr ]; then |
758 |
printf "\nWARNING! Could not compile math test " |
759 |
printf "at all!\nContinuing anyway.\n\n" |
760 |
else |
761 |
# -lm AND -lcpml |
762 |
OTHERLIBS="-lm -lcpml $OTHERLIBS" |
763 |
printf " -lm -lcpml\n" |
764 |
fi |
765 |
else |
766 |
# Normal -lm |
767 |
OTHERLIBS="-lm $OTHERLIBS" |
768 |
printf " -lm\n" |
769 |
fi |
770 |
else |
771 |
printf " none needed\n" |
772 |
fi |
773 |
rm -f _testr.[co] _testr |
774 |
|
775 |
|
776 |
# strlcpy missing? |
777 |
printf "checking for strlcpy... " |
778 |
printf "#include <string.h> |
779 |
int main(int argc, char *argv[]) { char *p; char *q; size_t x; |
780 |
x = strlcpy(p, q, 50); return 0;}\n" > _tests.c |
781 |
$CC $CFLAGS _tests.c -o _tests 2> /dev/null |
782 |
if [ ! -x _tests ]; then |
783 |
printf "missing, using mystrlcpy\n" |
784 |
printf "#define strlcpy mystrlcpy\n" >> config.h |
785 |
printf "#define strlcat mystrlcat\n" >> config.h |
786 |
printf "#define USE_STRLCPY_REPLACEMENTS\n" >> config.h |
787 |
else |
788 |
printf "found\n" |
789 |
fi |
790 |
rm -f _tests.[co] _tests |
791 |
|
792 |
|
793 |
# strtoull missing? |
794 |
printf "checking for strtoull... " |
795 |
printf "#include <stdlib.h> |
796 |
#include <limits.h> |
797 |
#include <stdio.h> |
798 |
int main(int argc, char *argv[]) { |
799 |
long long x = strtoull(argv[1], NULL, 0); return 0;}\n" > _tests.c |
800 |
$CC $CFLAGS _tests.c -o _tests 2> /dev/null |
801 |
if [ ! -x _tests ]; then |
802 |
printf "missing, using mystrtoull\n" |
803 |
printf "#define strtoull mystrtoull\n" >> config.h |
804 |
else |
805 |
printf "found\n" |
806 |
fi |
807 |
rm -f _tests.[co] _tests |
808 |
|
809 |
|
810 |
# mkstemp missing? |
811 |
printf "checking for mkstemp... " |
812 |
printf "#include <unistd.h> |
813 |
int main(int argc, char *argv[]) { int x; char *y = \"abc\"; |
814 |
x = mkstemp(y); return 0;}\n" > _tests.c |
815 |
$CC $CFLAGS _tests.c -o _tests 2> /dev/null |
816 |
if [ ! -x _tests ]; then |
817 |
printf "missing, using workaround\n" |
818 |
printf "#define mkstemp mymkstemp\n" >> config.h |
819 |
else |
820 |
printf "found\n" |
821 |
fi |
822 |
rm -f _tests.[co] _tests |
823 |
|
824 |
|
825 |
# fseeko missing? |
826 |
printf "checking for fseeko... " |
827 |
printf "#include <stdlib.h> |
828 |
#include <limits.h> |
829 |
#include <stdio.h> |
830 |
#include <sys/types.h> |
831 |
int main(int argc, char *argv[]) { fseeko(NULL, 0, 0); return 0;}\n" > _tests.c |
832 |
$CC $CFLAGS $CWARNINGS _tests.c -o _tests 2> /dev/null |
833 |
if [ ! -x _tests ]; then |
834 |
# Try with _LARGEFILE_SOURCE (hack to make fseeko |
835 |
# work on 64-bit Linux): |
836 |
$CC $CFLAGS -D_LARGEFILE_SOURCE $CWARNINGS _tests.c -o _tests 2> /dev/null |
837 |
if [ ! -x _tests ]; then |
838 |
printf "missing\n" |
839 |
printf "WARNING! fseeko missing from libc. Using a hack, " |
840 |
printf "which probably doesn't work.\n" |
841 |
printf "#define HACK_FSEEKO\n" >> config.h |
842 |
else |
843 |
printf "using -D_LARGEFILE_SOURCE hack\n" |
844 |
CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE" |
845 |
fi |
846 |
else |
847 |
printf "found\n" |
848 |
fi |
849 |
rm -f _tests.[co] _tests |
850 |
|
851 |
|
852 |
# socklen_t missing? |
853 |
# (for example really old OpenBSD/arc 2.3, inside the emulator) |
854 |
printf "checking for socklen_t... " |
855 |
printf "#include <stdlib.h> |
856 |
#include <stdio.h> |
857 |
#include <sys/types.h> |
858 |
#include <sys/socket.h> |
859 |
int main(int argc, char *argv[]) { socklen_t x; return 0;}\n" > _tests.c |
860 |
$CC $CFLAGS _tests.c -o _tests 2> /dev/null |
861 |
if [ ! -x _tests ]; then |
862 |
printf "no, using int\n" |
863 |
CFLAGS="$CFLAGS -Dsocklen_t=int" |
864 |
else |
865 |
printf "socklen_t\n" |
866 |
fi |
867 |
rm -f _tests.[co] _tests |
868 |
|
869 |
|
870 |
# MAP_ANON missing? (On some HP-UX systems? Use MAP_ANONYMOUS instead.) |
871 |
printf "checking for MAP_ANON... " |
872 |
rm -f _tests |
873 |
printf "#include <stdio.h> |
874 |
#include <sys/types.h> |
875 |
#include <sys/mman.h> |
876 |
int main(int argc, char *argv[]) { int x = MAP_ANON; return 0;}\n" > _tests.c |
877 |
$CC $CFLAGS _tests.c -o _tests 2> /dev/null |
878 |
if [ ! -x _tests ]; then |
879 |
printf "#include <stdio.h> |
880 |
#include <sys/types.h> |
881 |
#include <sys/mman.h> |
882 |
int main(int argc, char *argv[]) |
883 |
{ int x = MAP_ANONYMOUS; return 0;}\n" > _tests.c |
884 |
$CC $CFLAGS _tests.c -o _tests 2> /dev/null |
885 |
if [ ! -x _tests ]; then |
886 |
printf "no\n\n" |
887 |
printf "WARNING! Neither MAP_ANON nor MAP_ANONYMOUS work on " |
888 |
printf "this system.\nPlease try to compile anyway, and report" |
889 |
printf " to me whether it builds/runs or not.\n\n" |
890 |
printf "#define MAP_ANON 0\n" >> config.h |
891 |
printf "#define NO_MAP_ANON\n" >> config.h |
892 |
else |
893 |
printf "using MAP_ANONYMOUS\n" |
894 |
printf "#define MAP_ANON MAP_ANONYMOUS\n" >> config.h |
895 |
fi |
896 |
else |
897 |
printf "yes\n" |
898 |
fi |
899 |
rm -f _tests.[co] _tests |
900 |
|
901 |
|
902 |
# Check for PRIx64 in inttypes.h: |
903 |
printf "checking for PRIx64 in inttypes.h... " |
904 |
printf "#include <inttypes.h>\nint main(int argc, char *argv[])\n |
905 |
{\n#ifdef PRIx64\nreturn 0;\n#else\nreturn 1;\n#endif\n}\n" > _testpri.c |
906 |
$CC $CFLAGS _testpri.c -o _testpri 2> /dev/null |
907 |
if [ ! -x _testpri ]; then |
908 |
printf "\nERROR! COULD NOT COMPILE PRIx64 TEST PROGRAM AT ALL!\n" |
909 |
exit |
910 |
else |
911 |
if ./_testpri; then |
912 |
printf "yes\n" |
913 |
else |
914 |
printf "no, using an ugly hack instead, " |
915 |
printf "#define NO_C99_PRINTF_DEFINES\n" >> config.h |
916 |
|
917 |
# Try llx first: |
918 |
printf "#include <stdio.h>\n#include <inttypes.h>\nint main(int argc, char *argv[]){ |
919 |
printf(\"%%llx\\\n\", (int64_t)128);return 0;}\n" > _testpri.c |
920 |
rm -f _testpri |
921 |
$CC $CFLAGS $CWARNINGS _testpri.c -o _testpri 2> /dev/null |
922 |
if [ z`./_testpri` = z80 ]; then |
923 |
printf "PRIx64=llx\n" |
924 |
printf "#define NO_C99_64BIT_LONGLONG\n" >> config.h |
925 |
else |
926 |
# Try lx too: |
927 |
printf "#include <stdio.h>\n#include <inttypes.h>\nint main(int argc, char *argv[]){ |
928 |
printf(\"%%lx\\\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=lx\n" |
933 |
else |
934 |
printf "\nFailed, neither lx nor llx worked!\n" |
935 |
exit |
936 |
fi |
937 |
fi |
938 |
fi |
939 |
fi |
940 |
rm -f _testpri.c _testpri |
941 |
|
942 |
|
943 |
# Check for 64-bit off_t: |
944 |
printf "checking for 64-bit off_t... " |
945 |
printf "#include <stdio.h>\n#include <inttypes.h>\n#include <sys/types.h>\n |
946 |
int main(int argc, char *argv[]){printf(\"%%i\\\n\", |
947 |
(int)sizeof(off_t));return 0;}\n" > _testoff.c |
948 |
$CC $CFLAGS _testoff.c -o _testoff 2> /dev/null |
949 |
if [ ! -x _testoff ]; then |
950 |
printf "\nWARNING! COULD NOT COMPILE off_t TEST PROGRAM AT ALL!\n" |
951 |
else |
952 |
if [ z`./_testoff` = z8 ]; then |
953 |
printf "yes\n" |
954 |
else |
955 |
$CC $CFLAGS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \ |
956 |
_testoff.c -o _testoff 2> /dev/null |
957 |
if [ ! -x _testoff ]; then |
958 |
printf "\nWARNING! COULD NOT COMPILE off_t TEST " |
959 |
printf "PROGRAM!\n" |
960 |
else |
961 |
if [ z`./_testoff` = z8 ]; then |
962 |
CFLAGS="-D_FILE_OFFSET_BITS=64 $CFLAGS" |
963 |
CFLAGS="-D_LARGEFILE_SOURCE $CFLAGS" |
964 |
printf "using -D_FILE_OFFSET_BITS=64" |
965 |
printf " -D_LARGEFILE_SOURCE\n" |
966 |
else |
967 |
printf "NO\n" |
968 |
printf "Warning! No 64-bit off_t. Continuing " |
969 |
printf "anyway.\n" |
970 |
fi |
971 |
fi |
972 |
fi |
973 |
fi |
974 |
rm -f _testoff.c _testoff |
975 |
|
976 |
|
977 |
# Check for u_int8_t etc: |
978 |
# These are needed because some header files in src/include/ use u_int* |
979 |
# instead of uint*, and I don't have time to rewrite them all. |
980 |
printf "checking for u_int8_t... " |
981 |
printf "#include <stdio.h>\n#include <inttypes.h>\n#include <sys/types.h>\n |
982 |
int main(int argc, char *argv[]){printf(\"%%i\\\n\", |
983 |
(int)sizeof(u_int8_t));return 0;}\n" > _testuint.c |
984 |
$CC $CFLAGS _testuint.c -o _testuint 2> /dev/null |
985 |
if [ ! -x _testuint ]; then |
986 |
rm -f _testuint* |
987 |
printf "#include <stdio.h>\n#include <inttypes.h> |
988 |
\n#include <sys/types.h>\nint main(int argc, char *argv[]) |
989 |
{printf(\"%%i\\\n\", (int)sizeof(uint8_t));return 0;}\n" > _testuint.c |
990 |
$CC $CFLAGS _testuint.c -o _testuint 2> /dev/null |
991 |
if [ ! -x _testuint ]; then |
992 |
printf "no\n\nERROR: No u_int8_t or uint8_t. Aborting\n" |
993 |
# TODO: Automagically detect using various combinations |
994 |
# of char, int, short, long etc. |
995 |
exit |
996 |
fi |
997 |
|
998 |
printf "typedef uint8_t u_int8_t;\n" >> config.h |
999 |
printf "typedef uint16_t u_int16_t;\n" >> config.h |
1000 |
printf "typedef uint32_t u_int32_t;\n" >> config.h |
1001 |
printf "uint8_t\n" |
1002 |
else |
1003 |
printf "yes\n" |
1004 |
fi |
1005 |
rm -f _testuint.c _testuint |
1006 |
|
1007 |
printf "checking for u_int64_t... " |
1008 |
printf "#include <stdio.h>\n#include <inttypes.h>\n#include <sys/types.h>\n |
1009 |
int main(int argc, char *argv[]){printf(\"%%i\\\n\", |
1010 |
(int)sizeof(u_int64_t));return 0;}\n" > _testuint.c |
1011 |
$CC $CFLAGS _testuint.c -o _testuint 2> /dev/null |
1012 |
if [ ! -x _testuint ]; then |
1013 |
rm -f _testuint* |
1014 |
printf "#include <stdio.h>\n#include <inttypes.h> |
1015 |
\n#include <sys/types.h>\nint main(int argc, char *argv[]) |
1016 |
{printf(\"%%i\\\n\", (int)sizeof(uint64_t));return 0;}\n" > _testuint.c |
1017 |
$CC $CFLAGS _testuint.c -o _testuint 2> /dev/null |
1018 |
if [ ! -x _testuint ]; then |
1019 |
printf "no\n\nERROR: No u_int64_t or uint64_t. Aborting\n" |
1020 |
# TODO: Automagically detect using various combinations |
1021 |
# of char, int, short, long etc. |
1022 |
exit |
1023 |
fi |
1024 |
|
1025 |
printf "typedef uint64_t u_int64_t;\n" >> config.h |
1026 |
printf "uint64_t\n" |
1027 |
else |
1028 |
printf "yes\n" |
1029 |
fi |
1030 |
rm -f _testuint.c _testuint |
1031 |
|
1032 |
|
1033 |
############################################################################### |
1034 |
|
1035 |
# Host byte order? |
1036 |
printf "checking host endianness... " |
1037 |
rm -f _test_end* |
1038 |
printf '#include <stdio.h> |
1039 |
int main(int argc, char *argv[]) |
1040 |
{ int x = 1; void *xp = (void *)&x; char *p = (char *)xp; |
1041 |
if (*p) printf("little\\\n"); else printf("big\\\n"); } |
1042 |
' > _test_end.c |
1043 |
$CC $CFLAGS _test_end.c -o _test_end 2> /dev/null |
1044 |
X=`./_test_end` |
1045 |
echo $X |
1046 |
if [ z$X = zlittle ]; then |
1047 |
printf "#define HOST_LITTLE_ENDIAN\n" >> config.h |
1048 |
else |
1049 |
if [ z$X = zbig ]; then |
1050 |
printf "#define HOST_BIG_ENDIAN\n" >> config.h |
1051 |
else |
1052 |
echo "Error! Could not determine host's endianness." |
1053 |
exit |
1054 |
fi |
1055 |
fi |
1056 |
rm -f _test_end* |
1057 |
|
1058 |
############################################################################### |
1059 |
|
1060 |
INCLUDE=-Iinclude/ |
1061 |
DINCLUDE=-I../include/ |
1062 |
|
1063 |
rm -f _testprog.c |
1064 |
|
1065 |
echo C compiler flags: $CFLAGS $CWARNINGS |
1066 |
echo Linker flags: $OTHERLIBS |
1067 |
echo "CWARNINGS=$CWARNINGS" >> _Makefile.header |
1068 |
echo "COPTIM=$CFLAGS" >> _Makefile.header |
1069 |
echo "INCLUDE=$INCLUDE" >> _Makefile.header |
1070 |
echo "DINCLUDE=$DINCLUDE" >> _Makefile.header |
1071 |
echo "CC=$CC" >> _Makefile.header |
1072 |
echo "OTHERLIBS=$OTHERLIBS" >> _Makefile.header |
1073 |
echo "CPU_ARCHS=$CPU_ARCHS" >> _Makefile.header |
1074 |
echo "CPU_TOOLS=$CPU_TOOLS" >> _Makefile.header |
1075 |
echo "" >> _Makefile.header |
1076 |
|
1077 |
|
1078 |
# Create the Makefiles: |
1079 |
D=". src src/include src/cpus src/debugger src/devices src/devices/fonts" |
1080 |
D="$D src/machines src/promemul doc" |
1081 |
for a in $D; do |
1082 |
echo "creating $a/Makefile" |
1083 |
touch $a/Makefile |
1084 |
cat _Makefile.header > $a/Makefile |
1085 |
cat $a/Makefile.skel >> $a/Makefile |
1086 |
done |
1087 |
|
1088 |
# Tail of config.h: |
1089 |
printf "\n#endif /* CONFIG_H */\n" >> config.h |
1090 |
|
1091 |
# Remove temporary Makefile header: |
1092 |
rm -f _Makefile.header |
1093 |
|
1094 |
echo Configured. You may now run make to build gxemul. |