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-cross) build_cross
="yes"
178 --enable-assert) enable_assert
="yes"
180 --disable-static) disable_static
="yes"
182 --disable-rpath) disable_rpath
="yes"
184 --strip-binaries) strip_binaries
="yes"
186 --with-libgcc) use_libgcc
="yes"
188 --with-selinux) have_selinux
="yes"
190 --help|
-h) show_help
="yes"
192 *) echo "configure: WARNING: unrecognized option $opt"
197 if test -z "$cpu" ; then
198 if test -n "$ARCH" ; then
206 # Checking for CFLAGS
207 if test -z "$CFLAGS"; then
208 CFLAGS
="-Wall -g -O2"
211 if test "$mingw32" = "yes" ; then
212 if test x
"$tccdir" = x
""; then
215 if test -z "$prefix" ; then
216 prefix
="C:/Program Files/${tccdir}"
218 if test -z "$sharedir" ; then
224 libdir
="${prefix}/lib"
225 docdir
="${sharedir}/doc"
226 mandir
="${sharedir}/man"
227 infodir
="${sharedir}/info"
231 if test -z "$prefix" ; then
234 if test -z "$sharedir" ; then
235 sharedir
="${prefix}/share"
237 if test x
"$execprefix" = x
""; then
238 execprefix
="${prefix}"
240 if test x
"$libdir" = x
""; then
241 libdir
="${execprefix}/lib"
243 if test x
"$bindir" = x
""; then
244 bindir
="${execprefix}/bin"
246 if test x
"$tccdir" = x
""; then
249 if test x
"$docdir" = x
""; then
250 docdir
="${sharedir}/doc/${tccdir}"
252 if test x
"$mandir" = x
""; then
253 mandir
="${sharedir}/man"
255 if test x
"$infodir" = x
""; then
256 infodir
="${sharedir}/info"
258 tccdir
="${libdir}/${tccdir}"
261 if test x
"$includedir" = x
""; then
262 includedir
="${prefix}/include"
265 if test x
"$show_help" = "xyes" ; then
267 Usage: configure [options]
268 Options: [defaults in brackets after descriptions]
271 --help print this message
272 --prefix=PREFIX install in PREFIX [$prefix]
273 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
275 --bindir=DIR user executables in DIR [EPREFIX/bin]
276 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
277 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
278 --includedir=DIR C header files in DIR [PREFIX/include]
279 --sharedir=DIR documentation root DIR [PREFIX/share]
280 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
281 --mandir=DIR man documentation in DIR [SHAREDIR/man]
282 --infodir=DIR info documentation in DIR [SHAREDIR/info]
284 Advanced options (experts only):
285 --source-path=PATH path of source code [$source_path]
286 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
287 --sysroot=PREFIX prepend PREFIX to library/include paths []
288 --cc=CC use C compiler CC [$cc]
289 --extra-cflags= specify compiler flags [$CFLAGS]
290 --extra-ldflags= specify linker options []
292 --strip-binaries strip symbol tables from resulting binaries
293 --disable-static make libtcc.so instead of libtcc.a
294 --disable-rpath disable use of -rpath with the above
295 --with-libgcc use libgcc_s.so.1 instead of libtcc1.a in dynamic link
296 --enable-mingw32 build windows version on linux with mingw32
297 --enable-cygwin build windows version on windows with cygwin
298 --enable-cross build cross compilers
299 --enable-assert enable debug assertions
300 --with-selinux use mmap for exec mem [needs writable /tmp]
301 --sysincludepaths=... specify system include paths, colon separated
302 --libpaths=... specify system library paths, colon separated
303 --crtprefix=... specify locations of crt?.o, colon separated
304 --elfinterp=... specify elf interpreter
306 #echo "NOTE: The object files are build at the place where configure is launched"
310 cc
="${cross_prefix}${cc}"
311 ar="${cross_prefix}${ar}"
312 strip
="${cross_prefix}${strip}"
314 CONFTEST
=.
/conftest
$EXESUF
316 if test -z "$cross_prefix" ; then
317 if ! $cc -o $CONFTEST $source_path/conftest.c
2>/dev
/null
; then
318 echo "configure: error: '$cc' failed to compile conftest.c."
320 bigendian
="$($CONFTEST bigendian)"
321 gcc_major
="$($CONFTEST version)"
322 gcc_minor
="$($CONFTEST minor)"
323 if test "$mingw32" = "no" ; then
324 triplet
="$($CONFTEST triplet)"
325 if test -f "/usr/lib/$triplet/crti.o" ; then
327 multiarch_triplet
="$triplet"
328 elif test -f "/usr/lib64/crti.o" ; then
332 if test "$cpu" = "armv4l" ; then
333 if test "${triplet%eabihf}" != "$triplet" ; then
334 confvars
="$confvars arm_eabihf"
335 elif test "${triplet%eabi}" != "$triplet" ; then
336 confvars
="$confvars arm_eabi"
338 if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
; then
339 confvars
="$confvars arm_vfp"
343 # multiarch_triplet=${libc_dir#*/}
344 # multiarch_triplet=${multiarch_triplet%/}
345 # tcc_lddir="${libc_dir%%/*}"
346 # if test -n "$multiarch_triplet" ; then
347 # tcc_lddir="$tcc_lddir/$multiarch_triplet"
350 if test -f "/lib/ld-uClibc.so.0" ; then
351 confvars
="$confvars uClibc"
353 # gr: maybe for after the release:
354 # tcc_elfinterp="$(ldd $CONFTEST | grep 'ld.*.so' | sed 's,\s*\(\S\+\).*,\1,')"
355 # echo "elfinterp $tcc_elfinterp"
360 # if cross compiling, cannot launch a program, so make a static guess
362 powerpc|mips|s390
) bigendian
=yes;;
366 echo "Binary directory $bindir"
367 echo "TinyCC directory $tccdir"
368 echo "Library directory $libdir"
369 echo "Include directory $includedir"
370 echo "Manual directory $mandir"
371 echo "Info directory $infodir"
372 echo "Doc directory $docdir"
373 echo "Target root prefix $sysroot"
374 echo "Source path $source_path"
375 echo "C compiler $cc"
376 echo "cross compilers $build_cross"
377 if test "$build_cross" = "no"; then
378 echo "Target CPU $cpu"
380 echo "Target OS $targetos"
381 echo "Big Endian $bigendian"
382 echo "gprof enabled $gprof"
383 echo "use libgcc $use_libgcc"
385 echo "Creating config.mak and config.h"
387 cat >config.mak
<<EOF
388 # Automatically generated by configure - do not modify
390 bindir=\$(DESTDIR)$bindir
391 tccdir=\$(DESTDIR)$tccdir
392 libdir=\$(DESTDIR)$libdir
394 includedir=\$(DESTDIR)$includedir
395 mandir=\$(DESTDIR)$mandir
396 infodir=\$(DESTDIR)$infodir
397 docdir=\$(DESTDIR)$docdir
403 STRIP=$strip -s -R .comment -R .note
411 if test -n "$2"; then
412 echo "#ifndef $1" >> $TMPH
413 echo "# define $1 \"$2\"" >> $TMPH
414 echo "#endif" >> $TMPH
418 if test -n "$2"; then
419 echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak
423 echo "/* Automatically generated by configure - do not modify */" > $TMPH
425 print_inc CONFIG_SYSROOT
"$sysroot"
426 print_inc CONFIG_TCCDIR
"$tccdir"
427 print_mak CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
428 print_mak CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
429 print_mak CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
430 print_mak CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
431 print_mak CONFIG_LDDIR
"$tcc_lddir"
432 print_mak CONFIG_MULTIARCHDIR
"$multiarch_triplet"
434 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
435 echo "#define GCC_MINOR $gcc_minor" >> $TMPH
437 if test "$cpu" = "x86" ; then
438 echo "ARCH=i386" >> config.mak
439 elif test "$cpu" = "x86-64" ; then
440 echo "ARCH=x86-64" >> config.mak
441 elif test "$cpu" = "armv4l" ; then
442 echo "ARCH=arm" >> config.mak
443 echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH
444 elif test "$cpu" = "aarch64" ; then
445 echo "ARCH=arm64" >> config.mak
446 elif test "$cpu" = "powerpc" ; then
447 echo "ARCH=ppc" >> config.mak
448 elif test "$cpu" = "mips" ; then
449 echo "ARCH=mips" >> config.mak
450 elif test "$cpu" = "s390" ; then
451 echo "ARCH=s390" >> config.mak
452 elif test "$cpu" = "alpha" ; then
453 echo "ARCH=alpha" >> config.mak
455 echo "Unsupported CPU"
459 echo "TARGETOS=$targetos" >> config.mak
461 for v
in $confvars ; do
462 echo "CONFIG_$v=yes" >> config.mak
464 if test "$noldl" = "yes" ; then
465 echo "CONFIG_NOLDL=yes" >> config.mak
467 if test "$mingw32" = "yes" ; then
468 echo "CONFIG_WIN32=yes" >> config.mak
469 echo "#define CONFIG_WIN32 1" >> $TMPH
471 if test "$cygwin" = "yes" ; then
472 echo "#ifndef _WIN32" >> $TMPH
473 echo "# define _WIN32" >> $TMPH
474 echo "#endif" >> $TMPH
475 echo "AR=ar" >> config.mak
477 if test "$bigendian" = "yes" ; then
478 echo "WORDS_BIGENDIAN=yes" >> config.mak
479 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
481 if test "$gprof" = "yes" ; then
482 echo "TARGET_GPROF=yes" >> config.mak
483 echo "#define HAVE_GPROF 1" >> $TMPH
485 if test "$build_cross" = "yes" ; then
486 echo "CONFIG_CROSS=yes" >> config.mak
488 if test "$disable_static" = "yes" ; then
489 echo "DISABLE_STATIC=yes" >> config.mak
491 if test "$disable_rpath" = "yes" ; then
492 echo "DISABLE_RPATH=yes" >> config.mak
494 if test "$strip_binaries" = "yes" ; then
495 echo "STRIP_BINARIES=yes" >> config.mak
497 if test "$use_libgcc" = "yes" ; then
498 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
499 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
501 if test "$have_selinux" = "yes" ; then
502 echo "#define HAVE_SELINUX" >> $TMPH
503 echo "HAVE_SELINUX=yes" >> config.mak
505 if test "$enable_assert" = "yes" ; then
506 echo "#define CONFIG_TCC_ASSERT" >> $TMPH
509 version
=`head $source_path/VERSION`
510 echo "VERSION=$version" >>config.mak
511 echo "#define TCC_VERSION \"$version\"" >> $TMPH
512 echo "@set VERSION $version" > config.texi
513 echo "SRC_PATH=$source_path" >>config.mak
515 if test "$source_path_used" = "yes" ; then
517 /*) echo "top_srcdir=$source_path";;
518 *) echo "top_srcdir=\$(TOP)/$source_path";;
521 echo 'top_srcdir=$(TOP)' >>config.mak
523 echo 'top_builddir=$(TOP)' >>config.mak
525 diff $TMPH config.h
>/dev
/null
2>&1
526 if test $?
-ne 0 ; then
529 echo "config.h is unchanged"
532 rm -f $TMPN* $CONFTEST
534 # ---------------------------------------------------------------------------
535 # build tree in object directory if source path is different from current one
542 test -d $dn || mkdir
-p $dn
545 *) while test $dn ; do
546 tgt
=..
/$tgt; dn
=${dn#${dn%%/*}}; dn=${dn#/}
555 if test "$source_path_used" = "yes" ; then
556 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile"
558 fn_makelink
$source_path $f
562 # ---------------------------------------------------------------------------