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 # bashism: TMPN="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.c"
44 i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
50 arm|armv4l|armv5tel|armv5tejl|armv6j|armv7a|armv7l
)
56 "Power Macintosh"|ppc|ppc64
)
91 # XXX: we assume an absolute path is given when launching configure,
92 # except in './configure' case.
93 source_path
=${0%configure}
94 source_path
=${source_path%/}
95 source_path_used
="yes"
96 if test -z "$source_path" -o "$source_path" = "." ; then
103 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
105 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
107 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
109 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
111 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
113 --lddir=*) lddir
=`echo $opt | cut -d '=' -f 2`
115 --extralddir=*) extralddir
="$extralddir:`echo $opt | cut -d '=' -f 2`"
117 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
119 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
121 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
123 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
125 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
127 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
129 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
131 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
133 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
135 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
137 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
139 --extra-libs=*) extralibs
=${opt#--extra-libs=}
141 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
143 --enable-gprof) gprof
="yes"
145 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i686-pc-mingw32-" ; cpu
=x86
147 --enable-cygwin) mingw32
="yes" ; cygwin
="yes" ; cross_prefix
="mingw32-" ; cpu
=x86
149 --enable-cross) build_cross
="yes"
151 --disable-static) disable_static
="yes"
153 --disable-rpath) disable_rpath
="yes"
155 --strip-binaries) strip_binaries
="yes"
157 --with-libgcc) use_libgcc
="yes"
159 --with-selinux) have_selinux
="yes"
161 --help|
-h) show_help
="yes"
166 # Checking for CFLAGS
167 if test -z "$CFLAGS"; then
168 CFLAGS
="-Wall -g -O2"
171 cc
="${cross_prefix}${cc}"
172 ar="${cross_prefix}${ar}"
173 strip
="${cross_prefix}${strip}"
175 if test "$mingw32" = "yes" ; then
180 if test -z "$cross_prefix" ; then
183 # big/little endian test
185 #include <inttypes.h>
186 int main(int argc, char ** argv){
187 volatile uint32_t i=0x01234567;
188 return (*((uint8_t*)(&i))) == 0x67;
192 if $cc -o $TMPE $TMPC 2>/dev
/null
; then
193 $TMPE && bigendian
="yes"
195 echo big
/little
test failed
200 # if cross compiling, cannot launch a program, so make a static guess
201 if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" ; then
210 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
219 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
232 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
236 if test x
"$show_help" = "xyes" ; then
239 Usage: configure [options]
240 Options: [defaults in brackets after descriptions]
243 echo "Standard options:"
244 echo " --help print this message"
245 echo " --prefix=PREFIX install in PREFIX [$prefix]"
246 echo " --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX"
247 echo " [same as prefix]"
248 echo " --bindir=DIR user executables in DIR [EPREFIX/bin]"
249 echo " --libdir=DIR object code libraries in DIR [EPREFIX/lib]"
250 echo " --lddir=DIR loader library search path in DIR [/lib]"
251 echo " --extralddir=DIR extra loader library search path in DIR []"
252 echo " --tccdir=DIR installation directory [EPREFIX/lib/tcc]"
253 echo " --includedir=DIR C header files in DIR [PREFIX/include]"
254 echo " --sharedir=DIR documentation root DIR [PREFIX]/share"
255 echo " --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]"
256 echo " --mandir=DIR man documentation in DIR [SHAREDIR/man]"
257 echo " --infodir=DIR info documentation in DIR [SHAREDIR/info]"
259 echo "Advanced options (experts only):"
260 echo " --source-path=PATH path of source code [$source_path]"
261 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
262 echo " --sysroot=PREFIX prepend PREFIX to library/include paths []"
263 echo " --cc=CC use C compiler CC [$cc]"
264 echo " --disable-static make libtcc.so instead of libtcc.a"
265 echo " --disable-rpath disable use of -rpath with the above"
266 echo " --strip-binaries strip symbol tables from resulting binaries"
267 echo " --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc.a"
268 echo " --enable-mingw32 build windows version on linux with mingw32"
269 echo " --enable-cygwin build windows version on windows with cygwin"
270 echo " [requires cygwin and mingw32-make]"
271 echo " --enable-cross build cross compilers"
272 echo " --extra-cflags= extra compiler flags"
273 echo " --extra-ldflags= extra linker options"
274 echo " --with-selinux use mmap instead of exec mem"
275 echo " [requires write access to /tmp]"
277 #echo "NOTE: The object files are build at the place where configure is launched"
281 if test "$mingw32" = "yes" ; then
282 if test x
"$tccdir" = x
""; then
285 if test -z "$prefix" ; then
286 prefix
="C:/Program Files/${tccdir}"
288 if test -z "$sharedir" ; then
294 libdir
="${prefix}/lib"
295 docdir
="${sharedir}/doc"
296 mandir
="${sharedir}/man"
297 infodir
="${sharedir}/info"
299 if test -z "$prefix" ; then
302 if test -z "$sharedir" ; then
303 sharedir
="${prefix}/share"
305 if test x
"$execprefix" = x
""; then
306 execprefix
="${prefix}"
308 if test x
"$libdir" = x
""; then
309 libdir
="${execprefix}/lib"
311 if test x
"$bindir" = x
""; then
312 bindir
="${execprefix}/bin"
314 if test x
"$tccdir" = x
""; then
317 if test x
"$docdir" = x
""; then
318 docdir
="${sharedir}/doc/${tccdir}"
320 if test x
"$mandir" = x
""; then
321 mandir
="${sharedir}/man"
323 if test x
"$infodir" = x
""; then
324 infodir
="${sharedir}/info"
326 tccdir
="${libdir}/${tccdir}"
329 if test x
"$includedir" = x
""; then
330 includedir
="${prefix}/include"
333 echo "Binary directory $bindir"
334 echo "TinyCC directory $tccdir"
335 echo "Library directory $libdir"
336 echo "Loader library search directory ${lddir:-default value (see tcc.h)}"
337 echo "Extra loader library search directory ${extralddir:-(none)}"
338 echo "Include directory $includedir"
339 echo "Manual directory $mandir"
340 echo "Info directory $infodir"
341 echo "Doc directory $docdir"
342 echo "Target root prefix $sysroot"
343 echo "Source path $source_path"
344 echo "C compiler $cc"
346 echo "Big Endian $bigendian"
347 echo "gprof enabled $gprof"
348 echo "cross compilers $build_cross"
349 echo "use libgcc $use_libgcc"
351 echo "Creating config.mak and config.h"
353 echo "# Automatically generated by configure - do not modify" > config.mak
354 echo "/* Automatically generated by configure - do not modify */" > $TMPH
356 echo "prefix=$prefix" >> config.mak
357 echo "bindir=\$(DESTDIR)$bindir" >> config.mak
358 echo "tccdir=\$(DESTDIR)$tccdir" >> config.mak
359 echo "libdir=\$(DESTDIR)$libdir" >> config.mak
360 echo "ln_libdir=$libdir" >> config.mak
361 echo "includedir=\$(DESTDIR)$includedir" >> config.mak
362 echo "mandir=\$(DESTDIR)$mandir" >> config.mak
363 echo "infodir=\$(DESTDIR)$infodir" >> config.mak
364 echo "docdir=\$(DESTDIR)$docdir" >> config.mak
366 echo "#define CONFIG_SYSROOT \"$sysroot\"" >> $TMPH
367 echo "#ifndef CONFIG_TCCDIR" >> $TMPH
368 echo "#define CONFIG_TCCDIR \"$tccdir\"" >> $TMPH
369 echo "#define CONFIG_TCC_LDDIR \"$lddir\"" >> $TMPH
370 echo "#define CONFIG_TCC_EXTRA_LDDIR \"$extralddir\"" >> $TMPH
371 echo "#endif" >> $TMPH
372 echo "CC=$cc" >> config.mak
373 echo "GCC_MAJOR=$gcc_major" >> config.mak
374 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
375 echo "HOST_CC=$host_cc" >> config.mak
376 echo "AR=$ar" >> config.mak
377 echo "STRIP=$strip -s -R .comment -R .note" >> config.mak
378 echo "CFLAGS=$CFLAGS" >> config.mak
379 echo "LDFLAGS=$LDFLAGS" >> config.mak
380 echo "LIBSUF=$LIBSUF" >> config.mak
381 echo "EXESUF=$EXESUF" >> config.mak
382 if test "$cpu" = "x86" ; then
383 echo "ARCH=i386" >> config.mak
384 echo "#define HOST_I386 1" >> $TMPH
385 elif test "$cpu" = "x86-64" ; then
386 echo "ARCH=x86-64" >> config.mak
387 echo "#define HOST_X86_64 1" >> $TMPH
388 elif test "$cpu" = "armv4l" ; then
389 echo "ARCH=arm" >> config.mak
390 echo "#define HOST_ARM 1" >> $TMPH
391 elif test "$cpu" = "powerpc" ; then
392 echo "ARCH=ppc" >> config.mak
393 echo "#define HOST_PPC 1" >> $TMPH
394 elif test "$cpu" = "mips" ; then
395 echo "ARCH=mips" >> config.mak
396 echo "#define HOST_MIPS 1" >> $TMPH
397 elif test "$cpu" = "s390" ; then
398 echo "ARCH=s390" >> config.mak
399 echo "#define HOST_S390 1" >> $TMPH
400 elif test "$cpu" = "alpha" ; then
401 echo "ARCH=alpha" >> config.mak
402 echo "#define HOST_ALPHA 1" >> $TMPH
404 echo "Unsupported CPU"
407 if test "$noldl" = "yes" ; then
408 echo "CONFIG_NOLDL=yes" >> config.mak
410 if test "$mingw32" = "yes" ; then
411 echo "CONFIG_WIN32=yes" >> config.mak
412 echo "#define CONFIG_WIN32 1" >> $TMPH
414 if test "$cygwin" = "yes" ; then
415 echo "#ifndef _WIN32" >> $TMPH
416 echo "#define _WIN32" >> $TMPH
417 echo "#endif" >> $TMPH
418 echo "AR=ar" >> config.mak
420 if test "$bigendian" = "yes" ; then
421 echo "WORDS_BIGENDIAN=yes" >> config.mak
422 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
424 if test "$gprof" = "yes" ; then
425 echo "TARGET_GPROF=yes" >> config.mak
426 echo "#define HAVE_GPROF 1" >> $TMPH
428 if test "$build_cross" = "yes" ; then
429 echo "CONFIG_CROSS=yes" >> config.mak
431 if test "$disable_static" = "yes" ; then
432 echo "DISABLE_STATIC=yes" >> config.mak
434 if test "$disable_rpath" = "yes" ; then
435 echo "DISABLE_RPATH=yes" >> config.mak
437 if test "$strip_binaries" = "yes" ; then
438 echo "STRIP_BINARIES=yes" >> config.mak
440 if test "$use_libgcc" = "yes" ; then
441 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
442 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
444 if test "$have_selinux" = "yes" ; then
445 echo "#define HAVE_SELINUX" >> $TMPH
446 echo "HAVE_SELINUX=yes" >> config.mak
448 version
=`head $source_path/VERSION`
449 echo "VERSION=$version" >>config.mak
450 echo "#define TCC_VERSION \"$version\"" >> $TMPH
451 echo "@set VERSION $version" > config.texi
453 # build tree in object directory if source path is different from current one
454 if test "$source_path_used" = "yes" ; then
456 FILES
="Makefile tests/Makefile"
457 for dir
in $DIRS ; do
461 ln -sf $source_path/$f $f
464 echo "SRC_PATH=$source_path" >> config.mak
466 diff $TMPH config.h
>/dev
/null
2>&1
467 if test $?
-ne 0 ; then
470 echo "config.h is unchanged"