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"
44 tcc_sysincludepaths
=""
62 DragonFly|OpenBSD|FreeBSD|NetBSD
)
70 source_path
=${0%configure}
71 source_path
=${source_path%/}
72 source_path_used
="yes"
73 if test -z "$source_path" -o "$source_path" = "." ; then
81 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
83 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
85 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
87 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
89 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
91 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
93 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
95 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
97 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
99 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
101 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
103 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
105 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
107 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
109 --ar=*) ar=`echo $opt | cut -d '=' -f 2`
111 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
113 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
115 --extra-libs=*) extralibs
="${opt#--extra-libs=}"
117 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2`
119 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2`
121 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2`
123 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2`
125 --triplet=*) triplet
=`echo $opt | cut -d '=' -f 2`
127 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
129 --enable-gprof) gprof
="yes"
131 --enable-mingw32) mingw32
="yes"
133 --enable-cross) build_cross
="yes"
135 --disable-static) disable_static
="yes"
137 --enable-static) disable_static
="no"
139 --disable-rpath) disable_rpath
="yes"
141 --strip-binaries) strip_binaries
="yes"
143 --with-libgcc) use_libgcc
="yes"
145 --with-selinux) have_selinux
="yes"
147 --help|
-h) show_help
="yes"
149 *) echo "configure: WARNING: unrecognized option $opt"
154 if test -z "$cpu" ; then
155 if test -n "$ARCH" ; then
163 x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
192 "Power Macintosh"|ppc|ppc64
)
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 if test x
"$tccdir" = x
""; then
221 if test -z "$prefix" ; then
222 prefix
="C:/Program Files/${tccdir}"
224 if test -z "$sharedir" ; then
230 libdir
="${prefix}/lib"
231 docdir
="${sharedir}/doc"
232 mandir
="${sharedir}/man"
233 infodir
="${sharedir}/info"
238 if test -z "$prefix" ; then
241 if test -z "$sharedir" ; then
242 sharedir
="${prefix}/share"
244 if test x
"$execprefix" = x
""; then
245 execprefix
="${prefix}"
247 if test x
"$libdir" = x
""; then
248 libdir
="${execprefix}/lib"
250 if test x
"$bindir" = x
""; then
251 bindir
="${execprefix}/bin"
253 if test x
"$docdir" = x
""; then
254 docdir
="${sharedir}/doc"
256 if test x
"$mandir" = x
""; then
257 mandir
="${sharedir}/man"
259 if test x
"$infodir" = x
""; then
260 infodir
="${sharedir}/info"
262 if test x
"$tccdir" = x
""; then
263 tccdir
="${libdir}/tcc"
265 if test "$osx" = "yes" ; then
270 if test x
"$includedir" = x
""; then
271 includedir
="${prefix}/include"
274 if test x
"$show_help" = "xyes" ; then
276 Usage: configure [options]
277 Options: [defaults in brackets after descriptions]
280 --help print this message
281 --prefix=PREFIX install in PREFIX [$prefix]
282 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
284 --bindir=DIR user executables in DIR [EPREFIX/bin]
285 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
286 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
287 --includedir=DIR C header files in DIR [PREFIX/include]
288 --sharedir=DIR documentation root DIR [PREFIX/share]
289 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
290 --mandir=DIR man documentation in DIR [SHAREDIR/man]
291 --infodir=DIR info documentation in DIR [SHAREDIR/info]
293 Advanced options (experts only):
294 --source-path=PATH path of source code [$source_path]
295 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
296 --sysroot=PREFIX prepend PREFIX to library/include paths []
297 --cc=CC use C compiler CC [$cc]
298 --ar=AR create archives using AR [$ar]
299 --extra-cflags= specify compiler flags [$CFLAGS]
300 --extra-ldflags= specify linker options []
302 --strip-binaries strip symbol tables from 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 in dynamic link
307 --enable-mingw32 build windows version on linux with mingw32
308 --enable-cross build cross compilers
309 --with-selinux use mmap for executable memory (with tcc -run)
310 --sysincludepaths=... specify system include paths, colon separated
311 --libpaths=... specify system library paths, colon separated
312 --crtprefix=... specify locations of crt?.o, colon separated
313 --elfinterp=... specify elf interpreter
314 --triplet=... specify system library/include directory triplet
316 #echo "NOTE: The object files are build at the place where configure is launched"
320 cc
="${cross_prefix}${cc}"
321 ar="${cross_prefix}${ar}"
322 strip
="${cross_prefix}${strip}"
324 CONFTEST
=.
/conftest
$EXESUF
325 if ! $cc -o $CONFTEST $source_path/conftest.c
2>/dev
/null
; then
326 echo "configure: error: '$cc' failed to compile conftest.c."
328 gcc_major
="$($CONFTEST version)"
329 gcc_minor
="$($CONFTEST minor)"
332 if test -z "$cross_prefix" ; then
333 bigendian
="$($CONFTEST bigendian)"
334 if test "$mingw32" = "no" ; then
336 if test -z "$triplet"; then
337 tt
="$($CONFTEST triplet)"
338 if test -n "$tt" -a -f "/usr/lib/$tt/crti.o" ; then
343 if test -z "$triplet"; then
344 if test $cpu = "x86_64" -o $cpu = "aarch64" ; then
345 if test -f "/usr/lib64/crti.o" ; then
351 if test "$cpu" = "armv4l" ; then
352 if test "${triplet%eabihf}" != "$triplet" ; then
353 confvars
="$confvars arm_eabihf"
354 elif test "${triplet%eabi}" != "$triplet" ; then
355 confvars
="$confvars arm_eabi"
357 if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
; then
358 confvars
="$confvars arm_vfp"
362 # Enable uClibc or musl native support only if GNU ld is not already present
363 if test -f "/lib/ld-linux.so.2"; then
365 elif test -f "/lib64/ld-linux-x86-64.so.2"; then
367 elif test -f "/lib64/ld-linux-aarch64.so.1"; then
369 elif test -f "/lib/ld-uClibc.so.0" ; then
370 confvars
="$confvars uClibc"
371 elif test -f "/lib/ld-musl-$cpu.so.1"; then
372 confvars
="$confvars musl"
376 # if cross compiling, cannot launch a program, so make a static guess
378 powerpc|mips|s390
) bigendian
=yes;;
382 # a final configuration tuning
383 $cc -v --help > cc_help.txt
2>&1
384 W_OPTIONS
="declaration-after-statement undef strict-prototypes write-strings"
385 for i
in $W_OPTIONS; do
386 O_PRESENT
="$(grep -- -W$i cc_help.txt)"
387 if test -n "$O_PRESENT"; then CFLAGS
="$CFLAGS -W$i"; fi
389 W_OPTIONS
="pointer-sign sign-compare unused-result"
390 for i
in $W_OPTIONS; do
391 O_PRESENT
="$(grep -- -W$i cc_help.txt)"
392 if test -n "$O_PRESENT"; then CFLAGS
="$CFLAGS -Wno-$i"; fi
394 F_OPTIONS
="strict-aliasing"
395 for i
in $F_OPTIONS; do
396 O_PRESENT
="$(grep -- -f$i cc_help.txt)"
397 if test -n "$O_PRESENT"; then CFLAGS
="$CFLAGS -fno-$i"; fi
401 fcho
() { if test -n "$2"; then echo "$1$2"; else echo "$1-"; fi }
403 echo "Binary directory $bindir"
404 echo "TinyCC directory $tccdir"
405 echo "Library directory $libdir"
406 echo "Include directory $includedir"
407 echo "Manual directory $mandir"
408 echo "Info directory $infodir"
409 echo "Doc directory $docdir"
410 fcho
"Target root prefix " "$sysroot"
411 echo "Source path $source_path"
412 echo "C compiler $cc"
413 echo "Target OS $targetos"
415 echo "Big Endian $bigendian"
416 echo "Profiling $gprof"
417 echo "Cross compilers $build_cross"
418 echo "Use libgcc $use_libgcc"
419 fcho
"Triplet " "$triplet"
421 echo "Creating config.mak and config.h"
423 cat >config.mak
<<EOF
424 # Automatically generated by configure - do not modify
426 bindir=\$(DESTDIR)$bindir
427 tccdir=\$(DESTDIR)$tccdir
428 libdir=\$(DESTDIR)$libdir
429 includedir=\$(DESTDIR)$includedir
430 mandir=\$(DESTDIR)$mandir
431 infodir=\$(DESTDIR)$infodir
432 docdir=\$(DESTDIR)$docdir
437 STRIP=$strip -s -R .comment -R .note
446 if test -n "$2"; then
447 echo "#ifndef $1" >> $TMPH
448 echo "# define $1 \"$2\"" >> $TMPH
449 echo "#endif" >> $TMPH
453 if test -n "$2"; then
454 echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak
458 echo "/* Automatically generated by configure - do not modify */" > $TMPH
460 print_inc CONFIG_SYSROOT
"$sysroot"
461 print_inc CONFIG_TCCDIR
"$tccdir"
462 print_mak CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
463 print_mak CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
464 print_mak CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
465 print_mak CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
466 print_mak CONFIG_LDDIR
"$tcc_lddir"
467 print_mak CONFIG_TRIPLET
"$triplet"
469 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
470 echo "#define GCC_MINOR $gcc_minor" >> $TMPH
472 if test "$cpu" = "x86" ; then
473 echo "ARCH=i386" >> config.mak
474 elif test "$cpu" = "x86_64" ; then
475 echo "ARCH=x86_64" >> config.mak
476 elif test "$cpu" = "armv4l" ; then
477 echo "ARCH=arm" >> config.mak
478 echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH
479 elif test "$cpu" = "aarch64" ; then
480 echo "ARCH=arm64" >> config.mak
481 elif test "$cpu" = "powerpc" ; then
482 echo "ARCH=ppc" >> config.mak
483 elif test "$cpu" = "mips" ; then
484 echo "ARCH=mips" >> config.mak
485 elif test "$cpu" = "s390" ; then
486 echo "ARCH=s390" >> config.mak
487 elif test "$cpu" = "alpha" ; then
488 echo "ARCH=alpha" >> config.mak
490 echo "Unsupported CPU"
494 echo "TARGETOS=$targetos" >> config.mak
496 for v
in $confvars ; do
497 echo "CONFIG_$v=yes" >> config.mak
499 if test "$noldl" = "yes" ; then
500 echo "CONFIG_NOLDL=yes" >> config.mak
502 if test "$mingw32" = "yes" ; then
503 echo "CONFIG_WIN32=yes" >> config.mak
505 if test "$osx" = "yes" ; then
506 echo "CONFIG_OSX=yes" >> config.mak
508 if test "$bigendian" = "yes" ; then
509 echo "WORDS_BIGENDIAN=yes" >> config.mak
510 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
512 if test "$gprof" = "yes" ; then
513 echo "TARGET_GPROF=yes" >> config.mak
514 echo "#define HAVE_GPROF 1" >> $TMPH
516 if test "$build_cross" = "yes" ; then
517 echo "CONFIG_CROSS=yes" >> config.mak
519 if test -n "$disable_static" ; then
520 echo "DISABLE_STATIC=$disable_static" >> config.mak
522 if test "$disable_rpath" = "yes" ; then
523 echo "DISABLE_RPATH=yes" >> config.mak
525 if test "$strip_binaries" = "yes" ; then
526 echo "STRIP_BINARIES=yes" >> config.mak
528 if test "$use_libgcc" = "yes" ; then
529 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
530 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
532 if test "$have_selinux" = "yes" ; then
533 echo "#define HAVE_SELINUX" >> $TMPH
534 echo "HAVE_SELINUX=yes" >> config.mak
537 version
=`head $source_path/VERSION`
538 echo "VERSION = $version" >> config.mak
539 echo "#define TCC_VERSION \"$version\"" >> $TMPH
540 echo "@set VERSION $version" > config.texi
542 if test "$source_path_used" = "yes" ; then
544 /*) echo "TOPSRC=$source_path";;
545 *) echo "TOPSRC=\$(TOP)/$source_path";;
548 echo 'TOPSRC=$(TOP)' >>config.mak
551 diff $TMPH config.h
>/dev
/null
2>&1
552 if test $?
-ne 0 ; then
555 echo "config.h is unchanged"
558 rm -f $TMPN* $CONFTEST
560 # ---------------------------------------------------------------------------
561 # build tree in object directory if source path is different from current one
568 test -d $dn || mkdir
-p $dn
571 *) while test $dn ; do
572 tgt
=..
/$tgt; dn
=${dn#${dn%%/*}}; dn=${dn#/}
579 ln -sfn $tgt $2 ||
( echo "ln failed. Using cp instead."; cp -f $1/$2 $2 )
582 if test "$source_path_used" = "yes" ; then
583 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile tests/pp/Makefile"
585 fn_makelink
$source_path $f
589 # ---------------------------------------------------------------------------