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
=""
55 MINGW32
*) mingw32
=yes; host_os
=Windows
; ;;
56 DragonFly
) noldl
=yes;;
64 # XXX: we assume an absolute path is given when launching configure,
65 # except in './configure' case.
66 source_path
=${0%configure}
67 source_path
=${source_path%/}
68 source_path_used
="yes"
69 if test -z "$source_path" -o "$source_path" = "." ; then
79 x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
108 "Power Macintosh"|ppc|ppc64
)
118 echo "Unsupported CPU: $cpu"
127 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
129 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
131 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
133 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
135 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
137 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
139 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
141 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
143 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
145 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
147 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
149 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
151 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
153 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2`
155 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2`
157 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2`
159 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2`
161 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
163 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
165 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
167 --extra-libs=*) extralibs
=${opt#--extra-libs=}
169 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
171 --enable-gprof) gprof
="yes"
173 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i686-pc-mingw32-" ; cpu
=x86
175 --enable-cygwin) mingw32
="yes" ; cygwin
="yes" ; cross_prefix
="mingw32-" ; cpu
=x86
177 --enable-tcc32-mingw) mingw32
="yes" ; cross_prefix
="i386-win-" ; cpu
=x86
; cc
=tcc
179 --enable-tcc64-mingw) mingw32
="yes" ; cross_prefix
="x86_64-win-" ; cpu
=x86_64
; cc
=tcc
181 --enable-cross) build_cross
="yes"
183 --enable-assert) enable_assert
="yes"
185 --disable-static) disable_static
="yes"
187 --disable-rpath) disable_rpath
="yes"
189 --strip-binaries) strip_binaries
="yes"
191 --with-libgcc) use_libgcc
="yes"
193 --with-selinux) have_selinux
="yes"
195 --help|
-h) show_help
="yes"
197 *) echo "configure: WARNING: unrecognized option $opt"
202 if test -z "$cpu" ; then
203 if test -n "$ARCH" ; then
211 # Checking for CFLAGS
212 if test -z "$CFLAGS"; then
213 CFLAGS
="-Wall -g -O2"
216 if test "$mingw32" = "yes" ; then
217 if test x
"$tccdir" = x
""; then
220 if test -z "$prefix" ; then
221 prefix
="C:/Program Files/${tccdir}"
223 if test -z "$sharedir" ; then
229 libdir
="${prefix}/lib"
230 docdir
="${sharedir}/doc"
231 mandir
="${sharedir}/man"
232 infodir
="${sharedir}/info"
236 if test -z "$prefix" ; then
239 if test -z "$sharedir" ; then
240 sharedir
="${prefix}/share"
242 if test x
"$execprefix" = x
""; then
243 execprefix
="${prefix}"
245 if test x
"$tccdir" = x
""; then
248 if test x
"$libdir" = x
""; then
249 libdir
="${execprefix}/lib"
250 if test -n "${tccdir}"; then
251 tccdir
="${libdir}/${tccdir}"
255 if test "$cpu" = "x86-64"; then
256 libdir
="${execprefix}/lib64"
259 tccdir
="${libdir}/${tccdir}"
261 if test x
"$bindir" = x
""; then
262 bindir
="${execprefix}/bin"
264 if test x
"$docdir" = x
""; then
265 docdir
="${sharedir}/doc/${tccdir}"
267 if test x
"$mandir" = x
""; then
268 mandir
="${sharedir}/man"
270 if test x
"$infodir" = x
""; then
271 infodir
="${sharedir}/info"
275 if test x
"$includedir" = x
""; then
276 includedir
="${prefix}/include"
279 if test x
"$show_help" = "xyes" ; then
281 Usage: configure [options]
282 Options: [defaults in brackets after descriptions]
285 --help print this message
286 --prefix=PREFIX install in PREFIX [$prefix]
287 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
289 --bindir=DIR user executables in DIR [EPREFIX/bin]
290 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
291 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
292 --includedir=DIR C header files in DIR [PREFIX/include]
293 --sharedir=DIR documentation root DIR [PREFIX/share]
294 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
295 --mandir=DIR man documentation in DIR [SHAREDIR/man]
296 --infodir=DIR info documentation in DIR [SHAREDIR/info]
298 Advanced options (experts only):
299 --source-path=PATH path of source code [$source_path]
300 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
301 --sysroot=PREFIX prepend PREFIX to library/include paths []
302 --cc=CC use C compiler CC [$cc]
303 --extra-cflags= specify compiler flags [$CFLAGS]
304 --extra-ldflags= specify linker options []
306 --strip-binaries strip symbol tables from resulting binaries
307 --disable-static make libtcc.so instead of libtcc.a
308 --disable-rpath disable use of -rpath with the above
309 --with-libgcc use libgcc_s.so.1 instead of libtcc1.a in dynamic link
310 --enable-tcc64-mingw build windows version on linux with x86_64-win-tcc
311 --enable-tcc32-mingw build windows version on linux with i386-win-tcc
312 --enable-mingw32 build windows version on linux with mingw32
313 --enable-cygwin build windows version on windows with cygwin
314 --enable-cross build cross compilers
315 --enable-assert enable debug assertions
316 --with-selinux use mmap for exec mem [needs writable /tmp]
317 --sysincludepaths=... specify system include paths, colon separated
318 --libpaths=... specify system library paths, colon separated
319 --crtprefix=... specify locations of crt?.o, colon separated
320 --elfinterp=... specify elf interpreter
322 #echo "NOTE: The object files are build at the place where configure is launched"
326 if test "$cc" != "tcc"; then
327 ar="${cross_prefix}${ar}"
329 cc
="${cross_prefix}${cc}"
330 strip
="${cross_prefix}${strip}"
332 CONFTEST
=.
/conftest
$EXESUF
334 if test -z "$cross_prefix" ; then
335 if ! $cc -o $CONFTEST $source_path/conftest.c
2>/dev
/null
; then
336 echo "configure: error: '$cc' failed to compile conftest.c."
338 bigendian
="$($CONFTEST bigendian)"
339 gcc_major
="$($CONFTEST version)"
340 gcc_minor
="$($CONFTEST minor)"
341 if test "$mingw32" = "no" ; then
342 triplet
="$($CONFTEST triplet)"
343 if test -f "/usr/lib/$triplet/crti.o" ; then
345 multiarch_triplet
="$triplet"
346 elif test "$cpu" != "x86" -a -f "/usr/lib64/crti.o" ; then
350 if test "$cpu" = "armv4l" ; 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 # multiarch_triplet=${libc_dir#*/}
362 # multiarch_triplet=${multiarch_triplet%/}
363 # tcc_lddir="${libc_dir%%/*}"
364 # if test -n "$multiarch_triplet" ; then
365 # tcc_lddir="$tcc_lddir/$multiarch_triplet"
368 if test -f "/lib/ld-uClibc.so.0" ; then
369 confvars
="$confvars uClibc"
371 # gr: maybe for after the release:
372 # tcc_elfinterp="$(ldd $CONFTEST | grep 'ld.*.so' | sed 's,\s*\(\S\+\).*,\1,')"
373 # echo "elfinterp $tcc_elfinterp"
378 # if cross compiling, cannot launch a program, so make a static guess
380 powerpc|mips|s390
) bigendian
=yes;;
384 # a final configuration tuning
385 W_OPTIONS
="deprecated-declarations strict-aliasing pointer-sign sign-compare unused-result uninitialized"
386 for i
in $W_OPTIONS; do
387 O_PRESENT
="$($cc -v --help 2>&1 | grep -- -W$i)"
388 if test -n "$O_PRESENT"; then CFLAGS
="$CFLAGS -Wno-$i"; fi
390 F_OPTIONS
="strict-aliasing"
391 for i
in $F_OPTIONS; do
392 O_PRESENT
="$($cc -v --help 2>&1 | grep -- -f$i)"
393 if test -n "$O_PRESENT"; then CFLAGS
="$CFLAGS -fno-$i"; fi
395 if test -z "$tcc_lddir" -a "$cpu" = "x86-64"; then tcc_lddir
="lib64"; fi
397 echo "Binary directory $bindir"
398 echo "TinyCC directory $tccdir"
399 echo "Library directory $libdir"
400 echo "Include directory $includedir"
401 echo "Manual directory $mandir"
402 echo "Info directory $infodir"
403 echo "Doc directory $docdir"
404 echo "Target root prefix $sysroot"
405 echo "Source path $source_path"
406 echo "C compiler $cc"
407 echo "cross compilers $build_cross"
408 if test "$build_cross" = "no"; then
409 echo "Target CPU $cpu"
411 echo "Host OS $host_os"
412 echo "Target OS $targetos"
413 echo "Big Endian $bigendian"
414 echo "gprof enabled $gprof"
415 echo "use libgcc $use_libgcc"
417 echo "Creating config.mak and config.h"
419 cat >config.mak
<<EOF
420 # Automatically generated by configure - do not modify
422 bindir=\$(DESTDIR)$bindir
423 tccdir=\$(DESTDIR)$tccdir
424 libdir=\$(DESTDIR)$libdir
426 includedir=\$(DESTDIR)$includedir
427 mandir=\$(DESTDIR)$mandir
428 infodir=\$(DESTDIR)$infodir
429 docdir=\$(DESTDIR)$docdir
435 STRIP=$strip -s -R .comment -R .note
442 if test "$mingw32" = "yes"; then
443 cat >>config.mak
<<EOF
450 if test -n "$2"; then
451 echo "#ifndef $1" >> $TMPH
452 echo "# define $1 \"$2\"" >> $TMPH
453 echo "#endif" >> $TMPH
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_inc CONFIG_LDDIR
"$tcc_lddir"
467 print_mak CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
468 print_mak CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
469 print_mak CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
470 print_mak CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
471 print_mak CONFIG_MULTIARCHDIR
"$multiarch_triplet"
473 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
474 echo "#define GCC_MINOR $gcc_minor" >> $TMPH
476 if test "$cpu" = "x86" ; then
477 echo "ARCH=i386" >> config.mak
478 elif test "$cpu" = "x86-64" ; then
479 echo "ARCH=x86-64" >> config.mak
480 elif test "$cpu" = "armv4l" ; then
481 echo "ARCH=arm" >> config.mak
482 echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH
483 elif test "$cpu" = "aarch64" ; then
484 echo "ARCH=arm64" >> config.mak
485 elif test "$cpu" = "powerpc" ; then
486 echo "ARCH=ppc" >> config.mak
487 elif test "$cpu" = "mips" ; then
488 echo "ARCH=mips" >> config.mak
489 elif test "$cpu" = "s390" ; then
490 echo "ARCH=s390" >> config.mak
491 elif test "$cpu" = "alpha" ; then
492 echo "ARCH=alpha" >> config.mak
494 echo "Unsupported CPU"
498 echo "TARGETOS=$targetos" >> config.mak
500 for v
in $confvars ; do
501 echo "CONFIG_$v=yes" >> config.mak
503 if test "$noldl" = "yes" ; then
504 echo "CONFIG_NOLDL=yes" >> config.mak
506 if test "$mingw32" = "yes" ; then
507 echo "CONFIG_WIN32=yes" >> config.mak
508 echo "#define CONFIG_WIN32 1" >> $TMPH
510 if test "$cygwin" = "yes" ; then
511 echo "#ifndef _WIN32" >> $TMPH
512 echo "# define _WIN32" >> $TMPH
513 echo "#endif" >> $TMPH
514 echo "AR=ar" >> config.mak
516 if test "$bigendian" = "yes" ; then
517 echo "WORDS_BIGENDIAN=yes" >> config.mak
518 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
520 if test "$gprof" = "yes" ; then
521 echo "TARGET_GPROF=yes" >> config.mak
522 echo "#define HAVE_GPROF 1" >> $TMPH
524 if test "$build_cross" = "yes" ; then
525 echo "CONFIG_CROSS=yes" >> config.mak
527 if test "$disable_static" = "yes" ; then
528 echo "DISABLE_STATIC=yes" >> config.mak
530 if test "$disable_rpath" = "yes" ; then
531 echo "DISABLE_RPATH=yes" >> config.mak
533 if test "$strip_binaries" = "yes" ; then
534 echo "STRIP_BINARIES=yes" >> config.mak
536 if test "$use_libgcc" = "yes" ; then
537 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
538 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
540 if test "$have_selinux" = "yes" ; then
541 echo "#define HAVE_SELINUX" >> $TMPH
542 echo "HAVE_SELINUX=yes" >> config.mak
544 if test "$enable_assert" = "yes" ; then
545 echo "#define CONFIG_TCC_ASSERT" >> $TMPH
548 version
=`head $source_path/VERSION`
549 echo "VERSION=$version" >>config.mak
550 echo "#define TCC_VERSION \"$version\"" >> $TMPH
551 echo "@set VERSION $version" > config.texi
552 echo "SRC_PATH=$source_path" >>config.mak
554 if test "$source_path_used" = "yes" ; then
556 /*) echo "top_srcdir=$source_path";;
557 *) echo "top_srcdir=\$(TOP)/$source_path";;
560 echo 'top_srcdir=$(TOP)' >>config.mak
562 echo 'top_builddir=$(TOP)' >>config.mak
564 diff $TMPH config.h
>/dev
/null
2>&1
565 if test $?
-ne 0 ; then
568 echo "config.h is unchanged"
571 rm -f $TMPN* $CONFTEST
573 # ---------------------------------------------------------------------------
574 # build tree in object directory if source path is different from current one
581 test -d $dn || mkdir
-p $dn
584 *) while test $dn ; do
585 tgt
=..
/$tgt; dn
=${dn#${dn%%/*}}; dn=${dn#/}
594 if test "$source_path_used" = "yes" ; then
595 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile"
597 fn_makelink
$source_path $f
601 # ---------------------------------------------------------------------------