3 # tcc configure script (c) 2003 Fabrice Bellard
8 */*) echo "$1" |
sed -e 's,/[^/]*,,';;
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
)
117 # XXX: we assume an absolute path is given when launching configure,
118 # except in './configure' case.
119 source_path
=${0%configure}
120 source_path
=${source_path%/}
121 source_path_used
="yes"
122 if test -z "$source_path" -o "$source_path" = "." ; then
124 source_path_used
="no"
130 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
132 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
134 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
136 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
138 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
140 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
142 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
144 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
146 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
148 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
150 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
152 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
154 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
156 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
158 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
160 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
162 --extra-libs=*) extralibs
=${opt#--extra-libs=}
164 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2`
166 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2`
168 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2`
170 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2`
172 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
174 --enable-gprof) gprof
="yes"
176 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i686-pc-mingw32-" ; cpu
=x86
178 --enable-cygwin) mingw32
="yes" ; cygwin
="yes" ; cross_prefix
="mingw32-" ; cpu
=x86
180 --enable-cross) build_cross
="yes"
182 --disable-static) disable_static
="yes"
184 --disable-rpath) disable_rpath
="yes"
186 --strip-binaries) strip_binaries
="yes"
188 --with-libgcc) use_libgcc
="yes"
190 --with-selinux) have_selinux
="yes"
192 --help|
-h) show_help
="yes"
194 *) echo "configure: WARNING: unrecognized option $opt"
199 # Checking for CFLAGS
200 if test -z "$CFLAGS"; then
201 CFLAGS
="-Wall -g -O2"
204 cc
="${cross_prefix}${cc}"
205 ar="${cross_prefix}${ar}"
206 strip
="${cross_prefix}${strip}"
208 if test "$mingw32" = "yes" ; then
213 if test -z "$cross_prefix" ; then
216 # big/little endian test
218 #include <inttypes.h>
219 int main(int argc, char ** argv){
220 volatile uint32_t i=0x01234567;
221 return (*((uint8_t*)(&i))) == 0x67;
225 if $cc -o $TMPE $TMPC 2>/dev
/null
; then
226 $TMPE && bigendian
="yes"
228 echo big
/little
test failed
233 # if cross compiling, cannot launch a program, so make a static guess
234 if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" ; then
243 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
252 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
265 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
269 if test x
"$show_help" = "xyes" ; then
272 Usage: configure [options]
273 Options: [defaults in brackets after descriptions]
276 echo "Standard options:"
277 echo " --help print this message"
278 echo " --prefix=PREFIX install in PREFIX [$prefix]"
279 echo " --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX"
280 echo " [same as prefix]"
281 echo " --bindir=DIR user executables in DIR [EPREFIX/bin]"
282 echo " --libdir=DIR object code libraries in DIR [EPREFIX/lib]"
283 echo " --tccdir=DIR installation directory [EPREFIX/lib/tcc]"
284 echo " --includedir=DIR C header files in DIR [PREFIX/include]"
285 echo " --sharedir=DIR documentation root DIR [PREFIX]/share"
286 echo " --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]"
287 echo " --mandir=DIR man documentation in DIR [SHAREDIR/man]"
288 echo " --infodir=DIR info documentation in DIR [SHAREDIR/info]"
290 echo "Advanced options (experts only):"
291 echo " --source-path=PATH path of source code [$source_path]"
292 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
293 echo " --sysroot=PREFIX prepend PREFIX to library/include paths []"
294 echo " --cc=CC use C compiler CC [$cc]"
295 echo " --disable-static make libtcc.so instead of libtcc.a"
296 echo " --disable-rpath disable use of -rpath with the above"
297 echo " --strip-binaries strip symbol tables from resulting binaries"
298 echo " --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc.a"
299 echo " --enable-mingw32 build windows version on linux with mingw32"
300 echo " --enable-cygwin build windows version on windows with cygwin"
301 echo " [requires cygwin and mingw32-make]"
302 echo " --enable-cross build cross compilers"
303 echo " --extra-cflags= extra compiler flags"
304 echo " --extra-ldflags= extra linker options"
305 echo " --with-selinux use mmap instead of exec mem"
306 echo " [requires write access to /tmp]"
307 echo " --sysincludepaths=... specify system include paths, colon separated"
308 echo " --libpaths=... specify system library paths, colon separated"
309 echo " --crtprefix=... specify locations of crt?.o, colon separated"
310 echo " --elfinterp=... specify elf interpreter"
312 #echo "NOTE: The object files are build at the place where configure is launched"
316 if test "$mingw32" = "yes" ; then
317 if test x
"$tccdir" = x
""; then
320 if test -z "$prefix" ; then
321 prefix
="C:/Program Files/${tccdir}"
323 if test -z "$sharedir" ; then
329 libdir
="${prefix}/lib"
330 docdir
="${sharedir}/doc"
331 mandir
="${sharedir}/man"
332 infodir
="${sharedir}/info"
334 if test -z "$prefix" ; then
337 if test -z "$sharedir" ; then
338 sharedir
="${prefix}/share"
340 if test x
"$execprefix" = x
""; then
341 execprefix
="${prefix}"
343 if test x
"$libdir" = x
""; then
344 libdir
="${execprefix}/lib"
346 if test x
"$bindir" = x
""; then
347 bindir
="${execprefix}/bin"
349 if test x
"$tccdir" = x
""; then
352 if test x
"$docdir" = x
""; then
353 docdir
="${sharedir}/doc/${tccdir}"
355 if test x
"$mandir" = x
""; then
356 mandir
="${sharedir}/man"
358 if test x
"$infodir" = x
""; then
359 infodir
="${sharedir}/info"
361 tccdir
="${libdir}/${tccdir}"
364 if test x
"$includedir" = x
""; then
365 includedir
="${prefix}/include"
368 echo "Binary directory $bindir"
369 echo "TinyCC directory $tccdir"
370 echo "Library directory $libdir"
371 echo "Include directory $includedir"
372 echo "Manual directory $mandir"
373 echo "Info directory $infodir"
374 echo "Doc directory $docdir"
375 echo "Target root prefix $sysroot"
376 echo "Source path $source_path"
377 echo "C compiler $cc"
378 echo "Target OS $targetos"
380 echo "Big Endian $bigendian"
381 echo "gprof enabled $gprof"
382 echo "cross compilers $build_cross"
383 echo "use libgcc $use_libgcc"
385 echo "Creating config.mak and config.h"
387 echo "# Automatically generated by configure - do not modify" > config.mak
388 echo "/* Automatically generated by configure - do not modify */" > $TMPH
390 echo "prefix=$prefix" >> config.mak
391 echo "bindir=\$(DESTDIR)$bindir" >> config.mak
392 echo "tccdir=\$(DESTDIR)$tccdir" >> config.mak
393 echo "libdir=\$(DESTDIR)$libdir" >> config.mak
394 echo "ln_libdir=$libdir" >> config.mak
395 echo "includedir=\$(DESTDIR)$includedir" >> config.mak
396 echo "mandir=\$(DESTDIR)$mandir" >> config.mak
397 echo "infodir=\$(DESTDIR)$infodir" >> config.mak
398 echo "docdir=\$(DESTDIR)$docdir" >> config.mak
401 echo "#ifndef $1" >> $TMPH
402 echo "# define $1 \"$2\"" >> $TMPH
403 echo "#endif" >> $TMPH
407 if test -n "$2"; then print_var1
$1 "$2"; fi
409 print_var2 CONFIG_SYSROOT
"$sysroot"
410 print_var1 CONFIG_TCCDIR
"$tccdir"
411 print_var2 CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
412 print_var2 CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
413 print_var2 CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
414 print_var2 CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
416 echo "CC=$cc" >> config.mak
417 echo "GCC_MAJOR=$gcc_major" >> config.mak
418 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
419 echo "HOST_CC=$host_cc" >> config.mak
420 echo "AR=$ar" >> config.mak
421 echo "STRIP=$strip -s -R .comment -R .note" >> config.mak
422 cat >> config.mak
<<EOF
423 CPPFLAGS = -I. -I\$(top_srcdir)
430 if test "$cpu" = "x86" ; then
431 echo "ARCH=i386" >> config.mak
432 echo "#define HOST_I386 1" >> $TMPH
433 elif test "$cpu" = "x86-64" ; then
434 echo "ARCH=x86-64" >> config.mak
435 echo "#define HOST_X86_64 1" >> $TMPH
436 elif test "$cpu" = "armv4l" ; then
437 echo "ARCH=arm" >> config.mak
438 echo "#define HOST_ARM 1" >> $TMPH
439 echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH
440 elif test "$cpu" = "powerpc" ; then
441 echo "ARCH=ppc" >> config.mak
442 echo "#define HOST_PPC 1" >> $TMPH
443 elif test "$cpu" = "mips" ; then
444 echo "ARCH=mips" >> config.mak
445 echo "#define HOST_MIPS 1" >> $TMPH
446 elif test "$cpu" = "s390" ; then
447 echo "ARCH=s390" >> config.mak
448 echo "#define HOST_S390 1" >> $TMPH
449 elif test "$cpu" = "alpha" ; then
450 echo "ARCH=alpha" >> config.mak
451 echo "#define HOST_ALPHA 1" >> $TMPH
453 echo "Unsupported CPU"
456 echo "TARGETOS=$targetos" >> config.mak
457 if test "$noldl" = "yes" ; then
458 echo "CONFIG_NOLDL=yes" >> config.mak
460 if test "$mingw32" = "yes" ; then
461 echo "CONFIG_WIN32=yes" >> config.mak
462 echo "#define CONFIG_WIN32 1" >> $TMPH
464 if test "$cygwin" = "yes" ; then
465 echo "#ifndef _WIN32" >> $TMPH
466 echo "#define _WIN32" >> $TMPH
467 echo "#endif" >> $TMPH
468 echo "AR=ar" >> config.mak
470 if test "$bigendian" = "yes" ; then
471 echo "WORDS_BIGENDIAN=yes" >> config.mak
472 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
474 if test "$gprof" = "yes" ; then
475 echo "TARGET_GPROF=yes" >> config.mak
476 echo "#define HAVE_GPROF 1" >> $TMPH
478 if test "$build_cross" = "yes" ; then
479 echo "CONFIG_CROSS=yes" >> config.mak
481 if test "$disable_static" = "yes" ; then
482 echo "DISABLE_STATIC=yes" >> config.mak
484 if test "$disable_rpath" = "yes" ; then
485 echo "DISABLE_RPATH=yes" >> config.mak
487 if test "$strip_binaries" = "yes" ; then
488 echo "STRIP_BINARIES=yes" >> config.mak
490 if test "$use_libgcc" = "yes" ; then
491 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
492 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
494 if test "$have_selinux" = "yes" ; then
495 echo "#define HAVE_SELINUX" >> $TMPH
496 echo "HAVE_SELINUX=yes" >> config.mak
498 version
=`head $source_path/VERSION`
499 echo "VERSION=$version" >>config.mak
500 echo "#define TCC_VERSION \"$version\"" >> $TMPH
501 echo "@set VERSION $version" > config.texi
503 # build tree in object directory if source path is different from current one
504 if test "$source_path_used" = "yes" ; then
505 FILES
="Makefile lib/Makefile tests/Makefile tests2/Makefile"
507 dir
=`fn_dirname "$f"`
508 test -d "$dir" || mkdir
-p "$dir"
509 back
=`echo "$source_path/$dir/" | sed 's,/\./,/,g;s,[^/]*/,../,g'`
514 cat >>config.mak
<<EOF
515 SRC_PATH = $source_path
516 top_builddir = \$(TOP)
519 /*) echo 'top_srcdir = $(SRC_PATH)';;
520 *) echo 'top_srcdir = $(TOP)/$(SRC_PATH)';;
523 diff $TMPH config.h
>/dev
/null
2>&1
524 if test $?
-ne 0 ; then
527 echo "config.h is unchanged"