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
=""
54 MINGW32
*) mingw32
=yes;;
55 DragonFly
) noldl
=yes;;
63 # XXX: we assume an absolute path is given when launching configure,
64 # except in './configure' case.
65 source_path
=${0%configure}
66 source_path
=${source_path%/}
67 source_path_used
="yes"
68 if test -z "$source_path" -o "$source_path" = "." ; then
78 x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
107 "Power Macintosh"|ppc|ppc64
)
117 echo "Unsupported CPU: $cpu"
126 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
128 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
130 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
132 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
134 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
136 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
138 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
140 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
142 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
144 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
146 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
148 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
150 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
152 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2`
154 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2`
156 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2`
158 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2`
160 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
162 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
164 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
166 --extra-libs=*) extralibs
=${opt#--extra-libs=}
168 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
170 --enable-gprof) gprof
="yes"
172 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i686-pc-mingw32-" ; cpu
=x86
174 --enable-cygwin) mingw32
="yes" ; cygwin
="yes" ; cross_prefix
="mingw32-" ; cpu
=x86
176 --enable-tcc32-mingw) mingw32
="yes" ; cross_prefix
="i386-win-" ; cpu
=x86
; cc
=tcc
178 --enable-tcc64-mingw) mingw32
="yes" ; cross_prefix
="x86_64-win-" ; cpu
=x86_64
; cc
=tcc
180 --enable-cross) build_cross
="yes"
182 --enable-assert) enable_assert
="yes"
184 --disable-static) disable_static
="yes"
186 --disable-rpath) disable_rpath
="yes"
188 --strip-binaries) strip_binaries
="yes"
190 --with-libgcc) use_libgcc
="yes"
192 --with-selinux) have_selinux
="yes"
194 --help|
-h) show_help
="yes"
196 *) echo "configure: WARNING: unrecognized option $opt"
201 if test -z "$cpu" ; then
202 if test -n "$ARCH" ; then
210 # Checking for CFLAGS
211 if test -z "$CFLAGS"; then
212 CFLAGS
="-Wall -g -O2"
215 if test "$mingw32" = "yes" ; then
216 if test x
"$tccdir" = x
""; then
219 if test -z "$prefix" ; then
220 prefix
="C:/Program Files/${tccdir}"
222 if test -z "$sharedir" ; then
228 libdir
="${prefix}/lib"
229 docdir
="${sharedir}/doc"
230 mandir
="${sharedir}/man"
231 infodir
="${sharedir}/info"
235 if test -z "$prefix" ; then
238 if test -z "$sharedir" ; then
239 sharedir
="${prefix}/share"
241 if test x
"$execprefix" = x
""; then
242 execprefix
="${prefix}"
244 if test x
"$tccdir" = x
""; then
247 if test x
"$libdir" = x
""; then
248 libdir
="${execprefix}/lib"
249 if test -n "${tccdir}"; then
250 tccdir
="${libdir}/${tccdir}"
254 if test "$cpu" = "x86-64"; then
255 libdir
="${execprefix}/lib64"
258 tccdir
="${libdir}/${tccdir}"
260 if test x
"$bindir" = x
""; then
261 bindir
="${execprefix}/bin"
263 if test x
"$docdir" = x
""; then
264 docdir
="${sharedir}/doc/${tccdir}"
266 if test x
"$mandir" = x
""; then
267 mandir
="${sharedir}/man"
269 if test x
"$infodir" = x
""; then
270 infodir
="${sharedir}/info"
274 if test x
"$includedir" = x
""; then
275 includedir
="${prefix}/include"
278 if test x
"$show_help" = "xyes" ; then
280 Usage: configure [options]
281 Options: [defaults in brackets after descriptions]
284 --help print this message
285 --prefix=PREFIX install in PREFIX [$prefix]
286 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
288 --bindir=DIR user executables in DIR [EPREFIX/bin]
289 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
290 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
291 --includedir=DIR C header files in DIR [PREFIX/include]
292 --sharedir=DIR documentation root DIR [PREFIX/share]
293 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
294 --mandir=DIR man documentation in DIR [SHAREDIR/man]
295 --infodir=DIR info documentation in DIR [SHAREDIR/info]
297 Advanced options (experts only):
298 --source-path=PATH path of source code [$source_path]
299 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
300 --sysroot=PREFIX prepend PREFIX to library/include paths []
301 --cc=CC use C compiler CC [$cc]
302 --extra-cflags= specify compiler flags [$CFLAGS]
303 --extra-ldflags= specify linker options []
305 --strip-binaries strip symbol tables from resulting binaries
306 --disable-static make libtcc.so instead of libtcc.a
307 --disable-rpath disable use of -rpath with the above
308 --with-libgcc use libgcc_s.so.1 instead of libtcc1.a in dynamic link
309 --enable-tcc64-mingw build windows version on linux with x86_64-win-tcc
310 --enable-tcc32-mingw build windows version on linux with i386-win-tcc
311 --enable-mingw32 build windows version on linux with mingw32
312 --enable-cygwin build windows version on windows with cygwin
313 --enable-cross build cross compilers
314 --enable-assert enable debug assertions
315 --with-selinux use mmap for exec mem [needs writable /tmp]
316 --sysincludepaths=... specify system include paths, colon separated
317 --libpaths=... specify system library paths, colon separated
318 --crtprefix=... specify locations of crt?.o, colon separated
319 --elfinterp=... specify elf interpreter
321 #echo "NOTE: The object files are build at the place where configure is launched"
325 if test "$cc" != "tcc"; then
326 ar="${cross_prefix}${ar}"
328 cc
="${cross_prefix}${cc}"
329 strip
="${cross_prefix}${strip}"
331 CONFTEST
=.
/conftest
$EXESUF
333 if test -z "$cross_prefix" ; then
334 if ! $cc -o $CONFTEST $source_path/conftest.c
2>/dev
/null
; then
335 echo "configure: error: '$cc' failed to compile conftest.c."
337 bigendian
="$($CONFTEST bigendian)"
338 gcc_major
="$($CONFTEST version)"
339 gcc_minor
="$($CONFTEST minor)"
340 if test "$mingw32" = "no" ; then
341 triplet
="$($CONFTEST triplet)"
342 if test -f "/usr/lib/$triplet/crti.o" ; then
344 multiarch_triplet
="$triplet"
345 elif test "$cpu" != "x86" -a -f "/usr/lib64/crti.o" ; then
349 if test "$cpu" = "armv4l" ; then
350 if test "${triplet%eabihf}" != "$triplet" ; then
351 confvars
="$confvars arm_eabihf"
352 elif test "${triplet%eabi}" != "$triplet" ; then
353 confvars
="$confvars arm_eabi"
355 if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
; then
356 confvars
="$confvars arm_vfp"
360 # multiarch_triplet=${libc_dir#*/}
361 # multiarch_triplet=${multiarch_triplet%/}
362 # tcc_lddir="${libc_dir%%/*}"
363 # if test -n "$multiarch_triplet" ; then
364 # tcc_lddir="$tcc_lddir/$multiarch_triplet"
367 if test -f "/lib/ld-uClibc.so.0" ; then
368 confvars
="$confvars uClibc"
370 # gr: maybe for after the release:
371 # tcc_elfinterp="$(ldd $CONFTEST | grep 'ld.*.so' | sed 's,\s*\(\S\+\).*,\1,')"
372 # echo "elfinterp $tcc_elfinterp"
377 # if cross compiling, cannot launch a program, so make a static guess
379 powerpc|mips|s390
) bigendian
=yes;;
383 # a final configuration tuning
384 W_OPTIONS
="deprecated-declarations strict-aliasing pointer-sign sign-compare unused-result uninitialized"
385 for i
in $W_OPTIONS; do
386 O_PRESENT
="$($cc -v --help 2>&1 | grep -- -W$i)"
387 if test -n "$O_PRESENT"; then CFLAGS
="$CFLAGS -Wno-$i"; fi
389 F_OPTIONS
="strict-aliasing"
390 for i
in $F_OPTIONS; do
391 O_PRESENT
="$($cc -v --help 2>&1 | grep -- -f$i)"
392 if test -n "$O_PRESENT"; then CFLAGS
="$CFLAGS -fno-$i"; fi
394 if test -z "$tcc_lddir" -a "$cpu" = "x86-64"; then tcc_lddir
="lib64"; fi
396 echo "Binary directory $bindir"
397 echo "TinyCC directory $tccdir"
398 echo "Library directory $libdir"
399 echo "Include directory $includedir"
400 echo "Manual directory $mandir"
401 echo "Info directory $infodir"
402 echo "Doc directory $docdir"
403 echo "Target root prefix $sysroot"
404 echo "Source path $source_path"
405 echo "C compiler $cc"
406 echo "cross compilers $build_cross"
407 if test "$build_cross" = "no"; then
408 echo "Target CPU $cpu"
410 echo "Target OS $targetos"
411 echo "Big Endian $bigendian"
412 echo "gprof enabled $gprof"
413 echo "use libgcc $use_libgcc"
415 echo "Creating config.mak and config.h"
417 cat >config.mak
<<EOF
418 # Automatically generated by configure - do not modify
420 bindir=\$(DESTDIR)$bindir
421 tccdir=\$(DESTDIR)$tccdir
422 libdir=\$(DESTDIR)$libdir
424 includedir=\$(DESTDIR)$includedir
425 mandir=\$(DESTDIR)$mandir
426 infodir=\$(DESTDIR)$infodir
427 docdir=\$(DESTDIR)$docdir
433 STRIP=$strip -s -R .comment -R .note
439 if test "$mingw32" = "yes"; then
440 cat >>config.mak
<<EOF
447 if test -n "$2"; then
448 echo "#ifndef $1" >> $TMPH
449 echo "# define $1 \"$2\"" >> $TMPH
450 echo "#endif" >> $TMPH
454 if test -n "$2"; then
455 echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak
459 echo "/* Automatically generated by configure - do not modify */" > $TMPH
461 print_inc CONFIG_SYSROOT
"$sysroot"
462 print_inc CONFIG_TCCDIR
"$tccdir"
463 print_inc CONFIG_LDDIR
"$tcc_lddir"
464 print_mak CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
465 print_mak CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
466 print_mak CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
467 print_mak CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
468 print_mak CONFIG_MULTIARCHDIR
"$multiarch_triplet"
470 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
471 echo "#define GCC_MINOR $gcc_minor" >> $TMPH
473 if test "$cpu" = "x86" ; then
474 echo "ARCH=i386" >> config.mak
475 elif test "$cpu" = "x86-64" ; then
476 echo "ARCH=x86-64" >> config.mak
477 elif test "$cpu" = "armv4l" ; then
478 echo "ARCH=arm" >> config.mak
479 echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH
480 elif test "$cpu" = "aarch64" ; then
481 echo "ARCH=arm64" >> config.mak
482 elif test "$cpu" = "powerpc" ; then
483 echo "ARCH=ppc" >> config.mak
484 elif test "$cpu" = "mips" ; then
485 echo "ARCH=mips" >> config.mak
486 elif test "$cpu" = "s390" ; then
487 echo "ARCH=s390" >> config.mak
488 elif test "$cpu" = "alpha" ; then
489 echo "ARCH=alpha" >> config.mak
491 echo "Unsupported CPU"
495 echo "TARGETOS=$targetos" >> config.mak
497 for v
in $confvars ; do
498 echo "CONFIG_$v=yes" >> config.mak
500 if test "$noldl" = "yes" ; then
501 echo "CONFIG_NOLDL=yes" >> config.mak
503 if test "$mingw32" = "yes" ; then
504 echo "CONFIG_WIN32=yes" >> config.mak
505 echo "#define CONFIG_WIN32 1" >> $TMPH
507 if test "$cygwin" = "yes" ; then
508 echo "#ifndef _WIN32" >> $TMPH
509 echo "# define _WIN32" >> $TMPH
510 echo "#endif" >> $TMPH
511 echo "AR=ar" >> config.mak
513 if test "$bigendian" = "yes" ; then
514 echo "WORDS_BIGENDIAN=yes" >> config.mak
515 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
517 if test "$gprof" = "yes" ; then
518 echo "TARGET_GPROF=yes" >> config.mak
519 echo "#define HAVE_GPROF 1" >> $TMPH
521 if test "$build_cross" = "yes" ; then
522 echo "CONFIG_CROSS=yes" >> config.mak
524 if test "$disable_static" = "yes" ; then
525 echo "DISABLE_STATIC=yes" >> config.mak
527 if test "$disable_rpath" = "yes" ; then
528 echo "DISABLE_RPATH=yes" >> config.mak
530 if test "$strip_binaries" = "yes" ; then
531 echo "STRIP_BINARIES=yes" >> config.mak
533 if test "$use_libgcc" = "yes" ; then
534 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
535 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
537 if test "$have_selinux" = "yes" ; then
538 echo "#define HAVE_SELINUX" >> $TMPH
539 echo "HAVE_SELINUX=yes" >> config.mak
541 if test "$enable_assert" = "yes" ; then
542 echo "#define CONFIG_TCC_ASSERT" >> $TMPH
545 version
=`head $source_path/VERSION`
546 echo "VERSION=$version" >>config.mak
547 echo "#define TCC_VERSION \"$version\"" >> $TMPH
548 echo "@set VERSION $version" > config.texi
549 echo "SRC_PATH=$source_path" >>config.mak
551 if test "$source_path_used" = "yes" ; then
553 /*) echo "top_srcdir=$source_path";;
554 *) echo "top_srcdir=\$(TOP)/$source_path";;
557 echo 'top_srcdir=$(TOP)' >>config.mak
559 echo 'top_builddir=$(TOP)' >>config.mak
561 diff $TMPH config.h
>/dev
/null
2>&1
562 if test $?
-ne 0 ; then
565 echo "config.h is unchanged"
568 rm -f $TMPN* $CONFTEST
570 # ---------------------------------------------------------------------------
571 # build tree in object directory if source path is different from current one
578 test -d $dn || mkdir
-p $dn
581 *) while test $dn ; do
582 tgt
=..
/$tgt; dn
=${dn#${dn%%/*}}; dn=${dn#/}
591 if test "$source_path_used" = "yes" ; then
592 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile"
594 fn_makelink
$source_path $f
598 # ---------------------------------------------------------------------------