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
)
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 x
"$show_help" = "xyes" ; then
266 Usage: configure [options]
267 Options: [defaults in brackets after descriptions]
270 echo "Standard options:"
271 echo " --help print this message"
272 echo " --prefix=PREFIX install in PREFIX [$prefix]"
273 echo " --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX"
274 echo " [same as prefix]"
275 echo " --bindir=DIR user executables in DIR [EPREFIX/bin]"
276 echo " --libdir=DIR object code libraries in DIR [EPREFIX/lib]"
277 echo " --tccdir=DIR installation directory [EPREFIX/lib/tcc]"
278 echo " --includedir=DIR C header files in DIR [PREFIX/include]"
279 echo " --sharedir=DIR documentation root DIR [PREFIX]/share"
280 echo " --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]"
281 echo " --mandir=DIR man documentation in DIR [SHAREDIR/man]"
282 echo " --infodir=DIR info documentation in DIR [SHAREDIR/info]"
284 echo "Advanced options (experts only):"
285 echo " --source-path=PATH path of source code [$source_path]"
286 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
287 echo " --sysroot=PREFIX prepend PREFIX to library/include paths []"
288 echo " --cc=CC use C compiler CC [$cc]"
289 echo " --disable-static make libtcc.so instead of libtcc.a"
290 echo " --disable-rpath disable use of -rpath with the above"
291 echo " --strip-binaries strip symbol tables from resulting binaries"
292 echo " --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc.a"
293 echo " --enable-mingw32 build windows version on linux with mingw32"
294 echo " --enable-cygwin build windows version on windows with cygwin"
295 echo " [requires cygwin and mingw32-make]"
296 echo " --enable-cross build cross compilers"
297 echo " --extra-cflags= extra compiler flags"
298 echo " --extra-ldflags= extra linker options"
299 echo " --with-selinux use mmap instead of exec mem"
300 echo " [requires write access to /tmp]"
301 echo " --sysincludepaths=... specify system include paths, colon separated"
302 echo " --libpaths=... specify system library paths, colon separated"
303 echo " --crtprefix=... specify locations of crt?.o, colon separated"
304 echo " --elfinterp=... specify elf interpreter"
306 #echo "NOTE: The object files are build at the place where configure is launched"
310 if test "$mingw32" = "yes" ; then
311 if test x
"$tccdir" = x
""; then
314 if test -z "$prefix" ; then
315 prefix
="C:/Program Files/${tccdir}"
317 if test -z "$sharedir" ; then
323 libdir
="${prefix}/lib"
324 docdir
="${sharedir}/doc"
325 mandir
="${sharedir}/man"
326 infodir
="${sharedir}/info"
328 if test -z "$prefix" ; then
331 if test -z "$sharedir" ; then
332 sharedir
="${prefix}/share"
334 if test x
"$execprefix" = x
""; then
335 execprefix
="${prefix}"
337 if test x
"$libdir" = x
""; then
338 libdir
="${execprefix}/lib"
340 if test x
"$bindir" = x
""; then
341 bindir
="${execprefix}/bin"
343 if test x
"$tccdir" = x
""; then
346 if test x
"$docdir" = x
""; then
347 docdir
="${sharedir}/doc/${tccdir}"
349 if test x
"$mandir" = x
""; then
350 mandir
="${sharedir}/man"
352 if test x
"$infodir" = x
""; then
353 infodir
="${sharedir}/info"
355 tccdir
="${libdir}/${tccdir}"
358 if test x
"$includedir" = x
""; then
359 includedir
="${prefix}/include"
362 echo "Binary directory $bindir"
363 echo "TinyCC directory $tccdir"
364 echo "Library directory $libdir"
365 echo "Include directory $includedir"
366 echo "Manual directory $mandir"
367 echo "Info directory $infodir"
368 echo "Doc directory $docdir"
369 echo "Target root prefix $sysroot"
370 echo "Source path $source_path"
371 echo "C compiler $cc"
372 echo "Target OS $targetos"
374 echo "Big Endian $bigendian"
375 echo "gprof enabled $gprof"
376 echo "cross compilers $build_cross"
377 echo "use libgcc $use_libgcc"
379 echo "Creating config.mak and config.h"
381 echo "# Automatically generated by configure - do not modify" > config.mak
382 echo "/* Automatically generated by configure - do not modify */" > $TMPH
384 echo "prefix=$prefix" >> config.mak
385 echo "bindir=\$(DESTDIR)$bindir" >> config.mak
386 echo "tccdir=\$(DESTDIR)$tccdir" >> config.mak
387 echo "libdir=\$(DESTDIR)$libdir" >> config.mak
388 echo "ln_libdir=$libdir" >> config.mak
389 echo "includedir=\$(DESTDIR)$includedir" >> config.mak
390 echo "mandir=\$(DESTDIR)$mandir" >> config.mak
391 echo "infodir=\$(DESTDIR)$infodir" >> config.mak
392 echo "docdir=\$(DESTDIR)$docdir" >> config.mak
395 echo "#ifndef $1" >> $TMPH
396 echo "# define $1 \"$2\"" >> $TMPH
397 echo "#endif" >> $TMPH
401 if test -n "$2"; then print_var1
$1 "$2"; fi
403 print_var2 CONFIG_SYSROOT
"$sysroot"
404 print_var1 CONFIG_TCCDIR
"$tccdir"
405 print_var2 CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
406 print_var2 CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
407 print_var2 CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
408 print_var2 CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
410 echo "CC=$cc" >> config.mak
411 echo "GCC_MAJOR=$gcc_major" >> config.mak
412 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
413 echo "HOST_CC=$host_cc" >> config.mak
414 echo "AR=$ar" >> config.mak
415 echo "STRIP=$strip -s -R .comment -R .note" >> config.mak
416 cat >> config.mak
<<EOF
417 CPPFLAGS = -I. -I\$(top_srcdir)
424 if test "$cpu" = "x86" ; then
425 echo "ARCH=i386" >> config.mak
426 echo "#define HOST_I386 1" >> $TMPH
427 elif test "$cpu" = "x86-64" ; then
428 echo "ARCH=x86-64" >> config.mak
429 echo "#define HOST_X86_64 1" >> $TMPH
430 elif test "$cpu" = "armv4l" ; then
431 echo "ARCH=arm" >> config.mak
432 echo "#define HOST_ARM 1" >> $TMPH
433 echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH
434 elif test "$cpu" = "powerpc" ; then
435 echo "ARCH=ppc" >> config.mak
436 echo "#define HOST_PPC 1" >> $TMPH
437 elif test "$cpu" = "mips" ; then
438 echo "ARCH=mips" >> config.mak
439 echo "#define HOST_MIPS 1" >> $TMPH
440 elif test "$cpu" = "s390" ; then
441 echo "ARCH=s390" >> config.mak
442 echo "#define HOST_S390 1" >> $TMPH
443 elif test "$cpu" = "alpha" ; then
444 echo "ARCH=alpha" >> config.mak
445 echo "#define HOST_ALPHA 1" >> $TMPH
447 echo "Unsupported CPU"
450 echo "TARGETOS=$targetos" >> config.mak
451 if test "$noldl" = "yes" ; then
452 echo "CONFIG_NOLDL=yes" >> config.mak
454 if test "$mingw32" = "yes" ; then
455 echo "CONFIG_WIN32=yes" >> config.mak
456 echo "#define CONFIG_WIN32 1" >> $TMPH
458 if test "$cygwin" = "yes" ; then
459 echo "#ifndef _WIN32" >> $TMPH
460 echo "#define _WIN32" >> $TMPH
461 echo "#endif" >> $TMPH
462 echo "AR=ar" >> config.mak
464 if test "$bigendian" = "yes" ; then
465 echo "WORDS_BIGENDIAN=yes" >> config.mak
466 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
468 if test "$gprof" = "yes" ; then
469 echo "TARGET_GPROF=yes" >> config.mak
470 echo "#define HAVE_GPROF 1" >> $TMPH
472 if test "$build_cross" = "yes" ; then
473 echo "CONFIG_CROSS=yes" >> config.mak
475 if test "$disable_static" = "yes" ; then
476 echo "DISABLE_STATIC=yes" >> config.mak
478 if test "$disable_rpath" = "yes" ; then
479 echo "DISABLE_RPATH=yes" >> config.mak
481 if test "$strip_binaries" = "yes" ; then
482 echo "STRIP_BINARIES=yes" >> config.mak
484 if test "$use_libgcc" = "yes" ; then
485 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
486 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
488 if test "$have_selinux" = "yes" ; then
489 echo "#define HAVE_SELINUX" >> $TMPH
490 echo "HAVE_SELINUX=yes" >> config.mak
492 version
=`head $source_path/VERSION`
493 echo "VERSION=$version" >>config.mak
494 echo "#define TCC_VERSION \"$version\"" >> $TMPH
495 echo "@set VERSION $version" > config.texi
497 # build tree in object directory if source path is different from current one
498 if test "$source_path_used" = "yes" ; then
499 FILES
="Makefile lib/Makefile tests/Makefile tests2/Makefile"
501 dir
=`fn_dirname "$f"`
502 test -d "$dir" || mkdir
-p "$dir"
503 back
=`echo "$source_path/$dir/" | sed 's,/\./,/,g;s,[^/]*/,../,g'`
508 cat >>config.mak
<<EOF
509 SRC_PATH = $source_path
510 top_builddir = \$(TOP)
513 /*) echo 'top_srcdir = $(SRC_PATH)';;
514 *) echo 'top_srcdir = $(TOP)/$(SRC_PATH)';;
517 diff $TMPH config.h
>/dev
/null
2>&1
518 if test $?
-ne 0 ; then
521 echo "config.h is unchanged"