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"
38 tcc_sysincludepaths
=""
55 confvars
="$confvars OSX"
61 DragonFly|OpenBSD|FreeBSD|NetBSD
)
62 confvars
="$confvars ldl=no"
69 source_path
=${0%configure}
70 source_path
=${source_path%/}
71 source_path_used
="yes"
72 if test -z "$source_path" -o "$source_path" = "." ; then
80 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
82 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
84 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
86 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
88 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
90 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
92 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
94 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
96 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
98 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
100 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
102 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
104 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
106 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
108 --ar=*) ar=`echo $opt | cut -d '=' -f 2`
110 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
112 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
114 --extra-libs=*) extralibs
="${opt#--extra-libs=}"
116 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2`
118 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2`
120 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2`
122 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2`
124 --triplet=*) triplet
=`echo $opt | cut -d '=' -f 2`
126 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
128 --enable-cross) confvars
="$confvars cross"
130 --disable-static) confvars
="$confvars static=no"
132 --enable-static) confvars
="$confvars static"
134 --disable-rpath) confvars
="$confvars rpath=no"
136 --strip-binaries) confvars
="$confvars strip"
138 --with-libgcc) confvars
="$confvars libgcc"
140 --with-selinux) confvars
="$confvars selinux"
142 --config-mingw32*) mingw32
=$
(echo "$opt=yes" | cut
-d '=' -f 2)
144 --config-*) confvars
="$confvars ${opt#--config-}"; suggest
="no"
146 --help|
-h) show_help
="yes"
148 *) echo "configure: WARNING: unrecognized option $opt"
153 cc
="${cross_prefix}${cc}"
154 ar="${cross_prefix}${ar}"
155 strip
="${cross_prefix}${strip}"
168 # Succeeds when preprocessor condition `#if $1` is true.
169 # if $2 is not empty, prints to stderr `checking whether $2... <yes/no>`
170 # Works also when $cc is a cross compiler to any foreign platform.
171 # E.g. ppif "defined(__GNUC__) && (GCC_MAJOR >= 3)"
172 # or ppif "defined(_WIN32)" "target is Windows"
174 [ -z "${2-}" ] ||
printf "checking whether %s... " "$2" >&2
175 printf "$PPIF_TEMPLATE" "$1" > ppif.c \
176 && $cc -o ppif.o
-c ppif.c
2>/dev
/null
178 rm ppif.c ppif.o
2>/dev
/null
179 [ -z "${2-}" ] ||
{ [ 0 = $ppif_rv ] && echo yes ||
echo no
; } >&2
184 if test -z "$cpu" ; then
185 if test -n "$ARCH" ; then
187 elif ppif
"defined(__x86_64__)"; then
189 elif ppif
"defined(__i386__)"; then
197 x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
226 "Power Macintosh"|ppc|ppc64
)
236 echo "Unsupported CPU"
241 # Checking for CFLAGS
242 if test -z "$CFLAGS"; then
243 CFLAGS
="-Wall -g -O2"
246 if test "$mingw32" = "yes" ; then
247 if test "$source_path_used" = "no"; then
250 if test "$cc" = gcc
; then
251 test -z "$LDFLAGS" && LDFLAGS
="-static"
253 test -z "$prefix" && prefix
="C:/Program Files/tcc"
254 test -z "$tccdir" && tccdir
="${prefix}"
255 test -z "$bindir" && bindir
="${tccdir}"
256 test -z "$docdir" && docdir
="${tccdir}/doc"
257 test -z "$libdir" && libdir
="${tccdir}/libtcc"
258 confvars
="$confvars WIN32"
263 if test -z "$prefix" ; then
266 if test -z "$sharedir" ; then
267 sharedir
="${prefix}/share"
269 if test x
"$execprefix" = x
""; then
270 execprefix
="${prefix}"
272 if test x
"$libdir" = x
""; then
273 libdir
="${execprefix}/lib"
275 if test x
"$bindir" = x
""; then
276 bindir
="${execprefix}/bin"
278 if test x
"$docdir" = x
""; then
279 docdir
="${sharedir}/doc"
281 if test x
"$mandir" = x
""; then
282 mandir
="${sharedir}/man"
284 if test x
"$infodir" = x
""; then
285 infodir
="${sharedir}/info"
287 if test x
"$tccdir" = x
""; then
288 tccdir
="${libdir}/tcc"
290 if test x
"$includedir" = x
""; then
291 includedir
="${prefix}/include"
295 if test x
"$show_help" = "xyes" ; then
297 Usage: configure [options]
298 Options: [defaults in brackets after descriptions]
301 --help print this message
302 --prefix=PREFIX install in PREFIX [$prefix]
303 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
305 --bindir=DIR user executables in DIR [EPREFIX/bin]
306 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
307 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
308 --includedir=DIR C header files in DIR [PREFIX/include]
309 --sharedir=DIR documentation root DIR [PREFIX/share]
310 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
311 --mandir=DIR man documentation in DIR [SHAREDIR/man]
312 --infodir=DIR info documentation in DIR [SHAREDIR/info]
314 Advanced options (experts only):
315 --source-path=PATH path of source code [$source_path]
316 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
317 --sysroot=PREFIX prepend PREFIX to library/include paths []
318 --cc=CC use C compiler CC [$cc]
319 --ar=AR create archives using AR [$ar]
320 --extra-cflags= specify compiler flags [$CFLAGS]
321 --extra-ldflags= specify linker options []
323 --strip-binaries strip symbol tables from resulting binaries
324 --disable-static make libtcc.so instead of libtcc.a
325 --enable-static make libtcc.a instead of libtcc.dll (win32)
326 --disable-rpath disable use of -rpath with the above
327 --with-libgcc use libgcc_s.so.1 instead of libtcc1.a
328 --enable-cross build cross compilers
329 --with-selinux use mmap for executable memory (with tcc -run)
330 --sysincludepaths=... specify system include paths, colon separated
331 --libpaths=... specify system library paths, colon separated
332 --crtprefix=... specify locations of crt?.o, colon separated
333 --elfinterp=... specify elf interpreter
334 --triplet=... specify system library/include directory triplet
335 --config-uClibc,-musl,-mingw32... enable system specific configurations
337 #echo "NOTE: The object files are build at the place where configure is launched"
341 if test -z "$cross_prefix" ; then
342 CONFTEST
=.
/conftest
$EXESUF
343 if ! $cc -o $CONFTEST $source_path/conftest.c
2>/dev
/null
; then
344 echo "configure: error: '$cc' failed to compile conftest.c."
346 gcc_major
="$($CONFTEST version)"
347 gcc_minor
="$($CONFTEST minor)"
349 bigendian
="$($CONFTEST bigendian)"
350 if test "$mingw32" = "no" ; then
352 if test -z "$triplet"; then
353 tt
="$($CONFTEST triplet)"
354 if test -n "$tt" -a -f "/usr/lib/$tt/crti.o" ; then
359 if test -z "$triplet"; then
360 if test $cpu = "x86_64" -o $cpu = "aarch64" ; then
361 if test -f "/usr/lib64/crti.o" ; then
367 if test "$cpu" = "arm" ; then
368 if test "${triplet%eabihf}" != "$triplet" ; then
369 confvars
="$confvars arm_eabihf arm_vfp"
370 elif test "${triplet%eabi}" != "$triplet" ; then
371 confvars
="$confvars arm_eabi"
373 if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
; then
374 confvars
="$confvars arm_vfp"
378 if test "$suggest" = "yes"; then
379 if test -f "/lib/ld-uClibc.so.0" ; then
380 echo "Perhaps you want ./configure --config-uClibc"
382 if test -f "/lib/ld-musl-$cpu.so.1"; then
383 echo "Perhaps you want ./configure --config-musl"
388 # if cross compiling, cannot launch a program, so make a static guess
390 ppc|mips|s390
) bigendian
=yes;;
394 if test "$bigendian" = "yes" ; then
395 confvars
="$confvars BIGENDIAN"
398 # a final configuration tuning
399 if ! echo "$cc" |
grep -q "tcc"; then
400 OPT1
="-Wdeclaration-after-statement -fno-strict-aliasing"
401 # we want -Wno- but gcc does not always reject unknown -Wno- options
402 OPT2
="-Wpointer-sign -Wsign-compare -Wunused-result -Wformat-truncation"
403 if echo "$cc" |
grep -q "clang"; then
404 OPT1
="$OPT1 -fheinous-gnu-extensions"
405 OPT2
="$OPT2 -Wstring-plus-int"
407 $cc $OPT1 $OPT2 -o a.out
-c -xc - < /dev
/null
> cc_msg.txt
2>&1
408 for o
in $OPT1; do # enable these options
409 if ! grep -q -- $o cc_msg.txt
; then CFLAGS
="$CFLAGS $o"; fi
411 for o
in $OPT2; do # disable these options
412 if ! grep -q -- $o cc_msg.txt
; then CFLAGS
="$CFLAGS -Wno-${o#-W*}"; fi
416 rm -f cc_msg.txt a.out
419 fcho
() { if test -n "$2"; then echo "$1$2"; fi }
421 fcho
"Binary directory " "$bindir"
422 fcho
"TinyCC directory " "$tccdir"
423 fcho
"Library directory " "$libdir"
424 fcho
"Include directory " "$includedir"
425 fcho
"Manual directory " "$mandir"
426 fcho
"Info directory " "$infodir"
427 fcho
"Doc directory " "$docdir"
428 fcho
"Target root prefix " "$sysroot"
429 echo "Source path $source_path"
430 echo "C compiler $cc ($gcc_major.$gcc_minor)"
431 echo "Target OS $targetos"
433 fcho
"Triplet " "$triplet"
434 fcho
"Config " "${confvars# }"
435 echo "Creating config.mak and config.h"
437 cat >config.mak
<<EOF
438 # Automatically generated by configure - do not modify
440 bindir=\$(DESTDIR)$bindir
441 tccdir=\$(DESTDIR)$tccdir
442 libdir=\$(DESTDIR)$libdir
443 includedir=\$(DESTDIR)$includedir
444 mandir=\$(DESTDIR)$mandir
445 infodir=\$(DESTDIR)$infodir
446 docdir=\$(DESTDIR)$docdir
451 STRIP=$strip -s -R .comment -R .note
460 if test -n "$2"; then
461 echo "#ifndef $1" >> $TMPH
462 echo "# define $1 \"$2\"" >> $TMPH
463 echo "#endif" >> $TMPH
468 if test -n "$2"; then
469 echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak
474 if test -n "$2"; then
475 echo "NATIVE_DEFINES+=-D$1=$2" >> config.mak
479 echo "/* Automatically generated by configure - do not modify */" > $TMPH
481 print_inc CONFIG_SYSROOT
"$sysroot"
482 print_inc CONFIG_TCCDIR
"$tccdir"
483 print_mak CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
484 print_mak CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
485 print_mak CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
486 print_mak CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
487 print_mak CONFIG_LDDIR
"$tcc_lddir"
488 print_mak CONFIG_TRIPLET
"$triplet"
489 print_mak_int TCC_CPU_VERSION
"$cpuver"
491 if test "$cpu" = "aarch64" ; then
492 echo "ARCH=arm64" >> config.mak
494 echo "ARCH=$cpu" >> config.mak
496 echo "TARGETOS=$targetos" >> config.mak
498 for v
in $confvars ; do
499 if test "${v%=*}" = "$v"; then
500 echo "CONFIG_$v=yes" >> config.mak
502 echo "CONFIG_$v" >> config.mak
506 version
=`head $source_path/VERSION`
507 echo "VERSION = $version" >> config.mak
508 echo "#define TCC_VERSION \"$version\"" >> $TMPH
509 echo "@set VERSION $version" > config.texi
511 if test "$source_path_used" = "yes" ; then
513 /*) echo "TOPSRC=$source_path";;
514 *) echo "TOPSRC=\$(TOP)/$source_path";;
517 echo 'TOPSRC=$(TOP)' >>config.mak
520 diff $TMPH config.h
>/dev
/null
2>&1
521 if test $?
-ne 0 ; then
524 echo "config.h is unchanged"
527 rm -f $TMPN* $CONFTEST
529 # ---------------------------------------------------------------------------
530 # build tree in object directory if source path is different from current one
537 test -d $dn || mkdir
-p $dn
540 *) while test $dn ; do
541 tgt
=..
/$tgt; dn
=${dn#${dn%%/*}}; dn=${dn#/}
548 ln -sfn $tgt $2 ||
( echo "ln failed. Using cp instead."; cp -f $1/$2 $2 )
551 if test "$source_path_used" = "yes" ; then
552 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile tests/pp/Makefile"
554 fn_makelink
$source_path $f
558 # ---------------------------------------------------------------------------