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"
30 test -z "$CC" && CC
="gcc"
31 test -z "$cc" && cc
="$CC"
39 tcc_sysincludepaths
=""
62 confvars
="$confvars OSX dll=no"
64 cc
=`readlink $cc || echo clang`
65 tcc_usrinclude
="`xcrun --show-sdk-path`/usr/include"
68 Windows_NT|MINGW
*|MSYS
*|CYGWIN
*)
72 DragonFly|OpenBSD|FreeBSD|NetBSD
)
73 confvars
="$confvars BSD ldl=no"
80 source_path
=${0%configure}
81 source_path
=${source_path%/}
82 source_path_used
="yes"
83 if test -z "$source_path" -o "$source_path" = "." ; then
91 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2-`
93 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2-`
95 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2-`
97 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2-`
99 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2-`
101 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2-`
103 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2-`
105 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2-`
107 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2-`
109 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2-`
111 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2-`
113 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2-`
115 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2-`
117 --cc=*) cc
=`echo $opt | cut -d '=' -f 2-`
119 --ar=*) ar=`echo $opt | cut -d '=' -f 2-` ; ar_set
="yes"
121 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
123 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
125 --extra-libs=*) extralibs
="${opt#--extra-libs=}"
127 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2-`
129 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2-`
131 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2-`
133 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2-`
135 --triplet=*) triplet
=`echo $opt | cut -d '=' -f 2-`
137 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2-`
139 --enable-cross) confvars
="$confvars cross"
141 --disable-static) confvars
="$confvars static=no"
143 --enable-static) confvars
="$confvars static"
145 --disable-rpath) confvars
="$confvars rpath=no"
147 --debug) confvars
="$confvars debug"
149 --with-libgcc) confvars
="$confvars libgcc"
151 --with-selinux) confvars
="$confvars selinux"
153 --config-mingw32*) mingw32
=$
(echo "$opt=yes" | cut
-d '=' -f 2)
155 --config-*) confvars
="$confvars ${opt#--config-}"; suggest
="no"
157 --help|
-h) show_help
="yes"
159 *) echo "configure: WARNING: unrecognized option $opt"
164 cc
="${cross_prefix}${cc}"
165 ar="${cross_prefix}${ar}"
167 # Checking for CFLAGS
168 test -z "$CFLAGS" && CFLAGS
="-Wall -O2"
170 # on OSX M1 with --cpu=x86_64, build a tcc to run under rosetta entirely
171 if test "$darwin" = "yes" -a "$cpu" = "x86_64" -a "$cpu_sys" = "arm64"; then
172 CFLAGS
="$CFLAGS -arch $cpu"
173 LDFLAGS
="$LDFLAGS -arch $cpu"
177 test -z "$cpu" && cpu
="$cpu_sys"
180 x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
196 aarch64|arm64|evbarm
)
219 "Power Macintosh"|ppc|ppc64
)
232 echo "Unsupported CPU"
237 if test "$mingw32" = "yes" ; then
238 if test "$source_path_used" = "no"; then
241 test -z "$prefix" && prefix
="C:/Program Files/tcc"
242 test -z "$tccdir" && tccdir
="${prefix}" && tccdir_auto
="yes"
243 test -z "$bindir" && bindir
="${tccdir}"
244 test -z "$docdir" && docdir
="${tccdir}/doc"
245 test -z "$libdir" && libdir
="${tccdir}/libtcc"
246 confvars
="$confvars WIN32"
251 if test -z "$prefix" ; then
254 if test -z "$sharedir" ; then
255 sharedir
="${prefix}/share"
257 if test x
"$execprefix" = x
""; then
258 execprefix
="${prefix}"
260 if test x
"$libdir" = x
""; then
261 libdir
="${execprefix}/lib"
263 if test x
"$bindir" = x
""; then
264 bindir
="${execprefix}/bin"
266 if test x
"$docdir" = x
""; then
267 docdir
="${sharedir}/doc"
269 if test x
"$mandir" = x
""; then
270 mandir
="${sharedir}/man"
272 if test x
"$infodir" = x
""; then
273 infodir
="${sharedir}/info"
275 if test x
"$tccdir" = x
""; then
276 tccdir
="${libdir}/tcc"
278 if test x
"$includedir" = x
""; then
279 includedir
="${prefix}/include"
283 if test x
"$show_help" = "xyes" ; then
285 Usage: configure [options]
286 Options: [defaults in brackets after descriptions]
289 --help print this message
290 --prefix=PREFIX install in PREFIX [$prefix]
291 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
293 --bindir=DIR user executables in DIR [EPREFIX/bin]
294 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
295 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
296 --includedir=DIR C header files in DIR [PREFIX/include]
297 --sharedir=DIR documentation root DIR [PREFIX/share]
298 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
299 --mandir=DIR man documentation in DIR [SHAREDIR/man]
300 --infodir=DIR info documentation in DIR [SHAREDIR/info]
302 Advanced options (experts only):
303 --source-path=PATH path of source code [$source_path]
304 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
305 --sysroot=PREFIX prepend PREFIX to library/include paths [$sysroot]
306 --cc=CC use C compiler CC [$cc]
307 --ar=AR create archives using AR [$ar]
308 --extra-cflags= specify compiler flags [$CFLAGS]
309 --extra-ldflags= specify linker options [$LDFLAGS]
312 --debug include debug info with resulting binaries
313 --disable-static make libtcc.so instead of libtcc.a
314 --enable-static make libtcc.a instead of libtcc.dll (win32)
315 --disable-rpath disable use of -rpath with libtcc.so
316 --with-libgcc use libgcc_s.so.1 instead of libtcc1.a
317 --with-selinux use mmap for executable memory (tcc -run)
318 --enable-cross build cross compilers (see also 'make help')
320 --sysincludepaths=... specify system include paths, colon separated
321 --libpaths=... specify system library paths, colon separated
322 --crtprefix=... specify locations of crt?.o, colon separated
323 --elfinterp=... specify elf interpreter
324 --triplet=... specify system library/include directory triplet
326 --config-uClibc,-musl enable system specific configurations
327 --config-mingw32 build on windows using msys, busybox, etc.
328 --config-backtrace=no disable stack backtraces (with -run or -bt)
329 --config-bcheck=no disable bounds checker (-b)
330 --config-predefs=no do not compile tccdefs.h, instead just include
335 if test -z "$cross_prefix" ; then
336 CONFTEST
=.
/conftest
$EXESUF
337 if ! $cc -o $CONFTEST $source_path/conftest.c
2>/dev
/null
; then
338 echo "configure: error: '$cc' failed to compile conftest.c."
340 cc_name
="$($CONFTEST compiler)"
341 gcc_major
="$($CONFTEST version)"
342 gcc_minor
="$($CONFTEST minor)"
343 bigendian
="$($CONFTEST bigendian)"
344 _triplet
="$($CONFTEST triplet)"
346 if test "$mingw32" = "no" ; then
348 if test -z "$triplet"; then
349 if test -n "$_triplet" -a -f "/usr/lib/$_triplet/crti.o" ; then
354 if test -z "$triplet"; then
355 if test $cpu = "x86_64" -o $cpu = "arm64" -o $cpu = "riscv64" ; then
356 if test -f "/usr/lib64/crti.o" ; then
362 if test "$cpu" = "arm" ; then
363 if test "${triplet%eabihf}" != "$triplet" ; then
364 confvars
="$confvars arm_eabihf arm_vfp"
365 elif test "${triplet%eabi}" != "$triplet" ; then
366 confvars
="$confvars arm_eabi arm_vfp"
367 elif test "${_triplet%eabihf}" != "$_triplet" ; then
368 confvars
="$confvars arm_eabihf arm_vfp"
369 elif test "${_triplet%eabi}" != "$_triplet" ; then
370 confvars
="$confvars arm_eabi arm_vfp"
372 if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
; then
373 confvars
="$confvars arm_vfp"
377 if test "$suggest" = "yes"; then
378 if test -f "/lib/ld-uClibc.so.0" ; then
379 echo "Perhaps you want ./configure --config-uClibc"
381 if test -f "/lib/ld-musl-$cpu.so.1"; then
382 echo "Perhaps you want ./configure --config-musl"
386 if test "$cc_name" = "gcc"; then
387 # avoid mingw dependencies such as 'libgcc_s_dw2-1.dll'
388 test -z "$LDFLAGS" && LDFLAGS
="-static"
392 # if cross compiling, cannot launch a program, so make a static guess
394 ppc|mips|s390
) bigendian
=yes;;
398 if test "$bigendian" = "yes" ; then
399 confvars
="$confvars BIGENDIAN"
402 # a final configuration tuning
403 if test "$cc_name" != "tcc"; then
404 OPT1
="-Wdeclaration-after-statement -fno-strict-aliasing"
405 # we want -Wno- but gcc does not always reject unknown -Wno- options
406 OPT2
="-Wpointer-sign -Wsign-compare -Wunused-result -Wformat-truncation"
407 if test "$cc_name" = "clang"; then
408 OPT1
="$OPT1 -fheinous-gnu-extensions"
409 OPT2
="$OPT2 -Wstring-plus-int"
411 $cc $OPT1 $OPT2 -o a.out
-c -xc - < /dev
/null
> cc_msg.txt
2>&1
412 for o
in $OPT1; do # enable these options
413 if ! grep -q -- $o cc_msg.txt
; then CFLAGS
="$CFLAGS $o"; fi
415 for o
in $OPT2; do # disable these options
416 if ! grep -q -- $o cc_msg.txt
; then CFLAGS
="$CFLAGS -Wno-${o#-W*}"; fi
420 rm -f cc_msg.txt a.out
422 test "$ar_set" ||
ar="$cc -ar"
425 fcho
() { if test -n "$2"; then echo "$1$2"; fi }
427 fcho
"Binary directory " "$bindir"
428 fcho
"TinyCC directory " "$tccdir"
429 fcho
"Library directory " "$libdir"
430 fcho
"Include directory " "$includedir"
431 fcho
"Manual directory " "$mandir"
432 fcho
"Info directory " "$infodir"
433 fcho
"Doc directory " "$docdir"
434 fcho
"Target root prefix " "$sysroot"
435 fcho
"/usr/include dir " "$tcc_usrinclude"
436 echo "Source path $source_path"
437 echo "C compiler $cc ($gcc_major.$gcc_minor)"
438 echo "Target OS $targetos"
440 fcho
"Triplet " "$triplet"
441 fcho
"Config " "${confvars# }"
442 echo "Creating config.mak and config.h"
444 cat >config.mak
<<EOF
445 # Automatically generated by configure - do not modify
447 bindir=\$(DESTDIR)$bindir
448 tccdir=\$(DESTDIR)$tccdir
449 libdir=\$(DESTDIR)$libdir
450 includedir=\$(DESTDIR)$includedir
451 mandir=\$(DESTDIR)$mandir
452 infodir=\$(DESTDIR)$infodir
453 docdir=\$(DESTDIR)$docdir
468 if test -n "$v"; then
469 test "$3" = "num" || v
="\"$v\""
470 echo "#ifndef $1" >> $TMPH
471 echo "# define $1 $v" >> $TMPH
472 echo "#endif" >> $TMPH
478 if test -n "$v"; then
479 test "$3" = "num" || v
="\"\\\"$v\\\"\""
480 echo "NATIVE_DEFINES+=-D$1=$v" >> config.mak
484 echo "/* Automatically generated by configure - do not modify */" > $TMPH
486 print_inc CONFIG_SYSROOT
"$sysroot"
487 test "$tccdir_auto" = "yes" || print_inc CONFIG_TCCDIR
"$tccdir"
488 print_mak CONFIG_USR_INCLUDE
"$tcc_usrinclude"
489 print_mak CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
490 print_mak CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
491 print_mak CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
492 print_mak CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
493 print_mak CONFIG_LDDIR
"$tcc_lddir"
494 print_mak CONFIG_TRIPLET
"$triplet"
495 print_mak TCC_CPU_VERSION
"$cpuver" num
497 echo "ARCH=$cpu" >> config.mak
498 echo "TARGETOS=$targetos" >> config.mak
501 for v
in $confvars ; do
502 test "$v" = "predefs=no" && predefs
=""
503 if test "${v%=*}" = "$v"; then
504 echo "CONFIG_$v=yes" >> config.mak
506 echo "CONFIG_$v" >> config.mak
509 print_inc CONFIG_TCC_PREDEFS
"$predefs" num
511 version
=`head $source_path/VERSION`
512 echo "VERSION = $version" >> config.mak
513 echo "#define TCC_VERSION \"$version\"" >> $TMPH
514 echo "@set VERSION $version" > config.texi
516 if test "$source_path_used" = "yes" ; then
518 /*) echo "TOPSRC=$source_path";;
519 *) echo "TOPSRC=\$(TOP)/$source_path";;
522 echo 'TOPSRC=$(TOP)' >>config.mak
525 #define GCC_MAJOR $gcc_major
526 #define GCC_MINOR $gcc_minor
527 #define CC_NAME CC_${cc_name}
530 diff $TMPH config.h
>/dev
/null
2>&1
531 if test $?
-ne 0 ; then
534 echo "config.h is unchanged"
537 rm -f $TMPN* $CONFTEST
539 # ---------------------------------------------------------------------------
540 # build tree in object directory if source path is different from current one
547 test -d $dn || mkdir
-p $dn
550 *) while test $dn ; do
551 tgt
=..
/$tgt; dn
=${dn#${dn%%/*}}; dn=${dn#/}
558 ln -sfn $tgt $2 ||
( echo "ln failed. Using cp instead."; cp -f $1/$2 $2 )
561 if test "$source_path_used" = "yes" ; then
562 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile tests/pp/Makefile"
564 fn_makelink
$source_path $f
568 # ---------------------------------------------------------------------------