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
=""
48 i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
74 "Power Macintosh"|ppc|ppc64
)
109 # XXX: we assume an absolute path is given when launching configure,
110 # except in './configure' case.
111 source_path
=${0%configure}
112 source_path
=${source_path%/}
113 source_path_used
="yes"
114 if test -z "$source_path" -o "$source_path" = "." ; then
116 source_path_used
="no"
122 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
124 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
126 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
128 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
130 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
132 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
134 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
136 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
138 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
140 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
142 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
144 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
146 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
148 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
150 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
152 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
154 --extra-libs=*) extralibs
=${opt#--extra-libs=}
156 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2`
158 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2`
160 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2`
162 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2`
164 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
166 --enable-gprof) gprof
="yes"
168 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i686-pc-mingw32-" ; cpu
=x86
170 --enable-cygwin) mingw32
="yes" ; cygwin
="yes" ; cross_prefix
="mingw32-" ; cpu
=x86
172 --enable-cross) build_cross
="yes"
174 --disable-static) disable_static
="yes"
176 --disable-rpath) disable_rpath
="yes"
178 --strip-binaries) strip_binaries
="yes"
180 --with-libgcc) use_libgcc
="yes"
182 --with-selinux) have_selinux
="yes"
184 --help|
-h) show_help
="yes"
186 *) echo "configure: WARNING: unrecognized option $opt"
191 # Checking for CFLAGS
192 if test -z "$CFLAGS"; then
193 CFLAGS
="-Wall -g -O2"
196 cc
="${cross_prefix}${cc}"
197 ar="${cross_prefix}${ar}"
198 strip
="${cross_prefix}${strip}"
200 if test "$mingw32" = "yes" ; then
205 if test -z "$cross_prefix" ; then
208 # big/little endian test
210 #include <inttypes.h>
211 int main(int argc, char ** argv){
212 volatile uint32_t i=0x01234567;
213 return (*((uint8_t*)(&i))) == 0x67;
217 if $cc -o $TMPE $TMPC 2>/dev
/null
; then
218 $TMPE && bigendian
="yes"
220 echo big
/little
test failed
225 # if cross compiling, cannot launch a program, so make a static guess
226 if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" ; then
235 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
244 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
257 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
261 if test x
"$show_help" = "xyes" ; then
264 Usage: configure [options]
265 Options: [defaults in brackets after descriptions]
268 echo "Standard options:"
269 echo " --help print this message"
270 echo " --prefix=PREFIX install in PREFIX [$prefix]"
271 echo " --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX"
272 echo " [same as prefix]"
273 echo " --bindir=DIR user executables in DIR [EPREFIX/bin]"
274 echo " --libdir=DIR object code libraries in DIR [EPREFIX/lib]"
275 echo " --tccdir=DIR installation directory [EPREFIX/lib/tcc]"
276 echo " --includedir=DIR C header files in DIR [PREFIX/include]"
277 echo " --sharedir=DIR documentation root DIR [PREFIX]/share"
278 echo " --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]"
279 echo " --mandir=DIR man documentation in DIR [SHAREDIR/man]"
280 echo " --infodir=DIR info documentation in DIR [SHAREDIR/info]"
282 echo "Advanced options (experts only):"
283 echo " --source-path=PATH path of source code [$source_path]"
284 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
285 echo " --sysroot=PREFIX prepend PREFIX to library/include paths []"
286 echo " --cc=CC use C compiler CC [$cc]"
287 echo " --disable-static make libtcc.so instead of libtcc.a"
288 echo " --disable-rpath disable use of -rpath with the above"
289 echo " --strip-binaries strip symbol tables from resulting binaries"
290 echo " --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc.a"
291 echo " --enable-mingw32 build windows version on linux with mingw32"
292 echo " --enable-cygwin build windows version on windows with cygwin"
293 echo " [requires cygwin and mingw32-make]"
294 echo " --enable-cross build cross compilers"
295 echo " --extra-cflags= extra compiler flags"
296 echo " --extra-ldflags= extra linker options"
297 echo " --with-selinux use mmap instead of exec mem"
298 echo " [requires write access to /tmp]"
299 echo " --sysincludepaths=... specify system include paths, colon separated"
300 echo " --libpaths=... specify system library paths, colon separated"
301 echo " --crtprefix=... specify locations of crt?.o, colon separated"
302 echo " --elfinterp=... specify elf interpreter"
304 #echo "NOTE: The object files are build at the place where configure is launched"
308 if test "$mingw32" = "yes" ; then
309 if test x
"$tccdir" = x
""; then
312 if test -z "$prefix" ; then
313 prefix
="C:/Program Files/${tccdir}"
315 if test -z "$sharedir" ; then
321 libdir
="${prefix}/lib"
322 docdir
="${sharedir}/doc"
323 mandir
="${sharedir}/man"
324 infodir
="${sharedir}/info"
326 if test -z "$prefix" ; then
329 if test -z "$sharedir" ; then
330 sharedir
="${prefix}/share"
332 if test x
"$execprefix" = x
""; then
333 execprefix
="${prefix}"
335 if test x
"$libdir" = x
""; then
336 libdir
="${execprefix}/lib"
338 if test x
"$bindir" = x
""; then
339 bindir
="${execprefix}/bin"
341 if test x
"$tccdir" = x
""; then
344 if test x
"$docdir" = x
""; then
345 docdir
="${sharedir}/doc/${tccdir}"
347 if test x
"$mandir" = x
""; then
348 mandir
="${sharedir}/man"
350 if test x
"$infodir" = x
""; then
351 infodir
="${sharedir}/info"
353 tccdir
="${libdir}/${tccdir}"
356 if test x
"$includedir" = x
""; then
357 includedir
="${prefix}/include"
360 echo "Binary directory $bindir"
361 echo "TinyCC directory $tccdir"
362 echo "Library directory $libdir"
363 echo "Include directory $includedir"
364 echo "Manual directory $mandir"
365 echo "Info directory $infodir"
366 echo "Doc directory $docdir"
367 echo "Target root prefix $sysroot"
368 echo "Source path $source_path"
369 echo "C compiler $cc"
370 echo "Target OS $targetos"
372 echo "Big Endian $bigendian"
373 echo "gprof enabled $gprof"
374 echo "cross compilers $build_cross"
375 echo "use libgcc $use_libgcc"
377 echo "Creating config.mak and config.h"
379 echo "# Automatically generated by configure - do not modify" > config.mak
380 echo "/* Automatically generated by configure - do not modify */" > $TMPH
382 echo "prefix=$prefix" >> config.mak
383 echo "bindir=\$(DESTDIR)$bindir" >> config.mak
384 echo "tccdir=\$(DESTDIR)$tccdir" >> config.mak
385 echo "libdir=\$(DESTDIR)$libdir" >> config.mak
386 echo "ln_libdir=$libdir" >> config.mak
387 echo "includedir=\$(DESTDIR)$includedir" >> config.mak
388 echo "mandir=\$(DESTDIR)$mandir" >> config.mak
389 echo "infodir=\$(DESTDIR)$infodir" >> config.mak
390 echo "docdir=\$(DESTDIR)$docdir" >> config.mak
393 echo "#ifndef $1" >> $TMPH
394 echo "# define $1 \"$2\"" >> $TMPH
395 echo "#endif" >> $TMPH
399 if test -n "$2"; then print_var1
$1 "$2"; fi
401 print_var2 CONFIG_SYSROOT
"$sysroot"
402 print_var1 CONFIG_TCCDIR
"$tccdir"
403 print_var2 CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
404 print_var2 CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
405 print_var2 CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
406 print_var2 CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
408 echo "CC=$cc" >> config.mak
409 echo "GCC_MAJOR=$gcc_major" >> config.mak
410 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
411 echo "HOST_CC=$host_cc" >> config.mak
412 echo "AR=$ar" >> config.mak
413 echo "STRIP=$strip -s -R .comment -R .note" >> config.mak
414 echo "CFLAGS=$CFLAGS" >> config.mak
415 echo "LDFLAGS=$LDFLAGS" >> config.mak
416 echo "LIBSUF=$LIBSUF" >> config.mak
417 echo "EXESUF=$EXESUF" >> config.mak
419 if test "$cpu" = "x86" ; then
420 echo "ARCH=i386" >> config.mak
421 echo "#define HOST_I386 1" >> $TMPH
422 elif test "$cpu" = "x86-64" ; then
423 echo "ARCH=x86-64" >> config.mak
424 echo "#define HOST_X86_64 1" >> $TMPH
425 elif test "$cpu" = "armv4l" ; then
426 echo "ARCH=arm" >> config.mak
427 echo "#define HOST_ARM 1" >> $TMPH
428 echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH
429 elif test "$cpu" = "powerpc" ; then
430 echo "ARCH=ppc" >> config.mak
431 echo "#define HOST_PPC 1" >> $TMPH
432 elif test "$cpu" = "mips" ; then
433 echo "ARCH=mips" >> config.mak
434 echo "#define HOST_MIPS 1" >> $TMPH
435 elif test "$cpu" = "s390" ; then
436 echo "ARCH=s390" >> config.mak
437 echo "#define HOST_S390 1" >> $TMPH
438 elif test "$cpu" = "alpha" ; then
439 echo "ARCH=alpha" >> config.mak
440 echo "#define HOST_ALPHA 1" >> $TMPH
442 echo "Unsupported CPU"
445 echo "TARGETOS=$targetos" >> config.mak
446 if test "$noldl" = "yes" ; then
447 echo "CONFIG_NOLDL=yes" >> config.mak
449 if test "$mingw32" = "yes" ; then
450 echo "CONFIG_WIN32=yes" >> config.mak
451 echo "#define CONFIG_WIN32 1" >> $TMPH
453 if test "$cygwin" = "yes" ; then
454 echo "#ifndef _WIN32" >> $TMPH
455 echo "#define _WIN32" >> $TMPH
456 echo "#endif" >> $TMPH
457 echo "AR=ar" >> config.mak
459 if test "$bigendian" = "yes" ; then
460 echo "WORDS_BIGENDIAN=yes" >> config.mak
461 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
463 if test "$gprof" = "yes" ; then
464 echo "TARGET_GPROF=yes" >> config.mak
465 echo "#define HAVE_GPROF 1" >> $TMPH
467 if test "$build_cross" = "yes" ; then
468 echo "CONFIG_CROSS=yes" >> config.mak
470 if test "$disable_static" = "yes" ; then
471 echo "DISABLE_STATIC=yes" >> config.mak
473 if test "$disable_rpath" = "yes" ; then
474 echo "DISABLE_RPATH=yes" >> config.mak
476 if test "$strip_binaries" = "yes" ; then
477 echo "STRIP_BINARIES=yes" >> config.mak
479 if test "$use_libgcc" = "yes" ; then
480 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
481 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
483 if test "$have_selinux" = "yes" ; then
484 echo "#define HAVE_SELINUX" >> $TMPH
485 echo "HAVE_SELINUX=yes" >> config.mak
487 version
=`head $source_path/VERSION`
488 echo "VERSION=$version" >>config.mak
489 echo "#define TCC_VERSION \"$version\"" >> $TMPH
490 echo "@set VERSION $version" > config.texi
492 # build tree in object directory if source path is different from current one
493 if test "$source_path_used" = "yes" ; then
495 FILES
="Makefile tests/Makefile"
496 for dir
in $DIRS ; do
500 ln -sf $source_path/$f $f
503 echo "SRC_PATH=$source_path" >> config.mak
505 diff $TMPH config.h
>/dev
/null
2>&1
506 if test $?
-ne 0 ; then
509 echo "config.h is unchanged"