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

Annotation of /upstream/0.3.2/configure

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26