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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 18 - (hide annotations)
Mon Oct 8 16:19:11 2007 UTC (12 years, 7 months ago) by dpavlin
File size: 35678 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1004 2005/10/27 14:01:10 debug Exp $
20051011        Passing -A as the default boot arg for CATS (works fine with
                OpenBSD/cats).
20051012	Fixing the VGA cursor offset bug, and speeding up framebuffer
		redraws if character cells contain the same thing as during
		the last redraw.
20051013	Adding a slow strd ARM instruction hack.
20051017	Minor updates: Adding a dummy i80321 Verde controller (for
		XScale emulation), fixing the disassembly of the ARM "ldrd"
		instruction, adding "support" for less-than-4KB pages for ARM
		(by not adding them to translation tables).
20051020	Continuing on some HPCarm stuff. A NetBSD/hpcarm kernel prints
		some boot messages on an emulated Jornada 720.
		Making dev_ram work better with dyntrans (speeds up some things
		quite a bit).
20051021	Automatically generating some of the most common ARM load/store
		multiple instructions.
20051022	Better statistics gathering for the ARM load/store multiple.
		Various other dyntrans and device updates.
20051023	Various minor updates.
20051024	Continuing; minor device and dyntrans fine-tuning. Adding the
		first "reasonable" instruction combination hacks for ARM (the
		cores of NetBSD/cats' memset and memcpy).
20051025	Fixing a dyntrans-related bug in dev_vga. Also changing the
		dyntrans low/high access notification to only be updated on
		writes, not reads. Hopefully it will be enough. (dev_vga in
		charcell mode now seems to work correctly with both reads and
		writes.)
		Experimenting with gathering dyntrans statistics (which parts
		of emulated RAM that are actually executed), and adding
		instruction combination hacks for cache cleaning and a part of
		NetBSD's scanc() function.
20051026	Adding a bitmap for ARM emulation which indicates if a page is
		(specifically) user accessible; loads and stores with the t-
		flag set can now use the translation arrays, which results in
		a measurable speedup.
20051027	Dyntrans updates; adding an extra bitmap array for 32-bit
		emulation modes, speeding up the check whether a physical page
		has any code translations or not (O(n) -> O(1)). Doing a
		similar reduction of O(n) to O(1) by avoiding the scan through
		the translation entries on a translation update (32-bit mode
		only).
		Various other minor hacks.
20051029	Quick release, without any testing at all.

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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26