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 if test -z "$cpu" ; then
154 if test -n "$ARCH" ; then
162 x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
191 "Power Macintosh"|ppc|ppc64
)
201 echo "Unsupported CPU"
206 # Checking for CFLAGS
207 if test -z "$CFLAGS"; then
208 CFLAGS
="-Wall -g -O2"
211 if test "$mingw32" = "yes" ; then
212 if test "$source_path_used" = "no"; then
215 if test "$cc" = gcc
; then
216 test -z "$LDFLAGS" && LDFLAGS
="-static"
218 test -z "$prefix" && prefix
="C:/Program Files/tcc"
219 test -z "$tccdir" && tccdir
="${prefix}"
220 test -z "$bindir" && bindir
="${tccdir}"
221 test -z "$docdir" && docdir
="${tccdir}/doc"
222 test -z "$libdir" && libdir
="${tccdir}/libtcc"
223 confvars
="$confvars WIN32"
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"
255 if test x
"$includedir" = x
""; then
256 includedir
="${prefix}/include"
260 if test x
"$show_help" = "xyes" ; then
262 Usage: configure [options]
263 Options: [defaults in brackets after descriptions]
266 --help print this message
267 --prefix=PREFIX install in PREFIX [$prefix]
268 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
270 --bindir=DIR user executables in DIR [EPREFIX/bin]
271 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
272 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
273 --includedir=DIR C header files in DIR [PREFIX/include]
274 --sharedir=DIR documentation root DIR [PREFIX/share]
275 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
276 --mandir=DIR man documentation in DIR [SHAREDIR/man]
277 --infodir=DIR info documentation in DIR [SHAREDIR/info]
279 Advanced options (experts only):
280 --source-path=PATH path of source code [$source_path]
281 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
282 --sysroot=PREFIX prepend PREFIX to library/include paths []
283 --cc=CC use C compiler CC [$cc]
284 --ar=AR create archives using AR [$ar]
285 --extra-cflags= specify compiler flags [$CFLAGS]
286 --extra-ldflags= specify linker options []
288 --strip-binaries strip symbol tables from resulting binaries
289 --disable-static make libtcc.so instead of libtcc.a
290 --enable-static make libtcc.a instead of libtcc.dll (win32)
291 --disable-rpath disable use of -rpath with the above
292 --with-libgcc use libgcc_s.so.1 instead of libtcc1.a
293 --enable-cross build cross compilers
294 --with-selinux use mmap for executable memory (with tcc -run)
295 --sysincludepaths=... specify system include paths, colon separated
296 --libpaths=... specify system library paths, colon separated
297 --crtprefix=... specify locations of crt?.o, colon separated
298 --elfinterp=... specify elf interpreter
299 --triplet=... specify system library/include directory triplet
300 --config-uClibc,-musl,-mingw32... enable system specific configurations
302 #echo "NOTE: The object files are build at the place where configure is launched"
306 cc
="${cross_prefix}${cc}"
307 ar="${cross_prefix}${ar}"
308 strip
="${cross_prefix}${strip}"
310 if test -z "$cross_prefix" ; then
311 CONFTEST
=.
/conftest
$EXESUF
312 if ! $cc -o $CONFTEST $source_path/conftest.c
2>/dev
/null
; then
313 echo "configure: error: '$cc' failed to compile conftest.c."
315 gcc_major
="$($CONFTEST version)"
316 gcc_minor
="$($CONFTEST minor)"
318 bigendian
="$($CONFTEST bigendian)"
319 if test "$mingw32" = "no" ; then
321 if test -z "$triplet"; then
322 tt
="$($CONFTEST triplet)"
323 if test -n "$tt" -a -f "/usr/lib/$tt/crti.o" ; then
328 if test -z "$triplet"; then
329 if test $cpu = "x86_64" -o $cpu = "aarch64" ; then
330 if test -f "/usr/lib64/crti.o" ; then
336 if test "$cpu" = "arm" ; then
337 if test "${triplet%eabihf}" != "$triplet" ; then
338 confvars
="$confvars arm_eabihf"
339 elif test "${triplet%eabi}" != "$triplet" ; then
340 confvars
="$confvars arm_eabi"
342 if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
; then
343 confvars
="$confvars arm_vfp"
347 if test "$suggest" = "yes"; then
348 if test -f "/lib/ld-uClibc.so.0" ; then
349 echo "Perhaps you want ./configure --config-uClibc"
351 if test -f "/lib/ld-musl-$cpu.so.1"; then
352 echo "Perhaps you want ./configure --config-musl"
357 # if cross compiling, cannot launch a program, so make a static guess
359 ppc|mips|s390
) bigendian
=yes;;
363 if test "$bigendian" = "yes" ; then
364 confvars
="$confvars BIGENDIAN"
367 # a final configuration tuning
368 if ! echo "$cc" |
grep -q "tcc"; then
369 OPT1
="-Wdeclaration-after-statement -fno-strict-aliasing"
370 # we want -Wno- but gcc does not always reject unknown -Wno- options
371 OPT2
="-Wpointer-sign -Wsign-compare -Wunused-result"
372 if echo "$cc" |
grep -q "clang"; then
373 OPT1
="$OPT1 -fheinous-gnu-extensions"
374 OPT2
="$OPT2 -Wstring-plus-int"
376 $cc $OPT1 $OPT2 -o a.out
-c -xc - < /dev
/null
> cc_msg.txt
2>&1
377 for o
in $OPT1; do # enable these options
378 if ! grep -q -- $o cc_msg.txt
; then CFLAGS
="$CFLAGS $o"; fi
380 for o
in $OPT2; do # disable these options
381 if ! grep -q -- $o cc_msg.txt
; then CFLAGS
="$CFLAGS -Wno-${o#-W*}"; fi
385 rm -f cc_msg.txt a.out
388 fcho
() { if test -n "$2"; then echo "$1$2"; fi }
390 fcho
"Binary directory " "$bindir"
391 fcho
"TinyCC directory " "$tccdir"
392 fcho
"Library directory " "$libdir"
393 fcho
"Include directory " "$includedir"
394 fcho
"Manual directory " "$mandir"
395 fcho
"Info directory " "$infodir"
396 fcho
"Doc directory " "$docdir"
397 fcho
"Target root prefix " "$sysroot"
398 echo "Source path $source_path"
399 echo "C compiler $cc ($gcc_major.$gcc_minor)"
400 echo "Target OS $targetos"
402 fcho
"Triplet " "$triplet"
403 fcho
"Config " "${confvars# }"
404 echo "Creating config.mak and config.h"
406 cat >config.mak
<<EOF
407 # Automatically generated by configure - do not modify
409 bindir=\$(DESTDIR)$bindir
410 tccdir=\$(DESTDIR)$tccdir
411 libdir=\$(DESTDIR)$libdir
412 includedir=\$(DESTDIR)$includedir
413 mandir=\$(DESTDIR)$mandir
414 infodir=\$(DESTDIR)$infodir
415 docdir=\$(DESTDIR)$docdir
420 STRIP=$strip -s -R .comment -R .note
429 if test -n "$2"; then
430 echo "#ifndef $1" >> $TMPH
431 echo "# define $1 \"$2\"" >> $TMPH
432 echo "#endif" >> $TMPH
437 if test -n "$2"; then
438 echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak
443 if test -n "$2"; then
444 echo "NATIVE_DEFINES+=-D$1=$2" >> config.mak
448 echo "/* Automatically generated by configure - do not modify */" > $TMPH
450 print_inc CONFIG_SYSROOT
"$sysroot"
451 print_inc CONFIG_TCCDIR
"$tccdir"
452 print_mak CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
453 print_mak CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
454 print_mak CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
455 print_mak CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
456 print_mak CONFIG_LDDIR
"$tcc_lddir"
457 print_mak CONFIG_TRIPLET
"$triplet"
458 print_mak_int TCC_CPU_VERSION
"$cpuver"
460 if test "$cpu" = "aarch64" ; then
461 echo "ARCH=arm64" >> config.mak
463 echo "ARCH=$cpu" >> config.mak
465 echo "TARGETOS=$targetos" >> config.mak
467 for v
in $confvars ; do
468 if test "${v%=*}" = "$v"; then
469 echo "CONFIG_$v=yes" >> config.mak
471 echo "CONFIG_$v" >> config.mak
475 version
=`head $source_path/VERSION`
476 echo "VERSION = $version" >> config.mak
477 echo "#define TCC_VERSION \"$version\"" >> $TMPH
478 echo "@set VERSION $version" > config.texi
480 if test "$source_path_used" = "yes" ; then
482 /*) echo "TOPSRC=$source_path";;
483 *) echo "TOPSRC=\$(TOP)/$source_path";;
486 echo 'TOPSRC=$(TOP)' >>config.mak
489 diff $TMPH config.h
>/dev
/null
2>&1
490 if test $?
-ne 0 ; then
493 echo "config.h is unchanged"
496 rm -f $TMPN* $CONFTEST
498 # ---------------------------------------------------------------------------
499 # build tree in object directory if source path is different from current one
506 test -d $dn || mkdir
-p $dn
509 *) while test $dn ; do
510 tgt
=..
/$tgt; dn
=${dn#${dn%%/*}}; dn=${dn#/}
517 ln -sfn $tgt $2 ||
( echo "ln failed. Using cp instead."; cp -f $1/$2 $2 )
520 if test "$source_path_used" = "yes" ; then
521 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile tests/pp/Makefile"
523 fn_makelink
$source_path $f
527 # ---------------------------------------------------------------------------