3 # tcc configure script (c) 2003 Fabrice Bellard
13 # set temporary file name
14 if test ! -z "$TMPDIR" ; then
16 elif test ! -z "$TEMPDIR" ; then
22 # bashism: TMPN="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.c"
50 tcc_sysincludepaths
=""
56 i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
82 "Power Macintosh"|ppc|ppc64
)
104 MINGW32
*) mingw32
=yes;;
105 DragonFly
) noldl
=yes;;
111 # XXX: we assume an absolute path is given when launching configure,
112 # except in './configure' case.
113 source_path
=${0%configure}
114 source_path
=${source_path%/}
115 source_path_used
="yes"
116 if test -z "$source_path" -o "$source_path" = "." ; then
118 source_path_used
="no"
124 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
126 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
128 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
130 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
132 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
134 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
136 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
138 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
140 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
142 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
144 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
146 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
148 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
150 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
152 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
154 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
156 --extra-libs=*) extralibs
=${opt#--extra-libs=}
158 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2`
160 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2`
162 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2`
164 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2`
166 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
168 --enable-gprof) gprof
="yes"
170 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i686-pc-mingw32-" ; cpu
=x86
172 --enable-cygwin) mingw32
="yes" ; cygwin
="yes" ; cross_prefix
="mingw32-" ; cpu
=x86
174 --enable-cross) build_cross
="yes"
176 --disable-static) disable_static
="yes"
178 --disable-rpath) disable_rpath
="yes"
180 --strip-binaries) strip_binaries
="yes"
182 --with-libgcc) use_libgcc
="yes"
184 --with-selinux) have_selinux
="yes"
186 --help|
-h) show_help
="yes"
188 *) echo "configure: WARNING: unrecognized option $opt"
193 # Checking for CFLAGS
194 if test -z "$CFLAGS"; then
195 CFLAGS
="-Wall -g -O2"
198 cc
="${cross_prefix}${cc}"
199 ar="${cross_prefix}${ar}"
200 strip
="${cross_prefix}${strip}"
202 if test "$mingw32" = "yes" ; then
207 if test -z "$cross_prefix" ; then
210 # big/little endian test
212 #include <inttypes.h>
213 int main(int argc, char ** argv){
214 volatile uint32_t i=0x01234567;
215 return (*((uint8_t*)(&i))) == 0x67;
219 if $cc -o $TMPE $TMPC 2>/dev
/null
; then
220 $TMPE && bigendian
="yes"
222 echo big
/little
test failed
227 # if cross compiling, cannot launch a program, so make a static guess
229 powerpc|mips|s390
) bigendian
=yes;;
237 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
246 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
259 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
263 if test -z "$cross_prefix" ; then
264 libc_dir
="$(ldd $TMPO | grep libc.so | sed 's|[^/]*/\(.*/\)[^/]*|\1|')"
265 multiarch_triplet
=${libc_dir#*/}
266 multiarch_triplet
=${multiarch_triplet%/}
267 lddir
="${libc_dir%%/*}"
268 if test -n "$multiarch_triplet" ; then
269 lddir
="$lddir/$multiarch_triplet"
273 if test x
"$show_help" = "xyes" ; then
275 Usage: configure [options]
276 Options: [defaults in brackets after descriptions]
279 --help print this message
280 --prefix=PREFIX install in PREFIX [$prefix]
281 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
283 --bindir=DIR user executables in DIR [EPREFIX/bin]
284 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
285 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
286 --includedir=DIR C header files in DIR [PREFIX/include]
287 --sharedir=DIR documentation root DIR [PREFIX]/share
288 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
289 --mandir=DIR man documentation in DIR [SHAREDIR/man]
290 --infodir=DIR info documentation in DIR [SHAREDIR/info]
292 Advanced options (experts only):
293 --source-path=PATH path of source code [$source_path]
294 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
295 --sysroot=PREFIX prepend PREFIX to library/include paths []
296 --cc=CC use C compiler CC [$cc]
297 --disable-static make libtcc.so instead of libtcc.a
298 --disable-rpath disable use of -rpath with the above
299 --strip-binaries strip symbol tables from resulting binaries
300 --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc.a
301 --enable-mingw32 build windows version on linux with mingw32
302 --enable-cygwin build windows version on windows with cygwin
303 [requires cygwin and mingw32-make]
304 --enable-cross build cross compilers
305 --extra-cflags= extra compiler flags
306 --extra-ldflags= extra linker options
307 --with-selinux use mmap instead of exec mem
308 [requires write access to /tmp]
309 --sysincludepaths=... specify system include paths, colon separated
310 --libpaths=... specify system library paths, colon separated
311 --crtprefix=... specify locations of crt?.o, colon separated
312 --elfinterp=... specify elf interpreter
314 #echo "NOTE: The object files are build at the place where configure is launched"
318 if test "$mingw32" = "yes" ; then
319 if test x
"$tccdir" = x
""; then
322 if test -z "$prefix" ; then
323 prefix
="C:/Program Files/${tccdir}"
325 if test -z "$sharedir" ; then
331 libdir
="${prefix}/lib"
332 docdir
="${sharedir}/doc"
333 mandir
="${sharedir}/man"
334 infodir
="${sharedir}/info"
336 if test -z "$prefix" ; then
339 if test -z "$sharedir" ; then
340 sharedir
="${prefix}/share"
342 if test x
"$execprefix" = x
""; then
343 execprefix
="${prefix}"
345 if test x
"$libdir" = x
""; then
346 libdir
="${execprefix}/lib"
348 if test x
"$bindir" = x
""; then
349 bindir
="${execprefix}/bin"
351 if test x
"$tccdir" = x
""; then
354 if test x
"$docdir" = x
""; then
355 docdir
="${sharedir}/doc/${tccdir}"
357 if test x
"$mandir" = x
""; then
358 mandir
="${sharedir}/man"
360 if test x
"$infodir" = x
""; then
361 infodir
="${sharedir}/info"
363 tccdir
="${libdir}/${tccdir}"
366 if test x
"$includedir" = x
""; then
367 includedir
="${prefix}/include"
371 Binary directory $bindir
372 TinyCC directory $tccdir
373 Library directory $libdir
374 Include directory $includedir
375 Manual directory $mandir
376 Info directory $infodir
377 Doc directory $docdir
378 Target root prefix $sysroot
379 Source path $source_path
383 Big Endian $bigendian
385 cross compilers $build_cross
386 use libgcc $use_libgcc
389 echo "Creating config.mak and config.h"
391 cat >config.mak
<<EOF
392 # Automatically generated by configure - do not modify
394 bindir=\$(DESTDIR)$bindir
395 tccdir=\$(DESTDIR)$tccdir
396 libdir=\$(DESTDIR)$libdir
398 includedir=\$(DESTDIR)$includedir
399 mandir=\$(DESTDIR)$mandir
400 infodir=\$(DESTDIR)$infodir
401 docdir=\$(DESTDIR)$docdir
404 echo "/* Automatically generated by configure - do not modify */" > $TMPH
407 echo "#ifndef $1" >> $TMPH
408 echo "# define $1 \"$2\"" >> $TMPH
409 echo "#endif" >> $TMPH
413 if test -n "$2"; then print_var1
$1 "$2"; fi
415 print_var2 CONFIG_SYSROOT
"$sysroot"
416 print_var1 CONFIG_TCCDIR
"$tccdir"
417 print_var2 CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
418 print_var2 CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
419 print_var2 CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
420 print_var2 CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
421 print_var2 CONFIG_MULTIARCHDIR
"$multiarch_triplet"
422 print_var2 CONFIG_LDDIR
"$lddir"
424 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
426 cat >> config.mak
<<EOF
431 STRIP=$strip -s -R .comment -R .note
438 if test "$cpu" = "x86" ; then
439 echo "ARCH=i386" >> config.mak
440 echo "#define HOST_I386 1" >> $TMPH
441 elif test "$cpu" = "x86-64" ; then
442 echo "ARCH=x86-64" >> config.mak
443 echo "#define HOST_X86_64 1" >> $TMPH
444 elif test "$cpu" = "armv4l" ; then
445 echo "ARCH=arm" >> config.mak
446 echo "#define HOST_ARM 1" >> $TMPH
447 echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH
448 elif test "$cpu" = "powerpc" ; then
449 echo "ARCH=ppc" >> config.mak
450 echo "#define HOST_PPC 1" >> $TMPH
451 elif test "$cpu" = "mips" ; then
452 echo "ARCH=mips" >> config.mak
453 echo "#define HOST_MIPS 1" >> $TMPH
454 elif test "$cpu" = "s390" ; then
455 echo "ARCH=s390" >> config.mak
456 echo "#define HOST_S390 1" >> $TMPH
457 elif test "$cpu" = "alpha" ; then
458 echo "ARCH=alpha" >> config.mak
459 echo "#define HOST_ALPHA 1" >> $TMPH
461 echo "Unsupported CPU"
464 echo "TARGETOS=$targetos" >> config.mak
465 if test "$noldl" = "yes" ; then
466 echo "CONFIG_NOLDL=yes" >> config.mak
468 if test "$mingw32" = "yes" ; then
469 echo "CONFIG_WIN32=yes" >> config.mak
470 echo "#define CONFIG_WIN32 1" >> $TMPH
472 if test "$cygwin" = "yes" ; then
473 echo "#ifndef _WIN32" >> $TMPH
474 echo "#define _WIN32" >> $TMPH
475 echo "#endif" >> $TMPH
476 echo "AR=ar" >> config.mak
478 if test "$bigendian" = "yes" ; then
479 echo "WORDS_BIGENDIAN=yes" >> config.mak
480 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
482 if test "$gprof" = "yes" ; then
483 echo "TARGET_GPROF=yes" >> config.mak
484 echo "#define HAVE_GPROF 1" >> $TMPH
486 if test "$build_cross" = "yes" ; then
487 echo "CONFIG_CROSS=yes" >> config.mak
489 if test "$disable_static" = "yes" ; then
490 echo "DISABLE_STATIC=yes" >> config.mak
492 if test "$disable_rpath" = "yes" ; then
493 echo "DISABLE_RPATH=yes" >> config.mak
495 if test "$strip_binaries" = "yes" ; then
496 echo "STRIP_BINARIES=yes" >> config.mak
498 if test "$use_libgcc" = "yes" ; then
499 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
500 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
502 if test "$have_selinux" = "yes" ; then
503 echo "#define HAVE_SELINUX" >> $TMPH
504 echo "HAVE_SELINUX=yes" >> config.mak
507 version
=`head $source_path/VERSION`
508 echo "VERSION=$version" >>config.mak
509 echo "#define TCC_VERSION \"$version\"" >> $TMPH
510 echo "@set VERSION $version" > config.texi
511 echo "SRC_PATH=$source_path" >>config.mak
513 # build tree in object directory if source path is different from current one
514 if test "$source_path_used" = "yes" ; then
515 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile"
517 dir
=`fn_dirname "$f"`
518 test -d "$dir" || mkdir
-p "$dir"
519 # Build a symlink $f that points to $dest, its $source_path
522 /*) dest
=$source_path/$f;;
523 *) dest
=`echo "$dir/" | sed 's,^\./,,;s,[^/]*/,../,g'`
524 dest
=$dest$source_path/$f;;
529 /*) echo "top_srcdir=$source_path";;
530 *) echo "top_srcdir=\$(TOP)/$source_path";;
533 echo 'top_srcdir=$(TOP)' >>config.mak
535 echo 'top_builddir=$(TOP)' >>config.mak
537 diff $TMPH config.h
>/dev
/null
2>&1
538 if test $?
-ne 0 ; then
541 echo "config.h is unchanged"