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"
42 tcc_sysincludepaths
=""
53 MINGW32
*) mingw32
=yes;;
54 DragonFly
) noldl
=yes;;
60 # XXX: we assume an absolute path is given when launching configure,
61 # except in './configure' case.
62 source_path
=${0%configure}
63 source_path
=${source_path%/}
64 source_path_used
="yes"
65 if test -z "$source_path" -o "$source_path" = "." ; then
71 i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
97 "Power Macintosh"|ppc|ppc64
)
114 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
116 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
118 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
120 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
122 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
124 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
126 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
128 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
130 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
132 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
134 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
136 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
138 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
140 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
142 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
144 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
146 --extra-libs=*) extralibs
=${opt#--extra-libs=}
148 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2`
150 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2`
152 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2`
154 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2`
156 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
158 --enable-gprof) gprof
="yes"
160 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i686-pc-mingw32-" ; cpu
=x86
162 --enable-cygwin) mingw32
="yes" ; cygwin
="yes" ; cross_prefix
="mingw32-" ; cpu
=x86
164 --enable-cross) build_cross
="yes"
166 --disable-static) disable_static
="yes"
168 --disable-rpath) disable_rpath
="yes"
170 --strip-binaries) strip_binaries
="yes"
172 --with-libgcc) use_libgcc
="yes"
174 --with-selinux) have_selinux
="yes"
176 --help|
-h) show_help
="yes"
178 *) echo "configure: WARNING: unrecognized option $opt"
183 # Checking for CFLAGS
184 if test -z "$CFLAGS"; then
185 CFLAGS
="-Wall -g -O2"
188 if test "$mingw32" = "yes" ; then
189 if test x
"$tccdir" = x
""; then
192 if test -z "$prefix" ; then
193 prefix
="C:/Program Files/${tccdir}"
195 if test -z "$sharedir" ; then
201 libdir
="${prefix}/lib"
202 docdir
="${sharedir}/doc"
203 mandir
="${sharedir}/man"
204 infodir
="${sharedir}/info"
208 if test -z "$prefix" ; then
211 if test -z "$sharedir" ; then
212 sharedir
="${prefix}/share"
214 if test x
"$execprefix" = x
""; then
215 execprefix
="${prefix}"
217 if test x
"$libdir" = x
""; then
218 libdir
="${execprefix}/lib"
220 if test x
"$bindir" = x
""; then
221 bindir
="${execprefix}/bin"
223 if test x
"$tccdir" = x
""; then
226 if test x
"$docdir" = x
""; then
227 docdir
="${sharedir}/doc/${tccdir}"
229 if test x
"$mandir" = x
""; then
230 mandir
="${sharedir}/man"
232 if test x
"$infodir" = x
""; then
233 infodir
="${sharedir}/info"
235 tccdir
="${libdir}/${tccdir}"
238 if test x
"$includedir" = x
""; then
239 includedir
="${prefix}/include"
242 if test x
"$show_help" = "xyes" ; then
244 Usage: configure [options]
245 Options: [defaults in brackets after descriptions]
248 --help print this message
249 --prefix=PREFIX install in PREFIX [$prefix]
250 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
252 --bindir=DIR user executables in DIR [EPREFIX/bin]
253 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
254 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
255 --includedir=DIR C header files in DIR [PREFIX/include]
256 --sharedir=DIR documentation root DIR [PREFIX/share]
257 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
258 --mandir=DIR man documentation in DIR [SHAREDIR/man]
259 --infodir=DIR info documentation in DIR [SHAREDIR/info]
261 Advanced options (experts only):
262 --source-path=PATH path of source code [$source_path]
263 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
264 --sysroot=PREFIX prepend PREFIX to library/include paths []
265 --cc=CC use C compiler CC [$cc]
266 --extra-cflags= specify compiler flags [$CFLAGS]
267 --extra-ldflags= specify linker options []
268 --strip-binaries strip symbol tables from resulting binaries
269 --disable-static make libtcc.so instead of libtcc.a
270 --disable-rpath disable use of -rpath with the above
271 --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc.a
272 --enable-mingw32 build windows version on linux with mingw32
273 --enable-cygwin build windows version on windows with cygwin
274 --enable-cross build cross compilers
275 --with-selinux use mmap for exec mem [needs writable /tmp]
276 --sysincludepaths=... specify system include paths, colon separated
277 --libpaths=... specify system library paths, colon separated
278 --crtprefix=... specify locations of crt?.o, colon separated
279 --elfinterp=... specify elf interpreter
281 #echo "NOTE: The object files are build at the place where configure is launched"
285 cc
="${cross_prefix}${cc}"
286 ar="${cross_prefix}${ar}"
287 strip
="${cross_prefix}${strip}"
289 CONFTEST
=.
/conftest
$EXESUF
291 if test -z "$cross_prefix" ; then
292 if ! $cc -o $CONFTEST $source_path/conftest.c
2>/dev
/null
; then
293 echo "configure: error: '$cc' failed to compile conftest.c."
295 bigendian
="$($CONFTEST bigendian)"
296 gcc_major
="$($CONFTEST version)"
297 gcc_minor
="$($CONFTEST minor)"
298 if test "$mingw32" = "no" ; then
299 triplet
="$($CONFTEST triplet)"
300 if test -f "/usr/lib/$triplet/crti.o" ; then
301 tcc_lddir
="lib/$triplet"
302 multiarch_triplet
="$triplet"
303 elif test -f "/usr/lib64/crti.o" ; then
307 # multiarch_triplet=${libc_dir#*/}
308 # multiarch_triplet=${multiarch_triplet%/}
309 # tcc_lddir="${libc_dir%%/*}"
310 # if test -n "$multiarch_triplet" ; then
311 # tcc_lddir="$tcc_lddir/$multiarch_triplet"
314 # gr: maybe for after the release:
315 # tcc_elfinterp="$(ldd $CONFTEST | grep 'ld.*.so' | sed 's,\s*\(\S\+\).*,\1,')"
316 # echo "elfinterp $tcc_elfinterp"
321 # if cross compiling, cannot launch a program, so make a static guess
323 powerpc|mips|s390
) bigendian
=yes;;
328 Binary directory $bindir
329 TinyCC directory $tccdir
330 Library directory $libdir
331 Include directory $includedir
332 Manual directory $mandir
333 Info directory $infodir
334 Doc directory $docdir
335 Target root prefix $sysroot
336 Source path $source_path
340 Big Endian $bigendian
342 cross compilers $build_cross
343 use libgcc $use_libgcc
346 echo "Creating config.mak and config.h"
348 cat >config.mak
<<EOF
349 # Automatically generated by configure - do not modify
351 bindir=\$(DESTDIR)$bindir
352 tccdir=\$(DESTDIR)$tccdir
353 libdir=\$(DESTDIR)$libdir
355 includedir=\$(DESTDIR)$includedir
356 mandir=\$(DESTDIR)$mandir
357 infodir=\$(DESTDIR)$infodir
358 docdir=\$(DESTDIR)$docdir
364 STRIP=$strip -s -R .comment -R .note
372 if test -n "$2"; then
373 echo "#ifndef $1" >> $TMPH
374 echo "# define $1 \"$2\"" >> $TMPH
375 echo "#endif" >> $TMPH
379 if test -n "$2"; then
380 echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak
384 echo "/* Automatically generated by configure - do not modify */" > $TMPH
386 print_inc CONFIG_SYSROOT
"$sysroot"
387 print_inc CONFIG_TCCDIR
"$tccdir"
388 print_mak CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
389 print_mak CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
390 print_mak CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
391 print_mak CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
392 print_mak CONFIG_LDDIR
"$tcc_lddir"
393 print_mak CONFIG_MULTIARCHDIR
"$multiarch_triplet"
395 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
396 echo "#define GCC_MINOR $gcc_minor" >> $TMPH
398 if test "$cpu" = "x86" ; then
399 echo "ARCH=i386" >> config.mak
400 echo "#define HOST_I386 1" >> $TMPH
401 elif test "$cpu" = "x86-64" ; then
402 echo "ARCH=x86-64" >> config.mak
403 echo "#define HOST_X86_64 1" >> $TMPH
404 elif test "$cpu" = "armv4l" ; then
405 echo "ARCH=arm" >> config.mak
406 echo "#define HOST_ARM 1" >> $TMPH
407 echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH
408 elif test "$cpu" = "powerpc" ; then
409 echo "ARCH=ppc" >> config.mak
410 echo "#define HOST_PPC 1" >> $TMPH
411 elif test "$cpu" = "mips" ; then
412 echo "ARCH=mips" >> config.mak
413 echo "#define HOST_MIPS 1" >> $TMPH
414 elif test "$cpu" = "s390" ; then
415 echo "ARCH=s390" >> config.mak
416 echo "#define HOST_S390 1" >> $TMPH
417 elif test "$cpu" = "alpha" ; then
418 echo "ARCH=alpha" >> config.mak
419 echo "#define HOST_ALPHA 1" >> $TMPH
421 echo "Unsupported CPU"
425 echo "TARGETOS=$targetos" >> config.mak
427 if test "$noldl" = "yes" ; then
428 echo "CONFIG_NOLDL=yes" >> config.mak
430 if test "$mingw32" = "yes" ; then
431 echo "CONFIG_WIN32=yes" >> config.mak
432 echo "#define CONFIG_WIN32 1" >> $TMPH
434 if test "$cygwin" = "yes" ; then
435 echo "#ifndef _WIN32" >> $TMPH
436 echo "# define _WIN32" >> $TMPH
437 echo "#endif" >> $TMPH
438 echo "AR=ar" >> config.mak
440 if test "$bigendian" = "yes" ; then
441 echo "WORDS_BIGENDIAN=yes" >> config.mak
442 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
444 if test "$gprof" = "yes" ; then
445 echo "TARGET_GPROF=yes" >> config.mak
446 echo "#define HAVE_GPROF 1" >> $TMPH
448 if test "$build_cross" = "yes" ; then
449 echo "CONFIG_CROSS=yes" >> config.mak
451 if test "$disable_static" = "yes" ; then
452 echo "DISABLE_STATIC=yes" >> config.mak
454 if test "$disable_rpath" = "yes" ; then
455 echo "DISABLE_RPATH=yes" >> config.mak
457 if test "$strip_binaries" = "yes" ; then
458 echo "STRIP_BINARIES=yes" >> config.mak
460 if test "$use_libgcc" = "yes" ; then
461 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
462 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
464 if test "$have_selinux" = "yes" ; then
465 echo "#define HAVE_SELINUX" >> $TMPH
466 echo "HAVE_SELINUX=yes" >> config.mak
469 version
=`head $source_path/VERSION`
470 echo "VERSION=$version" >>config.mak
471 echo "#define TCC_VERSION \"$version\"" >> $TMPH
472 echo "@set VERSION $version" > config.texi
473 echo "SRC_PATH=$source_path" >>config.mak
475 if test "$source_path_used" = "yes" ; then
477 /*) echo "top_srcdir=$source_path";;
478 *) echo "top_srcdir=\$(TOP)/$source_path";;
481 echo 'top_srcdir=$(TOP)' >>config.mak
483 echo 'top_builddir=$(TOP)' >>config.mak
485 diff $TMPH config.h
>/dev
/null
2>&1
486 if test $?
-ne 0 ; then
489 echo "config.h is unchanged"
492 rm -f $TMPN* $CONFTEST
494 # ---------------------------------------------------------------------------
495 # build tree in object directory if source path is different from current one
502 test -d $dn || mkdir
-p $dn
505 *) while test $dn ; do
506 tgt
=..
/$tgt; dn
=${dn#${dn%%/*}}; dn=${dn#/}
515 if test "$source_path_used" = "yes" ; then
516 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile"
518 fn_makelink
$source_path $f
522 # ---------------------------------------------------------------------------