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"
42 tcc_sysincludepaths
=""
56 DragonFly
) noldl
=yes;;
64 # XXX: we assume an absolute path is given when launching configure,
65 # except in './configure' case.
66 source_path
=${0%configure}
67 source_path
=${source_path%/}
68 source_path_used
="yes"
69 if test -z "$source_path" -o "$source_path" = "." ; then
77 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
79 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
81 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
83 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
85 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
87 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
89 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
91 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
93 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
95 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
97 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
99 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
101 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
103 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
105 --ar=*) ar=`echo $opt | cut -d '=' -f 2`
107 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
109 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
111 --extra-libs=*) extralibs
="${opt#--extra-libs=}"
113 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2`
115 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2`
117 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2`
119 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2`
121 --triplet=*) triplet
=`echo $opt | cut -d '=' -f 2`
123 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
125 --enable-gprof) gprof
="yes"
127 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i686-pc-mingw32-" ; cpu
=x86
129 --enable-cygwin) mingw32
="yes" ; cygwin
="yes" ; cross_prefix
="mingw32-" ; cpu
=x86
131 --enable-cross) build_cross
="yes"
133 --disable-static) disable_static
="yes"
135 --disable-rpath) disable_rpath
="yes"
137 --strip-binaries) strip_binaries
="yes"
139 --with-libgcc) use_libgcc
="yes"
141 --with-selinux) have_selinux
="yes"
143 --help|
-h) show_help
="yes"
145 *) echo "configure: WARNING: unrecognized option $opt"
150 if test -z "$cpu" ; then
151 if test -n "$ARCH" ; then
159 x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
188 "Power Macintosh"|ppc|ppc64
)
202 # Checking for CFLAGS
203 if test -z "$CFLAGS"; then
204 CFLAGS
="-Wall -g -O2"
207 if test "$mingw32" = "yes" ; then
208 if test x
"$tccdir" = x
""; then
211 if test -z "$prefix" ; then
212 prefix
="C:/Program Files/${tccdir}"
214 if test -z "$sharedir" ; then
220 libdir
="${prefix}/lib"
221 docdir
="${sharedir}/doc"
222 mandir
="${sharedir}/man"
223 infodir
="${sharedir}/info"
228 if test -z "$prefix" ; then
231 if test -z "$sharedir" ; then
232 sharedir
="${prefix}/share"
234 if test x
"$execprefix" = x
""; then
235 execprefix
="${prefix}"
237 if test x
"$libdir" = x
""; then
238 libdir
="${execprefix}/lib"
240 if test x
"$bindir" = x
""; then
241 bindir
="${execprefix}/bin"
243 if test x
"$docdir" = x
""; then
244 docdir
="${sharedir}/doc"
246 if test x
"$mandir" = x
""; then
247 mandir
="${sharedir}/man"
249 if test x
"$infodir" = x
""; then
250 infodir
="${sharedir}/info"
252 if test x
"$tccdir" = x
""; then
253 tccdir
="${libdir}/tcc"
257 if test x
"$includedir" = x
""; then
258 includedir
="${prefix}/include"
261 if test x
"$show_help" = "xyes" ; then
263 Usage: configure [options]
264 Options: [defaults in brackets after descriptions]
267 --help print this message
268 --prefix=PREFIX install in PREFIX [$prefix]
269 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
271 --bindir=DIR user executables in DIR [EPREFIX/bin]
272 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
273 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
274 --includedir=DIR C header files in DIR [PREFIX/include]
275 --sharedir=DIR documentation root DIR [PREFIX/share]
276 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
277 --mandir=DIR man documentation in DIR [SHAREDIR/man]
278 --infodir=DIR info documentation in DIR [SHAREDIR/info]
280 Advanced options (experts only):
281 --source-path=PATH path of source code [$source_path]
282 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
283 --sysroot=PREFIX prepend PREFIX to library/include paths []
284 --cc=CC use C compiler CC [$cc]
285 --ar=AR create archives using AR [$ar]
286 --extra-cflags= specify compiler flags [$CFLAGS]
287 --extra-ldflags= specify linker options []
289 --strip-binaries strip symbol tables from resulting binaries
290 --disable-static make libtcc.so instead of libtcc.a
291 --disable-rpath disable use of -rpath with the above
292 --with-libgcc use libgcc_s.so.1 instead of libtcc1.a in dynamic link
293 --enable-mingw32 build windows version on linux with mingw32
294 --enable-cygwin build windows version on windows with cygwin
295 --enable-cross build cross compilers
296 --with-selinux use mmap for exec mem [needs writable /tmp]
297 --sysincludepaths=... specify system include paths, colon separated
298 --libpaths=... specify system library paths, colon separated
299 --crtprefix=... specify locations of crt?.o, colon separated
300 --elfinterp=... specify elf interpreter
301 --triplet=... specify system library/include directory triplet
303 #echo "NOTE: The object files are build at the place where configure is launched"
307 cc
="${cross_prefix}${cc}"
308 ar="${cross_prefix}${ar}"
309 strip
="${cross_prefix}${strip}"
311 CONFTEST
=.
/conftest
$EXESUF
313 if test -z "$cross_prefix" ; then
314 if ! $cc -o $CONFTEST $source_path/conftest.c
2>/dev
/null
; then
315 echo "configure: error: '$cc' failed to compile conftest.c."
317 bigendian
="$($CONFTEST bigendian)"
318 gcc_major
="$($CONFTEST version)"
319 gcc_minor
="$($CONFTEST minor)"
320 if test "$mingw32" = "no" ; then
322 if test -z "$triplet"; then
323 tt
="$($CONFTEST triplet)"
324 if test -n "$tt" -a -f "/usr/lib/$tt/crti.o" ; then
329 if test -z "$triplet"; then
330 if test $cpu = "x86-64" -o $cpu = "aarch64" ; then
331 if test -f "/usr/lib64/crti.o" ; then
337 if test "$cpu" = "armv4l" ; then
338 if test "${triplet%eabihf}" != "$triplet" ; then
339 confvars
="$confvars arm_eabihf"
340 elif test "${triplet%eabi}" != "$triplet" ; then
341 confvars
="$confvars arm_eabi"
343 if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
; then
344 confvars
="$confvars arm_vfp"
348 if test -f "/lib/ld-uClibc.so.0" ; then
349 confvars
="$confvars uClibc"
355 # if cross compiling, cannot launch a program, so make a static guess
357 powerpc|mips|s390
) bigendian
=yes;;
361 # a final configuration tuning
362 $cc -v --help > cc_help.txt
2>&1
363 W_OPTIONS
="declaration-after-statement"
364 for i
in $W_OPTIONS; do
365 O_PRESENT
="$(grep -- -W$i cc_help.txt)"
366 if test -n "$O_PRESENT"; then CFLAGS
="$CFLAGS -W$i"; fi
368 W_OPTIONS
="deprecated-declarations strict-aliasing pointer-sign sign-compare unused-result uninitialized"
369 for i
in $W_OPTIONS; do
370 O_PRESENT
="$(grep -- -W$i cc_help.txt)"
371 if test -n "$O_PRESENT"; then CFLAGS
="$CFLAGS -Wno-$i"; fi
373 F_OPTIONS
="strict-aliasing"
374 for i
in $F_OPTIONS; do
375 O_PRESENT
="$(grep -- -f$i cc_help.txt)"
376 if test -n "$O_PRESENT"; then CFLAGS
="$CFLAGS -fno-$i"; fi
380 fcho
() { if test -n "$2"; then echo "$1$2"; else echo "$1-"; fi }
382 echo "Binary directory $bindir"
383 echo "TinyCC directory $tccdir"
384 echo "Library directory $libdir"
385 echo "Include directory $includedir"
386 echo "Manual directory $mandir"
387 echo "Info directory $infodir"
388 echo "Doc directory $docdir"
389 fcho
"Target root prefix " "$sysroot"
390 echo "Source path $source_path"
391 echo "C compiler $cc"
392 echo "Target OS $targetos"
394 echo "Big Endian $bigendian"
395 echo "Profiling $gprof"
396 echo "Cross compilers $build_cross"
397 echo "Use libgcc $use_libgcc"
398 fcho
"Triplet " "$triplet"
400 echo "Creating config.mak and config.h"
402 cat >config.mak
<<EOF
403 # Automatically generated by configure - do not modify
405 bindir=\$(DESTDIR)$bindir
406 tccdir=\$(DESTDIR)$tccdir
407 libdir=\$(DESTDIR)$libdir
408 includedir=\$(DESTDIR)$includedir
409 mandir=\$(DESTDIR)$mandir
410 infodir=\$(DESTDIR)$infodir
411 docdir=\$(DESTDIR)$docdir
416 STRIP=$strip -s -R .comment -R .note
425 if test -n "$2"; then
426 echo "#ifndef $1" >> $TMPH
427 echo "# define $1 \"$2\"" >> $TMPH
428 echo "#endif" >> $TMPH
432 if test -n "$2"; then
433 echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak
437 echo "/* Automatically generated by configure - do not modify */" > $TMPH
439 print_inc CONFIG_SYSROOT
"$sysroot"
440 print_inc CONFIG_TCCDIR
"$tccdir"
441 print_mak CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
442 print_mak CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
443 print_mak CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
444 print_mak CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
445 print_mak CONFIG_LDDIR
"$tcc_lddir"
446 print_mak CONFIG_TRIPLET
"$triplet"
448 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
449 echo "#define GCC_MINOR $gcc_minor" >> $TMPH
451 if test "$cpu" = "x86" ; then
452 echo "ARCH=i386" >> config.mak
453 elif test "$cpu" = "x86-64" ; then
454 echo "ARCH=x86-64" >> config.mak
455 elif test "$cpu" = "armv4l" ; then
456 echo "ARCH=arm" >> config.mak
457 echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH
458 elif test "$cpu" = "aarch64" ; then
459 echo "ARCH=arm64" >> config.mak
460 elif test "$cpu" = "powerpc" ; then
461 echo "ARCH=ppc" >> config.mak
462 elif test "$cpu" = "mips" ; then
463 echo "ARCH=mips" >> config.mak
464 elif test "$cpu" = "s390" ; then
465 echo "ARCH=s390" >> config.mak
466 elif test "$cpu" = "alpha" ; then
467 echo "ARCH=alpha" >> config.mak
469 echo "Unsupported CPU"
473 echo "TARGETOS=$targetos" >> config.mak
475 for v
in $confvars ; do
476 echo "CONFIG_$v=yes" >> config.mak
478 if test "$noldl" = "yes" ; then
479 echo "CONFIG_NOLDL=yes" >> config.mak
481 if test "$mingw32" = "yes" ; then
482 echo "CONFIG_WIN32=yes" >> config.mak
484 if test "$cygwin" = "yes" ; then
485 echo "#ifndef _WIN32" >> $TMPH
486 echo "# define _WIN32" >> $TMPH
487 echo "#endif" >> $TMPH
488 echo "AR=ar" >> config.mak
490 if test "$bigendian" = "yes" ; then
491 echo "WORDS_BIGENDIAN=yes" >> config.mak
492 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
494 if test "$gprof" = "yes" ; then
495 echo "TARGET_GPROF=yes" >> config.mak
496 echo "#define HAVE_GPROF 1" >> $TMPH
498 if test "$build_cross" = "yes" ; then
499 echo "CONFIG_CROSS=yes" >> config.mak
501 if test "$disable_static" = "yes" ; then
502 echo "DISABLE_STATIC=yes" >> config.mak
504 if test "$disable_rpath" = "yes" ; then
505 echo "DISABLE_RPATH=yes" >> config.mak
507 if test "$strip_binaries" = "yes" ; then
508 echo "STRIP_BINARIES=yes" >> config.mak
510 if test "$use_libgcc" = "yes" ; then
511 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
512 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
514 if test "$have_selinux" = "yes" ; then
515 echo "#define HAVE_SELINUX" >> $TMPH
516 echo "HAVE_SELINUX=yes" >> config.mak
519 version
=`head $source_path/VERSION`
520 echo "VERSION = $version" >> config.mak
521 echo "#define TCC_VERSION \"$version\"" >> $TMPH
522 echo "@set VERSION $version" > config.texi
524 if test "$source_path_used" = "yes" ; then
526 /*) echo "TOPSRC=$source_path";;
527 *) echo "TOPSRC=\$(TOP)/$source_path";;
530 echo 'TOPSRC=$(TOP)' >>config.mak
533 diff $TMPH config.h
>/dev
/null
2>&1
534 if test $?
-ne 0 ; then
537 echo "config.h is unchanged"
540 rm -f $TMPN* $CONFTEST
542 # ---------------------------------------------------------------------------
543 # build tree in object directory if source path is different from current one
550 test -d $dn || mkdir
-p $dn
553 *) while test $dn ; do
554 tgt
=..
/$tgt; dn
=${dn#${dn%%/*}}; dn=${dn#/}
561 ln -sfn $tgt $2 ||
( echo "ln failed. Using cp instead."; cp -f $1/$2 $2 )
564 if test "$source_path_used" = "yes" ; then
565 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile tests/pp/Makefile"
567 fn_makelink
$source_path $f
571 # ---------------------------------------------------------------------------