root / configure @ 7d13299d
History | View | Annotate | Download (5.6 kB)
1 |
#!/bin/sh |
---|---|
2 |
# |
3 |
# gemu configure script (c) 2003 Fabrice Bellard |
4 |
# |
5 |
# set temporary file name |
6 |
if test ! -z "$TMPDIR" ; then |
7 |
TMPDIR1="${TMPDIR}" |
8 |
elif test ! -z "$TEMPDIR" ; then |
9 |
TMPDIR1="${TEMPDIR}" |
10 |
else |
11 |
TMPDIR1="/tmp" |
12 |
fi |
13 |
|
14 |
TMPC="${TMPDIR1}/qemacs-conf-${RANDOM}-$$-${RANDOM}.c" |
15 |
TMPO="${TMPDIR1}/qemacs-conf-${RANDOM}-$$-${RANDOM}.o" |
16 |
TMPS="${TMPDIR1}/qemacs-conf-${RANDOM}-$$-${RANDOM}.S" |
17 |
TMPH="${TMPDIR1}/qemacs-conf-${RANDOM}-$$-${RANDOM}.h" |
18 |
|
19 |
# default parameters |
20 |
prefix="/usr/local" |
21 |
cross_prefix="" |
22 |
cc="gcc" |
23 |
host_cc="gcc" |
24 |
ar="ar" |
25 |
make="make" |
26 |
strip="strip" |
27 |
cpu=`uname -m` |
28 |
case "$cpu" in |
29 |
i386|i486|i586|i686|i86pc|BePC) |
30 |
cpu="x86" |
31 |
;; |
32 |
armv4l) |
33 |
cpu="armv4l" |
34 |
;; |
35 |
alpha) |
36 |
cpu="alpha" |
37 |
;; |
38 |
"Power Macintosh"|ppc) |
39 |
cpu="powerpc" |
40 |
;; |
41 |
mips) |
42 |
cpu="mips" |
43 |
;; |
44 |
*) |
45 |
cpu="unknown" |
46 |
;; |
47 |
esac |
48 |
gprof="no" |
49 |
bigendian="no" |
50 |
|
51 |
# OS specific |
52 |
targetos=`uname -s` |
53 |
case $targetos in |
54 |
BeOS) |
55 |
prefix="/boot/home/config" |
56 |
# helps building libavcodec |
57 |
CFLAGS="-O2 -DPIC" |
58 |
# no need for libm, but the inet stuff |
59 |
# Check for BONE |
60 |
if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then |
61 |
extralibs="-lbind -lsocket" |
62 |
else |
63 |
echo "Not sure building for net_server will succeed... good luck." |
64 |
extralibs="-lsocket" |
65 |
fi ;; |
66 |
BSD/OS) |
67 |
extralibs="-lpoll -lgnugetopt -lm" |
68 |
make="gmake" |
69 |
;; |
70 |
*) ;; |
71 |
esac |
72 |
|
73 |
# find source path |
74 |
# XXX: we assume an absolute path is given when launching configure, |
75 |
# except in './configure' case. |
76 |
source_path=${0%configure} |
77 |
source_path=${source_path%/} |
78 |
source_path_used="yes" |
79 |
if test -z "$source_path" -o "$source_path" = "." ; then |
80 |
source_path=`pwd` |
81 |
source_path_used="no" |
82 |
fi |
83 |
|
84 |
for opt do |
85 |
case "$opt" in |
86 |
--prefix=*) prefix=`echo $opt | cut -d '=' -f 2` |
87 |
;; |
88 |
--source-path=*) source_path=`echo $opt | cut -d '=' -f 2` |
89 |
;; |
90 |
--cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2` |
91 |
;; |
92 |
--cc=*) cc=`echo $opt | cut -d '=' -f 2` |
93 |
;; |
94 |
--make=*) make=`echo $opt | cut -d '=' -f 2` |
95 |
;; |
96 |
--extra-cflags=*) CFLAGS="${opt#--extra-cflags=}" |
97 |
;; |
98 |
--extra-ldflags=*) LDFLAGS="${opt#--extra-ldflags=}" |
99 |
;; |
100 |
--extra-libs=*) extralibs=${opt#--extra-libs=} |
101 |
;; |
102 |
--cpu=*) cpu=`echo $opt | cut -d '=' -f 2` |
103 |
;; |
104 |
--enable-gprof) gprof="yes" |
105 |
;; |
106 |
esac |
107 |
done |
108 |
|
109 |
# Checking for CFLAGS |
110 |
if test -z "$CFLAGS"; then |
111 |
CFLAGS="-O2" |
112 |
fi |
113 |
|
114 |
cc="${cross_prefix}${cc}" |
115 |
ar="${cross_prefix}${ar}" |
116 |
strip="${cross_prefix}${strip}" |
117 |
|
118 |
if test -z "$cross_prefix" ; then |
119 |
|
120 |
# --- |
121 |
# big/little endian test |
122 |
cat > $TMPC << EOF |
123 |
#include <inttypes.h> |
124 |
int main(int argc, char ** argv){ |
125 |
volatile uint32_t i=0x01234567; |
126 |
return (*((uint8_t*)(&i))) == 0x67; |
127 |
} |
128 |
EOF |
129 |
|
130 |
if $cc -o $TMPE $TMPC 2>/dev/null ; then |
131 |
$TMPE && bigendian="yes" |
132 |
else |
133 |
echo big/little test failed |
134 |
fi |
135 |
|
136 |
else |
137 |
|
138 |
# if cross compiling, cannot launch a program, so make a static guess |
139 |
if test "$cpu" = "powerpc" -o "$cpu" = "mips" ; then |
140 |
bigendian="yes" |
141 |
fi |
142 |
|
143 |
fi |
144 |
|
145 |
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then |
146 |
cat << EOF |
147 |
|
148 |
Usage: configure [options] |
149 |
Options: [defaults in brackets after descriptions] |
150 |
|
151 |
EOF |
152 |
echo "Standard options:" |
153 |
echo " --help print this message" |
154 |
echo " --prefix=PREFIX install in PREFIX [$prefix]" |
155 |
echo " for audio/video/image support" |
156 |
echo "" |
157 |
echo "Advanced options (experts only):" |
158 |
echo " --source-path=PATH path of source code [$source_path]" |
159 |
echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]" |
160 |
echo " --cc=CC use C compiler CC [$cc]" |
161 |
echo " --make=MAKE use specified make [$make]" |
162 |
echo "" |
163 |
echo "NOTE: The object files are build at the place where configure is launched" |
164 |
exit 1 |
165 |
fi |
166 |
|
167 |
echo "Install prefix $prefix" |
168 |
echo "Source path $source_path" |
169 |
echo "C compiler $cc" |
170 |
echo "make $make" |
171 |
echo "CPU $cpu" |
172 |
echo "Big Endian $bigendian" |
173 |
echo "gprof enabled $gprof" |
174 |
|
175 |
echo "Creating config.mak and config.h" |
176 |
|
177 |
echo "# Automatically generated by configure - do not modify" > config.mak |
178 |
echo "/* Automatically generated by configure - do not modify */" > $TMPH |
179 |
|
180 |
echo "prefix=$prefix" >> config.mak |
181 |
echo "#define CONFIG_GEMU_PREFIX \"$prefix\"" >> $TMPH |
182 |
echo "MAKE=$make" >> config.mak |
183 |
echo "CC=$cc" >> config.mak |
184 |
echo "HOST_CC=$host_cc" >> config.mak |
185 |
echo "AR=$ar" >> config.mak |
186 |
echo "STRIP=$strip -s -R .comment -R .note" >> config.mak |
187 |
echo "CFLAGS=$CFLAGS" >> config.mak |
188 |
echo "LDFLAGS=$LDFLAGS" >> config.mak |
189 |
if test "$cpu" = "x86" ; then |
190 |
echo "ARCH=i386" >> config.mak |
191 |
elif test "$cpu" = "armv4l" ; then |
192 |
echo "ARCH=arm" >> config.mak |
193 |
elif test "$cpu" = "powerpc" ; then |
194 |
echo "ARCH=ppc" > config.mak |
195 |
elif test "$cpu" = "mips" ; then |
196 |
echo "ARCH=mips" > config.mak |
197 |
else |
198 |
echo "Unsupported CPU" |
199 |
exit 1 |
200 |
fi |
201 |
if test "$bigendian" = "yes" ; then |
202 |
echo "WORDS_BIGENDIAN=yes" >> config.mak |
203 |
echo "#define WORDS_BIGENDIAN 1" >> $TMPH |
204 |
fi |
205 |
if test "$gprof" = "yes" ; then |
206 |
echo "TARGET_GPROF=yes" >> config.mak |
207 |
echo "#define HAVE_GPROF 1" >> $TMPH |
208 |
fi |
209 |
echo -n "VERSION=" >>config.mak |
210 |
head $source_path/VERSION >>config.mak |
211 |
echo "" >>config.mak |
212 |
echo -n "#define GEMU_VERSION \"" >> $TMPH |
213 |
head $source_path/VERSION >> $TMPH |
214 |
echo "\"" >> $TMPH |
215 |
if test "$network" = "yes" ; then |
216 |
echo "#define CONFIG_NETWORK 1" >> $TMPH |
217 |
echo "CONFIG_NETWORK=yes" >> config.mak |
218 |
fi |
219 |
|
220 |
# build tree in object directory if source path is different from current one |
221 |
if test "$source_path_used" = "yes" ; then |
222 |
DIRS="tests" |
223 |
FILES="Makefile tests/Makefile" |
224 |
for dir in $DIRS ; do |
225 |
mkdir -p $dir |
226 |
done |
227 |
for f in $FILES ; do |
228 |
ln -sf $source_path/$f $f |
229 |
done |
230 |
fi |
231 |
echo "SRC_PATH=$source_path" >> config.mak |
232 |
|
233 |
diff $TMPH config.h >/dev/null 2>&1 |
234 |
if test $? -ne 0 ; then |
235 |
mv -f $TMPH config.h |
236 |
else |
237 |
echo "config.h is unchanged" |
238 |
fi |
239 |
|
240 |
rm -f $TMPH |