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
=""
55 confvars
="$confvars OSX"
59 confvars
="$confvars WIN32"
62 DragonFly|OpenBSD|FreeBSD|NetBSD
)
63 confvars
="$confvars ldl=no"
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-mingw32) confvars
="$confvars WIN32"; mingw32
="yes"
131 --enable-cross) confvars
="$confvars cross"
133 --disable-static) confvars
="$confvars static=no"
135 --enable-static) confvars
="$confvars static"
137 --disable-rpath) confvars
="$confvars rpath=no"
139 --strip-binaries) confvars
="$confvars strip"
141 --with-libgcc) confvars
="$confvars libgcc"
143 --with-selinux) confvars
="$confvars selinux"
145 --config-*) confvars
="$confvars ${opt#--config-}"; suggest
="no"
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
)
202 echo "Unsupported CPU"
207 # Checking for CFLAGS
208 if test -z "$CFLAGS"; then
209 CFLAGS
="-Wall -g -O2"
212 if test "$mingw32" = "yes" ; then
213 if test "$source_path_used" = "no"; then
216 if test "$cc" = gcc
; then
217 test -z "$LDFLAGS" && LDFLAGS
="-static"
219 if test x
"$tccdir" = x
""; then
222 if test -z "$prefix" ; then
223 prefix
="C:/Program Files/${tccdir}"
225 if test -z "$sharedir" ; then
231 libdir
="${prefix}/lib"
232 docdir
="${sharedir}/doc"
233 mandir
="${sharedir}/man"
234 infodir
="${sharedir}/info"
239 if test -z "$prefix" ; then
242 if test -z "$sharedir" ; then
243 sharedir
="${prefix}/share"
245 if test x
"$execprefix" = x
""; then
246 execprefix
="${prefix}"
248 if test x
"$libdir" = x
""; then
249 libdir
="${execprefix}/lib"
251 if test x
"$bindir" = x
""; then
252 bindir
="${execprefix}/bin"
254 if test x
"$docdir" = x
""; then
255 docdir
="${sharedir}/doc"
257 if test x
"$mandir" = x
""; then
258 mandir
="${sharedir}/man"
260 if test x
"$infodir" = x
""; then
261 infodir
="${sharedir}/info"
263 if test x
"$tccdir" = x
""; then
264 tccdir
="${libdir}/tcc"
268 if test x
"$includedir" = x
""; then
269 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 --disable-static make libtcc.so instead of libtcc.a
302 --enable-static make libtcc.a instead of libtcc.dll (win32)
303 --disable-rpath disable use of -rpath with the above
304 --with-libgcc use libgcc_s.so.1 instead of libtcc1.a
305 --enable-mingw32 build windows version on linux with mingw32
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... enable specific configuration for some systems
315 #echo "NOTE: The object files are build at the place where configure is launched"
319 cc
="${cross_prefix}${cc}"
320 ar="${cross_prefix}${ar}"
321 strip
="${cross_prefix}${strip}"
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 gcc_major
="$($CONFTEST version)"
328 gcc_minor
="$($CONFTEST minor)"
331 if test -z "$cross_prefix" ; then
332 bigendian
="$($CONFTEST bigendian)"
333 if test "$mingw32" = "no" ; then
335 if test -z "$triplet"; then
336 tt
="$($CONFTEST triplet)"
337 if test -n "$tt" -a -f "/usr/lib/$tt/crti.o" ; then
342 if test -z "$triplet"; then
343 if test $cpu = "x86_64" -o $cpu = "aarch64" ; then
344 if test -f "/usr/lib64/crti.o" ; then
350 if test "$cpu" = "arm" ; then
351 if test "${triplet%eabihf}" != "$triplet" ; then
352 confvars
="$confvars arm_eabihf"
353 elif test "${triplet%eabi}" != "$triplet" ; then
354 confvars
="$confvars arm_eabi"
356 if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
; then
357 confvars
="$confvars arm_vfp"
361 if test "$suggest" = "yes"; then
362 if test -f "/lib/ld-uClibc.so.0" ; then
363 echo "Perhaps you want ./configure --config-uClibc"
365 if test -f "/lib/ld-musl-$cpu.so.1"; then
366 echo "Perhaps you want ./configure --config-musl"
371 # if cross compiling, cannot launch a program, so make a static guess
373 ppc|mips|s390
) bigendian
=yes;;
377 if test "$bigendian" = "yes" ; then
378 confvars
="$confvars BIGENDIAN"
381 # a final configuration tuning
382 if ! echo "$cc" |
grep -q "tcc"; then
383 OPT1
="-Wdeclaration-after-statement -fno-strict-aliasing"
384 # we want -Wno- but gcc does not always reject unknown -Wno- options
385 OPT2
="-Wpointer-sign -Wsign-compare -Wunused-result"
386 if echo "$cc" |
grep -q "clang"; then
387 OPT1
="$OPT1 -fheinous-gnu-extensions"
388 OPT2
="$OPT2 -Wstring-plus-int"
390 $cc $OPT1 $OPT2 -o a.out
-c -xc - < /dev
/null
> cc_msg.txt
2>&1
391 for o
in $OPT1; do # enable these options
392 if ! grep -q -- $o cc_msg.txt
; then CFLAGS
="$CFLAGS $o"; fi
394 for o
in $OPT2; do # disable these options
395 if ! grep -q -- $o cc_msg.txt
; then CFLAGS
="$CFLAGS -Wno-${o#-W*}"; fi
399 rm -f cc_msg.txt a.out
402 fcho
() { if test -n "$2"; then echo "$1$2"; fi }
404 echo "Binary directory $bindir"
405 echo "TinyCC directory $tccdir"
406 echo "Library directory $libdir"
407 echo "Include directory $includedir"
408 echo "Manual directory $mandir"
409 echo "Info directory $infodir"
410 echo "Doc directory $docdir"
411 fcho
"Target root prefix " "$sysroot"
412 echo "Source path $source_path"
413 echo "C compiler $cc ($gcc_major.$gcc_minor)"
414 echo "Target OS $targetos"
416 fcho
"Triplet " "$triplet"
417 fcho
"Config " "${confvars# }"
418 echo "Creating config.mak and config.h"
420 cat >config.mak
<<EOF
421 # Automatically generated by configure - do not modify
423 bindir=\$(DESTDIR)$bindir
424 tccdir=\$(DESTDIR)$tccdir
425 libdir=\$(DESTDIR)$libdir
426 includedir=\$(DESTDIR)$includedir
427 mandir=\$(DESTDIR)$mandir
428 infodir=\$(DESTDIR)$infodir
429 docdir=\$(DESTDIR)$docdir
434 STRIP=$strip -s -R .comment -R .note
443 if test -n "$2"; then
444 echo "#ifndef $1" >> $TMPH
445 echo "# define $1 \"$2\"" >> $TMPH
446 echo "#endif" >> $TMPH
451 if test -n "$2"; then
452 echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak
457 if test -n "$2"; then
458 echo "NATIVE_DEFINES+=-D$1=$2" >> config.mak
462 echo "/* Automatically generated by configure - do not modify */" > $TMPH
464 print_inc CONFIG_SYSROOT
"$sysroot"
465 print_inc CONFIG_TCCDIR
"$tccdir"
466 print_mak CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
467 print_mak CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
468 print_mak CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
469 print_mak CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
470 print_mak CONFIG_LDDIR
"$tcc_lddir"
471 print_mak CONFIG_TRIPLET
"$triplet"
472 print_mak_int TCC_CPU_VERSION
"$cpuver"
474 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
475 echo "#define GCC_MINOR $gcc_minor" >> $TMPH
476 if test "$cpu" = "aarch64" ; then
477 echo "ARCH=arm64" >> config.mak
479 echo "ARCH=$cpu" >> config.mak
481 echo "TARGETOS=$targetos" >> config.mak
483 for v
in $confvars ; do
484 if test "${v%=*}" = "$v"; then
485 echo "CONFIG_$v=yes" >> config.mak
487 echo "CONFIG_$v" >> config.mak
491 version
=`head $source_path/VERSION`
492 echo "VERSION = $version" >> config.mak
493 echo "#define TCC_VERSION \"$version\"" >> $TMPH
494 echo "@set VERSION $version" > config.texi
496 if test "$source_path_used" = "yes" ; then
498 /*) echo "TOPSRC=$source_path";;
499 *) echo "TOPSRC=\$(TOP)/$source_path";;
502 echo 'TOPSRC=$(TOP)' >>config.mak
505 diff $TMPH config.h
>/dev
/null
2>&1
506 if test $?
-ne 0 ; then
509 echo "config.h is unchanged"
512 rm -f $TMPN* $CONFTEST
514 # ---------------------------------------------------------------------------
515 # build tree in object directory if source path is different from current one
522 test -d $dn || mkdir
-p $dn
525 *) while test $dn ; do
526 tgt
=..
/$tgt; dn
=${dn#${dn%%/*}}; dn=${dn#/}
533 ln -sfn $tgt $2 ||
( echo "ln failed. Using cp instead."; cp -f $1/$2 $2 )
536 if test "$source_path_used" = "yes" ; then
537 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile tests/pp/Makefile"
539 fn_makelink
$source_path $f
543 # ---------------------------------------------------------------------------