/[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 40 - (hide annotations)
Mon Oct 8 16:22:11 2007 UTC (12 years, 7 months ago) by dpavlin
File size: 30998 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1539 2007/05/01 04:03:51 debug Exp $
20070415	Landisk PCLOCK should be 33.33 MHz, not 50 MHz. (This makes
		the clock run at correct speed.)
		FINALLY found and fixed the bug which caused OpenBSD/landisk
		to randomly bug out: an &-sign was missing in the special case
		handling of FPSCR in the 'LDS.L @Rm+,FPSCR' instruction.
		Adding similar special case handling for 'LDC.L @Rm+,SR'
		(calling sh_update_sr() instead of just loading).
		Implementing the 'FCNVSD FPUL,DRn' and 'FCNVDS DRm,FPUL'
		SuperH instructions.
		The 'LDC Rm,SR' instruction now immediately breaks out of the
		dyntrans loop if an interrupt is to be triggered.
20070416	In memory_rw.c, if mapping a page as writable, make sure to
		invalidate code translations even if the data access was a
		read.
		Minor SuperH updates.
20070418	Removing the dummy M68K emulation mode.
		Minor SH update (turning unnecessary sts_mach_rn, sts_macl_rn,
		and sts_pr_rn instruction handlers into mov_rm_rn).
20070419	Beginning to add a skeleton for an M88K mode: Adding a hack to
		allow OpenBSD/m88k a.out binaries to be loaded, and disassembly
		of a few simple 88K instructions.
		Commenting out the 'LDC Rm,SR' fix from a few days ago, because
		it made Linux/dreamcast bug out.
		Adding a hack to dev_sh4.c (an extra translation cache
		invalidation), which allows OpenBSD/landisk to boot ok after
		an install. Upgrading the Landisk machine mode to stable,
		updating documentation, etc.
20070420	Experimenting with adding a PCI controller (pcic) to dev_sh4.
		Adding a dummy Realtek 8139C+ skeleton device (dev_rtl8139c).
		Implementing the first M88K instructions (br, or[.u] imm), and
		adding disassembly of some more instructions.
20070421	Continuing a little on dev_rtl8139c.
20070422	Implementing the 9346 EEPROM "read" command for dev_rtl8139c.
		Finally found and fixed an old bug in the log n symbol search
		(it sometimes missed symbols). Debug trace (-i, -t etc) should
		now show more symbols. :-)
20070423	Continuing a little on M88K disassembly.
20070428	Fixing a memset arg order bug in src/net/net.c (thanks to
		Nigel Horne for noticing the bug).
		Applying parts of a patch from Carl van Schaik to clear out
		bottom bits of MIPS addresses more correctly, when using large
		page sizes, and doing some other minor cleanup/refactoring.
		Fixing a couple of warnings given by gcc with the -W option (a
		few more warnings than just plain -Wall).
		Reducing SuperH dyntrans physical address space from 64-bit to
		32-bit (since SH5/SH64 isn't imlemented yet anyway).
		Adding address-to-symbol annotation to a few more instructions
		in the SuperH instruction trace output.
		Beginning regression testing for the next release.
		Reverting the value of SCIF_DELAYED_TX_VALUE from 1 to 2,
		because OpenBSD/landisk may otherwise hang randomly.
20070429	The ugly hack/workaround to get OpenBSD/landisk booting without
		crashing does NOT work anymore (with the April 21 snapshot
		of OpenBSD/landisk). Strangely enough, removing the hack
		completely causes OpenBSD/landisk to work (!).
		More regression testing (re-testing everything SuperH-related,
		and some other things).
		Cobalt interrupts were actually broken; fixing by commenting
		out the DEC21143s in the Cobalt machine.
20070430	More regression testing.
20070501	Updating the OpenBSD/landisk install instructions to use
		4.1 instead of the current snapshot.
		GAAAH! OpenBSD/landisk 4.1 _needs_ the ugly hack/workaround;
		reintroducing it again. (The 4.1 kernel is actually from
		2007-03-11.)
		Simplifying the NetBSD/evbarm install instructions a bit.
		More regression testing.

==============  RELEASE 0.4.5.1  ==============


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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26