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 dll=no"
61 tcc_usrinclude
="`xcrun --show-sdk-path`/usr/include"
64 Windows_NT|MINGW
*|MSYS
*|CYGWIN
*)
68 DragonFly|OpenBSD|FreeBSD|NetBSD
)
69 confvars
="$confvars BSD ldl=no"
76 source_path
=${0%configure}
77 source_path
=${source_path%/}
78 source_path_used
="yes"
79 if test -z "$source_path" -o "$source_path" = "." ; then
87 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
89 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
91 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
93 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
95 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
97 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
99 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
101 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
103 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
105 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
107 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
109 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
111 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
113 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
115 --ar=*) ar=`echo $opt | cut -d '=' -f 2` ; ar_set
="yes"
117 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
119 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
121 --extra-libs=*) extralibs
="${opt#--extra-libs=}"
123 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2`
125 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2`
127 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2`
129 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2`
131 --triplet=*) triplet
=`echo $opt | cut -d '=' -f 2`
133 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
135 --enable-cross) confvars
="$confvars cross"
137 --disable-static) confvars
="$confvars static=no"
139 --enable-static) confvars
="$confvars static"
141 --disable-rpath) confvars
="$confvars rpath=no"
143 --strip-binaries) confvars
="$confvars strip"
145 --debug) confvars
="$confvars strip=no"
147 --with-libgcc) confvars
="$confvars libgcc"
149 --with-selinux) confvars
="$confvars selinux"
151 --config-mingw32*) mingw32
=$
(echo "$opt=yes" | cut
-d '=' -f 2)
153 --config-*) confvars
="$confvars ${opt#--config-}"; suggest
="no"
155 --help|
-h) show_help
="yes"
157 *) echo "configure: WARNING: unrecognized option $opt"
162 cc
="${cross_prefix}${cc}"
163 ar="${cross_prefix}${ar}"
164 strip
="${cross_prefix}${strip}"
166 if test -z "$cpu" ; then
167 if test -n "$ARCH" ; then
175 x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
181 aarch64|arm64|evbarm
)
204 "Power Macintosh"|ppc|ppc64
)
217 echo "Unsupported CPU"
222 # Checking for CFLAGS
223 if test -z "$CFLAGS"; then
227 if test "$mingw32" = "yes" ; then
228 if test "$source_path_used" = "no"; then
231 test -z "$prefix" && prefix
="C:/Program Files/tcc"
232 test -z "$tccdir" && tccdir
="${prefix}"
233 test -z "$bindir" && bindir
="${tccdir}"
234 test -z "$docdir" && docdir
="${tccdir}/doc"
235 test -z "$libdir" && libdir
="${tccdir}/libtcc"
236 confvars
="$confvars WIN32"
241 if test -z "$prefix" ; then
244 if test -z "$sharedir" ; then
245 sharedir
="${prefix}/share"
247 if test x
"$execprefix" = x
""; then
248 execprefix
="${prefix}"
250 if test x
"$libdir" = x
""; then
251 libdir
="${execprefix}/lib"
253 if test x
"$bindir" = x
""; then
254 bindir
="${execprefix}/bin"
256 if test x
"$docdir" = x
""; then
257 docdir
="${sharedir}/doc"
259 if test x
"$mandir" = x
""; then
260 mandir
="${sharedir}/man"
262 if test x
"$infodir" = x
""; then
263 infodir
="${sharedir}/info"
265 if test x
"$tccdir" = x
""; then
266 tccdir
="${libdir}/tcc"
268 if test x
"$includedir" = x
""; then
269 includedir
="${prefix}/include"
273 if test x
"$show_help" = "xyes" ; then
275 Usage: configure [options]
276 Options: [defaults in brackets after descriptions]
279 --help print this message
280 --prefix=PREFIX install in PREFIX [$prefix]
281 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
283 --bindir=DIR user executables in DIR [EPREFIX/bin]
284 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
285 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
286 --includedir=DIR C header files in DIR [PREFIX/include]
287 --sharedir=DIR documentation root DIR [PREFIX/share]
288 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
289 --mandir=DIR man documentation in DIR [SHAREDIR/man]
290 --infodir=DIR info documentation in DIR [SHAREDIR/info]
292 Advanced options (experts only):
293 --source-path=PATH path of source code [$source_path]
294 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
295 --sysroot=PREFIX prepend PREFIX to library/include paths []
296 --cc=CC use C compiler CC [$cc]
297 --ar=AR create archives using AR [$ar]
298 --extra-cflags= specify compiler flags [$CFLAGS]
299 --extra-ldflags= specify linker options []
301 --strip-binaries strip symbol tables from resulting binaries
302 --debug include debug info with resulting binaries
303 --disable-static make libtcc.so instead of libtcc.a
304 --enable-static make libtcc.a instead of libtcc.dll (win32)
305 --disable-rpath disable use of -rpath with the above
306 --with-libgcc use libgcc_s.so.1 instead of libtcc1.a
307 --enable-cross build cross compilers
308 --with-selinux use mmap for executable memory (with tcc -run)
309 --sysincludepaths=... specify system include paths, colon separated
310 --libpaths=... specify system library paths, colon separated
311 --crtprefix=... specify locations of crt?.o, colon separated
312 --elfinterp=... specify elf interpreter
313 --triplet=... specify system library/include directory triplet
314 --config-uClibc,-musl,-mingw32... enable system specific configurations
315 --config-bcheck=no/-backtrace=no disable bounds checker/stack backtraces
316 --config-predefs=no do not compile tccdefs.h, instead just include
318 #echo "NOTE: The object files are build at the place where configure is launched"
322 if test -z "$cross_prefix" ; then
323 CONFTEST
=.
/conftest
$EXESUF
324 if ! $cc -o $CONFTEST $source_path/conftest.c
2>/dev
/null
; then
325 echo "configure: error: '$cc' failed to compile conftest.c."
327 cc_name
="$($CONFTEST compiler)"
328 gcc_major
="$($CONFTEST version)"
329 gcc_minor
="$($CONFTEST minor)"
330 bigendian
="$($CONFTEST bigendian)"
331 _triplet
="$($CONFTEST triplet)"
333 if test "$mingw32" = "no" ; then
335 if test -z "$triplet"; then
336 if test -n "$_triplet" -a -f "/usr/lib/$_triplet/crti.o" ; then
341 if test -z "$triplet"; then
342 if test $cpu = "x86_64" -o $cpu = "aarch64" -o $cpu = "riscv64" ; then
343 if test -f "/usr/lib64/crti.o" ; then
349 if test "$cpu" = "arm" ; then
350 if test "${triplet%eabihf}" != "$triplet" ; then
351 confvars
="$confvars arm_eabihf arm_vfp"
352 elif test "${triplet%eabi}" != "$triplet" ; then
353 confvars
="$confvars arm_eabi"
355 if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
; then
356 confvars
="$confvars arm_vfp"
360 if test "$suggest" = "yes"; then
361 if test -f "/lib/ld-uClibc.so.0" ; then
362 echo "Perhaps you want ./configure --config-uClibc"
364 if test -f "/lib/ld-musl-$cpu.so.1"; then
365 echo "Perhaps you want ./configure --config-musl"
369 if test "$cc_name" = "gcc"; then
370 # avoid mingw dependencies such as 'libgcc_s_dw2-1.dll'
371 test -z "$LDFLAGS" && LDFLAGS
="-static"
375 # if cross compiling, cannot launch a program, so make a static guess
377 ppc|mips|s390
) bigendian
=yes;;
381 if test "$bigendian" = "yes" ; then
382 confvars
="$confvars BIGENDIAN"
385 # a final configuration tuning
386 if test "$cc_name" != "tcc"; then
387 OPT1
="-Wdeclaration-after-statement -fno-strict-aliasing"
388 # we want -Wno- but gcc does not always reject unknown -Wno- options
389 OPT2
="-Wpointer-sign -Wsign-compare -Wunused-result -Wformat-truncation"
390 if test "$cc_name" = "clang"; then
391 OPT1
="$OPT1 -fheinous-gnu-extensions"
392 OPT2
="$OPT2 -Wstring-plus-int"
394 $cc $OPT1 $OPT2 -o a.out
-c -xc - < /dev
/null
> cc_msg.txt
2>&1
395 for o
in $OPT1; do # enable these options
396 if ! grep -q -- $o cc_msg.txt
; then CFLAGS
="$CFLAGS $o"; fi
398 for o
in $OPT2; do # disable these options
399 if ! grep -q -- $o cc_msg.txt
; then CFLAGS
="$CFLAGS -Wno-${o#-W*}"; fi
403 rm -f cc_msg.txt a.out
405 test "$ar_set" ||
ar="$cc -ar"
408 fcho
() { if test -n "$2"; then echo "$1$2"; fi }
410 fcho
"Binary directory " "$bindir"
411 fcho
"TinyCC directory " "$tccdir"
412 fcho
"Library directory " "$libdir"
413 fcho
"Include directory " "$includedir"
414 fcho
"Manual directory " "$mandir"
415 fcho
"Info directory " "$infodir"
416 fcho
"Doc directory " "$docdir"
417 fcho
"Target root prefix " "$sysroot"
418 fcho
"/usr/include dir " "$tcc_usrinclude"
419 echo "Source path $source_path"
420 echo "C compiler $cc ($gcc_major.$gcc_minor)"
421 echo "Target OS $targetos"
423 fcho
"Triplet " "$triplet"
424 fcho
"Config " "${confvars# }"
425 echo "Creating config.mak and config.h"
427 cat >config.mak
<<EOF
428 # Automatically generated by configure - do not modify
430 bindir=\$(DESTDIR)$bindir
431 tccdir=\$(DESTDIR)$tccdir
432 libdir=\$(DESTDIR)$libdir
433 includedir=\$(DESTDIR)$includedir
434 mandir=\$(DESTDIR)$mandir
435 infodir=\$(DESTDIR)$infodir
436 docdir=\$(DESTDIR)$docdir
442 STRIP=$strip -s -R .comment -R .note
452 if test -n "$v"; then
453 test "$3" = "num" || v
="\"$v\""
454 echo "#ifndef $1" >> $TMPH
455 echo "# define $1 $v" >> $TMPH
456 echo "#endif" >> $TMPH
462 if test -n "$v"; then
463 test "$3" = "num" || v
="\"\\\"$v\\\"\""
464 echo "NATIVE_DEFINES+=-D$1=$v" >> config.mak
468 echo "/* Automatically generated by configure - do not modify */" > $TMPH
470 print_inc CONFIG_SYSROOT
"$sysroot"
471 print_inc CONFIG_TCCDIR
"$tccdir"
472 print_mak CONFIG_USR_INCLUDE
"$tcc_usrinclude"
473 print_mak CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
474 print_mak CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
475 print_mak CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
476 print_mak CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
477 print_mak CONFIG_LDDIR
"$tcc_lddir"
478 print_mak CONFIG_TRIPLET
"$triplet"
479 print_mak TCC_CPU_VERSION
"$cpuver" num
481 if test "$cpu" = "aarch64" ; then
482 echo "ARCH=arm64" >> config.mak
484 echo "ARCH=$cpu" >> config.mak
486 echo "TARGETOS=$targetos" >> config.mak
489 for v
in $confvars ; do
490 test "$v" = "predefs=no" && predefs
=""
491 if test "${v%=*}" = "$v"; then
492 echo "CONFIG_$v=yes" >> config.mak
494 echo "CONFIG_$v" >> config.mak
497 print_inc CONFIG_TCC_PREDEFS
"$predefs" num
499 version
=`head $source_path/VERSION`
500 echo "VERSION = $version" >> config.mak
501 echo "#define TCC_VERSION \"$version\"" >> $TMPH
502 echo "@set VERSION $version" > config.texi
504 if test "$source_path_used" = "yes" ; then
506 /*) echo "TOPSRC=$source_path";;
507 *) echo "TOPSRC=\$(TOP)/$source_path";;
510 echo 'TOPSRC=$(TOP)' >>config.mak
513 #define GCC_MAJOR $gcc_major
514 #define GCC_MINOR $gcc_minor
515 #define CC_NAME CC_${cc_name}
518 diff $TMPH config.h
>/dev
/null
2>&1
519 if test $?
-ne 0 ; then
522 echo "config.h is unchanged"
525 rm -f $TMPN* $CONFTEST
527 # ---------------------------------------------------------------------------
528 # build tree in object directory if source path is different from current one
535 test -d $dn || mkdir
-p $dn
538 *) while test $dn ; do
539 tgt
=..
/$tgt; dn
=${dn#${dn%%/*}}; dn=${dn#/}
546 ln -sfn $tgt $2 ||
( echo "ln failed. Using cp instead."; cp -f $1/$2 $2 )
549 if test "$source_path_used" = "yes" ; then
550 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile tests/pp/Makefile"
552 fn_makelink
$source_path $f
556 # ---------------------------------------------------------------------------