/[gxemul]/upstream/0.3.1/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.3.1/configure

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26