/[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 24 - (hide annotations)
Mon Oct 8 16:19:56 2007 UTC (12 years, 9 months ago) by dpavlin
File size: 29719 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1256 2006/06/23 20:43:44 debug Exp $
20060219	Various minor updates. Removing the old MIPS16 skeleton code,
		because it will need to be rewritten for dyntrans anyway.
20060220-22	Removing the non-working dyntrans backend support.
		Continuing on the 64-bit dyntrans virtual memory generalization.
20060223	More work on the 64-bit vm generalization.
20060225	Beginning on MIPS dyntrans load/store instructions.
		Minor PPC updates (64-bit load/store, etc).
		Fixes for the variable-instruction-length framework, some
		minor AVR updates (a simple Hello World program works!).
		Beginning on a skeleton for automatically generating documen-
		tation (for devices etc.).
20060226	PPC updates (adding some more 64-bit instructions, etc).
		AVR updates (more instructions).
		FINALLY found and fixed the zs bug, making NetBSD/macppc
		accept the serial console.
20060301	Adding more AVR instructions.
20060304	Continuing on AVR-related stuff. Beginning on a framework for
		cycle-accurate device emulation. Adding an experimental "PAL
		TV" device (just a dummy so far).
20060305	Adding more AVR instructions.
		Adding a dummy epcom serial controller (for TS7200 emulation).
20060310	Removing the emul() command from configuration files, so only
		net() and machine() are supported.
		Minor progress on the MIPS dyntrans rewrite.
20060311	Continuing on the MIPS dyntrans rewrite (adding more
		instructions, etc).
20060315	Adding more instructions (sllv, srav, srlv, bgtz[l], blez[l],
		beql, bnel, slti[u], various loads and stores).
20060316	Removing the ALWAYS_SIGNEXTEND_32 option, since it was rarely
		used.
		Adding more MIPS dyntrans instructions, and fixing bugs.
20060318	Implementing fast loads/stores for MIPS dyntrans (big/little
		endian, 32-bit and 64-bit modes).
20060320	Making MIPS dyntrans the default configure option; use
		"--enable-oldmips" to use the old bintrans system.
		Adding MIPS dyntrans dmult[u]; minor updates.
20060322	Continuing... adding some more instructions.
		Adding a simple skeleton for demangling C++ "_ZN" symbols.
20060323	Moving src/debugger.c into a new directory (src/debugger/).
20060324	Fixing the hack used to load PPC ELFs (useful for relocated
		Linux/ppc kernels), and adding a dummy G3 machine mode.
20060325-26	Beginning to experiment with GDB remote serial protocol
		connections; adding a -G command line option for selecting
		which TCP port to listen to.
20060330	Beginning a major cleanup to replace things like "0x%016llx"
		with more correct "0x%016"PRIx64, etc.
		Continuing on the GDB remote serial protocol support.
20060331	More cleanup, and some minor GDB remote progress.
20060402	Adding a hack to the configure script, to allow compilation
		on systems that lack PRIx64 etc.
20060406	Removing the temporary FreeBSD/arm hack in dev_ns16550.c and
		replacing it with a better fix from Olivier Houchard.
20060407	A remote debugger (gdb or ddd) can now start and stop the
		emulator using the GDB remote serial protocol, and registers
		and memory can be read. MIPS only for now.
20060408	More GDB progress: single-stepping also works, and also adding
		support for ARM, PowerPC, and Alpha targets.
		Continuing on the delay-slot-across-page-boundary issue.
20060412	Minor update: beginning to add support for the SPARC target
		to the remote GDB functionality.
20060414	Various MIPS updates: adding more instructions for dyntrans
		(eret, add), and making some exceptions work. Fixing a bug
		in dmult[u].
		Implementing the first SPARC instructions (sethi, or).
20060415	Adding "magic trap" instructions so that PROM calls can be
		software emulated in MIPS dyntrans.
		Adding more MIPS dyntrans instructions (ddiv, dadd) and
		fixing another bug in dmult.
20060416	More MIPS dyntrans progress: adding [d]addi, movn, movz, dsllv,
		rfi, an ugly hack for supporting R2000/R3000 style faked caches,
		preliminary interrupt support, and various other updates and
		bugfixes.
20060417	Adding more SPARC instructions (add, sub, sll[x], sra[x],
		srl[x]), and useful SPARC header definitions.
		Adding the first (trivial) x86/AMD64 dyntrans instructions (nop,
		cli/sti, stc/clc, std/cld, simple mov, inc ax). Various other
		x86 updates related to variable instruction length stuff.
		Adding unaligned loads/stores to the MIPS dyntrans mode (but
		still using the pre-dyntrans (slow) imlementation).
20060419	Fixing a MIPS dyntrans exception-in-delay-slot bug.
		Removing the old "show opcode statistics" functionality, since
		it wasn't really useful and isn't implemented for dyntrans.
		Single-stepping (or running with instruction trace) now looks
		ok with dyntrans with delay-slot architectures.
20060420	Minor hacks (removing the -B command line option when compiled
		for non-bintrans, and some other very minor updates).
		Adding (slow) MIPS dyntrans load-linked/store-conditional.
20060422	Applying fixes for bugs discovered by Nils Weller's nwcc
		(static DEC memmap => now per machine, and adding an extern
		keyword in cpu_arm_instr.c).
		Finally found one of the MIPS dyntrans bugs that I've been
		looking for (copy/paste spelling error BIG vs LITTLE endian in
		cpu_mips_instr_loadstore.c for 16-bit fast stores).
		FINALLY found the major MIPS dyntrans bug: slti vs sltiu
		signed/unsigned code in cpu_mips_instr.c. :-)
		Adding more MIPS dyntrans instructions (lwc1, swc1, bgezal[l],
		ctc1, tlt[u], tge[u], tne, beginning on rdhwr).
		NetBSD/hpcmips can now reach userland when using dyntrans :-)
		Adding some more x86 dyntrans instructions.
		Finally removed the old Alpha-specific virtual memory code,
		and replaced it with the generic 64-bit version.
		Beginning to add disassembly support for SPECIAL3 MIPS opcodes.
20060423	Continuing on the delay-slot-across-page-boundary issue;
		adding an end_of_page2 ic slot (like I had planned before, but
		had removed for some reason).
		Adding a quick-and-dirty fallback to legacy coprocessor 1
		code (i.e. skipping dyntrans implementation for now).
		NetBSD/hpcmips and NetBSD/pmax (when running on an emulated
		R4400) can now be installed and run. :-)  (Many bugs left
		to fix, though.)
		Adding more MIPS dyntrans instructions: madd[u], msub[u].
		Cleaning up the SPECIAL2 vs R5900/TX79/C790 "MMI" opcode
		maps somewhat (disassembly and dyntrans instruction decoding).
20060424	Adding an isa_revision field to mips_cpu_types.h, and making
		sure that SPECIAL3 opcodes cause Reserved Instruction
		exceptions on MIPS32/64 revisions lower than 2.
		Adding the SPARC 'ba', 'call', 'jmpl/retl', 'and', and 'xor'
		instructions.
20060425	Removing the -m command line option ("run at most x 
		instructions") and -T ("single_step_on_bad_addr"), because
		they never worked correctly with dyntrans anyway.
		Freshening up the man page.
20060428	Adding more MIPS dyntrans instructions: bltzal[l], idle.
		Enabling MIPS dyntrans compare interrupts.
20060429	FINALLY found the weird dyntrans bug, causing NetBSD etc. to
		behave strangely: some floating point code (conditional
		coprocessor branches) could not be reused from the old
		non-dyntrans code. The "quick-and-dirty fallback" only appeared
		to work. Fixing by implementing bc1* for MIPS dyntrans.
		More MIPS instructions: [d]sub, sdc1, ldc1, dmtc1, dmfc1, cfc0.
		Freshening up MIPS floating point disassembly appearance.
20060430	Continuing on C790/R5900/TX79 disassembly; implementing 128-bit
		"por" and "pextlw".
20060504	Disabling -u (userland emulation) unless compiled as unstable
		development version.
		Beginning on freshening up the testmachine include files,
		to make it easier to reuse those files (placing them in
		src/include/testmachine/), and beginning on a set of "demos"
		or "tutorials" for the testmachine functionality.
		Minor updates to the MIPS GDB remote protocol stub.
		Refreshing doc/experiments.html and gdb_remote.html.
		Enabling Alpha emulation in the stable release configuration,
		even though no guest OSes for Alpha can run yet.
20060505	Adding a generic 'settings' object, which will contain
		references to settable variables (which will later be possible
		to access using the debugger).
20060506	Updating dev_disk and corresponding demo/documentation (and
		switching from SCSI to IDE disk types, so it actually works
		with current test machines :-).
20060510	Adding a -D_LARGEFILE_SOURCE hack for 64-bit Linux hosts,
		so that fseeko() doesn't give a warning.
		Updating the section about how dyntrans works (the "runnable
		IR") in doc/intro.html.
		Instruction updates (some x64=1 checks, some more R5900
		dyntrans stuff: better mul/mult separation from MIPS32/64,
		adding ei and di).
		Updating MIPS cpuregs.h to a newer one (from NetBSD).
		Adding more MIPS dyntrans instructions: deret, ehb.
20060514	Adding disassembly and beginning implementation of SPARC wr
		and wrpr instructions.
20060515	Adding a SUN SPARC machine mode, with dummy SS20 and Ultra1
		machines. Adding the 32-bit "rd psr" instruction.
20060517	Disassembly support for the general SPARC rd instruction.
		Partial implementation of the cmp (subcc) instruction.
		Some other minor updates (making sure that R5900 processors
		start up with the EIE bit enabled, otherwise Linux/playstation2
		receives no interrupts).
20060519	Minor MIPS updates/cleanups.
20060521	Moving the MeshCube machine into evbmips; this seems to work
		reasonably well with a snapshot of a NetBSD MeshCube kernel.
		Cleanup/fix of MIPS config0 register initialization.
20060529	Minor MIPS fixes, including a sign-extension fix to the
		unaligned load/store code, which makes NetBSD/pmax on R3000
		work better with dyntrans. (Ultrix and Linux/DECstation still
		don't work, though.)
20060530	Minor updates to the Alpha machine mode: adding an AlphaBook
		mode, an LCA bus (forwarding accesses to an ISA bus), etc.
20060531	Applying a bugfix for the MIPS dyntrans sc[d] instruction from
		Ondrej Palkovsky. (Many thanks.)
20060601	Minifix to allow ARM immediate msr instruction to not give
		an error for some valid values.
		More Alpha updates.
20060602	Some minor Alpha updates.
20060603	Adding the Alpha cmpbge instruction. NetBSD/alpha prints its
		first boot messages :-) on an emulated Alphabook 1.
20060612	Minor updates; adding a dev_ether.h include file for the
		testmachine ether device. Continuing the hunt for the dyntrans
		bug which makes Linux and Ultrix on DECstation behave
		strangely... FINALLY found it! It seems to be related to
		invalidation of the translation cache, on tlbw{r,i}. There
		also seems to be some remaining interrupt-related problems.
20060614	Correcting the implementation of ldc1/sdc1 for MIPS dyntrans
		(so that it uses 16 32-bit registers if the FR bit in the
		status register is not set).
20060616	REMOVING BINTRANS COMPLETELY!
		Removing the old MIPS interpretation mode.
		Removing the MFHILO_DELAY and instruction delay stuff, because
		they wouldn't work with dyntrans anyway.
20060617	Some documentation updates (adding "NetBSD-archive" to some
		URLs, and new Debian/DECstation installation screenshots).
		Removing the "tracenull" and "enable-caches" configure options.
		Improving MIPS dyntrans performance somewhat (only invalidate
		translations if necessary, on writes to the entryhi register,
		instead of doing it for all cop0 writes).
20060618	More cleanup after the removal of the old MIPS emulation.
		Trying to fix the MIPS dyntrans performance bugs/bottlenecks;
		only semi-successful so far (for R3000).
20060620	Minor update to allow clean compilation again on Tru64/Alpha.
20060622	MIPS cleanup and fixes (removing the pc_last stuff, which
		doesn't make sense with dyntrans anyway, and fixing a cross-
		page-delay-slot-with-exception case in end_of_page).
		Removing the old max_random_cycles_per_chunk stuff, and the
		concept of cycles vs instructions for MIPS emulation.
		FINALLY found and fixed the bug which caused NetBSD/pmax
		clocks to behave strangely (it was a load to the zero register,
		which was treated as a NOP; now it is treated as a load to a
		dummy scratch register).
20060623	Increasing the dyntrans chunk size back to
		N_SAFE_DYNTRANS_LIMIT, instead of N_SAFE_DYNTRANS_LIMIT/2.
		Preparing for a quick release, even though there are known
		bugs, and performance for non-R3000 MIPS emulation is very
		poor. :-/
		Reverting to half the dyntrans chunk size again, because
		NetBSD/cats seemed less stable with full size chunks. :(
		NetBSD/sgimips 3.0 can now run :-)  (With release 0.3.8, only
		NetBSD/sgimips 2.1 worked, not 3.0.)

==============  RELEASE 0.4.0  ==============


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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26