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-cross) build_cross
="yes"
159 --disable-static) disable_static
="yes"
161 --disable-rpath) disable_rpath
="yes"
163 --strip-binaries) strip_binaries
="yes"
165 --with-libgcc) use_libgcc
="yes"
167 --with-selinux) have_selinux
="yes"
169 --help|
-h) show_help
="yes"
174 # Checking for CFLAGS
175 if test -z "$CFLAGS"; then
176 CFLAGS
="-Wall -g -O2"
179 cc
="${cross_prefix}${cc}"
180 ar="${cross_prefix}${ar}"
181 strip
="${cross_prefix}${strip}"
183 if test "$mingw32" = "yes" ; then
188 if test -z "$cross_prefix" ; then
191 # big/little endian test
193 #include <inttypes.h>
194 int main(int argc, char ** argv){
195 volatile uint32_t i=0x01234567;
196 return (*((uint8_t*)(&i))) == 0x67;
200 if $cc -o $TMPE $TMPC 2>/dev
/null
; then
201 $TMPE && bigendian
="yes"
203 echo big
/little
test failed
208 # if cross compiling, cannot launch a program, so make a static guess
209 if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" ; then
218 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
227 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
240 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
244 if test x
"$show_help" = "xyes" ; then
247 Usage: configure [options]
248 Options: [defaults in brackets after descriptions]
251 echo "Standard options:"
252 echo " --help print this message"
253 echo " --prefix=PREFIX install in PREFIX [$prefix]"
254 echo " --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX"
255 echo " [same as prefix]"
256 echo " --bindir=DIR user executables in DIR [EPREFIX/bin]"
257 echo " --libdir=DIR object code libraries in DIR [EPREFIX/lib]"
258 echo " --tccdir=DIR installation directory [EPREFIX/lib/tcc]"
259 echo " --includedir=DIR C header files in DIR [PREFIX/include]"
260 echo " --sharedir=DIR documentation root DIR [PREFIX]/share"
261 echo " --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]"
262 echo " --mandir=DIR man documentation in DIR [SHAREDIR/man]"
263 echo " --infodir=DIR info documentation in DIR [SHAREDIR/info]"
265 echo "Advanced options (experts only):"
266 echo " --source-path=PATH path of source code [$source_path]"
267 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
268 echo " --sysroot=PREFIX prepend PREFIX to library/include paths []"
269 echo " --cc=CC use C compiler CC [$cc]"
270 echo " --disable-static make libtcc.so instead of libtcc.a"
271 echo " --disable-rpath disable use of -rpath with the above"
272 echo " --strip-binaries strip symbol tables from resulting binaries"
273 echo " --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc.a"
274 echo " --enable-mingw32 build windows version on linux with mingw32"
275 echo " --enable-cygwin build windows version on windows with cygwin"
276 echo " [requires cygwin and mingw32-make]"
277 echo " --enable-cross build cross compilers"
278 echo " --extra-cflags= extra compiler flags"
279 echo " --extra-ldflags= extra linker options"
280 echo " --with-selinux use mmap instead of exec mem"
281 echo " [requires write access to /tmp]"
282 echo " --sysincludepaths=... specify system include paths, colon separated"
283 echo " --libpaths=... specify system library paths, colon separated"
284 echo " --crtprefix=... specify locations of crt?.o, colon separated"
285 echo " --elfinterp=... specify elf interpreter"
287 #echo "NOTE: The object files are build at the place where configure is launched"
291 if test "$mingw32" = "yes" ; then
292 if test x
"$tccdir" = x
""; then
295 if test -z "$prefix" ; then
296 prefix
="C:/Program Files/${tccdir}"
298 if test -z "$sharedir" ; then
304 libdir
="${prefix}/lib"
305 docdir
="${sharedir}/doc"
306 mandir
="${sharedir}/man"
307 infodir
="${sharedir}/info"
309 if test -z "$prefix" ; then
312 if test -z "$sharedir" ; then
313 sharedir
="${prefix}/share"
315 if test x
"$execprefix" = x
""; then
316 execprefix
="${prefix}"
318 if test x
"$libdir" = x
""; then
319 libdir
="${execprefix}/lib"
321 if test x
"$bindir" = x
""; then
322 bindir
="${execprefix}/bin"
324 if test x
"$tccdir" = x
""; then
327 if test x
"$docdir" = x
""; then
328 docdir
="${sharedir}/doc/${tccdir}"
330 if test x
"$mandir" = x
""; then
331 mandir
="${sharedir}/man"
333 if test x
"$infodir" = x
""; then
334 infodir
="${sharedir}/info"
336 tccdir
="${libdir}/${tccdir}"
339 if test x
"$includedir" = x
""; then
340 includedir
="${prefix}/include"
343 echo "Binary directory $bindir"
344 echo "TinyCC directory $tccdir"
345 echo "Library directory $libdir"
346 echo "Include directory $includedir"
347 echo "Manual directory $mandir"
348 echo "Info directory $infodir"
349 echo "Doc directory $docdir"
350 echo "Target root prefix $sysroot"
351 echo "Source path $source_path"
352 echo "C compiler $cc"
354 echo "Big Endian $bigendian"
355 echo "gprof enabled $gprof"
356 echo "cross compilers $build_cross"
357 echo "use libgcc $use_libgcc"
359 echo "Creating config.mak and config.h"
361 echo "# Automatically generated by configure - do not modify" > config.mak
362 echo "/* Automatically generated by configure - do not modify */" > $TMPH
364 echo "prefix=$prefix" >> config.mak
365 echo "bindir=\$(DESTDIR)$bindir" >> config.mak
366 echo "tccdir=\$(DESTDIR)$tccdir" >> config.mak
367 echo "libdir=\$(DESTDIR)$libdir" >> config.mak
368 echo "ln_libdir=$libdir" >> config.mak
369 echo "includedir=\$(DESTDIR)$includedir" >> config.mak
370 echo "mandir=\$(DESTDIR)$mandir" >> config.mak
371 echo "infodir=\$(DESTDIR)$infodir" >> config.mak
372 echo "docdir=\$(DESTDIR)$docdir" >> config.mak
375 echo "#ifndef $1" >> $TMPH
376 echo "# define $1 \"$2\"" >> $TMPH
377 echo "#endif" >> $TMPH
381 if test -n "$2"; then print_var1
$1 "$2"; fi
383 print_var1 CONFIG_SYSROOT
"$sysroot"
384 print_var1 CONFIG_TCCDIR
"$tccdir"
385 print_var2 CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
386 print_var2 CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
387 print_var2 CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
388 print_var2 CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
390 echo "CC=$cc" >> config.mak
391 echo "GCC_MAJOR=$gcc_major" >> config.mak
392 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
393 echo "HOST_CC=$host_cc" >> config.mak
394 echo "AR=$ar" >> config.mak
395 echo "STRIP=$strip -s -R .comment -R .note" >> config.mak
396 echo "CFLAGS=$CFLAGS" >> config.mak
397 echo "LDFLAGS=$LDFLAGS" >> config.mak
398 echo "LIBSUF=$LIBSUF" >> config.mak
399 echo "EXESUF=$EXESUF" >> config.mak
401 if test "$cpu" = "x86" ; then
402 echo "ARCH=i386" >> config.mak
403 echo "#define HOST_I386 1" >> $TMPH
404 elif test "$cpu" = "x86-64" ; then
405 echo "ARCH=x86-64" >> config.mak
406 echo "#define HOST_X86_64 1" >> $TMPH
407 elif test "$cpu" = "armv4l" ; then
408 echo "ARCH=arm" >> config.mak
409 echo "#define HOST_ARM 1" >> $TMPH
410 elif test "$cpu" = "powerpc" ; then
411 echo "ARCH=ppc" >> config.mak
412 echo "#define HOST_PPC 1" >> $TMPH
413 elif test "$cpu" = "mips" ; then
414 echo "ARCH=mips" >> config.mak
415 echo "#define HOST_MIPS 1" >> $TMPH
416 elif test "$cpu" = "s390" ; then
417 echo "ARCH=s390" >> config.mak
418 echo "#define HOST_S390 1" >> $TMPH
419 elif test "$cpu" = "alpha" ; then
420 echo "ARCH=alpha" >> config.mak
421 echo "#define HOST_ALPHA 1" >> $TMPH
423 echo "Unsupported CPU"
426 if test "$noldl" = "yes" ; then
427 echo "CONFIG_NOLDL=yes" >> config.mak
429 if test "$mingw32" = "yes" ; then
430 echo "CONFIG_WIN32=yes" >> config.mak
431 echo "#define CONFIG_WIN32 1" >> $TMPH
433 if test "$cygwin" = "yes" ; then
434 echo "#ifndef _WIN32" >> $TMPH
435 echo "#define _WIN32" >> $TMPH
436 echo "#endif" >> $TMPH
437 echo "AR=ar" >> config.mak
439 if test "$bigendian" = "yes" ; then
440 echo "WORDS_BIGENDIAN=yes" >> config.mak
441 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
443 if test "$gprof" = "yes" ; then
444 echo "TARGET_GPROF=yes" >> config.mak
445 echo "#define HAVE_GPROF 1" >> $TMPH
447 if test "$build_cross" = "yes" ; then
448 echo "CONFIG_CROSS=yes" >> config.mak
450 if test "$disable_static" = "yes" ; then
451 echo "DISABLE_STATIC=yes" >> config.mak
453 if test "$disable_rpath" = "yes" ; then
454 echo "DISABLE_RPATH=yes" >> config.mak
456 if test "$strip_binaries" = "yes" ; then
457 echo "STRIP_BINARIES=yes" >> config.mak
459 if test "$use_libgcc" = "yes" ; then
460 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
461 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
463 if test "$have_selinux" = "yes" ; then
464 echo "#define HAVE_SELINUX" >> $TMPH
465 echo "HAVE_SELINUX=yes" >> config.mak
467 version
=`head $source_path/VERSION`
468 echo "VERSION=$version" >>config.mak
469 echo "#define TCC_VERSION \"$version\"" >> $TMPH
470 echo "@set VERSION $version" > config.texi
472 # build tree in object directory if source path is different from current one
473 if test "$source_path_used" = "yes" ; then
475 FILES
="Makefile tests/Makefile"
476 for dir
in $DIRS ; do
480 ln -sf $source_path/$f $f
483 echo "SRC_PATH=$source_path" >> config.mak
485 diff $TMPH config.h
>/dev
/null
2>&1
486 if test $?
-ne 0 ; then
489 echo "config.h is unchanged"