1 |
#!/bin/sh |
#!/bin/sh |
2 |
############################################################################### |
############################################################################### |
3 |
# |
# |
4 |
# Copyright (C) 2003-2006 Anders Gavare. All rights reserved. |
# Copyright (C) 2003-2007 Anders Gavare. All rights reserved. |
5 |
# |
# |
6 |
# Redistribution and use in source and binary forms, with or without |
# Redistribution and use in source and binary forms, with or without |
7 |
# modification, are permitted provided that the following conditions are met: |
# modification, are permitted provided that the following conditions are met: |
27 |
# SUCH DAMAGE. |
# SUCH DAMAGE. |
28 |
# |
# |
29 |
# |
# |
30 |
# $Id: configure,v 1.228 2006/07/25 21:49:14 debug Exp $ |
# $Id: configure,v 1.254 2007/04/19 15:18:15 debug Exp $ |
31 |
# |
# |
32 |
# This is a minimal configure script, hardcoded for GXemul. This script |
# This is a minimal configure script, hardcoded for GXemul. This script |
33 |
# figures out which compiler flags will work, and creates Makefiles in |
# figures out which compiler flags will work, and creates Makefiles in |
49 |
# o) which compiler flags to use (overridden by setting CFLAGS) |
# o) which compiler flags to use (overridden by setting CFLAGS) |
50 |
# o) X11 flags and libraries (TODO: should be possible to override |
# o) X11 flags and libraries (TODO: should be possible to override |
51 |
# via command line options?) |
# via command line options?) |
52 |
|
# o) native code generation backend (i.e. detect host ABI) |
53 |
# |
# |
54 |
# |
# |
55 |
# The general philosophy regarding command line switches is that anything |
# The general philosophy regarding command line switches is that anything |
61 |
# Figure out if this is a stable version (0.x.x). |
# Figure out if this is a stable version (0.x.x). |
62 |
X=`basename \`pwd\`|cut -d \- -f 2-|cut -c1-2` |
X=`basename \`pwd\`|cut -d \- -f 2-|cut -c1-2` |
63 |
if [ z"$X" = z0. ]; then |
if [ z"$X" = z0. ]; then |
64 |
# Stable: |
# Stable. |
65 |
ENABLEALPHA=YES |
: |
|
ENABLEARM=YES |
|
|
ENABLEMIPS=YES |
|
|
ENABLEPPC=YES |
|
66 |
else |
else |
67 |
# Development: |
# Development. |
68 |
UNSTABLE=YES |
UNSTABLE=YES |
|
ENABLEALPHA=YES |
|
|
ENABLEARM=YES |
|
|
ENABLEAVR=YES |
|
|
ENABLEHPPA=YES |
|
|
ENABLEI960=YES |
|
|
ENABLEIA64=YES |
|
|
ENABLEM68K=YES |
|
|
ENABLEMIPS=YES |
|
|
ENABLEPPC=YES |
|
|
ENABLESH=YES |
|
|
ENABLESPARC=YES |
|
|
ENABLETRANSPUTER=YES |
|
|
ENABLEX86=YES |
|
|
fi |
|
|
|
|
|
if [ z"$UNSTABLE" = zYES ]; then |
|
|
printf "###\n### DEVELOPMENT (UNSTABLE)\n###\n\n" |
|
69 |
fi |
fi |
70 |
|
|
71 |
if [ z"$*" != z ]; then |
if [ z"$*" != z ]; then |
73 |
for a in $*; do |
for a in $*; do |
74 |
if [ z$a = z--disable-x ]; then |
if [ z$a = z--disable-x ]; then |
75 |
NOX11=YES |
NOX11=YES |
76 |
|
else if [ z$a = z--debug ]; then |
77 |
|
DEBUG=YES |
78 |
else if [ z$a = z--help ]; then |
else if [ z$a = z--help ]; then |
79 |
printf "usage: $0 [options]\n\n" |
printf "usage: $0 [options]\n\n" |
80 |
echo " --disable-x don't include X11 support,"\ |
echo " --disable-x don't include X11 support,"\ |
81 |
"even if the host supports it" |
"even if the host supports it" |
82 |
|
if [ z"$UNSTABLE" = zYES ]; then |
83 |
|
echo " --debug configure" \ |
84 |
|
"for a debug build" |
85 |
|
fi |
86 |
echo |
echo |
87 |
exit |
exit |
88 |
else |
else |
90 |
echo "Run $0 --help to get a list of" \ |
echo "Run $0 --help to get a list of" \ |
91 |
"available options." |
"available options." |
92 |
exit |
exit |
93 |
fi; fi |
fi; fi; fi |
94 |
done |
done |
95 |
fi |
fi |
96 |
|
|
97 |
|
|
98 |
|
# Stable releases: |
99 |
|
ENABLEARM=YES |
100 |
|
ENABLEMIPS=YES |
101 |
|
ENABLEPPC=YES |
102 |
|
ENABLESH=YES |
103 |
|
|
104 |
|
if [ z"$UNSTABLE" = zYES ]; then |
105 |
|
# Development: |
106 |
|
printf "###\n### DEVELOPMENT (UNSTABLE)\n###\n### " |
107 |
|
printf "(Enabling some archs that are not working yet.)\n###\n\n" |
108 |
|
ENABLEALPHA=YES |
109 |
|
ENABLEAVR=YES |
110 |
|
ENABLEM88K=YES |
111 |
|
ENABLESPARC=YES |
112 |
|
fi |
113 |
|
|
114 |
|
|
115 |
############################################################################### |
############################################################################### |
116 |
# |
# |
117 |
# Configure options: |
# Configure options: |
172 |
printf "#define ENABLE_AVR\n" >> config.h |
printf "#define ENABLE_AVR\n" >> config.h |
173 |
CPU_ARCHS="$CPU_ARCHS cpu_avr.o" |
CPU_ARCHS="$CPU_ARCHS cpu_avr.o" |
174 |
fi |
fi |
175 |
if [ z$ENABLEHPPA = zYES ]; then |
if [ z$ENABLEM88K = zYES ]; then |
176 |
printf "#define ENABLE_HPPA\n" >> config.h |
printf "#define ENABLE_M88K\n" >> config.h |
177 |
CPU_ARCHS="$CPU_ARCHS cpu_hppa.o" |
CPU_ARCHS="$CPU_ARCHS cpu_m88k.o" |
|
fi |
|
|
if [ z$ENABLEI960 = zYES ]; then |
|
|
printf "#define ENABLE_I960\n" >> config.h |
|
|
CPU_ARCHS="$CPU_ARCHS cpu_i960.o" |
|
|
fi |
|
|
if [ z$ENABLEIA64 = zYES ]; then |
|
|
printf "#define ENABLE_IA64\n" >> config.h |
|
|
CPU_ARCHS="$CPU_ARCHS cpu_ia64.o" |
|
|
fi |
|
|
if [ z$ENABLEM68K = zYES ]; then |
|
|
printf "#define ENABLE_M68K\n" >> config.h |
|
|
CPU_ARCHS="$CPU_ARCHS cpu_m68k.o" |
|
178 |
fi |
fi |
179 |
if [ z$ENABLEMIPS = zYES ]; then |
if [ z$ENABLEMIPS = zYES ]; then |
180 |
printf "#define ENABLE_MIPS\n" >> config.h |
printf "#define ENABLE_MIPS\n" >> config.h |
181 |
CPU_ARCHS="$CPU_ARCHS cpu_mips.o cpu_mips_coproc.o " |
CPU_ARCHS="$CPU_ARCHS cpu_mips.o cpu_mips_coproc.o " |
182 |
CPU_ARCHS="$CPU_ARCHS cpu_mips_instr_unaligned.o" |
CPU_ARCHS="$CPU_ARCHS cpu_mips_instr_unaligned.o" |
183 |
CPU_TOOLS="$CPU_TOOLS generate_mips_loadstore" |
CPU_TOOLS="$CPU_TOOLS generate_mips_loadstore" |
184 |
|
CPU_TOOLS="$CPU_TOOLS generate_mips_loadstore_multi" |
185 |
fi |
fi |
186 |
if [ z$ENABLEPPC = zYES ]; then |
if [ z$ENABLEPPC = zYES ]; then |
187 |
printf "#define ENABLE_PPC\n" >> config.h |
printf "#define ENABLE_PPC\n" >> config.h |
194 |
fi |
fi |
195 |
if [ z$ENABLESPARC = zYES ]; then |
if [ z$ENABLESPARC = zYES ]; then |
196 |
printf "#define ENABLE_SPARC\n" >> config.h |
printf "#define ENABLE_SPARC\n" >> config.h |
197 |
CPU_ARCHS="$CPU_ARCHS cpu_sparc.o" |
CPU_ARCHS="$CPU_ARCHS cpu_sparc.o memory_sparc.o" |
198 |
CPU_TOOLS="$CPU_TOOLS generate_sparc_loadstore" |
CPU_TOOLS="$CPU_TOOLS generate_sparc_loadstore" |
199 |
fi |
fi |
|
if [ z$ENABLETRANSPUTER = zYES ]; then |
|
|
printf "#define ENABLE_TRANSPUTER\n" >> config.h |
|
|
CPU_ARCHS="$CPU_ARCHS cpu_transputer.o" |
|
|
fi |
|
|
if [ z$ENABLEX86 = zYES ]; then |
|
|
printf "#define ENABLE_X86\n" >> config.h |
|
|
CPU_ARCHS="$CPU_ARCHS cpu_x86.o" |
|
|
fi |
|
|
|
|
|
|
|
|
# Cache emulation: |
|
|
if [ z$CACHES = zYES ]; then |
|
|
echo 'Enabling Cache emulation. (EXPERIMENTAL and BUGGY)' |
|
|
printf "#define ENABLE_CACHE_EMULATION\n" >> config.h |
|
|
|
|
|
printf "\nNOTE: Cache emulation enabled, but right now it triggers " |
|
|
printf "weird bugs in the\n emulator. You have been warned.\n\n" |
|
|
fi |
|
200 |
|
|
201 |
|
|
202 |
############################################################################### |
############################################################################### |
343 |
|
|
344 |
rm -f _test_x11 _test_x11.o |
rm -f _test_x11 _test_x11.o |
345 |
|
|
346 |
|
# Special case for some 64-bit Linux/x86_64 systems: |
347 |
|
if [ z$XOK = z0 ]; then |
348 |
|
$CC $CFLAGS _test_x11.c -c -o _test_x11.o \ |
349 |
|
$XINCLUDE 2> /dev/null |
350 |
|
|
351 |
|
XLIB="-L/usr/X11R6/lib64 -lX11" |
352 |
|
$CC $CFLAGS _test_x11.o -o _test_x11 $XLIB 2> /dev/null |
353 |
|
|
354 |
|
if [ -x _test_x11 ]; then |
355 |
|
XOK=1 |
356 |
|
fi |
357 |
|
fi |
358 |
|
rm -f _test_x11 _test_x11.o |
359 |
|
|
360 |
if [ z$XOK = z0 ]; then |
if [ z$XOK = z0 ]; then |
361 |
XINCLUDE="" |
XINCLUDE="" |
362 |
$CC $CFLAGS _test_x11.c -c -o _test_x11.o \ |
$CC $CFLAGS _test_x11.c -c -o _test_x11.o \ |
569 |
|
|
570 |
if [ z"$COMPAQCC" = zYES ]; then |
if [ z"$COMPAQCC" = zYES ]; then |
571 |
# -O4 is possible, but sometimes -O3 is better? |
# -O4 is possible, but sometimes -O3 is better? |
572 |
CFLAGS="-O4 $CFLAGS" |
if [ ! z"$DEBUG" = zYES ]; then |
573 |
|
CFLAGS="-O4 $CFLAGS" |
574 |
|
fi |
575 |
else |
else |
576 |
if [ z"`uname`" = zSunOS ]; then |
if [ z"`uname`" = zSunOS ]; then |
577 |
# "cc", the system's default compiler: |
# "cc", the system's default compiler: |
578 |
if [ z"$SUNCC" = zYES ]; then |
if [ ! z"$DEBUG" = zYES ]; then |
579 |
CFLAGS="-xO5 -xdepend $CFLAGS" |
if [ z"$SUNCC" = zYES ]; then |
580 |
|
CFLAGS="-xO5 -xdepend $CFLAGS" |
581 |
|
fi |
582 |
fi |
fi |
583 |
printf "#define SOLARIS\n" >> config.h |
printf "#define SOLARIS\n" >> config.h |
584 |
OTHERLIBS="-lsocket $OTHERLIBS" |
OTHERLIBS="-lsocket $OTHERLIBS" |
585 |
else |
else |
586 |
# gcc or something else: |
# gcc or something else: |
587 |
$CC $CFLAGS _testprog.c -o _testprog -O 2> /dev/null |
if [ ! z"$DEBUG" = zYES ]; then |
588 |
if [ -x _testprog ]; then |
$CC $CFLAGS _testprog.c -o _testprog -O 2> /dev/null |
|
rm -f _testprog |
|
|
$CC $CFLAGS _testprog.c -o _testprog -O3 2> /dev/null |
|
589 |
if [ -x _testprog ]; then |
if [ -x _testprog ]; then |
590 |
CFLAGS="-O3 $CFLAGS" |
rm -f _testprog |
591 |
else |
$CC $CFLAGS _testprog.c -o _testprog \ |
592 |
CFLAGS="-O $CFLAGS" |
-O3 2> /dev/null |
593 |
|
if [ -x _testprog ]; then |
594 |
|
CFLAGS="-O3 $CFLAGS" |
595 |
|
else |
596 |
|
CFLAGS="-O $CFLAGS" |
597 |
|
fi |
598 |
fi |
fi |
599 |
fi |
fi |
600 |
fi |
fi |
604 |
|
|
605 |
# -fschedule-insns causes bugs on i386 with gcc, |
# -fschedule-insns causes bugs on i386 with gcc, |
606 |
# but works OK on my alpha with ccc (compaq's cc). |
# but works OK on my alpha with ccc (compaq's cc). |
607 |
if [ z"$COMPAQCC" = zYES ]; then |
if [ ! z"$DEBUG" = zYES ]; then |
608 |
|
if [ z"$COMPAQCC" = zYES ]; then |
609 |
printf "checking whether -fschedule-insns2 can be used... " |
printf "checking whether -fschedule-insns2 can be used... " |
610 |
$CC $CFLAGS _testprog.c -o _testprog -fschedule-insns2 2> /dev/null |
$CC $CFLAGS _testprog.c -o _testprog -fschedule-insns2 2> /dev/null |
611 |
if [ -x _testprog ]; then |
if [ -x _testprog ]; then |
643 |
printf "no\n" |
printf "no\n" |
644 |
fi |
fi |
645 |
rm -f _testprog |
rm -f _testprog |
646 |
fi |
fi; fi |
647 |
|
|
648 |
|
|
649 |
# -fpeephole |
# -fpeephole |
650 |
printf "checking whether -fpeephole can be used... " |
if [ ! z"$DEBUG" = zYES ]; then |
651 |
$CC $CFLAGS -fpeephole _testprog.c -o _testprog > _testprog.stdout 2>&1 |
printf "checking whether -fpeephole can be used... " |
652 |
cat _testprog.stdout >> _testprog.error |
$CC $CFLAGS -fpeephole _testprog.c -o _testprog > _testprog.stdout 2>&1 |
653 |
if grep peephole _testprog.error > /dev/null 2>&1; then |
cat _testprog.stdout >> _testprog.error |
654 |
printf "no\n" |
if grep peephole _testprog.error > /dev/null 2>&1; then |
|
else |
|
|
if [ -x _testprog ]; then |
|
|
CFLAGS="-fpeephole $CFLAGS" |
|
|
printf "yes\n" |
|
|
else |
|
655 |
printf "no\n" |
printf "no\n" |
656 |
|
else |
657 |
|
if [ -x _testprog ]; then |
658 |
|
CFLAGS="-fpeephole $CFLAGS" |
659 |
|
printf "yes\n" |
660 |
|
else |
661 |
|
printf "no\n" |
662 |
|
fi |
663 |
fi |
fi |
664 |
|
rm -f _testprog _testprog.error _testprog.stdout |
665 |
fi |
fi |
|
rm -f _testprog _testprog.error _testprog.stdout |
|
666 |
|
|
667 |
|
|
668 |
# -fomit-frame-pointer |
# -fomit-frame-pointer |
669 |
printf "checking whether -fomit-frame-pointer can be used... " |
if [ ! z"$DEBUG" = zYES ]; then |
670 |
$CC $CFLAGS -fomit-frame-pointer _testprog.c -o \ |
printf "checking whether -fomit-frame-pointer can be used... " |
671 |
_testprog 1> _testprog.stdout 2>&1 |
$CC $CFLAGS -fomit-frame-pointer _testprog.c -o \ |
672 |
cat _testprog.stdout >> _testprog.error |
_testprog 1> _testprog.stdout 2>&1 |
673 |
if grep frame _testprog.error > /dev/null 2>&1; then |
cat _testprog.stdout >> _testprog.error |
674 |
printf "no\n" |
if grep frame _testprog.error > /dev/null 2>&1; then |
|
else |
|
|
if [ -x _testprog ]; then |
|
|
CFLAGS="-fomit-frame-pointer $CFLAGS" |
|
|
printf "yes\n" |
|
|
else |
|
675 |
printf "no\n" |
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 |
fi |
684 |
|
rm -f _testprog _testprog.error _testprog.stdout |
685 |
fi |
fi |
|
rm -f _testprog _testprog.error _testprog.stdout |
|
686 |
|
|
687 |
|
|
688 |
# -g, for development builds |
# -g, for development builds |
757 |
# -lm? |
# -lm? |
758 |
printf "checking for math libs..." |
printf "checking for math libs..." |
759 |
printf "#include <math.h>\nint main(int argc, char *argv[]) { " > _testr.c |
printf "#include <math.h>\nint main(int argc, char *argv[]) { " > _testr.c |
760 |
printf "double x = sqrt((double)argc); return (int)x; }\n" >> _testr.c |
printf "double x = sqrt(sin((double)argc)); return (int)x; }\n" >> _testr.c |
761 |
$CC $CFLAGS _testr.c -o _testr 2> /dev/null |
$CC $CFLAGS _testr.c -o _testr 2> /dev/null |
762 |
if [ ! -x _testr ]; then |
if [ ! -x _testr ]; then |
763 |
$CC $CFLAGS _testr.c -lm -o _testr 2> /dev/null |
$CC $CFLAGS _testr.c -lm -o _testr 2> /dev/null |
1064 |
fi |
fi |
1065 |
rm -f _test_end* |
rm -f _test_end* |
1066 |
|
|
1067 |
|
|
1068 |
|
############################################################################### |
1069 |
|
# |
1070 |
|
# Native code generation backend: (Detect host ABI.) |
1071 |
|
# |
1072 |
|
############################################################################### |
1073 |
|
|
1074 |
|
if [ z$UNSTABLE = zYES ]; then |
1075 |
|
printf "detecting native code generation ABI... " |
1076 |
|
|
1077 |
|
if [ z"`uname -m`" = zalpha ]; then |
1078 |
|
NATIVE_CODE_GENERATION=YES |
1079 |
|
printf "Alpha\n" |
1080 |
|
printf "#define NATIVE_CODE_GENERATION\n" >> config.h |
1081 |
|
printf "#define HOST_ARCH_ALPHA\n" >> config.h |
1082 |
|
fi |
1083 |
|
|
1084 |
|
if [ z"`uname -m`" = zamd64 ]; then |
1085 |
|
NATIVE_CODE_GENERATION=YES |
1086 |
|
printf "amd64\n" |
1087 |
|
printf "#define NATIVE_CODE_GENERATION\n" >> config.h |
1088 |
|
printf "#define HOST_ARCH_AMD64\n" >> config.h |
1089 |
|
fi |
1090 |
|
|
1091 |
|
if [ z"`uname -m`" = zx86_64 ]; then |
1092 |
|
NATIVE_CODE_GENERATION=YES |
1093 |
|
printf "amd64\n" |
1094 |
|
printf "#define NATIVE_CODE_GENERATION\n" >> config.h |
1095 |
|
printf "#define HOST_ARCH_AMD64\n" >> config.h |
1096 |
|
fi |
1097 |
|
|
1098 |
|
if [ z$NATIVE_CODE_GENERATION = z ]; then |
1099 |
|
printf "not supported yet for this host platform\n" |
1100 |
|
fi |
1101 |
|
fi |
1102 |
|
|
1103 |
|
|
1104 |
############################################################################### |
############################################################################### |
1105 |
|
|
1106 |
INCLUDE=-Iinclude/ |
INCLUDE=-Iinclude/ |
1123 |
|
|
1124 |
# Create the Makefiles: |
# Create the Makefiles: |
1125 |
D=". src src/include src/cpus src/debugger src/devices src/devices/fonts" |
D=". src src/include src/cpus src/debugger src/devices src/devices/fonts" |
1126 |
D="$D src/machines src/promemul doc" |
D="$D src/disk src/file src/machines src/native src/net src/promemul" |
1127 |
for a in $D; do |
for a in $D; do |
1128 |
echo "creating $a/Makefile" |
echo "creating $a/Makefile" |
1129 |
touch $a/Makefile |
touch $a/Makefile |