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"
41 tcc_sysincludepaths
=""
52 MINGW32
*) mingw32
=yes;;
54 DragonFly
) noldl
=yes;;
62 # XXX: we assume an absolute path is given when launching configure,
63 # except in './configure' case.
64 source_path
=${0%configure}
65 source_path
=${source_path%/}
66 source_path_used
="yes"
67 if test -z "$source_path" -o "$source_path" = "." ; then
75 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
77 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
79 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
81 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
83 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
85 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
87 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
89 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
91 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
93 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
95 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
97 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
99 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
101 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
103 --ar=*) ar=`echo $opt | cut -d '=' -f 2`
105 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
107 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
109 --extra-libs=*) extralibs
="${opt#--extra-libs=}"
111 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2`
113 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2`
115 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2`
117 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2`
119 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
121 --enable-gprof) gprof
="yes"
123 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i686-pc-mingw32-" ; cpu
=x86
125 --enable-cygwin) mingw32
="yes" ; cygwin
="yes" ; cross_prefix
="mingw32-" ; cpu
=x86
127 --enable-cross) build_cross
="yes"
129 --disable-static) disable_static
="yes"
131 --disable-rpath) disable_rpath
="yes"
133 --strip-binaries) strip_binaries
="yes"
135 --with-libgcc) use_libgcc
="yes"
137 --with-selinux) have_selinux
="yes"
139 --help|
-h) show_help
="yes"
141 *) echo "configure: WARNING: unrecognized option $opt"
146 if test -z "$cpu" ; then
147 if test -n "$ARCH" ; then
155 x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
184 "Power Macintosh"|ppc|ppc64
)
198 # Checking for CFLAGS
199 if test -z "$CFLAGS"; then
200 CFLAGS
="-Wall -g -O2"
203 if test "$mingw32" = "yes" ; then
204 if test x
"$tccdir" = x
""; then
207 if test -z "$prefix" ; then
208 prefix
="C:/Program Files/${tccdir}"
210 if test -z "$sharedir" ; then
216 libdir
="${prefix}/lib"
217 docdir
="${sharedir}/doc"
218 mandir
="${sharedir}/man"
219 infodir
="${sharedir}/info"
223 if test -z "$prefix" ; then
226 if test -z "$sharedir" ; then
227 sharedir
="${prefix}/share"
229 if test x
"$execprefix" = x
""; then
230 execprefix
="${prefix}"
232 if test x
"$libdir" = x
""; then
233 libdir
="${execprefix}/lib"
235 if test x
"$bindir" = x
""; then
236 bindir
="${execprefix}/bin"
238 if test x
"$docdir" = x
""; then
239 docdir
="${sharedir}/doc"
241 if test x
"$mandir" = x
""; then
242 mandir
="${sharedir}/man"
244 if test x
"$infodir" = x
""; then
245 infodir
="${sharedir}/info"
247 if test x
"$tccdir" = x
""; then
248 tccdir
="${libdir}/tcc"
252 if test x
"$includedir" = x
""; then
253 includedir
="${prefix}/include"
256 if test x
"$show_help" = "xyes" ; then
258 Usage: configure [options]
259 Options: [defaults in brackets after descriptions]
262 --help print this message
263 --prefix=PREFIX install in PREFIX [$prefix]
264 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
266 --bindir=DIR user executables in DIR [EPREFIX/bin]
267 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
268 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
269 --includedir=DIR C header files in DIR [PREFIX/include]
270 --sharedir=DIR documentation root DIR [PREFIX/share]
271 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
272 --mandir=DIR man documentation in DIR [SHAREDIR/man]
273 --infodir=DIR info documentation in DIR [SHAREDIR/info]
275 Advanced options (experts only):
276 --source-path=PATH path of source code [$source_path]
277 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
278 --sysroot=PREFIX prepend PREFIX to library/include paths []
279 --cc=CC use C compiler CC [$cc]
280 --ar=AR create archives using AR [$ar]
281 --extra-cflags= specify compiler flags [$CFLAGS]
282 --extra-ldflags= specify linker options []
284 --strip-binaries strip symbol tables from resulting binaries
285 --disable-static make libtcc.so instead of libtcc.a
286 --disable-rpath disable use of -rpath with the above
287 --with-libgcc use libgcc_s.so.1 instead of libtcc1.a in dynamic link
288 --enable-mingw32 build windows version on linux with mingw32
289 --enable-cygwin build windows version on windows with cygwin
290 --enable-cross build cross compilers
291 --with-selinux use mmap for exec mem [needs writable /tmp]
292 --sysincludepaths=... specify system include paths, colon separated
293 --libpaths=... specify system library paths, colon separated
294 --crtprefix=... specify locations of crt?.o, colon separated
295 --elfinterp=... specify elf interpreter
297 #echo "NOTE: The object files are build at the place where configure is launched"
301 cc
="${cross_prefix}${cc}"
302 ar="${cross_prefix}${ar}"
303 strip
="${cross_prefix}${strip}"
305 CONFTEST
=.
/conftest
$EXESUF
307 if test -z "$cross_prefix" ; then
308 if ! $cc -o $CONFTEST $source_path/conftest.c
2>/dev
/null
; then
309 echo "configure: error: '$cc' failed to compile conftest.c."
311 bigendian
="$($CONFTEST bigendian)"
312 gcc_major
="$($CONFTEST version)"
313 gcc_minor
="$($CONFTEST minor)"
314 if test "$mingw32" = "no" ; then
315 triplet
="$($CONFTEST triplet)"
316 if test -f "/usr/lib/$triplet/crti.o" ; then
318 multiarch_triplet
="$triplet"
319 elif test "$cpu" != "x86" -a -f "/usr/lib64/crti.o" ; then
323 if test "$cpu" = "armv4l" ; then
324 if test "${triplet%eabihf}" != "$triplet" ; then
325 confvars
="$confvars arm_eabihf"
326 elif test "${triplet%eabi}" != "$triplet" ; then
327 confvars
="$confvars arm_eabi"
329 if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
; then
330 confvars
="$confvars arm_vfp"
334 # multiarch_triplet=${libc_dir#*/}
335 # multiarch_triplet=${multiarch_triplet%/}
336 # tcc_lddir="${libc_dir%%/*}"
337 # if test -n "$multiarch_triplet" ; then
338 # tcc_lddir="$tcc_lddir/$multiarch_triplet"
341 if test -f "/lib/ld-uClibc.so.0" ; then
342 confvars
="$confvars uClibc"
345 # if test -z "$tcc_elfinterp" ; then
346 # tcc_elfinterp="$(ldd $CONFTEST | grep '/ld-.*.so' | sed 's,\s*\(\S\+\).*,\1,')"
352 # if cross compiling, cannot launch a program, so make a static guess
354 powerpc|mips|s390
) bigendian
=yes;;
358 # a final configuration tuning
359 $cc -v --help > cc_help.txt
2>&1
360 W_OPTIONS
="declaration-after-statement"
361 for i
in $W_OPTIONS; do
362 O_PRESENT
="$(grep -- -W$i cc_help.txt)"
363 if test -n "$O_PRESENT"; then CFLAGS
="$CFLAGS -W$i"; fi
365 W_OPTIONS
="deprecated-declarations strict-aliasing pointer-sign sign-compare unused-result uninitialized"
366 for i
in $W_OPTIONS; do
367 O_PRESENT
="$(grep -- -W$i cc_help.txt)"
368 if test -n "$O_PRESENT"; then CFLAGS
="$CFLAGS -Wno-$i"; fi
370 F_OPTIONS
="strict-aliasing"
371 for i
in $F_OPTIONS; do
372 O_PRESENT
="$(grep -- -f$i cc_help.txt)"
373 if test -n "$O_PRESENT"; then CFLAGS
="$CFLAGS -fno-$i"; fi
377 echo "Binary directory $bindir"
378 echo "TinyCC directory $tccdir"
379 echo "Library directory $libdir"
380 echo "Include directory $includedir"
381 echo "Manual directory $mandir"
382 echo "Info directory $infodir"
383 echo "Doc directory $docdir"
384 echo "Target root prefix $sysroot"
385 echo "Source path $source_path"
386 echo "C compiler $cc"
387 echo "Target OS $targetos"
389 echo "Big Endian $bigendian"
390 echo "gprof enabled $gprof"
391 echo "cross compilers $build_cross"
392 echo "use libgcc $use_libgcc"
394 echo "Creating config.mak and config.h"
396 cat >config.mak
<<EOF
397 # Automatically generated by configure - do not modify
399 bindir=\$(DESTDIR)$bindir
400 tccdir=\$(DESTDIR)$tccdir
401 libdir=\$(DESTDIR)$libdir
403 includedir=\$(DESTDIR)$includedir
404 mandir=\$(DESTDIR)$mandir
405 infodir=\$(DESTDIR)$infodir
406 docdir=\$(DESTDIR)$docdir
411 STRIP=$strip -s -R .comment -R .note
419 if test -n "$2"; then
420 echo "#ifndef $1" >> $TMPH
421 echo "# define $1 \"$2\"" >> $TMPH
422 echo "#endif" >> $TMPH
426 if test -n "$2"; then
427 echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak
431 echo "/* Automatically generated by configure - do not modify */" > $TMPH
433 print_inc CONFIG_SYSROOT
"$sysroot"
434 print_inc CONFIG_TCCDIR
"$tccdir"
435 print_mak CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
436 print_mak CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
437 print_mak CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
438 print_mak CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
439 print_mak CONFIG_LDDIR
"$tcc_lddir"
440 print_mak CONFIG_MULTIARCHDIR
"$multiarch_triplet"
442 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
443 echo "#define GCC_MINOR $gcc_minor" >> $TMPH
445 if test "$cpu" = "x86" ; then
446 echo "ARCH=i386" >> config.mak
447 elif test "$cpu" = "x86-64" ; then
448 echo "ARCH=x86-64" >> config.mak
449 elif test "$cpu" = "armv4l" ; then
450 echo "ARCH=arm" >> config.mak
451 echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH
452 elif test "$cpu" = "aarch64" ; then
453 echo "ARCH=arm64" >> config.mak
454 elif test "$cpu" = "powerpc" ; then
455 echo "ARCH=ppc" >> config.mak
456 elif test "$cpu" = "mips" ; then
457 echo "ARCH=mips" >> config.mak
458 elif test "$cpu" = "s390" ; then
459 echo "ARCH=s390" >> config.mak
460 elif test "$cpu" = "alpha" ; then
461 echo "ARCH=alpha" >> config.mak
463 echo "Unsupported CPU"
467 echo "TARGETOS=$targetos" >> config.mak
469 for v
in $confvars ; do
470 echo "CONFIG_$v=yes" >> config.mak
472 if test "$noldl" = "yes" ; then
473 echo "CONFIG_NOLDL=yes" >> config.mak
475 if test "$mingw32" = "yes" ; then
476 echo "CONFIG_WIN32=yes" >> config.mak
478 if test "$cygwin" = "yes" ; then
479 echo "#ifndef _WIN32" >> $TMPH
480 echo "# define _WIN32" >> $TMPH
481 echo "#endif" >> $TMPH
482 echo "AR=ar" >> config.mak
484 if test "$bigendian" = "yes" ; then
485 echo "WORDS_BIGENDIAN=yes" >> config.mak
486 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
488 if test "$gprof" = "yes" ; then
489 echo "TARGET_GPROF=yes" >> config.mak
490 echo "#define HAVE_GPROF 1" >> $TMPH
492 if test "$build_cross" = "yes" ; then
493 echo "CONFIG_CROSS=yes" >> config.mak
495 if test "$disable_static" = "yes" ; then
496 echo "DISABLE_STATIC=yes" >> config.mak
498 if test "$disable_rpath" = "yes" ; then
499 echo "DISABLE_RPATH=yes" >> config.mak
501 if test "$strip_binaries" = "yes" ; then
502 echo "STRIP_BINARIES=yes" >> config.mak
504 if test "$use_libgcc" = "yes" ; then
505 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
506 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
508 if test "$have_selinux" = "yes" ; then
509 echo "#define HAVE_SELINUX" >> $TMPH
510 echo "HAVE_SELINUX=yes" >> config.mak
513 version
=`head $source_path/VERSION`
514 echo "VERSION = $version" >> config.mak
515 echo "#define TCC_VERSION \"$version\"" >> $TMPH
516 echo "@set VERSION $version" > config.texi
518 if test "$source_path_used" = "yes" ; then
520 /*) echo "TOPSRC=$source_path";;
521 *) echo "TOPSRC=\$(TOP)/$source_path";;
524 echo 'TOPSRC=$(TOP)' >>config.mak
527 diff $TMPH config.h
>/dev
/null
2>&1
528 if test $?
-ne 0 ; then
531 echo "config.h is unchanged"
534 rm -f $TMPN* $CONFTEST
536 # ---------------------------------------------------------------------------
537 # build tree in object directory if source path is different from current one
544 test -d $dn || mkdir
-p $dn
547 *) while test $dn ; do
548 tgt
=..
/$tgt; dn
=${dn#${dn%%/*}}; dn=${dn#/}
554 if test "$mingw32" = "yes" ; then
555 cmd
//c mklink
`echo "$2 $tgt" | sed 's,/,\\\\,g'`
561 if test "$source_path_used" = "yes" ; then
562 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile tests/pp/Makefile"
564 fn_makelink
$source_path $f
568 # ---------------------------------------------------------------------------