/[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 36 - (show annotations)
Mon Oct 8 16:21:34 2007 UTC (12 years, 7 months ago) by dpavlin
File size: 30620 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1497 2007/03/18 03:41:36 debug Exp $
20070224	Minor update to the initialization of the ns16550 in
		machine_walnut.c, to allow that machine type to boot with the
		new interrupt system (although it is still a dummy machine).
		Adding a wdc at 0x14000000 to machine_landisk.c, and fixing
		the SCIF serial interrupts of the SH4 cpu enough to get
		NetBSD/landisk booting from a disk image :-)  Adding a
		preliminary install instruction skeleton to guestoses.html.
20070306	Adding SH-IPL+G PROM emulation, and also passing the "end"
		symbol in r5 on bootup, for Landisk emulation. This is enough
		to get OpenBSD/landisk to install :)  Adding a preliminary
		install instruction skeleton to the documentation. SuperH
		emulation is still shaky, though :-/
20070307	Fixed a strangeness in memory_sh.c (read/write was never
		returned for any page). (Unknown whether this fixes any actual
		problems, though.)
20070308	dev_ram.c fix: invalidate code translations on writes to
		RAM, emulated as separate devices. Linux/dreamcast gets
		further in the boot process than before, but still bugs out
		in userland.
		Fixing bugs in the "stc.l gbr,@-rN" and "ldc.l @rN+,gbr" SuperH 
		instructions (they should NOT check the MD bit), allowing the
		Linux/dreamcast Live CD to reach userland correctly :-)
20070310	Changing the cpu name "Alpha" in src/useremul.c to "21364" to
		unbreak userland syscall emulation of FreeBSD/Alpha binaries.
20070314	Applying a patch from Michael Yaroslavtsev which fixes the
		previous Linux lib64 patch to the configure script.
20070315	Adding a (dummy) sun4v machine type, and SPARC T1 cpu type.
20070316	Creating a new directory, src/disk, and moving diskimage.c
		to it. Separating out bootblock loading stuff from emul.c into
		new files in src/disk.
		Adding some more SPARC registers.
20070318	Preparing/testing for a minirelease, 0.4.4.1.

==============  RELEASE 0.4.4.1  ==============


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.245 2007/03/16 14:13:59 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 # o) native code generation backend (i.e. detect host architecture)
53 #
54 #
55 # The general philosophy regarding command line switches is that anything
56 # which can be incorporated into the program as a runtime command line option
57 # should be, instead of requiring a recompile.
58 #
59 ###############################################################################
60
61 # Figure out if this is a stable version (0.x.x).
62 X=`basename \`pwd\`|cut -d \- -f 2-|cut -c1-2`
63 if [ z"$X" = z0. ]; then
64 # Stable:
65 ENABLEALPHA=YES
66 ENABLEARM=YES
67 ENABLEMIPS=YES
68 ENABLEPPC=YES
69 ENABLESH=YES
70 else
71 # Development:
72 UNSTABLE=YES
73 ENABLEALPHA=YES
74 ENABLEARM=YES
75 ENABLEAVR=YES
76 ENABLEM68K=YES
77 ENABLEMIPS=YES
78 ENABLEPPC=YES
79 ENABLERCA180X=YES
80 ENABLESH=YES
81 ENABLESPARC=YES
82 ENABLETRANSPUTER=YES
83 fi
84
85 if [ z"$UNSTABLE" = zYES ]; then
86 printf "###\n### DEVELOPMENT (UNSTABLE)\n###\n\n"
87 fi
88
89 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 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 exit
100 else
101 echo "Invalid option: $a"
102 echo "Run $0 --help to get a list of" \
103 "available options."
104 exit
105 fi; fi
106 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 echo '/* No VERSION defined. */' >> config.h
130 else
131 printf "#define VERSION \"$X\"\n" >> config.h
132 fi
133
134
135 if [ z"$UNSTABLE" = zYES ]; then
136 printf "#define UNSTABLE_DEVEL\n" >> config.h
137 fi
138
139
140 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 if [ z$ENABLEALPHA = zYES ]; then
147 printf "#define ENABLE_ALPHA\n" >> config.h
148 CPU_ARCHS="$CPU_ARCHS cpu_alpha.o cpu_alpha_palcode.o memory_alpha.o"
149 CPU_TOOLS="$CPU_TOOLS generate_alpha_misc"
150 fi
151 if [ z$ENABLEARM = zYES ]; then
152 printf "#define ENABLE_ARM\n" >> config.h
153 CPU_ARCHS="$CPU_ARCHS cpu_arm.o cpu_arm_coproc.o memory_arm.o "
154 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 CPU_ARCHS="$CPU_ARCHS tmp_arm_re.o tmp_arm_rf.o tmp_arm_multi.o"
163 CPU_TOOLS="$CPU_TOOLS generate_arm_dpi generate_arm_r"
164 CPU_TOOLS="$CPU_TOOLS generate_arm_loadstore generate_arm_multi"
165 fi
166 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$ENABLEM68K = zYES ]; then
171 printf "#define ENABLE_M68K\n" >> config.h
172 CPU_ARCHS="$CPU_ARCHS cpu_m68k.o"
173 fi
174 if [ z$ENABLEMIPS = zYES ]; then
175 printf "#define ENABLE_MIPS\n" >> config.h
176 CPU_ARCHS="$CPU_ARCHS cpu_mips.o cpu_mips_coproc.o "
177 CPU_ARCHS="$CPU_ARCHS cpu_mips_instr_unaligned.o"
178 CPU_TOOLS="$CPU_TOOLS generate_mips_loadstore"
179 CPU_TOOLS="$CPU_TOOLS generate_mips_loadstore_multi"
180 fi
181 if [ z$ENABLEPPC = zYES ]; then
182 printf "#define ENABLE_PPC\n" >> config.h
183 CPU_ARCHS="$CPU_ARCHS cpu_ppc.o"
184 CPU_TOOLS="$CPU_TOOLS generate_ppc_loadstore"
185 fi
186 if [ z$ENABLERCA180X = zYES ]; then
187 printf "#define ENABLE_RCA180X\n" >> config.h
188 CPU_ARCHS="$CPU_ARCHS cpu_rca180x.o"
189 fi
190 if [ z$ENABLESH = zYES ]; then
191 printf "#define ENABLE_SH\n" >> config.h
192 CPU_ARCHS="$CPU_ARCHS cpu_sh.o memory_sh.o"
193 fi
194 if [ z$ENABLESPARC = zYES ]; then
195 printf "#define ENABLE_SPARC\n" >> config.h
196 CPU_ARCHS="$CPU_ARCHS cpu_sparc.o memory_sparc.o"
197 CPU_TOOLS="$CPU_TOOLS generate_sparc_loadstore"
198 fi
199 if [ z$ENABLETRANSPUTER = zYES ]; then
200 printf "#define ENABLE_TRANSPUTER\n" >> config.h
201 CPU_ARCHS="$CPU_ARCHS cpu_transputer.o"
202 fi
203
204
205 ###############################################################################
206 #
207 # Special hacks for some host OSes:
208 #
209 ###############################################################################
210
211 if [ z"`uname|cut -c 1-6`" = zCYGWIN ]; then
212 CYGWIN=YES
213
214 if [ z"$CC" = z ]; then
215 # Assume gcc on Cygwin (Windows) systems.
216 CC=gcc
217 fi
218 fi
219
220 if [ z"`uname`" = zHP-UX ]; then
221 HPUX=YES
222
223 if [ z$CC = z ]; then
224 if [ -f /usr/local/pa64/bin/gcc ]; then
225 CC=/usr/local/pa64/bin/gcc
226 fi
227 fi
228 fi
229
230 if [ z"`uname`" = zOSF1 ]; then
231 OSF1=YES
232 fi
233
234
235 ###############################################################################
236 #
237 # Create the Makefile header:
238 #
239 ###############################################################################
240
241 rm -f _Makefile.header
242
243 printf "#
244 # DO NOT EDIT THIS FILE! It is automagically created by
245 # the configure script, based on Makefile.skel.
246 #\n\n" >> _Makefile.header
247
248
249 echo 'int main(int argc, char *argv[]) { return 0; }' > _testprog.c
250
251
252 # Try to detect which C compiler to use, if CC is not set:
253 printf "checking which C compiler to use... "
254
255 if [ z"$CC" = z ]; then
256 CC=cc
257
258 # Try gcc first:
259 printf "#!/bin/sh\ngcc _testprog.c -o _testprog >" > _test.sh
260 printf " /dev/null 2> /dev/null\n" >> _test.sh
261 chmod 755 _test.sh
262 ./_test.sh > /dev/null 2> /dev/null
263 if [ -x _testprog ]; then
264 CC=gcc
265 fi
266 rm -f _testprog
267
268 # If both gcc and cc exist, then cc might be a vendor specific
269 # compiler which produces faster code than gcc (eg on Solaris):
270 printf "#!/bin/sh\ncc _testprog.c -o _testprog >" > _test.sh
271 printf " /dev/null 2> /dev/null\n" >> _test.sh
272 chmod 755 _test.sh
273 ./_test.sh > /dev/null 2> /dev/null
274 if [ -x _testprog ]; then
275 CC=cc
276 fi
277 rm -f _testprog
278
279 # # Try ccc (FreeBSD/Alpha):
280 # printf "#!/bin/sh\nccc _testprog.c -o _testprog >" > _test.sh
281 # printf " /dev/null 2> /dev/null\n" >> _test.sh
282 # chmod 755 _test.sh
283 # ./_test.sh > /dev/null 2> /dev/null
284 # if [ -x _testprog ]; then
285 # CC="ccc"
286 # fi
287 # rm -f _testprog
288
289 rm -f _test.sh
290 fi
291
292
293 rm -f _testprog
294 printf "$CC $CFLAGS"
295
296
297 CCTYPE="generic"
298
299 if $CC $CFLAGS -V 2> /dev/null | grep ompaq 1> /dev/null 2> /dev/null; then
300 COMPAQCC=YES
301 CCTYPE="Compaq CC"
302 fi
303
304 if $CC $CFLAGS -V 2>&1 | grep Sun 1> /dev/null 2> /dev/null; then
305 SUNCC=YES
306 CCTYPE="Solaris CC"
307 fi
308
309 if $CC $CFLAGS -v 2>&1 | grep gcc 1> /dev/null 2> /dev/null; then
310 GCCCC=YES
311 CCTYPE="GNU CC"
312 fi
313
314 if [ z$CYGWIN = zYES ]; then
315 CCTYPE="$CCTYPE (Cygwin)"
316 fi
317
318 echo " ($CCTYPE)"
319
320
321 if [ z$NOX11 = z ]; then
322 printf "checking for X11 headers and libs\n"
323
324 # Try to compile a small X11 test program:
325 printf "#include <X11/Xlib.h>
326 #include <stdio.h>
327 Display *dis;
328 void f(void) {
329 dis = XOpenDisplay(NULL);
330 }
331 int main(int argc, char *argv[])
332 { return 0; }
333 " > _test_x11.c
334
335 XOK=0
336
337 XINCLUDE=-I/usr/X11R6/include
338 $CC $CFLAGS _test_x11.c -c -o _test_x11.o $XINCLUDE 2> /dev/null
339
340 XLIB="-L/usr/X11R6/lib -lX11"
341 $CC $CFLAGS _test_x11.o -o _test_x11 $XLIB 2> /dev/null
342
343 if [ -x _test_x11 ]; then
344 XOK=1
345 fi
346
347 rm -f _test_x11 _test_x11.o
348
349 # Special case for some 64-bit Linux/x86_64 systems:
350 if [ z$XOK = z0 ]; then
351 $CC $CFLAGS _test_x11.c -c -o _test_x11.o \
352 $XINCLUDE 2> /dev/null
353
354 XLIB="-L/usr/X11R6/lib64 -lX11"
355 $CC $CFLAGS _test_x11.o -o _test_x11 $XLIB 2> /dev/null
356
357 if [ -x _test_x11 ]; then
358 XOK=1
359 fi
360 fi
361 rm -f _test_x11 _test_x11.o
362
363 if [ z$XOK = z0 ]; then
364 XINCLUDE=""
365 $CC $CFLAGS _test_x11.c -c -o _test_x11.o \
366 $XINCLUDE 2> /dev/null
367
368 # -lsocket for Solaris
369 XLIB="-lX11 -lsocket"
370 $CC $CFLAGS _test_x11.o -o _test_x11 $XLIB 2> /dev/null
371
372 if [ -x _test_x11 ]; then
373 XOK=1
374 fi
375 rm -f _test_x11 _test_x11.o
376 fi
377
378 if [ z`uname` = zNetBSD ]; then
379 echo "Using NetBSD hack for X11 libs..."
380 XLIB="$XLIB -Wl,-rpath,/usr/X11R6/lib"
381 fi
382
383 if [ z`uname` = zOpenBSD ]; then
384 if [ z`uname -m` = zarc ]; then
385 echo "Using old OpenBSD/arc hack for X11 libs..."
386 XLIB="$XLIB -Wl,-rpath,/usr/X11R6/lib"
387 fi
388 fi
389
390 if [ z$XOK = z0 ]; then
391 echo "Failed to compile X11 test program." \
392 "Configuring without X11."
393 else
394 printf "X11 headers: $XINCLUDE\n"
395 printf "X11 libraries: $XLIB\n"
396 echo "XINCLUDE=$XINCLUDE" >> _Makefile.header
397 echo "XLIB=$XLIB" >> _Makefile.header
398 printf "#define WITH_X11\n" >> config.h
399 fi
400
401 rm -f _test_x11.c
402 fi
403
404
405 if [ z$HPUX = zYES ]; then
406 CFLAGS="-D_XOPEN_SOURCE_EXTENDED $CFLAGS"
407 printf "#define HPUX\n" >> config.h
408 fi
409
410
411 if [ z$OSF1 = zYES ]; then
412 CFLAGS="-D_XOPEN_SOURCE=500 -D_OSF_SOURCE -D_POSIX_PII_SOCKET $CFLAGS"
413 fi
414
415
416 # Check for 'alpha' define.
417 printf "checking for 'alpha' define... "
418 printf "#include <stdio.h>\nint main(int argc, char *argv[]){
419 #ifdef alpha
420 printf(\"1\");
421 #undef alpha
422 #ifdef alpha
423 printf(\"2\");
424 #endif
425 #endif
426 printf(\"\\\n\");return 0;}\n" > _testm.c
427 $CC $CFLAGS _testm.c -o _testm 2> /dev/null
428 if [ ! -x _testm ]; then
429 printf "\nWARNING! COULD NOT COMPILE alpha define TEST"
430 printf " PROGRAM AT ALL!\n"
431 else
432 if [ z`./_testm` = z1 ]; then
433 printf "yes, workaround applied\n"
434 echo "#undef alpha" >> config.h
435 else
436 if [ z`./_testm` = z12 ]; then
437 printf "yes, but workaround not possible\n"
438 exit
439 else
440 printf "no\n"
441 fi
442 fi
443 fi
444 rm -f _testm*
445
446
447 # Some OSes on MIPS seems to define 'mips' to 1. (eg OpenBSD/arc)
448 printf "checking for 'mips' define... "
449 printf "#include <stdio.h>\nint main(int argc, char *argv[]){
450 #ifdef mips
451 printf(\"1\");
452 #undef mips
453 #ifdef mips
454 printf(\"2\");
455 #endif
456 #endif
457 printf(\"\\\n\");return 0;}\n" > _testm.c
458 $CC $CFLAGS _testm.c -o _testm 2> /dev/null
459 if [ ! -x _testm ]; then
460 printf "\nWARNING! COULD NOT COMPILE mips define TEST"
461 printf " PROGRAM AT ALL!\n"
462 else
463 if [ z`./_testm` = z1 ]; then
464 printf "yes, workaround applied\n"
465 echo "#undef mips" >> config.h
466 else
467 if [ z`./_testm` = z12 ]; then
468 printf "yes, but workaround not possible\n"
469 exit
470 else
471 printf "no\n"
472 fi
473 fi
474 fi
475 rm -f _testm*
476
477
478 # Similar to the mips define check above, although I don't know if
479 # any OS actually defined ppc like this.
480 printf "checking for 'ppc' define... "
481 printf "#include <stdio.h>\nint main(int argc, char *argv[]){
482 #ifdef ppc
483 printf(\"1\");
484 #undef ppc
485 #ifdef ppc
486 printf(\"2\");
487 #endif
488 #endif
489 printf(\"\\\n\");return 0;}\n" > _testm.c
490 $CC $CFLAGS _testm.c -o _testm 2> /dev/null
491 if [ ! -x _testm ]; then
492 printf "\nWARNING! COULD NOT COMPILE ppc define TEST"
493 printf " PROGRAM AT ALL!\n"
494 else
495 if [ z`./_testm` = z1 ]; then
496 printf "yes, workaround applied\n"
497 echo "#undef ppc" >> config.h
498 else
499 if [ z`./_testm` = z12 ]; then
500 printf "yes, but workaround not possible\n"
501 exit
502 else
503 printf "no\n"
504 fi
505 fi
506 fi
507 rm -f _testm*
508
509
510 # Similar to the mips define check above, although I don't know if
511 # any OS actually defined sparc like this.
512 printf "checking for 'sparc' define... "
513 printf "#include <stdio.h>\nint main(int argc, char *argv[]){
514 #ifdef sparc
515 printf(\"1\");
516 #undef sparc
517 #ifdef sparc
518 printf(\"2\");
519 #endif
520 #endif
521 printf(\"\\\n\");return 0;}\n" > _testm.c
522 $CC $CFLAGS _testm.c -o _testm 2> /dev/null
523 if [ ! -x _testm ]; then
524 printf "\nWARNING! COULD NOT COMPILE sparc define TEST "
525 printf "PROGRAM AT ALL!\n"
526 else
527 if [ z`./_testm` = z1 ]; then
528 printf "yes, workaround applied\n"
529 echo "#undef sparc" >> config.h
530 else
531 if [ z`./_testm` = z12 ]; then
532 printf "yes, but workaround not possible\n"
533 exit
534 else
535 printf "no\n"
536 fi
537 fi
538 fi
539 rm -f _testm*
540
541
542 # CWARNINGS:
543 printf "checking whether -Wall can be used... "
544 $CC $CFLAGS _testprog.c -o _testprog -Wall 2> /dev/null
545 if [ -x _testprog ]; then
546 printf "yes\n"
547 CWARNINGS="-Wall $CWARNINGS"
548
549 # Compaq's compiler always seems to warn about the long long type,
550 # and unusedtop suppresses warnings about include files being
551 # included more than once.
552 if [ z"$COMPAQCC" = zYES ]; then
553 CWARNINGS="$CWARNINGS -msg_disable longlongtype,unusedtop"
554 fi
555
556 if [ z"$UNSTABLE" = zYES ]; then
557 printf "checking whether -Werror can be used... "
558 rm -f _testprog
559 $CC $CFLAGS $CWARNINGS _testprog.c -o _testprog -Werror 2> /dev/null
560 if [ -x _testprog ]; then
561 printf "yes\n"
562 CWARNINGS="$CWARNINGS -Werror"
563 else
564 printf "no\n"
565 fi
566 fi
567 else
568 printf "no\n"
569 fi
570 rm -f _testprog
571
572
573 if [ z"$COMPAQCC" = zYES ]; then
574 # -O4 is possible, but sometimes -O3 is better?
575 CFLAGS="-O4 $CFLAGS"
576 else
577 if [ z"`uname`" = zSunOS ]; then
578 # "cc", the system's default compiler:
579 if [ z"$SUNCC" = zYES ]; then
580 CFLAGS="-xO5 -xdepend $CFLAGS"
581 fi
582 printf "#define SOLARIS\n" >> config.h
583 OTHERLIBS="-lsocket $OTHERLIBS"
584 else
585 # gcc or something else:
586 $CC $CFLAGS _testprog.c -o _testprog -O 2> /dev/null
587 if [ -x _testprog ]; then
588 rm -f _testprog
589 $CC $CFLAGS _testprog.c -o _testprog -O3 2> /dev/null
590 if [ -x _testprog ]; then
591 CFLAGS="-O3 $CFLAGS"
592 else
593 CFLAGS="-O $CFLAGS"
594 fi
595 fi
596 fi
597 fi
598 rm -f _testprog
599
600
601 # -fschedule-insns causes bugs on i386 with gcc,
602 # but works OK on my alpha with ccc (compaq's cc).
603 if [ z"$COMPAQCC" = zYES ]; then
604 printf "checking whether -fschedule-insns2 can be used... "
605 $CC $CFLAGS _testprog.c -o _testprog -fschedule-insns2 2> /dev/null
606 if [ -x _testprog ]; then
607 CFLAGS="-fschedule-insns2 $CFLAGS"
608 printf "yes\n"
609 else
610 printf "no\n"
611 fi
612 rm -f _testprog
613
614 printf "checking whether -fschedule-insns can be used... "
615 $CC $CFLAGS _testprog.c -o _testprog -fschedule-insns 2> /dev/null
616 if [ -x _testprog ]; then
617 CFLAGS="-fschedule-insns $CFLAGS"
618 printf "yes\n"
619 else
620 printf "no\n"
621 fi
622 rm -f _testprog
623
624 # # -intrinsics
625 # $CC $CFLAGS _testprog.c -o _testprog -intrinsics 2> /dev/null
626 # if [ -x _testprog ]; then
627 # CFLAGS="-intrinsics $CFLAGS"
628 # fi
629 # rm -f _testprog
630
631 # -fast
632 printf "checking whether -fast can be used... "
633 $CC $CFLAGS _testprog.c -o _testprog -fast 2> /dev/null
634 if [ -x _testprog ]; then
635 CFLAGS="-fast $CFLAGS"
636 printf "yes\n"
637 else
638 printf "no\n"
639 fi
640 rm -f _testprog
641 fi
642
643
644 # -fpeephole
645 printf "checking whether -fpeephole can be used... "
646 $CC $CFLAGS -fpeephole _testprog.c -o _testprog > _testprog.stdout 2>&1
647 cat _testprog.stdout >> _testprog.error
648 if grep peephole _testprog.error > /dev/null 2>&1; then
649 printf "no\n"
650 else
651 if [ -x _testprog ]; then
652 CFLAGS="-fpeephole $CFLAGS"
653 printf "yes\n"
654 else
655 printf "no\n"
656 fi
657 fi
658 rm -f _testprog _testprog.error _testprog.stdout
659
660
661 # -fomit-frame-pointer
662 printf "checking whether -fomit-frame-pointer can be used... "
663 $CC $CFLAGS -fomit-frame-pointer _testprog.c -o \
664 _testprog 1> _testprog.stdout 2>&1
665 cat _testprog.stdout >> _testprog.error
666 if grep frame _testprog.error > /dev/null 2>&1; then
667 printf "no\n"
668 else
669 if [ -x _testprog ]; then
670 CFLAGS="-fomit-frame-pointer $CFLAGS"
671 printf "yes\n"
672 else
673 printf "no\n"
674 fi
675 fi
676 rm -f _testprog _testprog.error _testprog.stdout
677
678
679 # -g, for development builds
680 if [ z"$UNSTABLE" = zYES ]; then
681 printf "checking whether -g can be used... "
682 if [ z"$COMPAQCC" = zYES ]; then
683 printf "skipping\n"
684 else
685 $CC $CFLAGS -g _testprog.c -o _testprog > _testprog.stdout 2>&1
686 cat _testprog.stdout >> _testprog.error
687 if [ -x _testprog ]; then
688 CFLAGS="-g $CFLAGS"
689 printf "yes\n"
690 else
691 printf "no\n"
692 fi
693 fi
694 rm -f _testprog _testprog.error _testprog.stdout
695 fi
696
697
698 # -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 # 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 # 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 printf "found\n"
806 fi
807 rm -f _tests.[co] _tests
808
809
810 # 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 # 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 $CC $CFLAGS $CWARNINGS _tests.c -o _tests 2> /dev/null
833 if [ ! -x _tests ]; then
834 # 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 else
847 printf "found\n"
848 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 printf "socklen_t\n"
866 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 # 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 # 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 # 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 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 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
1025 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 ###############################################################################
1034
1035 # 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 #
1061 # Native code generation backend: (Detect host architecture.)
1062 #
1063 ###############################################################################
1064
1065 if [ z$UNSTABLE = zYES ]; then
1066 printf "native code generation backend... "
1067
1068 if [ z"`uname -m`" = zamd64 ]; then
1069 NATIVE_CODE_GENERATION=YES
1070 printf "amd64\n"
1071 printf "#define NATIVE_CODE_GENERATION\n" >> config.h
1072 printf "#define HOST_ARCH_AMD64\n" >> config.h
1073 fi
1074
1075 if [ z"`uname -m`" = zx86_64 ]; then
1076 NATIVE_CODE_GENERATION=YES
1077 printf "amd64\n"
1078 printf "#define NATIVE_CODE_GENERATION\n" >> config.h
1079 printf "#define HOST_ARCH_AMD64\n" >> config.h
1080 fi
1081
1082 if [ z$NATIVE_CODE_GENERATION = z ]; then
1083 printf "not yet for this host platform\n"
1084 fi
1085 fi
1086
1087
1088 ###############################################################################
1089
1090 INCLUDE=-Iinclude/
1091 DINCLUDE=-I../include/
1092
1093 rm -f _testprog.c
1094
1095 echo C compiler flags: $CFLAGS $CWARNINGS
1096 echo Linker flags: $OTHERLIBS
1097 echo "CWARNINGS=$CWARNINGS" >> _Makefile.header
1098 echo "COPTIM=$CFLAGS" >> _Makefile.header
1099 echo "INCLUDE=$INCLUDE" >> _Makefile.header
1100 echo "DINCLUDE=$DINCLUDE" >> _Makefile.header
1101 echo "CC=$CC" >> _Makefile.header
1102 echo "OTHERLIBS=$OTHERLIBS" >> _Makefile.header
1103 echo "CPU_ARCHS=$CPU_ARCHS" >> _Makefile.header
1104 echo "CPU_TOOLS=$CPU_TOOLS" >> _Makefile.header
1105 echo "" >> _Makefile.header
1106
1107
1108 # Create the Makefiles:
1109 D=". src src/include src/cpus src/debugger src/devices src/devices/fonts"
1110 D="$D src/disk src/machines src/native src/net src/promemul"
1111 for a in $D; do
1112 echo "creating $a/Makefile"
1113 touch $a/Makefile
1114 cat _Makefile.header > $a/Makefile
1115 cat $a/Makefile.skel >> $a/Makefile
1116 done
1117
1118 # Tail of config.h:
1119 printf "\n#endif /* CONFIG_H */\n" >> config.h
1120
1121 # Remove temporary Makefile header:
1122 rm -f _Makefile.header
1123
1124 echo Configured. You may now run make to build gxemul.

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26