/[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

Contents of /trunk/configure

Parent Directory Parent Directory | Revision Log Revision Log


Revision 42 - (show annotations)
Mon Oct 8 16:22:32 2007 UTC (12 years, 7 months ago) by dpavlin
File size: 33098 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1613 2007/06/15 20:11:26 debug Exp $
20070501	Continuing a little on m88k disassembly (control registers,
		more instructions).
		Adding a dummy mvme88k machine mode.
20070502	Re-adding MIPS load/store alignment exceptions.
20070503	Implementing more of the M88K disassembly code.
20070504	Adding disassembly of some more M88K load/store instructions.
		Implementing some relatively simple M88K instructions (br.n,
		xor[.u] imm, and[.u] imm).
20070505	Implementing M88K three-register and, or, xor, and jmp[.n],
		bsr[.n] including function call trace stuff.
		Applying a patch from Bruce M. Simpson which implements the
		SYSCON_BOARD_CPU_CLOCK_FREQ_ID object of the syscon call in
		the yamon PROM emulation.
20070506	Implementing M88K bb0[.n] and bb1[.n], and skeletons for
		ldcr and stcr (although no control regs are implemented yet).
20070509	Found and fixed the bug which caused Linux for QEMU_MIPS to
		stop working in 0.4.5.1: It was a faulty change to the MIPS
		'sc' and 'scd' instructions I made while going through gcc -W
		warnings on 20070428.
20070510	Updating the Linux/QEMU_MIPS section in guestoses.html to
		use mips-test-0.2.tar.gz instead of 0.1.
		A big thank you to Miod Vallat for sending me M88K manuals.
		Implementing more M88K instructions (addu, subu, div[u], mulu,
		ext[u], clr, set, cmp).
20070511	Fixing bugs in the M88K "and" and "and.u" instructions (found
		by comparing against the manual).
		Implementing more M88K instructions (mask[.u], mak, bcnd (auto-
		generated)) and some more control register details.
		Cleanup: Removing the experimental AVR emulation mode and
		corresponding devices; AVR emulation wasn't really meaningful.
		Implementing autogeneration of most M88K loads/stores. The
		rectangle drawing demo (with -O0) for M88K runs :-)
		Beginning on M88K exception handling.
		More M88K instructions: tb0, tb1, rte, sub, jsr[.n].
		Adding some skeleton MVME PROM ("BUG") emulation.
20070512	Fixing a bug in the M88K cmp instruction.
		Adding the M88K lda (scaled register) instruction.
		Fixing bugs in 64-bit (32-bit pairs) M88K loads/stores.
		Removing the unused tick_hz stuff from the machine struct.
		Implementing the M88K xmem instruction. OpenBSD/mvme88k gets
		far enough to display the Copyright banner :-)
		Implementing subu.co (guess), addu.co, addu.ci, ff0, and ff1.
		Adding a dev_mvme187, for MVME187-specific devices/registers.
		OpenBSD/mvme88k prints more boot messages. :)
20070515	Continuing on MVME187 emulation (adding more devices, beginning
		on the CMMUs, etc).
		Adding the M88K and.c, xor.c, and or.c instructions, and making
		sure that mul, div, etc cause exceptions if executed when SFD1
		is disabled.
20070517	Continuing on M88K and MVME187 emulation in general; moving
		the CMMU registers to the CPU struct, separating dev_pcc2 from
		dev_mvme187, and beginning on memory_m88k.c (BATC and PATC).
		Fixing a bug in 64-bit (32-bit pairs) M88K fast stores.
		Implementing the clock part of dev_mk48txx.
		Implementing the M88K fstcr and xcr instructions.
		Implementing m88k_cpu_tlbdump().
		Beginning on the implementation of a separate address space
		for M88K .usr loads/stores.
20070520	Removing the non-working (skeleton) Sandpoint, SonyNEWS, SHARK
		Dnard, and Zaurus machine modes.
		Experimenting with dyntrans to_be_translated read-ahead. It
		seems to give a very small performance increase for MIPS
		emulation, but a large performance degradation for SuperH. Hm.
20070522	Disabling correct SuperH ITLB emulation; it does not seem to be
		necessary in order to let SH4 guest OSes run, and it slows down
		userspace code.
		Implementing "samepage" branches for SuperH emulation, and some
		other minor speed hacks.
20070525	Continuing on M88K memory-related stuff: exceptions, memory
		transaction register contents, etc.
		Implementing the M88K subu.ci instruction.
		Removing the non-working (skeleton) Iyonix machine mode.
		OpenBSD/mvme88k reaches userland :-), starts executing
		/sbin/init's instructions, and issues a few syscalls, before
		crashing.
20070526	Fixing bugs in dev_mk48txx, so that OpenBSD/mvme88k detects
		the correct time-of-day.
		Implementing a generic IRQ controller for the test machines
		(dev_irqc), similar to a proposed patch from Petr Stepan.
		Experimenting some more with translation read-ahead.
		Adding an "expect" script for automated OpenBSD/landisk
		install regression/performance tests.
20070527	Adding a dummy mmEye (SH3) machine mode skeleton.
		FINALLY found the strange M88K bug I have been hunting: I had
		not emulated the SNIP value for exceptions occurring in
		branch delay slots correctly.
		Implementing correct exceptions for 64-bit M88K loads/stores.
		Address to symbol lookups are now disabled when M88K is
		running in usermode (because usermode addresses don't have
		anything to do with supervisor addresses).
20070531	Removing the mmEye machine mode skeleton.
20070604	Some minor code cleanup.
20070605	Moving src/useremul.c into a subdir (src/useremul/), and
		cleaning up some more legacy constructs.
		Adding -Wstrict-aliasing and -fstrict-aliasing detection to
		the configure script.
20070606	Adding a check for broken GCC on Solaris to the configure
		script. (GCC 3.4.3 on Solaris cannot handle static variables
		which are initialized to 0 or NULL. :-/)
		Removing the old (non-working) ARC emulation modes: NEC RD94,
		R94, R96, and R98, and the last traces of Olivetti M700 and
		Deskstation Tyne.
		Removing the non-working skeleton WDSC device (dev_wdsc).
20070607	Thinking about how to use the host's cc + ld at runtime to
		generate native code. (See experiments/native_cc_ld_test.i
		for an example.)
20070608	Adding a program counter sampling timer, which could be useful
		for native code generation experiments.
		The KN02_CSR_NRMMOD bit in the DECstation 5000/200 (KN02) CSR
		should always be set, to allow a 5000/200 PROM to boot.
20070609	Moving out breakpoint details from the machine struct into
		a helper struct, and removing the limit on max nr of
		breakpoints.
20070610	Moving out tick functions into a helper struct as well (which
		also gets rid of the max limit).
20070612	FINALLY figured out why Debian/DECstation stopped working when
		translation read-ahead was enabled: in src/memory_rw.c, the
		call to invalidate_code_translation was made also if the
		memory access was an instruction load (if the page was mapped
		as writable); it shouldn't be called in that case.
20070613	Implementing some more MIPS32/64 revision 2 instructions: di,
		ei, ext, dext, dextm, dextu, and ins.
20070614	Implementing an instruction combination for the NetBSD/arm
		idle loop (making the host not use any cpu if NetBSD/arm
		inside the emulator is not using any cpu).
		Increasing the nr of ARM VPH entries from 128 to 384.
20070615	Removing the ENABLE_arch stuff from the configure script, so
		that all included architectures are included in both release
		and development builds.
		Moving memory related helper functions from misc.c to memory.c.
		Adding preliminary instructions for netbooting NetBSD/pmppc to
		guestoses.html; it doesn't work yet, there are weird timeouts.
		Beginning a total rewrite of the userland emulation modes
		(removing all emulation modes, beginning from scratch with
		NetBSD/MIPS and FreeBSD/Alpha only).
20070616	After fixing a bug in the DEC21143 NIC (the TDSTAT_OWN bit was
		only cleared for the last segment when transmitting, not all
		segments), NetBSD/pmppc boots with root-on-nfs without the
		timeouts. Updating guestoses.html.
		Removing the skeleton PSP (Playstation Portable) mode.
		Moving X11-related stuff in the machine struct into a helper
		struct.
		Cleanup of out-of-memory checks, to use a new CHECK_ALLOCATION
		macro (which prints a meaningful error message).
		Adding a COMMENT to each machine and device (for automagic
		.index comment generation).
		Doing regression testing for the next release.

==============  RELEASE 0.4.6  ==============


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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26