/[gxemul]/trunk/configure
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/configure

Parent Directory Parent Directory | Revision Log Revision Log


Revision 44 - (show annotations)
Mon Oct 8 16:22:56 2007 UTC (11 years, 8 months ago) by dpavlin
File size: 33552 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1632 2007/09/11 21:46:35 debug Exp $
20070616	Implementing the MIPS32/64 revision 2 "ror" instruction.
20070617	Adding a struct for each physpage which keeps track of which
		ranges within that page (base offset, length) that are
		continuously translatable. When running with native code
		generation enabled (-b), a range is added after each read-
		ahead loop.
		Experimenting with using the physical program counter sample
		data (implemented 20070608) together with the "translatable
		range" information, to figure out which physical address ranges
		would be worth translating to native code (if the number of
		samples falling within a range is above a certain threshold).
20070618	Adding automagic building of .index comment files for
		src/file/, src/promemul/, src src/useremul/ as well.
		Adding a "has been translated" bit to the ranges, so that only
		not-yet-translated ranges will be sampled.
20070619	Moving src/cpu.c and src/memory_rw.c into src/cpus/,
		src/device.c into src/devices/, and src/machine.c into
		src/machines/.
		Creating a skeleton cc/ld native backend module; beginning on
		the function which will detect cc command line, etc.
20070620	Continuing on the native code generation infrastructure.
20070621	Moving src/x11.c and src/console.c into a new src/console/
		subdir (for everything that is console or framebuffer related).
		Moving src/symbol*.c into a new src/symbol/, which should
		contain anything that is symbol handling related.
20070624	Making the program counter sampling threshold a "settings
		variable" (sampling_threshold), i.e. it can now be changed
		during runtime.
		Switching the RELEASE notes format from plain text to HTML.
		If the TMPDIR environment variable is set, it is used instead
		of "/tmp" for temporary files.
		Continuing on the cc/ld backend: simple .c code is generated,
		the compiler and linker are called, etc.
		Adding detection of host architecture to the configure script
		(again), and adding icache invalidation support (only
		implemented for Alpha hosts so far).
20070625	Simplifying the program counter sampling mechanism.
20070626	Removing the cc/ld native code generation stuff, program
		counter sampling, etc; it would not have worked well in the
		general case.
20070627	Removing everything related to native code generation.
20070629	Removing the (practically unusable) support for multiple
		emulations. (The single emulation allowed now still supports
		multiple simultaneous machines, as before.)
		Beginning on PCCTWO and M88K interrupts.
20070723	Adding a dummy skeleton for emulation of M32R processors.
20070901	Fixing a warning found by "gcc version 4.3.0 20070817
		(experimental)" on amd64.
20070905	Removing some more traces of the old "multiple emulations"
		code.
		Also looking in /usr/local/include and /usr/local/lib for
		X11 libs, when running configure.
20070909	Minor updates to the guest OS install instructions, in
		preparation for the NetBSD 4.0 release.
20070918	More testing of NetBSD 4.0 RC1.

1 #!/bin/sh
2 ###############################################################################
3 #
4 # Copyright (C) 2003-2007 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.277 2007/08/29 20:36:05 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 # 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 # Figure out if this is a stable version (0.x.x).
60 X=`basename \`pwd\`|cut -d \- -f 2-|cut -c1-2`
61 if [ z"$X" = z0. ]; then
62 # Stable.
63 :
64 else
65 # Development.
66 UNSTABLE=YES
67 fi
68
69 if [ z"$*" != z ]; then
70 # Parse command line options:
71 for a in $*; do
72 if [ z$a = z--disable-x ]; then
73 NOX11=YES
74 else if [ z$a = z--debug ]; then
75 DEBUG=YES
76 else if [ z$a = z--help ]; then
77 printf "usage: $0 [options]\n\n"
78 echo " --disable-x don't include X11 support,"\
79 "even if the host supports it"
80 if [ z"$UNSTABLE" = zYES ]; then
81 echo " --debug configure" \
82 "for a debug build"
83 fi
84 echo
85 exit
86 else
87 echo "Invalid option: $a"
88 echo "Run $0 --help to get a list of" \
89 "available options."
90 exit
91 fi; fi; fi
92 done
93 fi
94
95
96 ###############################################################################
97 #
98 # Configure options:
99 #
100 # This creates a config.h file, which is then included from include/misc.h.
101 #
102 ###############################################################################
103
104 # Head of config.h:
105 printf "/*
106 * THIS FILE IS AUTOMATICALLY CREATED BY configure!
107 * DON'T EDIT THIS FILE MANUALLY, IT WILL BE OVERWRITTEN.
108 */
109 \n#ifndef CONFIG_H\n#define CONFIG_H\n\n" > config.h
110
111
112 # Figure out if VERSION should be defined.
113 X=`basename \`pwd\`|cut -d \- -f 2-`
114 if [ z"$X" = zgxemul ]; then
115 printf "#define VERSION \"(unknown version)\"\n" >> config.h
116 else
117 printf "#define VERSION \"$X\"\n" >> config.h
118 fi
119
120
121 if [ z"$UNSTABLE" = zYES ]; then
122 printf "#define UNSTABLE_DEVEL\n" >> config.h
123 else
124 CFLAGS="-DNDEBUG $CFLAGS"
125 fi
126
127
128 ZZ=`echo compiled on \`uname\`/\`uname -m\`, \`date\``
129 printf "#define COMPILE_DATE \"$ZZ\"\n" >> config.h
130
131
132 # Include support for all CPU types:
133 printf "#define ADD_ALL_CPU_FAMILIES " >> config.h
134
135 # Alpha
136 printf " add_cpu_family(alpha_cpu_family_init, ARCH_ALPHA);" >> config.h
137 CPU_ARCHS="$CPU_ARCHS cpu_alpha.o cpu_alpha_palcode.o memory_alpha.o"
138 CPU_TOOLS="$CPU_TOOLS generate_alpha_misc"
139
140 # 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 # M32R
165 printf " add_cpu_family(m32r_cpu_family_init, ARCH_M32R);" >> config.h
166 CPU_ARCHS="$CPU_ARCHS cpu_m32r.o memory_m32r.o"
167
168 # M88K
169 printf " add_cpu_family(m88k_cpu_family_init, ARCH_M88K);" >> config.h
170 CPU_ARCHS="$CPU_ARCHS cpu_m88k.o memory_m88k.o"
171 CPU_TOOLS="$CPU_TOOLS generate_m88k_bcnd"
172 CPU_TOOLS="$CPU_TOOLS generate_m88k_loadstore"
173
174 # MIPS
175 printf " add_cpu_family(mips_cpu_family_init, ARCH_MIPS);" >> config.h
176 CPU_ARCHS="$CPU_ARCHS cpu_mips.o cpu_mips_coproc.o "
177 CPU_ARCHS="$CPU_ARCHS cpu_mips_instr_unaligned.o"
178 CPU_TOOLS="$CPU_TOOLS generate_mips_loadstore"
179 CPU_TOOLS="$CPU_TOOLS generate_mips_loadstore_multi"
180
181 # POWER/PowerPC
182 printf " add_cpu_family(ppc_cpu_family_init, ARCH_PPC);" >> config.h
183 CPU_ARCHS="$CPU_ARCHS cpu_ppc.o"
184 CPU_TOOLS="$CPU_TOOLS generate_ppc_loadstore"
185
186 # SuperH
187 printf " add_cpu_family(sh_cpu_family_init, ARCH_SH);" >> config.h
188 CPU_ARCHS="$CPU_ARCHS cpu_sh.o memory_sh.o"
189
190 # SPARC
191 printf " add_cpu_family(sparc_cpu_family_init, ARCH_SPARC);" >> config.h
192 CPU_ARCHS="$CPU_ARCHS cpu_sparc.o memory_sparc.o"
193 CPU_TOOLS="$CPU_TOOLS generate_sparc_loadstore"
194
195 printf "\n" >> config.h
196
197
198 ###############################################################################
199 #
200 # Special hacks for some host OSes:
201 #
202 ###############################################################################
203
204 if [ z"`uname|cut -c 1-6`" = zCYGWIN ]; then
205 CYGWIN=YES
206
207 if [ z"$CC" = z ]; then
208 # Assume gcc on Cygwin (Windows) systems.
209 CC=gcc
210 fi
211 fi
212
213 if [ z"`uname`" = zHP-UX ]; then
214 HPUX=YES
215
216 if [ z$CC = z ]; then
217 if [ -f /usr/local/pa64/bin/gcc ]; then
218 CC=/usr/local/pa64/bin/gcc
219 fi
220 fi
221 fi
222
223 if [ z"`uname`" = zOSF1 ]; then
224 OSF1=YES
225 fi
226
227
228 ###############################################################################
229 #
230 # Create the Makefile header:
231 #
232 ###############################################################################
233
234 rm -f _Makefile.header
235
236 printf "#
237 # DO NOT EDIT THIS FILE! It is automagically created by
238 # the configure script, based on Makefile.skel.
239 #\n\n" >> _Makefile.header
240
241
242 # Try with the simplest possible test program. Actually, test static variables
243 # as well, because GXemul uses things like NULL-initialized global pointers,
244 # and it is important that they work. (GCC on Solaris is known to be completely
245 # broken, for instance.)
246
247 echo '#include <stdio.h>
248
249 int main(int argc, char *argv[])
250 {
251 static int x = 0;
252 static int y = 1;
253 printf("%i,%i", x, y);
254 return 0;
255 }
256 ' > _testprog.c
257
258
259 # Try to detect which C compiler to use, if CC is not set:
260 printf "checking which C compiler to use... "
261 rm -f _testprog
262 if [ z"$CC" = z ]; then
263 # Try gcc first:
264 printf "#!/bin/sh\ngcc $CFLAGS _testprog.c -o _testprog >" > _test.sh
265 printf " /dev/null 2> /dev/null\n" >> _test.sh
266 chmod 755 _test.sh
267 ./_test.sh > /dev/null 2> /dev/null
268 if [ -x _testprog ]; then
269 if [ z`./_testprog` = z0,1 ]; then
270 CC=gcc
271 else
272 printf "broken gcc detected\n"
273 printf "The test program:\n\n"
274 cat _testprog.c
275 printf "\nshould have resulted in 0,1, but the"
276 printf " result was: "
277 ./_testprog
278 printf "\n\nchecking for other C compilers... "
279 fi
280 fi
281 rm -f _testprog
282
283 # If both gcc and cc exist, then cc might be a vendor specific
284 # compiler which produces faster code than gcc (eg on Solaris):
285 printf "#!/bin/sh\ncc $CFLAGS _testprog.c -o _testprog >" > _test.sh
286 printf " /dev/null 2> /dev/null\n" >> _test.sh
287 chmod 755 _test.sh
288 ./_test.sh > /dev/null 2> /dev/null
289 if [ -x _testprog ]; then
290 if [ z`./_testprog` = z0,1 ]; then
291 CC=cc
292 else
293 printf "broken cc detected\n"
294 printf "checking for other C compilers... "
295 fi
296 fi
297 rm -f _testprog
298
299 # Actually, don't try ccc on Alpha. ccc generates broken code :(
300
301 # # Try ccc (FreeBSD/Alpha):
302 # printf "#!/bin/sh\nccc $CFLAGS _testprog.c -o _testprog >" > _test.sh
303 # printf " /dev/null 2> /dev/null\n" >> _test.sh
304 # chmod 755 _test.sh
305 # ./_test.sh > /dev/null 2> /dev/null
306 # if [ -x _testprog ]; then
307 # CC="ccc"
308 # fi
309 # rm -f _testprog
310
311 rm -f _test.sh
312 fi
313
314
315 rm -f _testprog
316
317 if [ z$CC = z ]; then
318 printf "no working compiler detected\n"
319 printf "\nPlease set the CC environment variable to a working C "
320 printf "compiler before running\nthe configure script, and make"
321 printf " sure that the CFLAGS environment variable is\nalso valid"
322 printf " for that compiler.\n"
323 exit
324 fi
325
326 printf "$CC $CFLAGS"
327
328
329 CCTYPE="generic"
330
331 if $CC $CFLAGS -V 2> /dev/null | grep ompaq 1> /dev/null 2> /dev/null; then
332 COMPAQCC=YES
333 CCTYPE="Compaq CC"
334 fi
335
336 if $CC $CFLAGS -V 2>&1 | grep Sun 1> /dev/null 2> /dev/null; then
337 SUNCC=YES
338 CCTYPE="Solaris CC"
339 fi
340
341 if $CC $CFLAGS -v 2>&1 | grep gcc 1> /dev/null 2> /dev/null; then
342 GCCCC=YES
343 CCTYPE="GNU CC"
344 fi
345
346 if [ z$CYGWIN = zYES ]; then
347 CCTYPE="$CCTYPE (Cygwin)"
348 fi
349
350 echo " ($CCTYPE)"
351
352
353 if [ z$NOX11 = z ]; then
354 printf "checking for X11 headers and libs\n"
355
356 # Try to compile a small X11 test program:
357 printf "#include <X11/Xlib.h>
358 #include <stdio.h>
359 Display *dis;
360 void f(void) {
361 dis = XOpenDisplay(NULL);
362 }
363 int main(int argc, char *argv[])
364 { return 0; }
365 " > _test_x11.c
366
367 XOK=0
368
369 XINCLUDE=-I/usr/X11R6/include
370 $CC $CFLAGS _test_x11.c -c -o _test_x11.o $XINCLUDE 2> /dev/null
371
372 XLIB="-L/usr/X11R6/lib -lX11"
373 $CC $CFLAGS _test_x11.o -o _test_x11 $XLIB 2> /dev/null
374
375 if [ -x _test_x11 ]; then
376 XOK=1
377 fi
378
379 rm -f _test_x11 _test_x11.o
380
381 if [ z$XOK = z0 ]; then
382 XINCLUDE=-I/usr/local/include
383 $CC $CFLAGS _test_x11.c -c -o _test_x11.o \
384 $XINCLUDE 2> /dev/null
385
386 XLIB="-L/usr/local/lib -lX11"
387 $CC $CFLAGS _test_x11.o -o _test_x11 $XLIB 2> /dev/null
388
389 if [ -x _test_x11 ]; then
390 XOK=1
391 fi
392 fi
393 rm -f _test_x11 _test_x11.o
394
395 # Special case for some 64-bit Linux/x86_64 systems:
396 if [ z$XOK = z0 ]; then
397 $CC $CFLAGS _test_x11.c -c -o _test_x11.o \
398 $XINCLUDE 2> /dev/null
399
400 XLIB="-L/usr/X11R6/lib64 -lX11"
401 $CC $CFLAGS _test_x11.o -o _test_x11 $XLIB 2> /dev/null
402
403 if [ -x _test_x11 ]; then
404 XOK=1
405 fi
406 fi
407 rm -f _test_x11 _test_x11.o
408
409 if [ z$XOK = z0 ]; then
410 XINCLUDE=""
411 $CC $CFLAGS _test_x11.c -c -o _test_x11.o \
412 $XINCLUDE 2> /dev/null
413
414 # -lsocket for Solaris
415 XLIB="-lX11 -lsocket"
416 $CC $CFLAGS _test_x11.o -o _test_x11 $XLIB 2> /dev/null
417
418 if [ -x _test_x11 ]; then
419 XOK=1
420 fi
421 rm -f _test_x11 _test_x11.o
422 fi
423
424 if [ z`uname` = zNetBSD ]; then
425 echo "Using NetBSD hack for X11 libs..."
426 XLIB="$XLIB -Wl,-rpath,/usr/X11R6/lib"
427 fi
428
429 if [ z`uname` = zOpenBSD ]; then
430 if [ z`uname -m` = zarc ]; then
431 echo "Using old OpenBSD/arc hack for X11 libs..."
432 XLIB="$XLIB -Wl,-rpath,/usr/X11R6/lib"
433 fi
434 fi
435
436 if [ z$XOK = z0 ]; then
437 echo "Failed to compile X11 test program." \
438 "Configuring without X11."
439 else
440 printf "X11 headers: $XINCLUDE\n"
441 printf "X11 libraries: $XLIB\n"
442 echo "XINCLUDE=$XINCLUDE" >> _Makefile.header
443 echo "XLIB=$XLIB" >> _Makefile.header
444 printf "#define WITH_X11\n" >> config.h
445 fi
446
447 rm -f _test_x11.c
448 fi
449
450
451 if [ z$HPUX = zYES ]; then
452 CFLAGS="-D_XOPEN_SOURCE_EXTENDED $CFLAGS"
453 printf "#define HPUX\n" >> config.h
454 fi
455
456
457 if [ z$OSF1 = zYES ]; then
458 CFLAGS="-D_XOPEN_SOURCE=500 -D_OSF_SOURCE -D_POSIX_PII_SOCKET $CFLAGS"
459 fi
460
461
462 # Check for 'alpha' define.
463 printf "checking for 'alpha' define... "
464 printf "#include <stdio.h>\nint main(int argc, char *argv[]){
465 #ifdef alpha
466 printf(\"1\");
467 #undef alpha
468 #ifdef alpha
469 printf(\"2\");
470 #endif
471 #endif
472 printf(\"\\\n\");return 0;}\n" > _testm.c
473 $CC $CFLAGS _testm.c -o _testm 2> /dev/null
474 if [ ! -x _testm ]; then
475 printf "\nWARNING! COULD NOT COMPILE alpha define TEST"
476 printf " PROGRAM AT ALL!\n"
477 else
478 if [ z`./_testm` = z1 ]; then
479 printf "yes, workaround applied\n"
480 echo "#undef alpha" >> config.h
481 else
482 if [ z`./_testm` = z12 ]; then
483 printf "yes, but workaround not possible\n"
484 exit
485 else
486 printf "no\n"
487 fi
488 fi
489 fi
490 rm -f _testm*
491
492
493 # Some OSes on MIPS seems to define 'mips' to 1. (eg OpenBSD/arc)
494 printf "checking for 'mips' define... "
495 printf "#include <stdio.h>\nint main(int argc, char *argv[]){
496 #ifdef mips
497 printf(\"1\");
498 #undef mips
499 #ifdef mips
500 printf(\"2\");
501 #endif
502 #endif
503 printf(\"\\\n\");return 0;}\n" > _testm.c
504 $CC $CFLAGS _testm.c -o _testm 2> /dev/null
505 if [ ! -x _testm ]; then
506 printf "\nWARNING! COULD NOT COMPILE mips define TEST"
507 printf " PROGRAM AT ALL!\n"
508 else
509 if [ z`./_testm` = z1 ]; then
510 printf "yes, workaround applied\n"
511 echo "#undef mips" >> config.h
512 else
513 if [ z`./_testm` = z12 ]; then
514 printf "yes, but workaround not possible\n"
515 exit
516 else
517 printf "no\n"
518 fi
519 fi
520 fi
521 rm -f _testm*
522
523
524 # Similar to the mips define check above, although I don't know if
525 # any OS actually defined ppc like this.
526 printf "checking for 'ppc' define... "
527 printf "#include <stdio.h>\nint main(int argc, char *argv[]){
528 #ifdef ppc
529 printf(\"1\");
530 #undef ppc
531 #ifdef ppc
532 printf(\"2\");
533 #endif
534 #endif
535 printf(\"\\\n\");return 0;}\n" > _testm.c
536 $CC $CFLAGS _testm.c -o _testm 2> /dev/null
537 if [ ! -x _testm ]; then
538 printf "\nWARNING! COULD NOT COMPILE ppc define TEST"
539 printf " PROGRAM AT ALL!\n"
540 else
541 if [ z`./_testm` = z1 ]; then
542 printf "yes, workaround applied\n"
543 echo "#undef ppc" >> config.h
544 else
545 if [ z`./_testm` = z12 ]; then
546 printf "yes, but workaround not possible\n"
547 exit
548 else
549 printf "no\n"
550 fi
551 fi
552 fi
553 rm -f _testm*
554
555
556 # Similar to the mips define check above, although I don't know if
557 # any OS actually defined sparc like this.
558 printf "checking for 'sparc' define... "
559 printf "#include <stdio.h>\nint main(int argc, char *argv[]){
560 #ifdef sparc
561 printf(\"1\");
562 #undef sparc
563 #ifdef sparc
564 printf(\"2\");
565 #endif
566 #endif
567 printf(\"\\\n\");return 0;}\n" > _testm.c
568 $CC $CFLAGS _testm.c -o _testm 2> /dev/null
569 if [ ! -x _testm ]; then
570 printf "\nWARNING! COULD NOT COMPILE sparc define TEST "
571 printf "PROGRAM AT ALL!\n"
572 else
573 if [ z`./_testm` = z1 ]; then
574 printf "yes, workaround applied\n"
575 echo "#undef sparc" >> config.h
576 else
577 if [ z`./_testm` = z12 ]; then
578 printf "yes, but workaround not possible\n"
579 exit
580 else
581 printf "no\n"
582 fi
583 fi
584 fi
585 rm -f _testm*
586
587
588 # CWARNINGS:
589 printf "checking whether -Wall can be used... "
590 $CC $CFLAGS _testprog.c -o _testprog -Wall 2> /dev/null
591 if [ -x _testprog ]; then
592 printf "yes\n"
593 CWARNINGS="-Wall $CWARNINGS"
594
595 # Compaq's compiler always seems to warn about the long long type,
596 # and unusedtop suppresses warnings about include files being
597 # included more than once.
598 if [ z"$COMPAQCC" = zYES ]; then
599 CWARNINGS="$CWARNINGS -msg_disable longlongtype,unusedtop"
600 fi
601
602 if [ z"$UNSTABLE" = zYES ]; then
603 printf "checking whether -Werror can be used... "
604 rm -f _testprog
605 $CC $CFLAGS $CWARNINGS _testprog.c -o _testprog -Werror 2> /dev/null
606 if [ -x _testprog ]; then
607 printf "yes\n"
608 CWARNINGS="$CWARNINGS -Werror"
609 else
610 printf "no\n"
611 fi
612 fi
613 else
614 printf "no\n"
615 fi
616 rm -f _testprog
617
618
619 # -Wstrict-aliasing
620 if [ ! z"$DEBUG" = zYES ]; then
621 printf "checking whether -Wstrict-aliasing can be used... "
622 $CC $CFLAGS -Wstrict-aliasing _testprog.c -o \
623 _testprog 1> _testprog.stdout 2>&1
624 cat _testprog.stdout >> _testprog.error
625 if grep frame _testprog.error > /dev/null 2>&1; then
626 printf "no\n"
627 else
628 if [ -x _testprog ]; then
629 CWARNINGS="-Wstrict-aliasing $CWARNINGS"
630 printf "yes\n"
631 else
632 printf "no\n"
633 fi
634 fi
635 rm -f _testprog _testprog.error _testprog.stdout
636 fi
637
638
639 if [ z"$COMPAQCC" = zYES ]; then
640 # -O4 is possible, but sometimes -O3 is better?
641 if [ ! z"$DEBUG" = zYES ]; then
642 CFLAGS="-O4 $CFLAGS"
643 fi
644 else
645 if [ z"`uname`" = zSunOS ]; then
646 # "cc", the system's default compiler:
647 if [ ! z"$DEBUG" = zYES ]; then
648 if [ z"$SUNCC" = zYES ]; then
649 CFLAGS="-xO5 -xdepend $CFLAGS"
650 fi
651 fi
652 printf "#define SOLARIS\n" >> config.h
653 OTHERLIBS="-lsocket $OTHERLIBS"
654 else
655 # gcc or something else:
656 if [ ! z"$DEBUG" = zYES ]; then
657 $CC $CFLAGS _testprog.c -o _testprog -O 2> /dev/null
658 if [ -x _testprog ]; then
659 rm -f _testprog
660 $CC $CFLAGS _testprog.c -o _testprog \
661 -O3 2> /dev/null
662 if [ -x _testprog ]; then
663 CFLAGS="-O3 $CFLAGS"
664 else
665 CFLAGS="-O $CFLAGS"
666 fi
667 fi
668 fi
669 fi
670 fi
671 rm -f _testprog
672
673
674 # -fschedule-insns causes bugs on i386 with gcc,
675 # but works OK on my alpha with ccc (compaq's cc).
676 if [ ! z"$DEBUG" = zYES ]; then
677 if [ z"$COMPAQCC" = zYES ]; then
678 printf "checking whether -fschedule-insns2 can be used... "
679 $CC $CFLAGS _testprog.c -o _testprog -fschedule-insns2 2> /dev/null
680 if [ -x _testprog ]; then
681 CFLAGS="-fschedule-insns2 $CFLAGS"
682 printf "yes\n"
683 else
684 printf "no\n"
685 fi
686 rm -f _testprog
687
688 printf "checking whether -fschedule-insns can be used... "
689 $CC $CFLAGS _testprog.c -o _testprog -fschedule-insns 2> /dev/null
690 if [ -x _testprog ]; then
691 CFLAGS="-fschedule-insns $CFLAGS"
692 printf "yes\n"
693 else
694 printf "no\n"
695 fi
696 rm -f _testprog
697
698 # -intrinsics
699 printf "checking whether -intrinsics can be used... "
700 $CC $CFLAGS _testprog.c -o _testprog -intrinsics 2> /dev/null
701 if [ -x _testprog ]; then
702 CFLAGS="-intrinsics $CFLAGS"
703 printf "yes\n"
704 else
705 printf "no\n"
706 fi
707 rm -f _testprog
708
709 # -fast
710 printf "checking whether -fast can be used... "
711 $CC $CFLAGS _testprog.c -o _testprog -fast 2> /dev/null
712 if [ -x _testprog ]; then
713 CFLAGS="-fast $CFLAGS"
714 printf "yes\n"
715 else
716 printf "no\n"
717 fi
718 rm -f _testprog
719 fi; fi
720
721
722 # -fpeephole
723 if [ ! z"$DEBUG" = zYES ]; then
724 printf "checking whether -fpeephole can be used... "
725 $CC $CFLAGS -fpeephole _testprog.c -o _testprog > _testprog.stdout 2>&1
726 cat _testprog.stdout >> _testprog.error
727 if grep peephole _testprog.error > /dev/null 2>&1; then
728 printf "no\n"
729 else
730 if [ -x _testprog ]; then
731 CFLAGS="-fpeephole $CFLAGS"
732 printf "yes\n"
733 else
734 printf "no\n"
735 fi
736 fi
737 rm -f _testprog _testprog.error _testprog.stdout
738 fi
739
740
741 # -fomit-frame-pointer
742 if [ ! z"$DEBUG" = zYES ]; then
743 printf "checking whether -fomit-frame-pointer can be used... "
744 $CC $CFLAGS -fomit-frame-pointer _testprog.c -o \
745 _testprog 1> _testprog.stdout 2>&1
746 cat _testprog.stdout >> _testprog.error
747 if grep frame _testprog.error > /dev/null 2>&1; then
748 printf "no\n"
749 else
750 if [ -x _testprog ]; then
751 CFLAGS="-fomit-frame-pointer $CFLAGS"
752 printf "yes\n"
753 else
754 printf "no\n"
755 fi
756 fi
757 rm -f _testprog _testprog.error _testprog.stdout
758 fi
759
760
761 # -fstrict-aliasing
762 if [ ! z"$DEBUG" = zYES ]; then
763 printf "checking whether -fstrict-aliasing can be used... "
764 $CC $CFLAGS -fstrict-aliasing _testprog.c -o \
765 _testprog 1> _testprog.stdout 2>&1
766 cat _testprog.stdout >> _testprog.error
767 if grep frame _testprog.error > /dev/null 2>&1; then
768 printf "no\n"
769 else
770 if [ -x _testprog ]; then
771 CFLAGS="-fstrict-aliasing $CFLAGS"
772 printf "yes\n"
773 else
774 printf "no\n"
775 fi
776 fi
777 rm -f _testprog _testprog.error _testprog.stdout
778 fi
779
780
781 # -g, for development builds
782 if [ z"$UNSTABLE" = zYES ]; then
783 printf "checking whether -g can be used... "
784 if [ z"$COMPAQCC" = zYES ]; then
785 $CC $CFLAGS -g3 _testprog.c -o _testprog > _testprog.stdout 2>&1
786 cat _testprog.stdout >> _testprog.error
787 if [ -x _testprog ]; then
788 CFLAGS="-g3 $CFLAGS"
789 printf "yes (-g3)\n"
790 else
791 printf "no\n"
792 fi
793 else
794 $CC $CFLAGS -g _testprog.c -o _testprog > _testprog.stdout 2>&1
795 cat _testprog.stdout >> _testprog.error
796 if [ -x _testprog ]; then
797 CFLAGS="-g $CFLAGS"
798 printf "yes\n"
799 else
800 printf "no\n"
801 fi
802 fi
803 rm -f _testprog _testprog.error _testprog.stdout
804 fi
805
806
807 # -lrt for nanosleep?
808 printf "checking whether -lrt is required for nanosleep... "
809 printf "#include <time.h>\n#include <stdio.h>
810 int main(int argc, char *argv[]){nanosleep(NULL,NULL);return 0;}\n" > _testns.c
811 $CC $CFLAGS _testns.c -o _testns 2> /dev/null
812 if [ ! -x _testns ]; then
813 $CC $CFLAGS -lrt _testns.c -o _testns 2> /dev/null
814 if [ ! -x _testns ]; then
815 printf "WARNING! COULD NOT COMPILE WITH nanosleep AT ALL!\n"
816 else
817 # -lrt for nanosleep
818 OTHERLIBS="-lrt $OTHERLIBS"
819 printf "yes\n"
820 fi
821 else
822 printf "no\n"
823 fi
824 rm -f _testns.c _testns
825
826
827 # -lresolv for inet_pton?
828 printf "checking whether -lresolv is required for inet_pton... "
829 printf "int inet_pton(void); int main(int argc, " > _testr.c
830 printf "char *argv[]) { return inet_pton(); }\n" >> _testr.c
831 $CC $CFLAGS _testr.c -o _testr 2> /dev/null
832 if [ ! -x _testr ]; then
833 $CC $CFLAGS _testr.c -lresolv -o _testr 2> /dev/null
834 if [ ! -x _testr ]; then
835 $CC $CFLAGS _testr.c -lresolv -lnsl -o _testr 2> /dev/null
836 if [ ! -x _testr ]; then
837 printf "no, using inet_aton\n"
838 else
839 # -lresolv -lnsl for inet_pton
840 OTHERLIBS="-lresolv -lnsl $OTHERLIBS"
841 printf "yes (and -lnsl)\n"
842 printf "#define HAVE_INET_PTON\n" >> config.h
843 fi
844 else
845 # -lresolv for inet_pton
846 OTHERLIBS="-lresolv $OTHERLIBS"
847 printf "yes\n"
848 printf "#define HAVE_INET_PTON\n" >> config.h
849 fi
850 else
851 printf "no\n"
852 printf "#define HAVE_INET_PTON\n" >> config.h
853 fi
854 rm -f _testr.[co] _testr
855
856
857 # -lm?
858 printf "checking for math libs..."
859 printf "#include <math.h>\nint main(int argc, char *argv[]) { " > _testr.c
860 printf "double x = sqrt(sin((double)argc)); return (int)x; }\n" >> _testr.c
861 $CC $CFLAGS _testr.c -o _testr 2> /dev/null
862 if [ ! -x _testr ]; then
863 $CC $CFLAGS _testr.c -lm -o _testr 2> /dev/null
864 if [ ! -x _testr ]; then
865 $CC $CFLAGS _testr.c -lm -lcpml -o _testr 2> /dev/null
866 if [ ! -x _testr ]; then
867 printf "\nWARNING! Could not compile math test "
868 printf "at all!\nContinuing anyway.\n\n"
869 else
870 # -lm AND -lcpml
871 OTHERLIBS="-lm -lcpml $OTHERLIBS"
872 printf " -lm -lcpml\n"
873 fi
874 else
875 # Normal -lm
876 OTHERLIBS="-lm $OTHERLIBS"
877 printf " -lm\n"
878 fi
879 else
880 printf " none needed\n"
881 fi
882 rm -f _testr.[co] _testr
883
884
885 # strlcpy missing?
886 printf "checking for strlcpy... "
887 printf "#include <string.h>
888 int main(int argc, char *argv[]) { char *p; char *q; size_t x;
889 x = strlcpy(p, q, 50); return 0;}\n" > _tests.c
890 $CC $CFLAGS _tests.c -o _tests 2> /dev/null
891 if [ ! -x _tests ]; then
892 printf "missing, using mystrlcpy\n"
893 printf "#define strlcpy mystrlcpy\n" >> config.h
894 printf "#define strlcat mystrlcat\n" >> config.h
895 printf "#define USE_STRLCPY_REPLACEMENTS\n" >> config.h
896 else
897 printf "found\n"
898 fi
899 rm -f _tests.[co] _tests
900
901
902 # strtoull missing?
903 printf "checking for strtoull... "
904 printf "#include <stdlib.h>
905 #include <limits.h>
906 #include <stdio.h>
907 int main(int argc, char *argv[]) {
908 long long x = strtoull(argv[1], NULL, 0); return 0;}\n" > _tests.c
909 $CC $CFLAGS _tests.c -o _tests 2> /dev/null
910 if [ ! -x _tests ]; then
911 printf "missing, using mystrtoull\n"
912 printf "#define strtoull mystrtoull\n" >> config.h
913 else
914 printf "found\n"
915 fi
916 rm -f _tests.[co] _tests
917
918
919 # mkstemp missing?
920 printf "checking for mkstemp... "
921 printf "#include <unistd.h>
922 int main(int argc, char *argv[]) { int x; char *y = \"abc\";
923 x = mkstemp(y); return 0;}\n" > _tests.c
924 $CC $CFLAGS _tests.c -o _tests 2> /dev/null
925 if [ ! -x _tests ]; then
926 printf "missing, using workaround\n"
927 printf "#define mkstemp mymkstemp\n" >> config.h
928 else
929 printf "found\n"
930 fi
931 rm -f _tests.[co] _tests
932
933
934 # fseeko missing?
935 printf "checking for fseeko... "
936 printf "#include <stdlib.h>
937 #include <limits.h>
938 #include <stdio.h>
939 #include <sys/types.h>
940 int main(int argc, char *argv[]) { fseeko(NULL, 0, 0); return 0;}\n" > _tests.c
941 $CC $CFLAGS $CWARNINGS _tests.c -o _tests 2> /dev/null
942 if [ ! -x _tests ]; then
943 # Try with _LARGEFILE_SOURCE (hack to make fseeko
944 # work on 64-bit Linux):
945 $CC $CFLAGS -D_LARGEFILE_SOURCE $CWARNINGS _tests.c -o _tests 2> /dev/null
946 if [ ! -x _tests ]; then
947 printf "missing\n"
948 printf "WARNING! fseeko missing from libc. Using a hack, "
949 printf "which probably doesn't work.\n"
950 printf "#define HACK_FSEEKO\n" >> config.h
951 else
952 printf "using -D_LARGEFILE_SOURCE hack\n"
953 CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE"
954 fi
955 else
956 printf "found\n"
957 fi
958 rm -f _tests.[co] _tests
959
960
961 # socklen_t missing?
962 # (for example really old OpenBSD/arc 2.3, inside the emulator)
963 printf "checking for socklen_t... "
964 printf "#include <stdlib.h>
965 #include <stdio.h>
966 #include <sys/types.h>
967 #include <sys/socket.h>
968 int main(int argc, char *argv[]) { socklen_t x; return 0;}\n" > _tests.c
969 $CC $CFLAGS _tests.c -o _tests 2> /dev/null
970 if [ ! -x _tests ]; then
971 printf "no, using int\n"
972 CFLAGS="$CFLAGS -Dsocklen_t=int"
973 else
974 printf "socklen_t\n"
975 fi
976 rm -f _tests.[co] _tests
977
978
979 # MAP_ANON missing? (On some HP-UX systems? Use MAP_ANONYMOUS instead.)
980 printf "checking for MAP_ANON... "
981 rm -f _tests
982 printf "#include <stdio.h>
983 #include <sys/types.h>
984 #include <sys/mman.h>
985 int main(int argc, char *argv[]) { int x = MAP_ANON; return 0;}\n" > _tests.c
986 $CC $CFLAGS _tests.c -o _tests 2> /dev/null
987 if [ ! -x _tests ]; then
988 printf "#include <stdio.h>
989 #include <sys/types.h>
990 #include <sys/mman.h>
991 int main(int argc, char *argv[])
992 { int x = MAP_ANONYMOUS; return 0;}\n" > _tests.c
993 $CC $CFLAGS _tests.c -o _tests 2> /dev/null
994 if [ ! -x _tests ]; then
995 printf "no\n\n"
996 printf "WARNING! Neither MAP_ANON nor MAP_ANONYMOUS work on "
997 printf "this system.\nPlease try to compile anyway, and report"
998 printf " to me whether it builds/runs or not.\n\n"
999 printf "#define MAP_ANON 0\n" >> config.h
1000 printf "#define NO_MAP_ANON\n" >> config.h
1001 else
1002 printf "using MAP_ANONYMOUS\n"
1003 printf "#define MAP_ANON MAP_ANONYMOUS\n" >> config.h
1004 fi
1005 else
1006 printf "yes\n"
1007 fi
1008 rm -f _tests.[co] _tests
1009
1010
1011 # Check for PRIx64 in inttypes.h:
1012 printf "checking for PRIx64 in inttypes.h... "
1013 printf "#include <inttypes.h>\nint main(int argc, char *argv[])\n
1014 {\n#ifdef PRIx64\nreturn 0;\n#else\nreturn 1;\n#endif\n}\n" > _testpri.c
1015 $CC $CFLAGS _testpri.c -o _testpri 2> /dev/null
1016 if [ ! -x _testpri ]; then
1017 printf "\nERROR! COULD NOT COMPILE PRIx64 TEST PROGRAM AT ALL!\n"
1018 exit
1019 else
1020 if ./_testpri; then
1021 printf "yes\n"
1022 else
1023 printf "no, using an ugly hack instead, "
1024 printf "#define NO_C99_PRINTF_DEFINES\n" >> config.h
1025
1026 # Try llx first:
1027 printf "#include <stdio.h>\n#include <inttypes.h>\nint main(int argc, char *argv[]){
1028 printf(\"%%llx\\\n\", (int64_t)128);return 0;}\n" > _testpri.c
1029 rm -f _testpri
1030 $CC $CFLAGS $CWARNINGS _testpri.c -o _testpri 2> /dev/null
1031 if [ z`./_testpri` = z80 ]; then
1032 printf "PRIx64=llx\n"
1033 printf "#define NO_C99_64BIT_LONGLONG\n" >> config.h
1034 else
1035 # Try lx too:
1036 printf "#include <stdio.h>\n#include <inttypes.h>\nint main(int argc, char *argv[]){
1037 printf(\"%%lx\\\n\", (int64_t)128);return 0;}\n" > _testpri.c
1038 rm -f _testpri
1039 $CC $CFLAGS $CWARNINGS _testpri.c -o _testpri 2> _testpri.result
1040 if [ z`./_testpri` = z80 ]; then
1041 printf "PRIx64=lx\n"
1042 else
1043 printf "\nFailed, neither lx nor llx worked!\n"
1044 exit
1045 fi
1046 fi
1047 fi
1048 fi
1049 rm -f _testpri.c _testpri _testpri.result
1050
1051
1052 # Check for 64-bit off_t:
1053 printf "checking for 64-bit off_t... "
1054 printf "#include <stdio.h>\n#include <inttypes.h>\n#include <sys/types.h>\n
1055 int main(int argc, char *argv[]){printf(\"%%i\\\n\",
1056 (int)sizeof(off_t));return 0;}\n" > _testoff.c
1057 $CC $CFLAGS _testoff.c -o _testoff 2> /dev/null
1058 if [ ! -x _testoff ]; then
1059 printf "\nWARNING! COULD NOT COMPILE off_t TEST PROGRAM AT ALL!\n"
1060 else
1061 if [ z`./_testoff` = z8 ]; then
1062 printf "yes\n"
1063 else
1064 $CC $CFLAGS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
1065 _testoff.c -o _testoff 2> /dev/null
1066 if [ ! -x _testoff ]; then
1067 printf "\nWARNING! COULD NOT COMPILE off_t TEST "
1068 printf "PROGRAM!\n"
1069 else
1070 if [ z`./_testoff` = z8 ]; then
1071 CFLAGS="-D_FILE_OFFSET_BITS=64 $CFLAGS"
1072 CFLAGS="-D_LARGEFILE_SOURCE $CFLAGS"
1073 printf "using -D_FILE_OFFSET_BITS=64"
1074 printf " -D_LARGEFILE_SOURCE\n"
1075 else
1076 printf "NO\n"
1077 printf "Warning! No 64-bit off_t. Continuing "
1078 printf "anyway.\n"
1079 fi
1080 fi
1081 fi
1082 fi
1083 rm -f _testoff.c _testoff
1084
1085
1086 # Check for u_int8_t etc:
1087 # These are needed because some header files in src/include/ use u_int*
1088 # instead of uint*, and I don't have time to rewrite them all.
1089 printf "checking for u_int8_t... "
1090 printf "#include <stdio.h>\n#include <inttypes.h>\n#include <sys/types.h>\n
1091 int main(int argc, char *argv[]){printf(\"%%i\\\n\",
1092 (int)sizeof(u_int8_t));return 0;}\n" > _testuint.c
1093 $CC $CFLAGS _testuint.c -o _testuint 2> /dev/null
1094 if [ ! -x _testuint ]; then
1095 rm -f _testuint*
1096 printf "#include <stdio.h>\n#include <inttypes.h>
1097 \n#include <sys/types.h>\nint main(int argc, char *argv[])
1098 {printf(\"%%i\\\n\", (int)sizeof(uint8_t));return 0;}\n" > _testuint.c
1099 $CC $CFLAGS _testuint.c -o _testuint 2> /dev/null
1100 if [ ! -x _testuint ]; then
1101 printf "no\n\nERROR: No u_int8_t or uint8_t. Aborting\n"
1102 # TODO: Automagically detect using various combinations
1103 # of char, int, short, long etc.
1104 exit
1105 fi
1106
1107 printf "typedef uint8_t u_int8_t;\n" >> config.h
1108 printf "typedef uint16_t u_int16_t;\n" >> config.h
1109 printf "typedef uint32_t u_int32_t;\n" >> config.h
1110 printf "uint8_t\n"
1111 else
1112 printf "yes\n"
1113 fi
1114 rm -f _testuint.c _testuint
1115
1116 printf "checking for u_int64_t... "
1117 printf "#include <stdio.h>\n#include <inttypes.h>\n#include <sys/types.h>\n
1118 int main(int argc, char *argv[]){printf(\"%%i\\\n\",
1119 (int)sizeof(u_int64_t));return 0;}\n" > _testuint.c
1120 $CC $CFLAGS _testuint.c -o _testuint 2> /dev/null
1121 if [ ! -x _testuint ]; then
1122 rm -f _testuint*
1123 printf "#include <stdio.h>\n#include <inttypes.h>
1124 \n#include <sys/types.h>\nint main(int argc, char *argv[])
1125 {printf(\"%%i\\\n\", (int)sizeof(uint64_t));return 0;}\n" > _testuint.c
1126 $CC $CFLAGS _testuint.c -o _testuint 2> /dev/null
1127 if [ ! -x _testuint ]; then
1128 printf "no\n\nERROR: No u_int64_t or uint64_t. Aborting\n"
1129 # TODO: Automagically detect using various combinations
1130 # of char, int, short, long etc.
1131 exit
1132 fi
1133
1134 printf "typedef uint64_t u_int64_t;\n" >> config.h
1135 printf "uint64_t\n"
1136 else
1137 printf "yes\n"
1138 fi
1139 rm -f _testuint*
1140
1141 printf "checking for __FUNCTION__... "
1142 printf "#include <stdio.h>\n\nint main(int argc, char *argv[]) {
1143 if (__FUNCTION__) printf(__FUNCTION__);\n return 0;\n}\n" > _testfunction.c
1144 $CC $CFLAGS _testfunction.c -o _testfunction 2> /dev/null
1145 if [ ! -x _testfunction ]; then
1146 printf "no\n"
1147 else
1148 if [ z`./_testfunction` = zmain ]; then
1149 printf "yes\n"
1150 printf "#define HAVE___FUNCTION__\n" >> config.h
1151 else
1152 printf "no\n"
1153 fi
1154 fi
1155 rm -f _testfunction*
1156
1157
1158 ###############################################################################
1159
1160 # Host byte order?
1161 printf "checking host endianness... "
1162 rm -f _test_end*
1163 printf '#include <stdio.h>
1164 int main(int argc, char *argv[])
1165 { int x = 1; void *xp = (void *)&x; char *p = (char *)xp;
1166 if (*p) printf("little\\\n"); else printf("big\\\n"); }
1167 ' > _test_end.c
1168 $CC $CFLAGS _test_end.c -o _test_end 2> /dev/null
1169 X=`./_test_end`
1170 echo $X
1171 if [ z$X = zlittle ]; then
1172 printf "#define HOST_LITTLE_ENDIAN\n" >> config.h
1173 else
1174 if [ z$X = zbig ]; then
1175 printf "#define HOST_BIG_ENDIAN\n" >> config.h
1176 else
1177 echo "Error! Could not determine host's endianness."
1178 exit
1179 fi
1180 fi
1181 rm -f _test_end*
1182
1183
1184 ###############################################################################
1185
1186 INCLUDE=-Iinclude/
1187 DINCLUDE=-I../include/
1188
1189 rm -f _testprog.c
1190
1191 echo C compiler flags: $CFLAGS $CWARNINGS
1192 echo Linker flags: $OTHERLIBS
1193 echo "CWARNINGS=$CWARNINGS" >> _Makefile.header
1194 echo "COPTIM=$CFLAGS" >> _Makefile.header
1195 echo "INCLUDE=$INCLUDE" >> _Makefile.header
1196 echo "DINCLUDE=$DINCLUDE" >> _Makefile.header
1197 echo "CC=$CC" >> _Makefile.header
1198 echo "OTHERLIBS=$OTHERLIBS" >> _Makefile.header
1199 echo "CPU_ARCHS=$CPU_ARCHS" >> _Makefile.header
1200 echo "CPU_TOOLS=$CPU_TOOLS" >> _Makefile.header
1201 echo "" >> _Makefile.header
1202
1203
1204 # Create the Makefiles:
1205 D=". src src/include src/console src/cpus src/debugger src/devices"
1206 D="$D src/devices/fonts src/disk src/file src/machines"
1207 D="$D src/net src/promemul src/symbol src/useremul"
1208 for a in $D; do
1209 echo "creating $a/Makefile"
1210 touch $a/Makefile
1211 cat _Makefile.header > $a/Makefile
1212 cat $a/Makefile.skel >> $a/Makefile
1213 done
1214
1215 # Tail of config.h:
1216 printf "\n#endif /* CONFIG_H */\n" >> config.h
1217
1218 # Remove temporary Makefile header:
1219 rm -f _Makefile.header
1220
1221 echo Configured. You may now run make to build gxemul.
1222

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26