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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26