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"
107 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
109 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
111 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
113 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
115 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
117 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
119 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
121 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
123 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
125 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
127 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
129 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
131 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
133 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
135 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
137 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
139 --extra-libs=*) extralibs
=${opt#--extra-libs=}
141 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2`
143 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2`
145 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2`
147 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2`
149 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
151 --enable-gprof) gprof
="yes"
153 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i686-pc-mingw32-" ; cpu
=x86
155 --enable-cygwin) mingw32
="yes" ; cygwin
="yes" ; cross_prefix
="mingw32-" ; cpu
=x86
157 --enable-cygwin64) mingw32
="yes" ; cygwin
="yes" ; cross_prefix
="x86_64-w64-mingw32-" ; cpu
="x86-64"
159 --enable-cross) build_cross
="yes"
161 --disable-static) disable_static
="yes"
163 --disable-rpath) disable_rpath
="yes"
165 --strip-binaries) strip_binaries
="yes"
167 --with-libgcc) use_libgcc
="yes"
169 --with-selinux) have_selinux
="yes"
171 --help|
-h) show_help
="yes"
173 *) echo "configure: unrecognized option $opt"; exit 1
178 # Checking for CFLAGS
179 if test -z "$CFLAGS"; then
180 CFLAGS
="-Wall -g -O2"
183 cc
="${cross_prefix}${cc}"
184 ar="${cross_prefix}${ar}"
185 strip
="${cross_prefix}${strip}"
187 if test "$mingw32" = "yes" ; then
192 if test -z "$cross_prefix" ; then
195 # big/little endian test
197 #include <inttypes.h>
198 int main(int argc, char ** argv){
199 volatile uint32_t i=0x01234567;
200 return (*((uint8_t*)(&i))) == 0x67;
204 if $cc -o $TMPE $TMPC 2>/dev
/null
; then
205 $TMPE && bigendian
="yes"
207 echo big
/little
test failed
212 # if cross compiling, cannot launch a program, so make a static guess
213 if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" ; then
222 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
231 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
244 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
248 if test x
"$show_help" = "xyes" ; then
251 Usage: configure [options]
252 Options: [defaults in brackets after descriptions]
255 echo "Standard options:"
256 echo " --help print this message"
257 echo " --prefix=PREFIX install in PREFIX [$prefix]"
258 echo " --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX"
259 echo " [same as prefix]"
260 echo " --bindir=DIR user executables in DIR [EPREFIX/bin]"
261 echo " --libdir=DIR object code libraries in DIR [EPREFIX/lib]"
262 echo " --tccdir=DIR installation directory [EPREFIX/lib/tcc]"
263 echo " --includedir=DIR C header files in DIR [PREFIX/include]"
264 echo " --sharedir=DIR documentation root DIR [PREFIX]/share"
265 echo " --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]"
266 echo " --mandir=DIR man documentation in DIR [SHAREDIR/man]"
267 echo " --infodir=DIR info documentation in DIR [SHAREDIR/info]"
269 echo "Advanced options (experts only):"
270 echo " --source-path=PATH path of source code [$source_path]"
271 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
272 echo " --sysroot=PREFIX prepend PREFIX to library/include paths []"
273 echo " --cc=CC use C compiler CC [$cc]"
274 echo " --disable-static make libtcc.so instead of libtcc.a"
275 echo " --disable-rpath disable use of -rpath with the above"
276 echo " --strip-binaries strip symbol tables from resulting binaries"
277 echo " --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc.a"
278 echo " --enable-mingw32 build windows version on linux with mingw32"
279 echo " --enable-cygwin build windows version on windows with cygwin"
280 echo " [requires cygwin and mingw32-make]"
281 echo " --enable-cross build cross compilers"
282 echo " --extra-cflags= extra compiler flags"
283 echo " --extra-ldflags= extra linker options"
284 echo " --with-selinux use mmap instead of exec mem"
285 echo " [requires write access to /tmp]"
286 echo " --sysincludepaths=... specify system include paths, colon separated"
287 echo " --libpaths=... specify system library paths, colon separated"
288 echo " --crtprefix=... specify locations of crt?.o, colon separated"
289 echo " --elfinterp=... specify elf interpreter"
291 #echo "NOTE: The object files are build at the place where configure is launched"
295 if test "$mingw32" = "yes" ; then
296 if test x
"$tccdir" = x
""; then
299 if test -z "$prefix" ; then
300 prefix
="C:/Program Files/${tccdir}"
302 if test -z "$sharedir" ; then
308 libdir
="${prefix}/lib"
309 docdir
="${sharedir}/doc"
310 mandir
="${sharedir}/man"
311 infodir
="${sharedir}/info"
313 if test -z "$prefix" ; then
316 if test -z "$sharedir" ; then
317 sharedir
="${prefix}/share"
319 if test x
"$execprefix" = x
""; then
320 execprefix
="${prefix}"
322 if test x
"$libdir" = x
""; then
323 libdir
="${execprefix}/lib"
325 if test x
"$bindir" = x
""; then
326 bindir
="${execprefix}/bin"
328 if test x
"$tccdir" = x
""; then
331 if test x
"$docdir" = x
""; then
332 docdir
="${sharedir}/doc/${tccdir}"
334 if test x
"$mandir" = x
""; then
335 mandir
="${sharedir}/man"
337 if test x
"$infodir" = x
""; then
338 infodir
="${sharedir}/info"
340 tccdir
="${libdir}/${tccdir}"
343 if test x
"$includedir" = x
""; then
344 includedir
="${prefix}/include"
347 echo "Binary directory $bindir"
348 echo "TinyCC directory $tccdir"
349 echo "Library directory $libdir"
350 echo "Include directory $includedir"
351 echo "Manual directory $mandir"
352 echo "Info directory $infodir"
353 echo "Doc directory $docdir"
354 echo "Target root prefix $sysroot"
355 echo "Source path $source_path"
356 echo "C compiler $cc"
357 echo "Target OS $targetos"
359 echo "Big Endian $bigendian"
360 echo "gprof enabled $gprof"
361 echo "cross compilers $build_cross"
362 echo "use libgcc $use_libgcc"
364 echo "Creating config.mak and config.h"
366 echo "# Automatically generated by configure - do not modify" > config.mak
367 echo "/* Automatically generated by configure - do not modify */" > $TMPH
369 echo "prefix=$prefix" >> config.mak
370 echo "bindir=\$(DESTDIR)$bindir" >> config.mak
371 echo "tccdir=\$(DESTDIR)$tccdir" >> config.mak
372 echo "libdir=\$(DESTDIR)$libdir" >> config.mak
373 echo "ln_libdir=$libdir" >> config.mak
374 echo "includedir=\$(DESTDIR)$includedir" >> config.mak
375 echo "mandir=\$(DESTDIR)$mandir" >> config.mak
376 echo "infodir=\$(DESTDIR)$infodir" >> config.mak
377 echo "docdir=\$(DESTDIR)$docdir" >> config.mak
380 echo "#ifndef $1" >> $TMPH
381 echo "# define $1 \"$2\"" >> $TMPH
382 echo "#endif" >> $TMPH
386 if test -n "$2"; then print_var1
$1 "$2"; fi
388 print_var2 CONFIG_SYSROOT
"$sysroot"
389 print_var1 CONFIG_TCCDIR
"$tccdir"
390 print_var2 CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
391 print_var2 CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
392 print_var2 CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
393 print_var2 CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
395 echo "CC=$cc" >> config.mak
396 echo "GCC_MAJOR=$gcc_major" >> config.mak
397 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
398 echo "HOST_CC=$host_cc" >> config.mak
399 echo "AR=$ar" >> config.mak
400 echo "STRIP=$strip -s -R .comment -R .note" >> config.mak
401 echo "CFLAGS=$CFLAGS" >> config.mak
402 echo "LDFLAGS=$LDFLAGS" >> config.mak
403 echo "LIBSUF=$LIBSUF" >> config.mak
404 echo "EXESUF=$EXESUF" >> config.mak
406 if test "$cpu" = "x86" ; then
407 echo "ARCH=i386" >> config.mak
408 echo "#define HOST_I386 1" >> $TMPH
409 elif test "$cpu" = "x86-64" ; then
410 echo "ARCH=x86-64" >> config.mak
411 echo "#define HOST_X86_64 1" >> $TMPH
412 elif test "$cpu" = "armv4l" ; then
413 echo "ARCH=arm" >> config.mak
414 echo "#define HOST_ARM 1" >> $TMPH
415 elif test "$cpu" = "powerpc" ; then
416 echo "ARCH=ppc" >> config.mak
417 echo "#define HOST_PPC 1" >> $TMPH
418 elif test "$cpu" = "mips" ; then
419 echo "ARCH=mips" >> config.mak
420 echo "#define HOST_MIPS 1" >> $TMPH
421 elif test "$cpu" = "s390" ; then
422 echo "ARCH=s390" >> config.mak
423 echo "#define HOST_S390 1" >> $TMPH
424 elif test "$cpu" = "alpha" ; then
425 echo "ARCH=alpha" >> config.mak
426 echo "#define HOST_ALPHA 1" >> $TMPH
428 echo "Unsupported CPU"
431 echo "TARGETOS=$targetos" >> config.mak
432 if test "$noldl" = "yes" ; then
433 echo "CONFIG_NOLDL=yes" >> config.mak
435 if test "$mingw32" = "yes" ; then
436 if test "$cpu" = "x86-64" ; then
437 echo "CONFIG_WIN64=yes" >> config.mak
438 echo "#define CONFIG_WIN64 1" >> $TMPH
440 echo "CONFIG_WIN32=yes" >> config.mak
441 echo "#define CONFIG_WIN32 1" >> $TMPH
444 if test "$cygwin" = "yes" ; then
445 echo "#ifndef _WIN32" >> $TMPH
446 echo "#define _WIN32" >> $TMPH
447 echo "#endif" >> $TMPH
449 if test "$bigendian" = "yes" ; then
450 echo "WORDS_BIGENDIAN=yes" >> config.mak
451 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
453 if test "$gprof" = "yes" ; then
454 echo "TARGET_GPROF=yes" >> config.mak
455 echo "#define HAVE_GPROF 1" >> $TMPH
457 if test "$build_cross" = "yes" ; then
458 echo "CONFIG_CROSS=yes" >> config.mak
460 if test "$disable_static" = "yes" ; then
461 echo "DISABLE_STATIC=yes" >> config.mak
463 if test "$disable_rpath" = "yes" ; then
464 echo "DISABLE_RPATH=yes" >> config.mak
466 if test "$strip_binaries" = "yes" ; then
467 echo "STRIP_BINARIES=yes" >> config.mak
469 if test "$use_libgcc" = "yes" ; then
470 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
471 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
473 if test "$have_selinux" = "yes" ; then
474 echo "#define HAVE_SELINUX" >> $TMPH
475 echo "HAVE_SELINUX=yes" >> config.mak
477 version
=`head $source_path/VERSION`
478 echo "VERSION=$version" >>config.mak
479 echo "#define TCC_VERSION \"$version\"" >> $TMPH
480 echo "@set VERSION $version" > config.texi
482 # build tree in object directory if source path is different from current one
483 if test "$source_path_used" = "yes" ; then
485 FILES
="Makefile tests/Makefile"
486 for dir
in $DIRS ; do
490 ln -sf $source_path/$f $f
493 echo "SRC_PATH=$source_path" >> config.mak
495 diff $TMPH config.h
>/dev
/null
2>&1
496 if test $?
-ne 0 ; then
499 echo "config.h is unchanged"