3 # tcc configure script (c) 2003 Fabrice Bellard
5 # set temporary file name
6 if test ! -z "$TMPDIR" ; then
8 elif test ! -z "$TEMPDIR" ; then
14 TMPC
="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.c"
15 TMPO
="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.o"
16 TMPE
="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}"
17 TMPS
="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.S"
18 TMPH
="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.h"
37 i386|i486|i586|i686|i86pc|BePC
)
46 "Power Macintosh"|ppc|ppc64
)
81 # XXX: we assume an absolute path is given when launching configure,
82 # except in './configure' case.
83 source_path
=${0%configure}
84 source_path
=${source_path%/}
85 source_path_used
="yes"
86 if test -z "$source_path" -o "$source_path" = "." ; then
93 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
95 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
97 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
99 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
101 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
103 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
105 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
107 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
109 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
111 --make=*) make=`echo $opt | cut -d '=' -f 2`
113 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
115 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
117 --extra-libs=*) extralibs
=${opt#--extra-libs=}
119 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
121 --enable-gprof) gprof
="yes"
123 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i386-mingw32-"
125 --enable-cross) build_cross
="yes"
130 # Checking for CFLAGS
131 if test -z "$CFLAGS"; then
135 cc
="${cross_prefix}${cc}"
136 ar="${cross_prefix}${ar}"
137 strip
="${cross_prefix}${strip}"
139 if test "$mingw32" = "yes" ; then
144 if test -z "$cross_prefix" ; then
147 # big/little endian test
149 #include <inttypes.h>
150 int main(int argc, char ** argv){
151 volatile uint32_t i=0x01234567;
152 return (*((uint8_t*)(&i))) == 0x67;
156 if $cc -o $TMPE $TMPC 2>/dev
/null
; then
157 $TMPE && bigendian
="yes"
159 echo big
/little
test failed
164 # if cross compiling, cannot launch a program, so make a static guess
165 if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" ; then
174 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
183 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
196 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
200 if test x
"$1" = x
"-h" -o x
"$1" = x
"--help" ; then
203 Usage: configure [options]
204 Options: [defaults in brackets after descriptions]
207 echo "Standard options:"
208 echo " --help print this message"
209 echo " --prefix=PREFIX install in PREFIX [$prefix]"
210 echo " --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX"
211 echo " [same as prefix]"
212 echo " --bindir=DIR user executables in DIR [EPREFIX/bin]"
213 echo " --libdir=DIR object code libraries in DIR [EPREFIX/lib]"
214 echo " --includedir=DIR C header files in DIR [PREFIX/include]"
215 echo " --mandir=DIR man documentation in DIR [PREFIX/man]"
216 echo " --enable-cross build cross compilers"
218 echo "Advanced options (experts only):"
219 echo " --source-path=PATH path of source code [$source_path]"
220 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
221 echo " --cc=CC use C compiler CC [$cc]"
222 echo " --make=MAKE use specified make [$make]"
224 #echo "NOTE: The object files are build at the place where configure is launched"
228 if test "$mingw32" = "yes" ; then
229 if test -z "$prefix" ; then
230 prefix
="/c/Program Files/tcc"
237 if test -z "$prefix" ; then
240 if test x
"$execprefix" = x
""; then
241 execprefix
="${prefix}"
243 if test x
"$bindir" = x
""; then
244 bindir
="${execprefix}/bin"
246 if test x
"$docdir" = x
""; then
247 docdir
="$prefix/share/doc/tcc"
251 if test x
"$libdir" = x
""; then
252 libdir
="${execprefix}/lib"
254 if test x
"$tccdir" = x
""; then
255 tccdir
="${execprefix}/lib/tcc"
257 if test x
"$mandir" = x
""; then
258 mandir
="${prefix}/man"
260 if test x
"$includedir" = x
""; then
261 includedir
="${prefix}/include"
264 echo "Binary directory $bindir"
265 echo "TinyCC directory $tccdir"
266 echo "Library directory $libdir"
267 echo "Include directory $includedir"
268 echo "Manual directory $mandir"
269 echo "Doc directory $docdir"
270 echo "Source path $source_path"
271 echo "C compiler $cc"
274 echo "Big Endian $bigendian"
275 echo "gprof enabled $gprof"
276 echo "cross compilers $build_cross"
278 echo "Creating config.mak and config.h"
280 echo "# Automatically generated by configure - do not modify" > config.mak
281 echo "/* Automatically generated by configure - do not modify */" > $TMPH
283 echo "prefix=$prefix" >> config.mak
284 echo "bindir=$bindir" >> config.mak
285 echo "tccdir=$tccdir" >> config.mak
286 echo "libdir=$libdir" >> config.mak
287 echo "includedir=$includedir" >> config.mak
288 echo "mandir=$mandir" >> config.mak
289 echo "docdir=$docdir" >> config.mak
290 echo "#define CONFIG_TCCDIR \"$tccdir\"" >> $TMPH
291 echo "MAKE=$make" >> config.mak
292 echo "CC=$cc" >> config.mak
293 echo "GCC_MAJOR=$gcc_major" >> config.mak
294 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
295 echo "HOST_CC=$host_cc" >> config.mak
296 echo "AR=$ar" >> config.mak
297 echo "STRIP=$strip -s -R .comment -R .note" >> config.mak
298 echo "CFLAGS=$CFLAGS" >> config.mak
299 echo "LDFLAGS=$LDFLAGS" >> config.mak
300 echo "LIBSUF=$LIBSUF" >> config.mak
301 echo "EXESUF=$EXESUF" >> config.mak
302 if test "$cpu" = "x86" ; then
303 echo "ARCH=i386" >> config.mak
304 echo "#define HOST_I386 1" >> $TMPH
305 elif test "$cpu" = "armv4l" ; then
306 echo "ARCH=arm" >> config.mak
307 echo "#define HOST_ARM 1" >> $TMPH
308 elif test "$cpu" = "powerpc" ; then
309 echo "ARCH=ppc" >> config.mak
310 echo "#define HOST_PPC 1" >> $TMPH
311 elif test "$cpu" = "mips" ; then
312 echo "ARCH=mips" >> config.mak
313 echo "#define HOST_MIPS 1" >> $TMPH
314 elif test "$cpu" = "s390" ; then
315 echo "ARCH=s390" >> config.mak
316 echo "#define HOST_S390 1" >> $TMPH
317 elif test "$cpu" = "alpha" ; then
318 echo "ARCH=alpha" >> config.mak
319 echo "#define HOST_ALPHA 1" >> $TMPH
321 echo "Unsupported CPU"
324 if test "$noldl" = "yes" ; then
325 echo "CONFIG_NOLDL=yes" >> config.mak
327 if test "$mingw32" = "yes" ; then
328 echo "CONFIG_WIN32=yes" >> config.mak
329 echo "#define CONFIG_WIN32 1" >> $TMPH
331 if test "$bigendian" = "yes" ; then
332 echo "WORDS_BIGENDIAN=yes" >> config.mak
333 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
335 if test "$gprof" = "yes" ; then
336 echo "TARGET_GPROF=yes" >> config.mak
337 echo "#define HAVE_GPROF 1" >> $TMPH
339 if test "$build_cross" = "yes" ; then
340 echo "CONFIG_CROSS=yes" >> config.mak
342 version
=`head $source_path/VERSION`
343 echo "VERSION=$version" >>config.mak
344 echo "#define TCC_VERSION \"$version\"" >> $TMPH
345 echo "@set VERSION $version" > config.texi
347 # build tree in object directory if source path is different from current one
348 if test "$source_path_used" = "yes" ; then
350 FILES
="Makefile tests/Makefile"
351 for dir
in $DIRS ; do
355 ln -sf $source_path/$f $f
358 echo "SRC_PATH=$source_path" >> config.mak
360 diff $TMPH config.h
>/dev
/null
2>&1
361 if test $?
-ne 0 ; then
364 echo "config.h is unchanged"
367 rm -f $TMPO $TMPC $TMPE $TMPS $TMPH