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;;
56 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
74 i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
100 "Power Macintosh"|ppc|ppc64
)
117 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
119 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
121 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
123 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
125 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
127 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
129 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
131 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
133 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
135 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
137 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
139 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
141 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
143 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
145 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
147 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
149 --extra-libs=*) extralibs
=${opt#--extra-libs=}
151 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2`
153 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2`
155 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2`
157 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2`
159 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
161 --enable-gprof) gprof
="yes"
163 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i686-pc-mingw32-" ; cpu
=x86
165 --enable-cygwin) mingw32
="yes" ; cygwin
="yes" ; cross_prefix
="mingw32-" ; cpu
=x86
167 --enable-cross) build_cross
="yes"
169 --enable-assert) enable_assert
="yes"
171 --disable-static) disable_static
="yes"
173 --disable-rpath) disable_rpath
="yes"
175 --strip-binaries) strip_binaries
="yes"
177 --with-libgcc) use_libgcc
="yes"
179 --with-selinux) have_selinux
="yes"
181 --help|
-h) show_help
="yes"
183 *) echo "configure: WARNING: unrecognized option $opt"
188 # Checking for CFLAGS
189 if test -z "$CFLAGS"; then
190 CFLAGS
="-Wall -g -O2"
193 if test "$mingw32" = "yes" ; then
194 if test x
"$tccdir" = x
""; then
197 if test -z "$prefix" ; then
198 prefix
="C:/Program Files/${tccdir}"
200 if test -z "$sharedir" ; then
206 libdir
="${prefix}/lib"
207 docdir
="${sharedir}/doc"
208 mandir
="${sharedir}/man"
209 infodir
="${sharedir}/info"
213 if test -z "$prefix" ; then
216 if test -z "$sharedir" ; then
217 sharedir
="${prefix}/share"
219 if test x
"$execprefix" = x
""; then
220 execprefix
="${prefix}"
222 if test x
"$libdir" = x
""; then
223 libdir
="${execprefix}/lib"
225 if test x
"$bindir" = x
""; then
226 bindir
="${execprefix}/bin"
228 if test x
"$tccdir" = x
""; then
231 if test x
"$docdir" = x
""; then
232 docdir
="${sharedir}/doc/${tccdir}"
234 if test x
"$mandir" = x
""; then
235 mandir
="${sharedir}/man"
237 if test x
"$infodir" = x
""; then
238 infodir
="${sharedir}/info"
240 tccdir
="${libdir}/${tccdir}"
243 if test x
"$includedir" = x
""; then
244 includedir
="${prefix}/include"
247 if test x
"$show_help" = "xyes" ; then
249 Usage: configure [options]
250 Options: [defaults in brackets after descriptions]
253 --help print this message
254 --prefix=PREFIX install in PREFIX [$prefix]
255 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
257 --bindir=DIR user executables in DIR [EPREFIX/bin]
258 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
259 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
260 --includedir=DIR C header files in DIR [PREFIX/include]
261 --sharedir=DIR documentation root DIR [PREFIX/share]
262 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
263 --mandir=DIR man documentation in DIR [SHAREDIR/man]
264 --infodir=DIR info documentation in DIR [SHAREDIR/info]
266 Advanced options (experts only):
267 --source-path=PATH path of source code [$source_path]
268 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
269 --sysroot=PREFIX prepend PREFIX to library/include paths []
270 --cc=CC use C compiler CC [$cc]
271 --extra-cflags= specify compiler flags [$CFLAGS]
272 --extra-ldflags= specify linker options []
273 --strip-binaries strip symbol tables from resulting binaries
274 --disable-static make libtcc.so instead of libtcc.a
275 --disable-rpath disable use of -rpath with the above
276 --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc.a
277 --enable-mingw32 build windows version on linux with mingw32
278 --enable-cygwin build windows version on windows with cygwin
279 --enable-cross build cross compilers
280 --enable-assert enable debug assertions
281 --with-selinux use mmap for exec mem [needs writable /tmp]
282 --sysincludepaths=... specify system include paths, colon separated
283 --libpaths=... specify system library paths, colon separated
284 --crtprefix=... specify locations of crt?.o, colon separated
285 --elfinterp=... specify elf interpreter
287 #echo "NOTE: The object files are build at the place where configure is launched"
291 cc
="${cross_prefix}${cc}"
292 ar="${cross_prefix}${ar}"
293 strip
="${cross_prefix}${strip}"
295 CONFTEST
=.
/conftest
$EXESUF
297 if test -z "$cross_prefix" ; then
298 if ! $cc -o $CONFTEST $source_path/conftest.c
2>/dev
/null
; then
299 echo "configure: error: '$cc' failed to compile conftest.c."
301 bigendian
="$($CONFTEST bigendian)"
302 gcc_major
="$($CONFTEST version)"
303 gcc_minor
="$($CONFTEST minor)"
304 if test "$mingw32" = "no" ; then
305 triplet
="$($CONFTEST triplet)"
306 if test -f "/usr/lib/$triplet/crti.o" ; then
308 multiarch_triplet
="$triplet"
309 elif test -f "/usr/lib64/crti.o" ; then
313 if test "$cpu" = "armv4l" ; then
314 if test "${triplet%eabihf}" != "$triplet" ; then
315 confvars
="$confvars arm_eabihf"
316 elif test "${triplet%eabi}" != "$triplet" ; then
317 confvars
="$confvars arm_eabi"
319 if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
; then
320 confvars
="$confvars arm_vfp"
324 # multiarch_triplet=${libc_dir#*/}
325 # multiarch_triplet=${multiarch_triplet%/}
326 # tcc_lddir="${libc_dir%%/*}"
327 # if test -n "$multiarch_triplet" ; then
328 # tcc_lddir="$tcc_lddir/$multiarch_triplet"
331 if test -f "/lib/ld-uClibc.so.0" ; then
332 confvars
="$confvars uClibc"
334 # gr: maybe for after the release:
335 # tcc_elfinterp="$(ldd $CONFTEST | grep 'ld.*.so' | sed 's,\s*\(\S\+\).*,\1,')"
336 # echo "elfinterp $tcc_elfinterp"
341 # if cross compiling, cannot launch a program, so make a static guess
343 powerpc|mips|s390
) bigendian
=yes;;
348 Binary directory $bindir
349 TinyCC directory $tccdir
350 Library directory $libdir
351 Include directory $includedir
352 Manual directory $mandir
353 Info directory $infodir
354 Doc directory $docdir
355 Target root prefix $sysroot
356 Source path $source_path
360 Big Endian $bigendian
362 cross compilers $build_cross
363 use libgcc $use_libgcc
366 echo "Creating config.mak and config.h"
368 cat >config.mak
<<EOF
369 # Automatically generated by configure - do not modify
371 bindir=\$(DESTDIR)$bindir
372 tccdir=\$(DESTDIR)$tccdir
373 libdir=\$(DESTDIR)$libdir
375 includedir=\$(DESTDIR)$includedir
376 mandir=\$(DESTDIR)$mandir
377 infodir=\$(DESTDIR)$infodir
378 docdir=\$(DESTDIR)$docdir
384 STRIP=$strip -s -R .comment -R .note
392 if test -n "$2"; then
393 echo "#ifndef $1" >> $TMPH
394 echo "# define $1 \"$2\"" >> $TMPH
395 echo "#endif" >> $TMPH
399 if test -n "$2"; then
400 echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak
404 echo "/* Automatically generated by configure - do not modify */" > $TMPH
406 print_inc CONFIG_SYSROOT
"$sysroot"
407 print_inc CONFIG_TCCDIR
"$tccdir"
408 print_mak CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
409 print_mak CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
410 print_mak CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
411 print_mak CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
412 print_mak CONFIG_LDDIR
"$tcc_lddir"
413 print_mak CONFIG_MULTIARCHDIR
"$multiarch_triplet"
415 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
416 echo "#define GCC_MINOR $gcc_minor" >> $TMPH
418 if test "$cpu" = "x86" ; then
419 echo "ARCH=i386" >> config.mak
420 echo "#define HOST_I386 1" >> $TMPH
421 elif test "$cpu" = "x86-64" ; then
422 echo "ARCH=x86-64" >> config.mak
423 echo "#define HOST_X86_64 1" >> $TMPH
424 elif test "$cpu" = "armv4l" ; then
425 echo "ARCH=arm" >> config.mak
426 echo "#define HOST_ARM 1" >> $TMPH
427 echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH
428 elif test "$cpu" = "powerpc" ; then
429 echo "ARCH=ppc" >> config.mak
430 echo "#define HOST_PPC 1" >> $TMPH
431 elif test "$cpu" = "mips" ; then
432 echo "ARCH=mips" >> config.mak
433 echo "#define HOST_MIPS 1" >> $TMPH
434 elif test "$cpu" = "s390" ; then
435 echo "ARCH=s390" >> config.mak
436 echo "#define HOST_S390 1" >> $TMPH
437 elif test "$cpu" = "alpha" ; then
438 echo "ARCH=alpha" >> config.mak
439 echo "#define HOST_ALPHA 1" >> $TMPH
441 echo "Unsupported CPU"
445 echo "TARGETOS=$targetos" >> config.mak
447 for v
in $confvars ; do
448 echo "CONFIG_$v=yes" >> config.mak
450 if test "$noldl" = "yes" ; then
451 echo "CONFIG_NOLDL=yes" >> config.mak
453 if test "$mingw32" = "yes" ; then
454 echo "CONFIG_WIN32=yes" >> config.mak
455 echo "#define CONFIG_WIN32 1" >> $TMPH
457 if test "$cygwin" = "yes" ; then
458 echo "#ifndef _WIN32" >> $TMPH
459 echo "# define _WIN32" >> $TMPH
460 echo "#endif" >> $TMPH
461 echo "AR=ar" >> config.mak
463 if test "$bigendian" = "yes" ; then
464 echo "WORDS_BIGENDIAN=yes" >> config.mak
465 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
467 if test "$gprof" = "yes" ; then
468 echo "TARGET_GPROF=yes" >> config.mak
469 echo "#define HAVE_GPROF 1" >> $TMPH
471 if test "$build_cross" = "yes" ; then
472 echo "CONFIG_CROSS=yes" >> config.mak
474 if test "$disable_static" = "yes" ; then
475 echo "DISABLE_STATIC=yes" >> config.mak
477 if test "$disable_rpath" = "yes" ; then
478 echo "DISABLE_RPATH=yes" >> config.mak
480 if test "$strip_binaries" = "yes" ; then
481 echo "STRIP_BINARIES=yes" >> config.mak
483 if test "$use_libgcc" = "yes" ; then
484 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
485 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
487 if test "$have_selinux" = "yes" ; then
488 echo "#define HAVE_SELINUX" >> $TMPH
489 echo "HAVE_SELINUX=yes" >> config.mak
491 if test "$enable_assert" = "yes" ; then
492 echo "#define CONFIG_TCC_ASSERT" >> $TMPH
495 version
=`head $source_path/VERSION`
496 echo "VERSION=$version" >>config.mak
497 echo "#define TCC_VERSION \"$version\"" >> $TMPH
498 echo "@set VERSION $version" > config.texi
499 echo "SRC_PATH=$source_path" >>config.mak
501 if test "$source_path_used" = "yes" ; then
503 /*) echo "top_srcdir=$source_path";;
504 *) echo "top_srcdir=\$(TOP)/$source_path";;
507 echo 'top_srcdir=$(TOP)' >>config.mak
509 echo 'top_builddir=$(TOP)' >>config.mak
511 diff $TMPH config.h
>/dev
/null
2>&1
512 if test $?
-ne 0 ; then
515 echo "config.h is unchanged"
518 rm -f $TMPN* $CONFTEST
520 # ---------------------------------------------------------------------------
521 # build tree in object directory if source path is different from current one
528 test -d $dn || mkdir
-p $dn
531 *) while test $dn ; do
532 tgt
=..
/$tgt; dn
=${dn#${dn%%/*}}; dn=${dn#/}
541 if test "$source_path_used" = "yes" ; then
542 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile"
544 fn_makelink
$source_path $f
548 # ---------------------------------------------------------------------------