Statistics
| Branch: | Revision:

root / configure @ b6d78bfa

History | View | Annotate | Download (7.8 kB)

1
#!/bin/sh
2
#
3
# qemu 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}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
15
TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
16
TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}"
17
TMPS="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.S"
18
TMPH="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.h"
19

    
20
# default parameters
21
prefix="/usr/local"
22
interp_prefix="/usr/gnemul/qemu-i386"
23
static="no"
24
cross_prefix=""
25
cc="gcc"
26
host_cc="gcc"
27
ar="ar"
28
make="make"
29
strip="strip"
30
target_cpu="x86"
31
target_bigendian="default"
32
cpu=`uname -m`
33
case "$cpu" in
34
  i386|i486|i586|i686|i86pc|BePC)
35
    cpu="x86"
36
  ;;
37
  armv4l)
38
    cpu="armv4l"
39
  ;;
40
  alpha)
41
    cpu="alpha"
42
  ;;
43
  "Power Macintosh"|ppc|ppc64)
44
    cpu="powerpc"
45
  ;;
46
  mips)
47
    cpu="mips"
48
  ;;
49
  s390)
50
    cpu="s390"
51
  ;;
52
  sparc)
53
    cpu="sparc"
54
  ;;
55
  sparc64)
56
    cpu="sparc64"
57
  ;;
58
  ia64)
59
    cpu="ia64"
60
  ;;
61
  *)
62
    cpu="unknown"
63
  ;;
64
esac
65
gprof="no"
66
bigendian="no"
67

    
68
# OS specific
69
targetos=`uname -s`
70
case $targetos in
71
*) ;;
72
esac
73

    
74
# find source path
75
# XXX: we assume an absolute path is given when launching configure, 
76
# except in './configure' case.
77
source_path=${0%configure}
78
source_path=${source_path%/}
79
source_path_used="yes"
80
if test -z "$source_path" -o "$source_path" = "." ; then
81
    source_path=`pwd`
82
    source_path_used="no"
83
fi
84

    
85
for opt do
86
  case "$opt" in
87
  --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
88
  ;;
89
  --interp-prefix=*) interp_prefix=`echo $opt | cut -d '=' -f 2`
90
  ;;
91
  --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
92
  ;;
93
  --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
94
  ;;
95
  --cc=*) cc=`echo $opt | cut -d '=' -f 2`
96
  ;;
97
  --make=*) make=`echo $opt | cut -d '=' -f 2`
98
  ;;
99
  --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
100
  ;;
101
  --extra-ldflags=*) LDFLAGS="${opt#--extra-ldflags=}"
102
  ;;
103
  --extra-libs=*) extralibs=${opt#--extra-libs=}
104
  ;;
105
  --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
106
  ;;
107
  --target-cpu=*) target_cpu=`echo $opt | cut -d '=' -f 2`
108
  ;;
109
  --target-big-endian) target_bigendian="yes"
110
  ;;
111
  --target-little-endian) target_bigendian="no"
112
  ;;
113
  --enable-gprof) gprof="yes"
114
  ;;
115
  --static) static="yes"
116
  ;;
117
  esac
118
done
119

    
120
# Checking for CFLAGS
121
if test -z "$CFLAGS"; then
122
    CFLAGS="-O2"
123
fi
124

    
125
cc="${cross_prefix}${cc}"
126
ar="${cross_prefix}${ar}"
127
strip="${cross_prefix}${strip}"
128

    
129
if test -z "$cross_prefix" ; then
130

    
131
# ---
132
# big/little endian test
133
cat > $TMPC << EOF
134
#include <inttypes.h>
135
int main(int argc, char ** argv){
136
	volatile uint32_t i=0x01234567;
137
	return (*((uint8_t*)(&i))) == 0x67;
138
}
139
EOF
140

    
141
if $cc -o $TMPE $TMPC 2>/dev/null ; then
142
$TMPE && bigendian="yes"
143
else
144
echo big/little test failed
145
fi
146

    
147
else
148

    
149
# if cross compiling, cannot launch a program, so make a static guess
150
if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" -o "$cpu" = "sparc" -o "$cpu" = "sparc64"; then
151
    bigendian="yes"
152
fi
153

    
154
fi
155

    
156
# check gcc options support
157
cat > $TMPC <<EOF
158
int main(void) {
159
}
160
EOF
161

    
162
have_gcc3_options="no"
163
if $cc -fno-reorder-blocks -fno-optimize-sibling-calls -o $TMPO $TMPC 2> /dev/null ; then
164
   have_gcc3_options="yes"
165
fi
166

    
167
if test "$target_bigendian" = "default" ; then
168
    if test "$target_cpu" = "x86" ; then
169
         target_bigendian="no"
170
    elif test "$target_cpu" = "arm" ; then
171
         target_bigendian="no"
172
    else
173
         target_bigendian="no"
174
    fi
175
fi
176

    
177
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
178
cat << EOF
179

    
180
Usage: configure [options]
181
Options: [defaults in brackets after descriptions]
182

    
183
EOF
184
echo "Standard options:"
185
echo "  --help                   print this message"
186
echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
187
echo "  --interp-prefix=PREFIX   where to find shared libraries, etc. [$interp_prefix]"
188
echo "  --target_cpu=CPU         set target cpu (x86 or arm) [$target_cpu]"
189
echo ""
190
echo "Advanced options (experts only):"
191
echo "  --source-path=PATH       path of source code [$source_path]"
192
echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
193
echo "  --cc=CC                  use C compiler CC [$cc]"
194
echo "  --make=MAKE              use specified make [$make]"
195
echo "  --static                 enable static build [$static]"
196
echo ""
197
echo "NOTE: The object files are build at the place where configure is launched"
198
exit 1
199
fi
200

    
201
echo "Install prefix    $prefix"
202
echo "Source path       $source_path"
203
echo "ELF interp prefix $interp_prefix"
204
echo "C compiler        $cc"
205
echo "make              $make"
206
echo "host CPU          $cpu"
207
echo "host big endian   $bigendian"
208
echo "target CPU        $target_cpu"
209
echo "target big endian $target_bigendian"
210
echo "gprof enabled     $gprof"
211
echo "static build      $static"
212

    
213
echo "Creating config.mak and config.h"
214

    
215
echo "# Automatically generated by configure - do not modify" > config.mak
216
echo "/* Automatically generated by configure - do not modify */" > $TMPH
217

    
218
echo "prefix=$prefix" >> config.mak
219
echo "#define CONFIG_QEMU_PREFIX \"$interp_prefix\"" >> $TMPH
220
echo "MAKE=$make" >> config.mak
221
echo "CC=$cc" >> config.mak
222
if test "$have_gcc3_options" = "yes" ; then
223
  echo "HAVE_GCC3_OPTIONS=yes" >> config.mak
224
fi
225
echo "HOST_CC=$host_cc" >> config.mak
226
echo "AR=$ar" >> config.mak
227
echo "STRIP=$strip -s -R .comment -R .note" >> config.mak
228
echo "CFLAGS=$CFLAGS" >> config.mak
229
echo "LDFLAGS=$LDFLAGS" >> config.mak
230
if test "$cpu" = "x86" ; then
231
  echo "ARCH=i386" >> config.mak
232
  echo "#define HOST_I386 1" >> $TMPH
233
elif test "$cpu" = "armv4l" ; then
234
  echo "ARCH=arm" >> config.mak
235
  echo "#define HOST_ARM 1" >> $TMPH
236
elif test "$cpu" = "powerpc" ; then
237
  echo "ARCH=ppc" >> config.mak
238
  echo "#define HOST_PPC 1" >> $TMPH
239
elif test "$cpu" = "mips" ; then
240
  echo "ARCH=mips" >> config.mak
241
  echo "#define HOST_MIPS 1" >> $TMPH
242
elif test "$cpu" = "s390" ; then
243
  echo "ARCH=s390" >> config.mak
244
  echo "#define HOST_S390 1" >> $TMPH
245
elif test "$cpu" = "alpha" ; then
246
  echo "ARCH=alpha" >> config.mak
247
  echo "#define HOST_ALPHA 1" >> $TMPH
248
elif test "$cpu" = "sparc" ; then
249
  echo "ARCH=sparc" >> config.mak
250
  echo "#define HOST_SPARC 1" >> $TMPH
251
elif test "$cpu" = "sparc64" ; then
252
  echo "ARCH=sparc64" >> config.mak
253
  echo "#define HOST_SPARC64 1" >> $TMPH
254
elif test "$cpu" = "ia64" ; then
255
  echo "ARCH=ia64" >> config.mak
256
  echo "#define HOST_IA64 1" >> $TMPH
257
else
258
  echo "Unsupported CPU"
259
  exit 1
260
fi
261
if test "$bigendian" = "yes" ; then
262
  echo "WORDS_BIGENDIAN=yes" >> config.mak
263
  echo "#define WORDS_BIGENDIAN 1" >> $TMPH
264
fi
265

    
266
if test "$target_cpu" = "x86" ; then
267
  echo "TARGET_ARCH=i386" >> config.mak
268
  echo "#define TARGET_ARCH \"i386\"" >> $TMPH
269
  echo "#define TARGET_I386 1" >> $TMPH
270
elif test "$target_cpu" = "arm" ; then
271
  echo "TARGET_ARCH=arm" >> config.mak
272
  echo "#define TARGET_ARCH \"arm\"" >> $TMPH
273
  echo "#define TARGET_ARM 1" >> $TMPH
274
else
275
  echo "Unsupported target CPU"
276
  exit 1
277
fi
278
if test "$target_bigendian" = "yes" ; then
279
  echo "TARGET_WORDS_BIGENDIAN=yes" >> config.mak
280
  echo "#define TARGET_WORDS_BIGENDIAN 1" >> $TMPH
281
fi
282

    
283
if test "$gprof" = "yes" ; then
284
  echo "TARGET_GPROF=yes" >> config.mak
285
  echo "#define HAVE_GPROF 1" >> $TMPH
286
fi
287
if test "$static" = "yes" ; then
288
  echo "CONFIG_STATIC=yes" >> config.mak
289
fi
290
echo -n "VERSION=" >>config.mak
291
head $source_path/VERSION >>config.mak
292
echo "" >>config.mak
293
echo -n "#define QEMU_VERSION \"" >> $TMPH
294
head $source_path/VERSION >> $TMPH
295
echo "\"" >> $TMPH
296

    
297
# build tree in object directory if source path is different from current one
298
if test "$source_path_used" = "yes" ; then
299
    DIRS="tests"
300
    FILES="Makefile tests/Makefile"
301
    for dir in $DIRS ; do
302
            mkdir -p $dir
303
    done
304
    for f in $FILES ; do
305
        ln -sf $source_path/$f $f
306
    done
307
fi
308
echo "SRC_PATH=$source_path" >> config.mak
309

    
310
diff $TMPH config.h >/dev/null 2>&1
311
if test $? -ne 0 ; then
312
	mv -f $TMPH config.h
313
else
314
	echo "config.h is unchanged"
315
fi
316

    
317
rm -f $TMPO $TMPC $TMPE $TMPS $TMPH