/[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 30 - (show annotations)
Mon Oct 8 16:20:40 2007 UTC (12 years, 7 months ago) by dpavlin
File size: 30009 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1325 2006/08/15 15:38:37 debug Exp $
20060723	More Transputer instructions (pfix, nfix, opr, mint, ldl, ldlp,
		eqc, rev, ajw, stl, stlf, sthf, sub, ldnl, ldnlp, ldpi, move,
		wcnt, add, bcnt).
		Adding more SPARC instructions (andcc, addcc, bl, rdpr).
		Progress on the igsfb framebuffer used by NetBSD/netwinder.
		Enabling 8-bit fills in dev_fb.
		NetBSD/netwinder 3.0.1 can now run from a disk image :-)
20060724	Cleanup/performance fix for 64-bit virtual translation table
		updates (by removing the "timestamp" stuff). A full NetBSD/pmax
		3.0.1 install for R4400 has dropped from 667 seconds to 584 :)
		Fixing the igsfb "almost vga" color (it is 24-bit, not 18-bit).
		Adding some MIPS instruction combinations (3*lw, and 3*addu).
		The 8048 keyboard now turns off interrupt enable between the
		KBR_ACK and the KBR_RSTDONE, to work better with Linux 2.6.
		Not causing PPC DEC interrupts if PPC_NO_DEC is set for a
		specific CPU; NetBSD/bebox gets slightly further than before.
		Adding some more SPARC instructions: branches, udiv.
20060725	Refreshing dev_pckbc.c a little.
		Cleanups for the SH emulation mode, and adding the first
		"compact" (16-bit) instructions: various simple movs, nop,
		shll, stc, or, ldc.
20060726	Adding dummy "pcn" (AMD PCnet NIC) PCI glue.
20060727	Various cleanups; removing stuff from cpu.h, such as
		running_translated (not really meaningful anymore), and
		page flags (breaking into the debugger clears all translations
		anyway).
		Minor MIPS instruction combination updates.
20060807	Expanding the 3*sw and 3*lw MIPS instruction combinations to
		work with 2* and 4* too, resulting in a minor performance gain.
		Implementing a usleep hack for the RM52xx/MIPS32/MIPS64 "wait"
		instruction (when emulating 1 cpu).
20060808	Experimenting with some more MIPS instruction combinations.
		Implementing support for showing a (hardcoded 12x22) text
		cursor in igsfb.
20060809	Simplifying the NetBSD/evbmips (Malta) install instructions
		somewhat (by using a NetBSD/pmax ramdisk install kernel).
20060812	Experimenting more with the MIPS 'wait' instruction.
		PCI configuration register writes can now be handled, which
		allow PCI IDE controllers to work with NetBSD/Malta 3.0.1 and
		NetBSD/cobalt 3.0.1. (Previously only NetBSD 2.1 worked.)
20060813	Updating dev_gt.c based on numbers from Alec Voropay, to enable
		Linux 2.6 to use PCI on Malta.
		Continuing on Algor interrupt stuff.
20060814	Adding support for routing ISA interrupts to two different
		interrupts, making it possible to run NetBSD/algor :-)
20060814-15	Testing for the release.

==============  RELEASE 0.4.2  ==============


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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26