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"
39 tcc_sysincludepaths
=""
58 confvars
="$confvars OSX"
61 tcc_usrinclude
="`xcrun --show-sdk-path`/usr/include"
64 Windows_NT|MINGW
*|MSYS
*|CYGWIN
*)
67 DragonFly|OpenBSD|FreeBSD|NetBSD
)
68 confvars
="$confvars ldl=no"
75 source_path
=${0%configure}
76 source_path
=${source_path%/}
77 source_path_used
="yes"
78 if test -z "$source_path" -o "$source_path" = "." ; then
86 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
88 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
90 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
92 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
94 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
96 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
98 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
100 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
102 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
104 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
106 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
108 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
110 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
112 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
114 --ar=*) ar=`echo $opt | cut -d '=' -f 2` ; ar_set
="yes"
116 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
118 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
120 --extra-libs=*) extralibs
="${opt#--extra-libs=}"
122 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2`
124 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2`
126 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2`
128 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2`
130 --triplet=*) triplet
=`echo $opt | cut -d '=' -f 2`
132 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
134 --enable-cross) confvars
="$confvars cross"
136 --disable-static) confvars
="$confvars static=no"
138 --enable-static) confvars
="$confvars static"
140 --disable-rpath) confvars
="$confvars rpath=no"
142 --strip-binaries) confvars
="$confvars strip"
144 --debug) confvars
="$confvars strip=no"
146 --with-libgcc) confvars
="$confvars libgcc"
148 --with-selinux) confvars
="$confvars selinux"
150 --config-mingw32*) mingw32
=$
(echo "$opt=yes" | cut
-d '=' -f 2)
152 --config-*) confvars
="$confvars ${opt#--config-}"; suggest
="no"
154 --help|
-h) show_help
="yes"
156 *) echo "configure: WARNING: unrecognized option $opt"
161 cc
="${cross_prefix}${cc}"
162 ar="${cross_prefix}${ar}"
163 strip
="${cross_prefix}${strip}"
165 if test -z "$cpu" ; then
166 if test -n "$ARCH" ; then
174 x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
203 "Power Macintosh"|ppc|ppc64
)
216 echo "Unsupported CPU"
221 # Checking for CFLAGS
222 if test -z "$CFLAGS"; then
226 if test "$mingw32" = "yes" ; then
227 if test "$source_path_used" = "no"; then
230 test -z "$prefix" && prefix
="C:/Program Files/tcc"
231 test -z "$tccdir" && tccdir
="${prefix}"
232 test -z "$bindir" && bindir
="${tccdir}"
233 test -z "$docdir" && docdir
="${tccdir}/doc"
234 test -z "$libdir" && libdir
="${tccdir}/libtcc"
235 confvars
="$confvars WIN32"
240 if test -z "$prefix" ; then
243 if test -z "$sharedir" ; then
244 sharedir
="${prefix}/share"
246 if test x
"$execprefix" = x
""; then
247 execprefix
="${prefix}"
249 if test x
"$libdir" = x
""; then
250 libdir
="${execprefix}/lib"
252 if test x
"$bindir" = x
""; then
253 bindir
="${execprefix}/bin"
255 if test x
"$docdir" = x
""; then
256 docdir
="${sharedir}/doc"
258 if test x
"$mandir" = x
""; then
259 mandir
="${sharedir}/man"
261 if test x
"$infodir" = x
""; then
262 infodir
="${sharedir}/info"
264 if test x
"$tccdir" = x
""; then
265 tccdir
="${libdir}/tcc"
267 if test x
"$includedir" = x
""; then
268 includedir
="${prefix}/include"
272 if test x
"$show_help" = "xyes" ; then
274 Usage: configure [options]
275 Options: [defaults in brackets after descriptions]
278 --help print this message
279 --prefix=PREFIX install in PREFIX [$prefix]
280 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
282 --bindir=DIR user executables in DIR [EPREFIX/bin]
283 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
284 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
285 --includedir=DIR C header files in DIR [PREFIX/include]
286 --sharedir=DIR documentation root DIR [PREFIX/share]
287 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
288 --mandir=DIR man documentation in DIR [SHAREDIR/man]
289 --infodir=DIR info documentation in DIR [SHAREDIR/info]
291 Advanced options (experts only):
292 --source-path=PATH path of source code [$source_path]
293 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
294 --sysroot=PREFIX prepend PREFIX to library/include paths []
295 --cc=CC use C compiler CC [$cc]
296 --ar=AR create archives using AR [$ar]
297 --extra-cflags= specify compiler flags [$CFLAGS]
298 --extra-ldflags= specify linker options []
300 --strip-binaries strip symbol tables from resulting binaries
301 --debug include debug info with resulting binaries
302 --disable-static make libtcc.so instead of libtcc.a
303 --enable-static make libtcc.a instead of libtcc.dll (win32)
304 --disable-rpath disable use of -rpath with the above
305 --with-libgcc use libgcc_s.so.1 instead of libtcc1.a
306 --enable-cross build cross compilers
307 --with-selinux use mmap for executable memory (with tcc -run)
308 --sysincludepaths=... specify system include paths, colon separated
309 --libpaths=... specify system library paths, colon separated
310 --crtprefix=... specify locations of crt?.o, colon separated
311 --elfinterp=... specify elf interpreter
312 --triplet=... specify system library/include directory triplet
313 --config-uClibc,-musl,-mingw32... enable system specific configurations
315 #echo "NOTE: The object files are build at the place where configure is launched"
319 if test -z "$cross_prefix" ; then
320 CONFTEST
=.
/conftest
$EXESUF
321 if ! $cc -o $CONFTEST $source_path/conftest.c
2>/dev
/null
; then
322 echo "configure: error: '$cc' failed to compile conftest.c."
324 cc_name
="$($CONFTEST compiler)"
325 gcc_major
="$($CONFTEST version)"
326 gcc_minor
="$($CONFTEST minor)"
327 bigendian
="$($CONFTEST bigendian)"
328 _triplet
="$($CONFTEST triplet)"
330 if test "$mingw32" = "no" ; then
332 if test -z "$triplet"; then
333 if test -n "$_triplet" -a -f "/usr/lib/$_triplet/crti.o" ; then
338 if test -z "$triplet"; then
339 if test $cpu = "x86_64" -o $cpu = "aarch64" -o $cpu = "riscv64" ; then
340 if test -f "/usr/lib64/crti.o" ; then
346 if test "$cpu" = "arm" ; then
347 if test "${triplet%eabihf}" != "$triplet" ; then
348 confvars
="$confvars arm_eabihf arm_vfp"
349 elif test "${triplet%eabi}" != "$triplet" ; then
350 confvars
="$confvars arm_eabi"
352 if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
; then
353 confvars
="$confvars arm_vfp"
357 if test "$suggest" = "yes"; then
358 if test -f "/lib/ld-uClibc.so.0" ; then
359 echo "Perhaps you want ./configure --config-uClibc"
361 if test -f "/lib/ld-musl-$cpu.so.1"; then
362 echo "Perhaps you want ./configure --config-musl"
366 if test "$cc_name" = "gcc"; then
367 # avoid mingw dependencies such as 'libgcc_s_dw2-1.dll'
368 test -z "$LDFLAGS" && LDFLAGS
="-static"
372 # if cross compiling, cannot launch a program, so make a static guess
374 ppc|mips|s390
) bigendian
=yes;;
378 if test "$bigendian" = "yes" ; then
379 confvars
="$confvars BIGENDIAN"
382 # a final configuration tuning
383 if test "$cc_name" != "tcc"; then
384 OPT1
="-Wdeclaration-after-statement -fno-strict-aliasing"
385 # we want -Wno- but gcc does not always reject unknown -Wno- options
386 OPT2
="-Wpointer-sign -Wsign-compare -Wunused-result -Wformat-truncation"
387 if test "$cc_name" = "clang"; then
388 OPT1
="$OPT1 -fheinous-gnu-extensions"
389 OPT2
="$OPT2 -Wstring-plus-int"
391 $cc $OPT1 $OPT2 -o a.out
-c -xc - < /dev
/null
> cc_msg.txt
2>&1
392 for o
in $OPT1; do # enable these options
393 if ! grep -q -- $o cc_msg.txt
; then CFLAGS
="$CFLAGS $o"; fi
395 for o
in $OPT2; do # disable these options
396 if ! grep -q -- $o cc_msg.txt
; then CFLAGS
="$CFLAGS -Wno-${o#-W*}"; fi
400 rm -f cc_msg.txt a.out
402 test "$ar_set" ||
ar="$cc -ar"
405 fcho
() { if test -n "$2"; then echo "$1$2"; fi }
407 fcho
"Binary directory " "$bindir"
408 fcho
"TinyCC directory " "$tccdir"
409 fcho
"Library directory " "$libdir"
410 fcho
"Include directory " "$includedir"
411 fcho
"Manual directory " "$mandir"
412 fcho
"Info directory " "$infodir"
413 fcho
"Doc directory " "$docdir"
414 fcho
"Target root prefix " "$sysroot"
415 fcho
"/usr/include dir " "$tcc_usrinclude"
416 echo "Source path $source_path"
417 echo "C compiler $cc ($gcc_major.$gcc_minor)"
418 echo "Target OS $targetos"
420 fcho
"Triplet " "$triplet"
421 fcho
"Config " "${confvars# }"
422 echo "Creating config.mak and config.h"
424 cat >config.mak
<<EOF
425 # Automatically generated by configure - do not modify
427 bindir=\$(DESTDIR)$bindir
428 tccdir=\$(DESTDIR)$tccdir
429 libdir=\$(DESTDIR)$libdir
430 includedir=\$(DESTDIR)$includedir
431 mandir=\$(DESTDIR)$mandir
432 infodir=\$(DESTDIR)$infodir
433 docdir=\$(DESTDIR)$docdir
439 STRIP=$strip -s -R .comment -R .note
448 if test -n "$2"; then
449 echo "#ifndef $1" >> $TMPH
450 echo "# define $1 \"$2\"" >> $TMPH
451 echo "#endif" >> $TMPH
456 if test -n "$2"; then
457 echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak
462 if test -n "$2"; then
463 echo "NATIVE_DEFINES+=-D$1=$2" >> config.mak
467 echo "/* Automatically generated by configure - do not modify */" > $TMPH
469 print_inc CONFIG_SYSROOT
"$sysroot"
470 print_inc CONFIG_TCCDIR
"$tccdir"
471 print_mak CONFIG_USR_INCLUDE
"$tcc_usrinclude"
472 print_mak CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
473 print_mak CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
474 print_mak CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
475 print_mak CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
476 print_mak CONFIG_LDDIR
"$tcc_lddir"
477 print_mak CONFIG_TRIPLET
"$triplet"
478 print_mak_int TCC_CPU_VERSION
"$cpuver"
480 if test "$cpu" = "aarch64" ; then
481 echo "ARCH=arm64" >> config.mak
483 echo "ARCH=$cpu" >> config.mak
485 echo "TARGETOS=$targetos" >> config.mak
487 for v
in $confvars ; do
488 if test "${v%=*}" = "$v"; then
489 echo "CONFIG_$v=yes" >> config.mak
491 echo "CONFIG_$v" >> config.mak
495 version
=`head $source_path/VERSION`
496 echo "VERSION = $version" >> config.mak
497 echo "#define TCC_VERSION \"$version\"" >> $TMPH
498 echo "@set VERSION $version" > config.texi
500 if test "$source_path_used" = "yes" ; then
502 /*) echo "TOPSRC=$source_path";;
503 *) echo "TOPSRC=\$(TOP)/$source_path";;
506 echo 'TOPSRC=$(TOP)' >>config.mak
509 #define GCC_MAJOR $gcc_major
510 #define GCC_MINOR $gcc_minor
511 #define CC_NAME CC_${cc_name}
514 diff $TMPH config.h
>/dev
/null
2>&1
515 if test $?
-ne 0 ; then
518 echo "config.h is unchanged"
521 rm -f $TMPN* $CONFTEST
523 # ---------------------------------------------------------------------------
524 # build tree in object directory if source path is different from current one
531 test -d $dn || mkdir
-p $dn
534 *) while test $dn ; do
535 tgt
=..
/$tgt; dn
=${dn#${dn%%/*}}; dn=${dn#/}
542 ln -sfn $tgt $2 ||
( echo "ln failed. Using cp instead."; cp -f $1/$2 $2 )
545 if test "$source_path_used" = "yes" ; then
546 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile tests/pp/Makefile"
548 fn_makelink
$source_path $f
552 # ---------------------------------------------------------------------------