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
)
54 arm|armv4l|armv5tel|armv5tejl|armv6j|armv7a|armv7l
)
60 "Power Macintosh"|ppc|ppc64
)
95 # XXX: we assume an absolute path is given when launching configure,
96 # except in './configure' case.
97 source_path
=${0%configure}
98 source_path
=${source_path%/}
99 source_path_used
="yes"
100 if test -z "$source_path" -o "$source_path" = "." ; then
102 source_path_used
="no"
108 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
110 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
112 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
114 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
116 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
118 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
120 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
122 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
124 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
126 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
128 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
130 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
132 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
134 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
136 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
138 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
140 --extra-libs=*) extralibs
=${opt#--extra-libs=}
142 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2`
144 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2`
146 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2`
148 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2`
150 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
152 --enable-gprof) gprof
="yes"
154 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i686-pc-mingw32-" ; cpu
=x86
156 --enable-cygwin) mingw32
="yes" ; cygwin
="yes" ; cross_prefix
="mingw32-" ; cpu
=x86
158 --enable-cross) build_cross
="yes"
160 --disable-static) disable_static
="yes"
162 --disable-rpath) disable_rpath
="yes"
164 --strip-binaries) strip_binaries
="yes"
166 --with-libgcc) use_libgcc
="yes"
168 --with-selinux) have_selinux
="yes"
170 --help|
-h) show_help
="yes"
172 *) echo "configure: WARNING: unrecognized option $opt"
177 # Checking for CFLAGS
178 if test -z "$CFLAGS"; then
179 CFLAGS
="-Wall -g -O2"
182 cc
="${cross_prefix}${cc}"
183 ar="${cross_prefix}${ar}"
184 strip
="${cross_prefix}${strip}"
186 if test "$mingw32" = "yes" ; then
191 if test -z "$cross_prefix" ; then
194 # big/little endian test
196 #include <inttypes.h>
197 int main(int argc, char ** argv){
198 volatile uint32_t i=0x01234567;
199 return (*((uint8_t*)(&i))) == 0x67;
203 if $cc -o $TMPE $TMPC 2>/dev
/null
; then
204 $TMPE && bigendian
="yes"
206 echo big
/little
test failed
211 # if cross compiling, cannot launch a program, so make a static guess
212 if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" ; then
221 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
230 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
243 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
247 if test x
"$show_help" = "xyes" ; then
250 Usage: configure [options]
251 Options: [defaults in brackets after descriptions]
254 echo "Standard options:"
255 echo " --help print this message"
256 echo " --prefix=PREFIX install in PREFIX [$prefix]"
257 echo " --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX"
258 echo " [same as prefix]"
259 echo " --bindir=DIR user executables in DIR [EPREFIX/bin]"
260 echo " --libdir=DIR object code libraries in DIR [EPREFIX/lib]"
261 echo " --tccdir=DIR installation directory [EPREFIX/lib/tcc]"
262 echo " --includedir=DIR C header files in DIR [PREFIX/include]"
263 echo " --sharedir=DIR documentation root DIR [PREFIX]/share"
264 echo " --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]"
265 echo " --mandir=DIR man documentation in DIR [SHAREDIR/man]"
266 echo " --infodir=DIR info documentation in DIR [SHAREDIR/info]"
268 echo "Advanced options (experts only):"
269 echo " --source-path=PATH path of source code [$source_path]"
270 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
271 echo " --sysroot=PREFIX prepend PREFIX to library/include paths []"
272 echo " --cc=CC use C compiler CC [$cc]"
273 echo " --disable-static make libtcc.so instead of libtcc.a"
274 echo " --disable-rpath disable use of -rpath with the above"
275 echo " --strip-binaries strip symbol tables from resulting binaries"
276 echo " --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc.a"
277 echo " --enable-mingw32 build windows version on linux with mingw32"
278 echo " --enable-cygwin build windows version on windows with cygwin"
279 echo " [requires cygwin and mingw32-make]"
280 echo " --enable-cross build cross compilers"
281 echo " --extra-cflags= extra compiler flags"
282 echo " --extra-ldflags= extra linker options"
283 echo " --with-selinux use mmap instead of exec mem"
284 echo " [requires write access to /tmp]"
285 echo " --sysincludepaths=... specify system include paths, colon separated"
286 echo " --libpaths=... specify system library paths, colon separated"
287 echo " --crtprefix=... specify locations of crt?.o, colon separated"
288 echo " --elfinterp=... specify elf interpreter"
290 #echo "NOTE: The object files are build at the place where configure is launched"
294 if test "$mingw32" = "yes" ; then
295 if test x
"$tccdir" = x
""; then
298 if test -z "$prefix" ; then
299 prefix
="C:/Program Files/${tccdir}"
301 if test -z "$sharedir" ; then
307 libdir
="${prefix}/lib"
308 docdir
="${sharedir}/doc"
309 mandir
="${sharedir}/man"
310 infodir
="${sharedir}/info"
312 if test -z "$prefix" ; then
315 if test -z "$sharedir" ; then
316 sharedir
="${prefix}/share"
318 if test x
"$execprefix" = x
""; then
319 execprefix
="${prefix}"
321 if test x
"$libdir" = x
""; then
322 libdir
="${execprefix}/lib"
324 if test x
"$bindir" = x
""; then
325 bindir
="${execprefix}/bin"
327 if test x
"$tccdir" = x
""; then
330 if test x
"$docdir" = x
""; then
331 docdir
="${sharedir}/doc/${tccdir}"
333 if test x
"$mandir" = x
""; then
334 mandir
="${sharedir}/man"
336 if test x
"$infodir" = x
""; then
337 infodir
="${sharedir}/info"
339 tccdir
="${libdir}/${tccdir}"
342 if test x
"$includedir" = x
""; then
343 includedir
="${prefix}/include"
346 echo "Binary directory $bindir"
347 echo "TinyCC directory $tccdir"
348 echo "Library directory $libdir"
349 echo "Include directory $includedir"
350 echo "Manual directory $mandir"
351 echo "Info directory $infodir"
352 echo "Doc directory $docdir"
353 echo "Target root prefix $sysroot"
354 echo "Source path $source_path"
355 echo "C compiler $cc"
356 echo "Target OS $targetos"
358 echo "Big Endian $bigendian"
359 echo "gprof enabled $gprof"
360 echo "cross compilers $build_cross"
361 echo "use libgcc $use_libgcc"
363 echo "Creating config.mak and config.h"
365 echo "# Automatically generated by configure - do not modify" > config.mak
366 echo "/* Automatically generated by configure - do not modify */" > $TMPH
368 echo "prefix=$prefix" >> config.mak
369 echo "bindir=\$(DESTDIR)$bindir" >> config.mak
370 echo "tccdir=\$(DESTDIR)$tccdir" >> config.mak
371 echo "libdir=\$(DESTDIR)$libdir" >> config.mak
372 echo "ln_libdir=$libdir" >> config.mak
373 echo "includedir=\$(DESTDIR)$includedir" >> config.mak
374 echo "mandir=\$(DESTDIR)$mandir" >> config.mak
375 echo "infodir=\$(DESTDIR)$infodir" >> config.mak
376 echo "docdir=\$(DESTDIR)$docdir" >> config.mak
379 echo "#ifndef $1" >> $TMPH
380 echo "# define $1 \"$2\"" >> $TMPH
381 echo "#endif" >> $TMPH
385 if test -n "$2"; then print_var1
$1 "$2"; fi
387 print_var2 CONFIG_SYSROOT
"$sysroot"
388 print_var1 CONFIG_TCCDIR
"$tccdir"
389 print_var2 CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
390 print_var2 CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
391 print_var2 CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
392 print_var2 CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
394 echo "CC=$cc" >> config.mak
395 echo "GCC_MAJOR=$gcc_major" >> config.mak
396 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
397 echo "HOST_CC=$host_cc" >> config.mak
398 echo "AR=$ar" >> config.mak
399 echo "STRIP=$strip -s -R .comment -R .note" >> config.mak
400 echo "CFLAGS=$CFLAGS" >> config.mak
401 echo "LDFLAGS=$LDFLAGS" >> config.mak
402 echo "LIBSUF=$LIBSUF" >> config.mak
403 echo "EXESUF=$EXESUF" >> config.mak
405 if test "$cpu" = "x86" ; then
406 echo "ARCH=i386" >> config.mak
407 echo "#define HOST_I386 1" >> $TMPH
408 elif test "$cpu" = "x86-64" ; then
409 echo "ARCH=x86-64" >> config.mak
410 echo "#define HOST_X86_64 1" >> $TMPH
411 elif test "$cpu" = "armv4l" ; then
412 echo "ARCH=arm" >> config.mak
413 echo "#define HOST_ARM 1" >> $TMPH
414 elif test "$cpu" = "powerpc" ; then
415 echo "ARCH=ppc" >> config.mak
416 echo "#define HOST_PPC 1" >> $TMPH
417 elif test "$cpu" = "mips" ; then
418 echo "ARCH=mips" >> config.mak
419 echo "#define HOST_MIPS 1" >> $TMPH
420 elif test "$cpu" = "s390" ; then
421 echo "ARCH=s390" >> config.mak
422 echo "#define HOST_S390 1" >> $TMPH
423 elif test "$cpu" = "alpha" ; then
424 echo "ARCH=alpha" >> config.mak
425 echo "#define HOST_ALPHA 1" >> $TMPH
427 echo "Unsupported CPU"
430 echo "TARGETOS=$targetos" >> config.mak
431 if test "$noldl" = "yes" ; then
432 echo "CONFIG_NOLDL=yes" >> config.mak
434 if test "$mingw32" = "yes" ; then
435 echo "CONFIG_WIN32=yes" >> config.mak
436 echo "#define CONFIG_WIN32 1" >> $TMPH
438 if test "$cygwin" = "yes" ; then
439 echo "#ifndef _WIN32" >> $TMPH
440 echo "#define _WIN32" >> $TMPH
441 echo "#endif" >> $TMPH
442 echo "AR=ar" >> config.mak
444 if test "$bigendian" = "yes" ; then
445 echo "WORDS_BIGENDIAN=yes" >> config.mak
446 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
448 if test "$gprof" = "yes" ; then
449 echo "TARGET_GPROF=yes" >> config.mak
450 echo "#define HAVE_GPROF 1" >> $TMPH
452 if test "$build_cross" = "yes" ; then
453 echo "CONFIG_CROSS=yes" >> config.mak
455 if test "$disable_static" = "yes" ; then
456 echo "DISABLE_STATIC=yes" >> config.mak
458 if test "$disable_rpath" = "yes" ; then
459 echo "DISABLE_RPATH=yes" >> config.mak
461 if test "$strip_binaries" = "yes" ; then
462 echo "STRIP_BINARIES=yes" >> config.mak
464 if test "$use_libgcc" = "yes" ; then
465 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
466 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
468 if test "$have_selinux" = "yes" ; then
469 echo "#define HAVE_SELINUX" >> $TMPH
470 echo "HAVE_SELINUX=yes" >> config.mak
472 version
=`head $source_path/VERSION`
473 echo "VERSION=$version" >>config.mak
474 echo "#define TCC_VERSION \"$version\"" >> $TMPH
475 echo "@set VERSION $version" > config.texi
477 # build tree in object directory if source path is different from current one
478 if test "$source_path_used" = "yes" ; then
480 FILES
="Makefile tests/Makefile"
481 for dir
in $DIRS ; do
485 ln -sf $source_path/$f $f
488 echo "SRC_PATH=$source_path" >> config.mak
490 diff $TMPH config.h
>/dev
/null
2>&1
491 if test $?
-ne 0 ; then
494 echo "config.h is unchanged"