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
=""
61 confvars
="$confvars OSX dll=no"
63 cc
=`readlink $cc || echo clang`
64 tcc_usrinclude
="`xcrun --show-sdk-path`/usr/include"
67 Windows_NT|MINGW
*|MSYS
*|CYGWIN
*)
71 DragonFly|OpenBSD|FreeBSD|NetBSD
)
72 confvars
="$confvars BSD ldl=no"
79 source_path
=${0%configure}
80 source_path
=${source_path%/}
81 source_path_used
="yes"
82 if test -z "$source_path" -o "$source_path" = "." ; then
90 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
92 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
94 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
96 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
98 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
100 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
102 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
104 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
106 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
108 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
110 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
112 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
114 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
116 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
118 --ar=*) ar=`echo $opt | cut -d '=' -f 2` ; ar_set
="yes"
120 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
122 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
124 --extra-libs=*) extralibs
="${opt#--extra-libs=}"
126 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2`
128 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2`
130 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2`
132 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2`
134 --triplet=*) triplet
=`echo $opt | cut -d '=' -f 2`
136 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
138 --enable-cross) confvars
="$confvars cross"
140 --disable-static) confvars
="$confvars static=no"
142 --enable-static) confvars
="$confvars static"
144 --disable-rpath) confvars
="$confvars rpath=no"
146 --debug) confvars
="$confvars debug"
148 --with-libgcc) confvars
="$confvars libgcc"
150 --with-selinux) confvars
="$confvars selinux"
152 --config-mingw32*) mingw32
=$
(echo "$opt=yes" | cut
-d '=' -f 2)
154 --config-*) confvars
="$confvars ${opt#--config-}"; suggest
="no"
156 --help|
-h) show_help
="yes"
158 *) echo "configure: WARNING: unrecognized option $opt"
163 cc
="${cross_prefix}${cc}"
164 ar="${cross_prefix}${ar}"
166 # Checking for CFLAGS
167 test -z "$CFLAGS" && CFLAGS
="-Wall -O2"
169 # on OSX M1 with --cpu=x86_64, build a tcc to run under rosetta entirely
170 if test "$darwin" = "yes" -a "$cpu" = "x86_64" -a "$cpu_sys" = "arm64"; then
171 CFLAGS
="$CFLAGS -arch $cpu"
172 LDFLAGS
="$LDFLAGS -arch $cpu"
176 test -z "$cpu" && cpu
="$cpu_sys"
179 x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
195 aarch64|arm64|evbarm
)
218 "Power Macintosh"|ppc|ppc64
)
231 echo "Unsupported CPU"
236 if test "$mingw32" = "yes" ; then
237 if test "$source_path_used" = "no"; then
240 test -z "$prefix" && prefix
="C:/Program Files/tcc"
241 test -z "$tccdir" && tccdir
="${prefix}" && tccdir_auto
="yes"
242 test -z "$bindir" && bindir
="${tccdir}"
243 test -z "$docdir" && docdir
="${tccdir}/doc"
244 test -z "$libdir" && libdir
="${tccdir}/libtcc"
245 confvars
="$confvars WIN32"
250 if test -z "$prefix" ; then
253 if test -z "$sharedir" ; then
254 sharedir
="${prefix}/share"
256 if test x
"$execprefix" = x
""; then
257 execprefix
="${prefix}"
259 if test x
"$libdir" = x
""; then
260 libdir
="${execprefix}/lib"
262 if test x
"$bindir" = x
""; then
263 bindir
="${execprefix}/bin"
265 if test x
"$docdir" = x
""; then
266 docdir
="${sharedir}/doc"
268 if test x
"$mandir" = x
""; then
269 mandir
="${sharedir}/man"
271 if test x
"$infodir" = x
""; then
272 infodir
="${sharedir}/info"
274 if test x
"$tccdir" = x
""; then
275 tccdir
="${libdir}/tcc"
277 if test x
"$includedir" = x
""; then
278 includedir
="${prefix}/include"
282 if test x
"$show_help" = "xyes" ; then
284 Usage: configure [options]
285 Options: [defaults in brackets after descriptions]
288 --help print this message
289 --prefix=PREFIX install in PREFIX [$prefix]
290 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
292 --bindir=DIR user executables in DIR [EPREFIX/bin]
293 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
294 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
295 --includedir=DIR C header files in DIR [PREFIX/include]
296 --sharedir=DIR documentation root DIR [PREFIX/share]
297 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
298 --mandir=DIR man documentation in DIR [SHAREDIR/man]
299 --infodir=DIR info documentation in DIR [SHAREDIR/info]
301 Advanced options (experts only):
302 --source-path=PATH path of source code [$source_path]
303 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
304 --sysroot=PREFIX prepend PREFIX to library/include paths [$sysroot]
305 --cc=CC use C compiler CC [$cc]
306 --ar=AR create archives using AR [$ar]
307 --extra-cflags= specify compiler flags [$CFLAGS]
308 --extra-ldflags= specify linker options [$LDFLAGS]
311 --debug include debug info with resulting binaries
312 --disable-static make libtcc.so instead of libtcc.a
313 --enable-static make libtcc.a instead of libtcc.dll (win32)
314 --disable-rpath disable use of -rpath with libtcc.so
315 --with-libgcc use libgcc_s.so.1 instead of libtcc1.a
316 --with-selinux use mmap for executable memory (tcc -run)
317 --enable-cross build cross compilers (see also 'make help')
319 --sysincludepaths=... specify system include paths, colon separated
320 --libpaths=... specify system library paths, colon separated
321 --crtprefix=... specify locations of crt?.o, colon separated
322 --elfinterp=... specify elf interpreter
323 --triplet=... specify system library/include directory triplet
325 --config-uClibc,-musl enable system specific configurations
326 --config-mingw32 build on windows using msys, busybox, etc.
327 --config-backtrace=no disable stack backtraces (with -run or -bt)
328 --config-bcheck=no disable bounds checker (-b)
329 --config-predefs=no do not compile tccdefs.h, instead just include
334 if test -z "$cross_prefix" ; then
335 CONFTEST
=.
/conftest
$EXESUF
336 if ! $cc -o $CONFTEST $source_path/conftest.c
2>/dev
/null
; then
337 echo "configure: error: '$cc' failed to compile conftest.c."
339 cc_name
="$($CONFTEST compiler)"
340 gcc_major
="$($CONFTEST version)"
341 gcc_minor
="$($CONFTEST minor)"
342 bigendian
="$($CONFTEST bigendian)"
343 _triplet
="$($CONFTEST triplet)"
345 if test "$mingw32" = "no" ; then
347 if test -z "$triplet"; then
348 if test -n "$_triplet" -a -f "/usr/lib/$_triplet/crti.o" ; then
353 if test -z "$triplet"; then
354 if test $cpu = "x86_64" -o $cpu = "arm64" -o $cpu = "riscv64" ; then
355 if test -f "/usr/lib64/crti.o" ; then
361 if test "$cpu" = "arm" ; then
362 if test "${triplet%eabihf}" != "$triplet" ; then
363 confvars
="$confvars arm_eabihf arm_vfp"
364 elif test "${triplet%eabi}" != "$triplet" ; then
365 confvars
="$confvars arm_eabi arm_vfp"
366 elif test "${_triplet%eabihf}" != "$_triplet" ; then
367 confvars
="$confvars arm_eabihf arm_vfp"
368 elif test "${_triplet%eabi}" != "$_triplet" ; then
369 confvars
="$confvars arm_eabi arm_vfp"
371 if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
; then
372 confvars
="$confvars arm_vfp"
376 if test "$suggest" = "yes"; then
377 if test -f "/lib/ld-uClibc.so.0" ; then
378 echo "Perhaps you want ./configure --config-uClibc"
380 if test -f "/lib/ld-musl-$cpu.so.1"; then
381 echo "Perhaps you want ./configure --config-musl"
385 if test "$cc_name" = "gcc"; then
386 # avoid mingw dependencies such as 'libgcc_s_dw2-1.dll'
387 test -z "$LDFLAGS" && LDFLAGS
="-static"
391 # if cross compiling, cannot launch a program, so make a static guess
393 ppc|mips|s390
) bigendian
=yes;;
397 if test "$bigendian" = "yes" ; then
398 confvars
="$confvars BIGENDIAN"
401 # a final configuration tuning
402 if test "$cc_name" != "tcc"; then
403 OPT1
="-Wdeclaration-after-statement -fno-strict-aliasing"
404 # we want -Wno- but gcc does not always reject unknown -Wno- options
405 OPT2
="-Wpointer-sign -Wsign-compare -Wunused-result -Wformat-truncation"
406 if test "$cc_name" = "clang"; then
407 OPT1
="$OPT1 -fheinous-gnu-extensions"
408 OPT2
="$OPT2 -Wstring-plus-int"
410 $cc $OPT1 $OPT2 -o a.out
-c -xc - < /dev
/null
> cc_msg.txt
2>&1
411 for o
in $OPT1; do # enable these options
412 if ! grep -q -- $o cc_msg.txt
; then CFLAGS
="$CFLAGS $o"; fi
414 for o
in $OPT2; do # disable these options
415 if ! grep -q -- $o cc_msg.txt
; then CFLAGS
="$CFLAGS -Wno-${o#-W*}"; fi
419 rm -f cc_msg.txt a.out
421 test "$ar_set" ||
ar="$cc -ar"
424 fcho
() { if test -n "$2"; then echo "$1$2"; fi }
426 fcho
"Binary directory " "$bindir"
427 fcho
"TinyCC directory " "$tccdir"
428 fcho
"Library directory " "$libdir"
429 fcho
"Include directory " "$includedir"
430 fcho
"Manual directory " "$mandir"
431 fcho
"Info directory " "$infodir"
432 fcho
"Doc directory " "$docdir"
433 fcho
"Target root prefix " "$sysroot"
434 fcho
"/usr/include dir " "$tcc_usrinclude"
435 echo "Source path $source_path"
436 echo "C compiler $cc ($gcc_major.$gcc_minor)"
437 echo "Target OS $targetos"
439 fcho
"Triplet " "$triplet"
440 fcho
"Config " "${confvars# }"
441 echo "Creating config.mak and config.h"
443 cat >config.mak
<<EOF
444 # Automatically generated by configure - do not modify
446 bindir=\$(DESTDIR)$bindir
447 tccdir=\$(DESTDIR)$tccdir
448 libdir=\$(DESTDIR)$libdir
449 includedir=\$(DESTDIR)$includedir
450 mandir=\$(DESTDIR)$mandir
451 infodir=\$(DESTDIR)$infodir
452 docdir=\$(DESTDIR)$docdir
467 if test -n "$v"; then
468 test "$3" = "num" || v
="\"$v\""
469 echo "#ifndef $1" >> $TMPH
470 echo "# define $1 $v" >> $TMPH
471 echo "#endif" >> $TMPH
477 if test -n "$v"; then
478 test "$3" = "num" || v
="\"\\\"$v\\\"\""
479 echo "NATIVE_DEFINES+=-D$1=$v" >> config.mak
483 echo "/* Automatically generated by configure - do not modify */" > $TMPH
485 print_inc CONFIG_SYSROOT
"$sysroot"
486 test "$tccdir_auto" = "yes" || print_inc CONFIG_TCCDIR
"$tccdir"
487 print_mak CONFIG_USR_INCLUDE
"$tcc_usrinclude"
488 print_mak CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
489 print_mak CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
490 print_mak CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
491 print_mak CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
492 print_mak CONFIG_LDDIR
"$tcc_lddir"
493 print_mak CONFIG_TRIPLET
"$triplet"
494 print_mak TCC_CPU_VERSION
"$cpuver" num
496 echo "ARCH=$cpu" >> config.mak
497 echo "TARGETOS=$targetos" >> config.mak
500 for v
in $confvars ; do
501 test "$v" = "predefs=no" && predefs
=""
502 if test "${v%=*}" = "$v"; then
503 echo "CONFIG_$v=yes" >> config.mak
505 echo "CONFIG_$v" >> config.mak
508 print_inc CONFIG_TCC_PREDEFS
"$predefs" num
510 version
=`head $source_path/VERSION`
511 echo "VERSION = $version" >> config.mak
512 echo "#define TCC_VERSION \"$version\"" >> $TMPH
513 echo "@set VERSION $version" > config.texi
515 if test "$source_path_used" = "yes" ; then
517 /*) echo "TOPSRC=$source_path";;
518 *) echo "TOPSRC=\$(TOP)/$source_path";;
521 echo 'TOPSRC=$(TOP)' >>config.mak
524 #define GCC_MAJOR $gcc_major
525 #define GCC_MINOR $gcc_minor
526 #define CC_NAME CC_${cc_name}
529 diff $TMPH config.h
>/dev
/null
2>&1
530 if test $?
-ne 0 ; then
533 echo "config.h is unchanged"
536 rm -f $TMPN* $CONFTEST
538 # ---------------------------------------------------------------------------
539 # build tree in object directory if source path is different from current one
546 test -d $dn || mkdir
-p $dn
549 *) while test $dn ; do
550 tgt
=..
/$tgt; dn
=${dn#${dn%%/*}}; dn=${dn#/}
557 ln -sfn $tgt $2 ||
( echo "ln failed. Using cp instead."; cp -f $1/$2 $2 )
560 if test "$source_path_used" = "yes" ; then
561 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile tests/pp/Makefile"
563 fn_makelink
$source_path $f
567 # ---------------------------------------------------------------------------