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

Annotation of /upstream/0.4.1/configure

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26