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 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
168 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
170 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
172 --extra-libs=*) extralibs
=${opt#--extra-libs=}
174 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
176 --enable-gprof) gprof
="yes"
178 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i686-pc-mingw32-" ; cpu
=x86
; targetos
=Windows
;
180 --enable-cygwin) mingw32
="yes" ; cygwin
="yes" ; cross_prefix
="mingw32-" ; cpu
=x86
; targetos
=Windows
;
182 --enable-tcc32-mingw) mingw32
="yes" ; cross_prefix
="i386-win-" ; cpu
=x86
; cc
=tcc
; targetos
=Windows
;
184 --enable-tcc64-mingw) mingw32
="yes" ; cross_prefix
="x86_64-win-" ; cpu
=x86_64
; cc
=tcc
; targetos
=Windows
;
186 --enable-cross) build_cross
="yes"
188 --enable-assert) enable_assert
="yes"
190 --disable-static) disable_static
="yes"
192 --disable-rpath) disable_rpath
="yes"
194 --strip-binaries) strip_binaries
="yes"
196 --with-libgcc) use_libgcc
="yes"
198 --with-selinux) have_selinux
="yes"
200 --help|
-h) show_help
="yes"
202 *) echo "configure: WARNING: unrecognized option $opt"
207 if test -z "$cpu" ; then
208 if test -n "$ARCH" ; then
216 # Checking for CFLAGS
217 if test -z "$CFLAGS"; then
218 CFLAGS
="-Wall -g -O0"
221 if test "$mingw32" = "yes" ; then
222 if test x
"$tccdir" = x
""; then
225 if test -z "$prefix" ; then
226 prefix
="C:/Program Files/${tccdir}"
228 if test -z "$sharedir" ; then
234 libdir
="${prefix}/lib"
235 docdir
="${sharedir}/doc"
236 mandir
="${sharedir}/man"
237 infodir
="${sharedir}/info"
241 if test -z "$prefix" ; then
244 if test -z "$sharedir" ; then
245 sharedir
="${prefix}/share"
247 if test x
"$execprefix" = x
""; then
248 execprefix
="${prefix}"
250 if test x
"$tccdir" = x
""; then
253 if test x
"$libdir" = x
""; then
254 libdir
="${execprefix}/lib"
255 if test -n "${tccdir}"; then
256 tccdir
="${libdir}/${tccdir}"
260 if test "$cpu" = "x86-64"; then
261 libdir
="${execprefix}/lib64"
264 tccdir
="${libdir}/${tccdir}"
266 if test x
"$bindir" = x
""; then
267 bindir
="${execprefix}/bin"
269 if test x
"$docdir" = x
""; then
270 docdir
="${sharedir}/doc/${tccdir}"
272 if test x
"$mandir" = x
""; then
273 mandir
="${sharedir}/man"
275 if test x
"$infodir" = x
""; then
276 infodir
="${sharedir}/info"
280 if test x
"$includedir" = x
""; then
281 includedir
="${prefix}/include"
284 if test x
"$show_help" = "xyes" ; then
286 Usage: configure [options]
287 Options: [defaults in brackets after descriptions]
290 --help print this message
291 --prefix=PREFIX install in PREFIX [$prefix]
292 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
294 --bindir=DIR user executables in DIR [EPREFIX/bin]
295 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
296 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
297 --includedir=DIR C header files in DIR [PREFIX/include]
298 --sharedir=DIR documentation root DIR [PREFIX/share]
299 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
300 --mandir=DIR man documentation in DIR [SHAREDIR/man]
301 --infodir=DIR info documentation in DIR [SHAREDIR/info]
303 Advanced options (experts only):
304 --source-path=PATH path of source code [$source_path]
305 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
306 --sysroot=PREFIX prepend PREFIX to library/include paths []
307 --cc=CC use C compiler CC [$cc]
308 --extra-cflags= specify compiler flags [$CFLAGS]
309 --extra-ldflags= specify linker options []
311 --strip-binaries strip symbol tables from resulting binaries
312 --disable-static make libtcc.so instead of libtcc.a
313 --disable-rpath disable use of -rpath with the above
314 --with-libgcc use libgcc_s.so.1 instead of libtcc1.a in dynamic link
315 --enable-tcc64-mingw build windows version on linux with x86_64-win-tcc
316 --enable-tcc32-mingw build windows version on linux with i386-win-tcc
317 --enable-mingw32 build windows version on linux with mingw32
318 --enable-cygwin build windows version on windows with cygwin
319 --enable-cross build cross compilers
320 --enable-assert enable debug assertions
321 --with-selinux use mmap for exec mem [needs writable /tmp]
322 --sysincludepaths=... specify system include paths, colon separated
323 --libpaths=... specify system library paths, colon separated
324 --crtprefix=... specify locations of crt?.o, colon separated
325 --elfinterp=... specify elf interpreter
327 #echo "NOTE: The object files are build at the place where configure is launched"
331 if test "$cc" != "tcc"; then
332 ar="${cross_prefix}${ar}"
334 cc
="${cross_prefix}${cc}"
335 strip
="${cross_prefix}${strip}"
337 CONFTEST
=.
/conftest
$EXESUF
339 if test -z "$cross_prefix" ; then
340 if ! $cc -o $CONFTEST $source_path/conftest.c
2>/dev
/null
; then
341 echo "configure: error: '$cc' failed to compile conftest.c."
343 bigendian
="$($CONFTEST bigendian)"
344 gcc_major
="$($CONFTEST version)"
345 gcc_minor
="$($CONFTEST minor)"
346 if test "$mingw32" = "no" ; then
347 triplet
="$($CONFTEST triplet)"
348 if test -f "/usr/lib/$triplet/crti.o" ; then
350 multiarch_triplet
="$triplet"
351 elif test "$cpu" != "x86" -a -f "/usr/lib64/crti.o" ; then
355 if test "$cpu" = "armv4l" ; then
356 if test "${triplet%eabihf}" != "$triplet" ; then
357 confvars
="$confvars arm_eabihf"
358 elif test "${triplet%eabi}" != "$triplet" ; then
359 confvars
="$confvars arm_eabi"
361 if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
; then
362 confvars
="$confvars arm_vfp"
366 # multiarch_triplet=${libc_dir#*/}
367 # multiarch_triplet=${multiarch_triplet%/}
368 # tcc_lddir="${libc_dir%%/*}"
369 # if test -n "$multiarch_triplet" ; then
370 # tcc_lddir="$tcc_lddir/$multiarch_triplet"
373 if test -f "/lib/ld-uClibc.so.0" ; then
374 confvars
="$confvars uClibc"
376 # gr: maybe for after the release:
377 # tcc_elfinterp="$(ldd $CONFTEST | grep 'ld.*.so' | sed 's,\s*\(\S\+\).*,\1,')"
378 # echo "elfinterp $tcc_elfinterp"
383 # if cross compiling, cannot launch a program, so make a static guess
385 powerpc|mips|s390
) bigendian
=yes;;
389 # a final configuration tuning
390 W_OPTIONS
="declaration-after-statement"
391 for i
in $W_OPTIONS; do
392 O_PRESENT
="$($cc -v --help 2>&1 | grep -- -W$i)"
393 if test -n "$O_PRESENT"; then CFLAGS
="$CFLAGS -W$i"; fi
395 W_OPTIONS
="deprecated-declarations strict-aliasing pointer-sign sign-compare unused-result uninitialized"
396 for i
in $W_OPTIONS; do
397 O_PRESENT
="$($cc -v --help 2>&1 | grep -- -W$i)"
398 if test -n "$O_PRESENT"; then CFLAGS
="$CFLAGS -Wno-$i"; fi
400 F_OPTIONS
="strict-aliasing"
401 for i
in $F_OPTIONS; do
402 O_PRESENT
="$($cc -v --help 2>&1 | grep -- -f$i)"
403 if test -n "$O_PRESENT"; then CFLAGS
="$CFLAGS -fno-$i"; fi
405 if test -z "$tcc_lddir" -a "$cpu" = "x86-64"; then tcc_lddir
="lib64"; fi
407 echo "Binary directory $bindir"
408 echo "TinyCC directory $tccdir"
409 echo "Library directory $libdir"
410 echo "Include directory $includedir"
411 echo "Manual directory $mandir"
412 echo "Info directory $infodir"
413 echo "Doc directory $docdir"
414 echo "Target root prefix $sysroot"
415 echo "Source path $source_path"
416 echo "C compiler $cc"
417 echo "cross compilers $build_cross"
418 if test "$build_cross" = "no"; then
419 echo "Target CPU $cpu"
421 echo "Host OS $host_os"
422 echo "Target OS $targetos"
423 echo "Big Endian $bigendian"
424 echo "gprof enabled $gprof"
425 echo "use libgcc $use_libgcc"
427 echo "Creating config.mak and config.h"
429 cat >config.mak
<<EOF
430 # Automatically generated by configure - do not modify
432 bindir=\$(DESTDIR)$bindir
433 tccdir=\$(DESTDIR)$tccdir
434 libdir=\$(DESTDIR)$libdir
436 includedir=\$(DESTDIR)$includedir
437 mandir=\$(DESTDIR)$mandir
438 infodir=\$(DESTDIR)$infodir
439 docdir=\$(DESTDIR)$docdir
445 STRIP=$strip -s -R .comment -R .note
452 if test "$mingw32" = "yes" -a "$host_os" != "Windows" ; then
453 cat >>config.mak
<<EOF
460 if test -n "$2"; then
461 echo "#ifndef $1" >> $TMPH
462 echo "# define $1 \"$2\"" >> $TMPH
463 echo "#endif" >> $TMPH
467 if test -n "$2"; then
468 echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak
472 echo "/* Automatically generated by configure - do not modify */" > $TMPH
474 print_inc CONFIG_SYSROOT
"$sysroot"
475 print_inc CONFIG_TCCDIR
"$tccdir"
476 if test "$build_cross" = "no"; then
477 print_inc CONFIG_LDDIR
"$tcc_lddir"
479 print_mak CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
480 print_mak CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
481 print_mak CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
482 print_mak CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
483 print_mak CONFIG_MULTIARCHDIR
"$multiarch_triplet"
485 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
486 echo "#define GCC_MINOR $gcc_minor" >> $TMPH
488 if test "$cpu" = "x86" ; then
489 echo "ARCH=i386" >> config.mak
490 elif test "$cpu" = "x86-64" ; then
491 echo "ARCH=x86-64" >> config.mak
492 elif test "$cpu" = "armv4l" ; then
493 echo "ARCH=arm" >> config.mak
494 echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH
495 elif test "$cpu" = "aarch64" ; then
496 echo "ARCH=arm64" >> config.mak
497 elif test "$cpu" = "powerpc" ; then
498 echo "ARCH=ppc" >> config.mak
499 elif test "$cpu" = "mips" ; then
500 echo "ARCH=mips" >> config.mak
501 elif test "$cpu" = "s390" ; then
502 echo "ARCH=s390" >> config.mak
503 elif test "$cpu" = "alpha" ; then
504 echo "ARCH=alpha" >> config.mak
506 echo "Unsupported CPU"
510 echo "TARGETOS=$targetos" >> config.mak
512 for v
in $confvars ; do
513 echo "CONFIG_$v=yes" >> config.mak
515 if test "$noldl" = "yes" ; then
516 echo "CONFIG_NOLDL=yes" >> config.mak
518 if test "$mingw32" = "yes" ; then
519 echo "CONFIG_WIN32=yes" >> config.mak
520 echo "#define CONFIG_WIN32 1" >> $TMPH
522 if test "$cygwin" = "yes" ; then
523 echo "#ifndef _WIN32" >> $TMPH
524 echo "# define _WIN32" >> $TMPH
525 echo "#endif" >> $TMPH
526 echo "AR=ar" >> config.mak
528 if test "$bigendian" = "yes" ; then
529 echo "WORDS_BIGENDIAN=yes" >> config.mak
530 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
532 if test "$gprof" = "yes" ; then
533 echo "TARGET_GPROF=yes" >> config.mak
534 echo "#define HAVE_GPROF 1" >> $TMPH
536 if test "$build_cross" = "yes" ; then
537 echo "CONFIG_CROSS=yes" >> config.mak
539 if test "$disable_static" = "yes" ; then
540 echo "DISABLE_STATIC=yes" >> config.mak
542 if test "$disable_rpath" = "yes" ; then
543 echo "DISABLE_RPATH=yes" >> config.mak
545 if test "$strip_binaries" = "yes" ; then
546 echo "STRIP_BINARIES=yes" >> config.mak
548 if test "$use_libgcc" = "yes" ; then
549 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
550 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
552 if test "$have_selinux" = "yes" ; then
553 echo "#define HAVE_SELINUX" >> $TMPH
554 echo "HAVE_SELINUX=yes" >> config.mak
556 if test "$enable_assert" = "yes" ; then
557 echo "#define CONFIG_TCC_ASSERT" >> $TMPH
560 version
=`head $source_path/VERSION`
561 echo "VERSION=$version" >>config.mak
562 echo "#define TCC_VERSION \"$version\"" >> $TMPH
563 echo "@set VERSION $version" > config.texi
564 echo "SRC_PATH=$source_path" >>config.mak
566 if test "$source_path_used" = "yes" ; then
568 /*) echo "top_srcdir=$source_path";;
569 *) echo "top_srcdir=\$(TOP)/$source_path";;
572 echo 'top_srcdir=$(TOP)' >>config.mak
574 echo 'top_builddir=$(TOP)' >>config.mak
576 diff $TMPH config.h
>/dev
/null
2>&1
577 if test $?
-ne 0 ; then
580 echo "config.h is unchanged"
583 rm -f $TMPN* $CONFTEST
585 # ---------------------------------------------------------------------------
586 # build tree in object directory if source path is different from current one
593 test -d $dn || mkdir
-p $dn
596 *) while test $dn ; do
597 tgt
=..
/$tgt; dn
=${dn#${dn%%/*}}; dn=${dn#/}
606 if test "$source_path_used" = "yes" ; then
607 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile"
609 fn_makelink
$source_path $f
613 # ---------------------------------------------------------------------------