/[gxemul]/upstream/0.4.3/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 /upstream/0.4.3/configure

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26