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"
43 tcc_sysincludepaths
=""
53 MINGW32
*) host_os
=Windows
; ;;
60 MINGW32
*) mingw32
=yes; host_os
=Windows
; ;;
61 DragonFly
) noldl
=yes;;
69 # XXX: we assume an absolute path is given when launching configure,
70 # except in './configure' case.
71 source_path
=${0%configure}
72 source_path
=${source_path%/}
73 source_path_used
="yes"
74 if test -z "$source_path" -o "$source_path" = "." ; then
84 x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
113 "Power Macintosh"|ppc|ppc64
)
123 echo "Unsupported CPU: $cpu"
132 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
134 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
136 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
138 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
140 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
142 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
144 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
146 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
148 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
150 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
152 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
154 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
156 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
158 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2`
160 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2`
162 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2`
164 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2`
166 --ar=*) ar=`echo $opt | cut -d '=' -f 2`
168 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
170 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
172 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
174 --extra-libs=*) extralibs
=${opt#--extra-libs=}
176 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
178 --enable-gprof) gprof
="yes"
180 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i686-pc-mingw32-" ; cpu
=x86
; targetos
=Windows
;
182 --enable-cygwin) mingw32
="yes" ; cygwin
="yes" ; cross_prefix
="mingw32-" ; cpu
=x86
; targetos
=Windows
;
184 --enable-tcc32-mingw) mingw32
="yes" ; cross_prefix
="i386-win-" ; cpu
=x86
; cc
=tcc
; targetos
=Windows
;
186 --enable-tcc64-mingw) mingw32
="yes" ; cross_prefix
="x86_64-win-" ; cpu
=x86_64
; cc
=tcc
; targetos
=Windows
;
188 --enable-cross) build_cross
="yes"
190 --enable-assert) enable_assert
="yes"
192 --disable-static) disable_static
="yes"
194 --disable-rpath) disable_rpath
="yes"
196 --strip-binaries) strip_binaries
="yes"
198 --with-libgcc) use_libgcc
="yes"
200 --with-selinux) have_selinux
="yes"
202 --help|
-h) show_help
="yes"
204 *) echo "configure: WARNING: unrecognized option $opt"
209 if test -z "$cpu" ; then
210 if test -n "$ARCH" ; then
218 # Checking for CFLAGS
219 if test -z "$CFLAGS"; then
220 CFLAGS
="-Wall -g -O0"
223 if test "$mingw32" = "yes" ; then
224 if test x
"$tccdir" = x
""; then
227 if test -z "$prefix" ; then
228 prefix
="C:/Program Files/${tccdir}"
230 if test -z "$sharedir" ; then
236 libdir
="${prefix}/lib"
237 docdir
="${sharedir}/doc"
238 mandir
="${sharedir}/man"
239 infodir
="${sharedir}/info"
243 if test -z "$prefix" ; then
246 if test -z "$sharedir" ; then
247 sharedir
="${prefix}/share"
249 if test x
"$execprefix" = x
""; then
250 execprefix
="${prefix}"
252 if test x
"$tccdir" = x
""; then
255 if test x
"$libdir" = x
""; then
256 libdir
="${execprefix}/lib"
257 if test -n "${tccdir}"; then
258 tccdir
="${libdir}/${tccdir}"
262 if test "$cpu" = "x86-64"; then
263 libdir
="${execprefix}/lib64"
266 tccdir
="${libdir}/${tccdir}"
268 if test x
"$bindir" = x
""; then
269 bindir
="${execprefix}/bin"
271 if test x
"$docdir" = x
""; then
272 docdir
="${sharedir}/doc"
274 if test x
"$mandir" = x
""; then
275 mandir
="${sharedir}/man"
277 if test x
"$infodir" = x
""; then
278 infodir
="${sharedir}/info"
282 if test x
"$includedir" = x
""; then
283 includedir
="${prefix}/include"
286 if test x
"$show_help" = "xyes" ; then
288 Usage: configure [options]
289 Options: [defaults in brackets after descriptions]
292 --help print this message
293 --prefix=PREFIX install in PREFIX [$prefix]
294 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
296 --bindir=DIR user executables in DIR [EPREFIX/bin]
297 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
298 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
299 --includedir=DIR C header files in DIR [PREFIX/include]
300 --sharedir=DIR documentation root DIR [PREFIX/share]
301 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
302 --mandir=DIR man documentation in DIR [SHAREDIR/man]
303 --infodir=DIR info documentation in DIR [SHAREDIR/info]
305 Advanced options (experts only):
306 --source-path=PATH path of source code [$source_path]
307 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
308 --sysroot=PREFIX prepend PREFIX to library/include paths []
309 --cc=CC use C compiler CC [$cc]
310 --ar=AR create archives using AR [$ar]
311 --extra-cflags= specify compiler flags [$CFLAGS]
312 --extra-ldflags= specify linker options []
314 --strip-binaries strip symbol tables from resulting binaries
315 --disable-static make libtcc.so instead of libtcc.a
316 --disable-rpath disable use of -rpath with the above
317 --with-libgcc use libgcc_s.so.1 instead of libtcc1.a in dynamic link
318 --enable-tcc64-mingw build windows version on linux with x86_64-win-tcc
319 --enable-tcc32-mingw build windows version on linux with i386-win-tcc
320 --enable-mingw32 build windows version on linux with mingw32
321 --enable-cygwin build windows version on windows with cygwin
322 --enable-cross build cross compilers
323 --enable-assert enable debug assertions
324 --with-selinux use mmap for exec mem [needs writable /tmp]
325 --sysincludepaths=... specify system include paths, colon separated
326 --libpaths=... specify system library paths, colon separated
327 --crtprefix=... specify locations of crt?.o, colon separated
328 --elfinterp=... specify elf interpreter
330 #echo "NOTE: The object files are build at the place where configure is launched"
334 if test "$cc" != "tcc"; then
335 ar="${cross_prefix}${ar}"
337 cc
="${cross_prefix}${cc}"
338 strip
="${cross_prefix}${strip}"
340 CONFTEST
=.
/conftest
$EXESUF
342 if test -z "$cross_prefix" ; then
343 if ! $cc -o $CONFTEST $source_path/conftest.c
2>/dev
/null
; then
344 echo "configure: error: '$cc' failed to compile conftest.c."
346 bigendian
="$($CONFTEST bigendian)"
347 gcc_major
="$($CONFTEST version)"
348 gcc_minor
="$($CONFTEST minor)"
349 if test "$mingw32" = "no" ; then
350 triplet
="$($CONFTEST triplet)"
351 if test -f "/usr/lib/$triplet/crti.o" ; then
353 multiarch_triplet
="$triplet"
354 elif test "$cpu" != "x86" -a -f "/usr/lib64/crti.o" ; then
358 if test "$cpu" = "armv4l" ; then
359 if test "${triplet%eabihf}" != "$triplet" ; then
360 confvars
="$confvars arm_eabihf"
361 elif test "${triplet%eabi}" != "$triplet" ; then
362 confvars
="$confvars arm_eabi"
364 if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
; then
365 confvars
="$confvars arm_vfp"
369 # multiarch_triplet=${libc_dir#*/}
370 # multiarch_triplet=${multiarch_triplet%/}
371 # tcc_lddir="${libc_dir%%/*}"
372 # if test -n "$multiarch_triplet" ; then
373 # tcc_lddir="$tcc_lddir/$multiarch_triplet"
376 if test -f "/lib/ld-uClibc.so.0" ; then
377 confvars
="$confvars uClibc"
379 # gr: maybe for after the release:
380 # tcc_elfinterp="$(ldd $CONFTEST | grep 'ld.*.so' | sed 's,\s*\(\S\+\).*,\1,')"
381 # echo "elfinterp $tcc_elfinterp"
386 # if cross compiling, cannot launch a program, so make a static guess
388 powerpc|mips|s390
) bigendian
=yes;;
392 # a final configuration tuning
393 W_OPTIONS
="declaration-after-statement"
394 for i
in $W_OPTIONS; do
395 O_PRESENT
="$($cc -v --help 2>&1 | grep -- -W$i)"
396 if test -n "$O_PRESENT"; then CFLAGS
="$CFLAGS -W$i"; fi
398 W_OPTIONS
="deprecated-declarations strict-aliasing pointer-sign sign-compare unused-result uninitialized"
399 for i
in $W_OPTIONS; do
400 O_PRESENT
="$($cc -v --help 2>&1 | grep -- -W$i)"
401 if test -n "$O_PRESENT"; then CFLAGS
="$CFLAGS -Wno-$i"; fi
403 F_OPTIONS
="strict-aliasing"
404 for i
in $F_OPTIONS; do
405 O_PRESENT
="$($cc -v --help 2>&1 | grep -- -f$i)"
406 if test -n "$O_PRESENT"; then CFLAGS
="$CFLAGS -fno-$i"; fi
408 if test -z "$tcc_lddir" -a "$cpu" = "x86-64"; then tcc_lddir
="lib64"; fi
410 echo "Binary directory $bindir"
411 echo "TinyCC directory $tccdir"
412 echo "Library directory $libdir"
413 echo "Include directory $includedir"
414 echo "Manual directory $mandir"
415 echo "Info directory $infodir"
416 echo "Doc directory $docdir"
417 echo "Target root prefix $sysroot"
418 echo "Source path $source_path"
419 echo "C compiler $cc"
421 echo "cross compilers $build_cross"
422 if test "$build_cross" = "no"; then
423 echo "Target CPU $cpu"
425 echo "Host OS $host_os"
426 echo "Target OS $targetos"
427 echo "Big Endian $bigendian"
428 echo "gprof enabled $gprof"
429 echo "use libgcc $use_libgcc"
431 echo "Creating config.mak and config.h"
433 cat >config.mak
<<EOF
434 # Automatically generated by configure - do not modify
436 bindir=\$(DESTDIR)$bindir
437 tccdir=\$(DESTDIR)$tccdir
438 libdir=\$(DESTDIR)$libdir
440 includedir=\$(DESTDIR)$includedir
441 mandir=\$(DESTDIR)$mandir
442 infodir=\$(DESTDIR)$infodir
443 docdir=\$(DESTDIR)$docdir
449 STRIP=$strip -s -R .comment -R .note
456 if test "$mingw32" = "yes" -a "$host_os" != "Windows" ; then
457 cat >>config.mak
<<EOF
464 if test -n "$2"; then
465 echo "#ifndef $1" >> $TMPH
466 echo "# define $1 \"$2\"" >> $TMPH
467 echo "#endif" >> $TMPH
471 if test -n "$2"; then
472 echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak
476 echo "/* Automatically generated by configure - do not modify */" > $TMPH
478 print_inc CONFIG_SYSROOT
"$sysroot"
479 print_inc CONFIG_TCCDIR
"$tccdir"
480 if test "$build_cross" = "no"; then
481 print_inc CONFIG_LDDIR
"$tcc_lddir"
483 print_mak CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
484 print_mak CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
485 print_mak CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
486 print_mak CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
487 print_mak CONFIG_MULTIARCHDIR
"$multiarch_triplet"
489 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
490 echo "#define GCC_MINOR $gcc_minor" >> $TMPH
492 if test "$cpu" = "x86" ; then
493 echo "ARCH=i386" >> config.mak
494 elif test "$cpu" = "x86-64" ; then
495 echo "ARCH=x86-64" >> config.mak
496 elif test "$cpu" = "armv4l" ; then
497 echo "ARCH=arm" >> config.mak
498 echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH
499 elif test "$cpu" = "aarch64" ; then
500 echo "ARCH=arm64" >> config.mak
501 elif test "$cpu" = "powerpc" ; then
502 echo "ARCH=ppc" >> config.mak
503 elif test "$cpu" = "mips" ; then
504 echo "ARCH=mips" >> config.mak
505 elif test "$cpu" = "s390" ; then
506 echo "ARCH=s390" >> config.mak
507 elif test "$cpu" = "alpha" ; then
508 echo "ARCH=alpha" >> config.mak
510 echo "Unsupported CPU"
514 echo "TARGETOS=$targetos" >> config.mak
516 for v
in $confvars ; do
517 echo "CONFIG_$v=yes" >> config.mak
519 if test "$noldl" = "yes" ; then
520 echo "CONFIG_NOLDL=yes" >> config.mak
522 if test "$mingw32" = "yes" ; then
523 if test "$cpu" = "x86-64"; then
524 echo "CONFIG_WIN64=yes" >> config.mak
525 echo "#define CONFIG_WIN64 1" >> $TMPH
527 echo "CONFIG_WIN32=yes" >> config.mak
528 echo "#define CONFIG_WIN32 1" >> $TMPH
531 if test "$cygwin" = "yes" ; then
532 echo "#ifndef _WIN32" >> $TMPH
533 echo "# define _WIN32" >> $TMPH
534 echo "#endif" >> $TMPH
535 echo "AR=ar" >> config.mak
537 if test "$bigendian" = "yes" ; then
538 echo "WORDS_BIGENDIAN=yes" >> config.mak
539 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
541 if test "$gprof" = "yes" ; then
542 echo "TARGET_GPROF=yes" >> config.mak
543 echo "#define HAVE_GPROF 1" >> $TMPH
545 if test "$build_cross" = "yes" ; then
546 echo "CONFIG_CROSS=yes" >> config.mak
548 if test "$disable_static" = "yes" ; then
549 echo "DISABLE_STATIC=yes" >> config.mak
551 if test "$disable_rpath" = "yes" ; then
552 echo "DISABLE_RPATH=yes" >> config.mak
554 if test "$strip_binaries" = "yes" ; then
555 echo "STRIP_BINARIES=yes" >> config.mak
557 if test "$use_libgcc" = "yes" ; then
558 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
559 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
561 if test "$have_selinux" = "yes" ; then
562 echo "#define HAVE_SELINUX" >> $TMPH
563 echo "HAVE_SELINUX=yes" >> config.mak
565 if test "$enable_assert" = "yes" ; then
566 echo "#define CONFIG_TCC_ASSERT" >> $TMPH
569 version
=`head $source_path/VERSION`
570 echo "VERSION=$version" >>config.mak
571 echo "#define TCC_VERSION \"$version\"" >> $TMPH
572 echo "@set VERSION $version" > config.texi
573 echo "SRC_PATH=$source_path" >>config.mak
575 if test "$source_path_used" = "yes" ; then
577 /*) echo "top_srcdir=$source_path";;
578 *) echo "top_srcdir=\$(TOP)/$source_path";;
581 echo 'top_srcdir=$(TOP)' >>config.mak
583 echo 'top_builddir=$(TOP)' >>config.mak
585 diff $TMPH config.h
>/dev
/null
2>&1
586 if test $?
-ne 0 ; then
589 echo "config.h is unchanged"
592 rm -f $TMPN* $CONFTEST
594 # ---------------------------------------------------------------------------
595 # build tree in object directory if source path is different from current one
599 SRCDIR
=$
(realpath
$1)
602 if test ! -d "$DIR"; then
605 ln -s $SRCDIR/$DIR/$FILE $DIR/
608 if test "$source_path_used" = "yes" ; then
609 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/* tests/pp/* tests/exsymtab/*"
611 fn_makelink
$source_path $f
615 # ---------------------------------------------------------------------------