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 i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
48 armv4l|armv5tel|armv6j|armv7a
)
54 "Power Macintosh"|ppc|ppc64
)
89 # XXX: we assume an absolute path is given when launching configure,
90 # except in './configure' case.
91 source_path
=${0%configure}
92 source_path
=${source_path%/}
93 source_path_used
="yes"
94 if test -z "$source_path" -o "$source_path" = "." ; then
101 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
103 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
105 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
107 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
109 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
111 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
113 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
115 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
117 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
119 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
121 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
123 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
125 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
127 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
129 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
131 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
133 --extra-libs=*) extralibs
=${opt#--extra-libs=}
135 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
137 --enable-gprof) gprof
="yes"
139 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i686-pc-mingw32-" ; cpu
=x86
141 --enable-cygwin) mingw32
="yes" ; cygwin
="yes" ; cross_prefix
="mingw32-" ; cpu
=x86
143 --enable-cross) build_cross
="yes"
145 --disable-static) disable_static
="yes"
147 --disable-rpath) disable_rpath
="yes"
149 --with-libgcc) use_libgcc
="yes"
151 --with-selinux) have_selinux
="yes"
153 --help|
-h) show_help
="yes"
158 # Checking for CFLAGS
159 if test -z "$CFLAGS"; then
163 cc
="${cross_prefix}${cc}"
164 ar="${cross_prefix}${ar}"
165 strip
="${cross_prefix}${strip}"
167 if test "$mingw32" = "yes" ; then
172 if test -z "$cross_prefix" ; then
175 # big/little endian test
177 #include <inttypes.h>
178 int main(int argc, char ** argv){
179 volatile uint32_t i=0x01234567;
180 return (*((uint8_t*)(&i))) == 0x67;
184 if $cc -o $TMPE $TMPC 2>/dev
/null
; then
185 $TMPE && bigendian
="yes"
187 echo big
/little
test failed
192 # if cross compiling, cannot launch a program, so make a static guess
193 if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" ; then
202 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
211 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
224 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
228 if test x
"$show_help" = "xyes" ; then
231 Usage: configure [options]
232 Options: [defaults in brackets after descriptions]
235 echo "Standard options:"
236 echo " --help print this message"
237 echo " --prefix=PREFIX install in PREFIX [$prefix]"
238 echo " --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX"
239 echo " [same as prefix]"
240 echo " --bindir=DIR user executables in DIR [EPREFIX/bin]"
241 echo " --libdir=DIR object code libraries in DIR [EPREFIX/lib]"
242 echo " --tccdir=DIR installation directory [EPREFIX/lib/tcc]"
243 echo " --includedir=DIR C header files in DIR [PREFIX/include]"
244 echo " --sharedir=DIR documentation root DIR [PREFIX]/share"
245 echo " --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]"
246 echo " --mandir=DIR man documentation in DIR [SHAREDIR/man]"
247 echo " --infodir=DIR info documentation in DIR [SHAREDIR/info]"
249 echo "Advanced options (experts only):"
250 echo " --source-path=PATH path of source code [$source_path]"
251 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
252 echo " --sysroot=PREFIX prepend PREFIX to library/include paths []"
253 echo " --cc=CC use C compiler CC [$cc]"
254 echo " --disable-static make libtcc.so instead of libtcc.a"
255 echo " --disable-rpath disable use of -rpath with the above"
256 echo " --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc.a"
257 echo " --enable-mingw32 build windows version on linux with mingw32"
258 echo " --enable-cygwin build windows version on windows with cygwin"
259 echo " [requires cygwin and mingw32-make]"
260 echo " --enable-cross build cross compilers"
261 echo " --extra-cflags= extra compiler flags"
262 echo " --extra-ldflags= extra linker options"
263 echo " --with-selinux use mmap instead of exec mem"
264 echo " [requires write access to /tmp]"
266 #echo "NOTE: The object files are build at the place where configure is launched"
270 if test "$mingw32" = "yes" ; then
271 if test x
"$tccdir" = x
""; then
274 if test -z "$prefix" ; then
275 prefix
="C:/Program Files/${tccdir}"
277 if test -z "$sharedir" ; then
283 libdir
="${prefix}/lib"
284 docdir
="${sharedir}/doc"
285 mandir
="${sharedir}/man"
286 infodir
="${sharedir}/info"
288 if test -z "$prefix" ; then
291 if test -z "$sharedir" ; then
292 sharedir
="${prefix}/share"
294 if test x
"$execprefix" = x
""; then
295 execprefix
="${prefix}"
297 if test x
"$libdir" = x
""; then
298 libdir
="${execprefix}/lib"
300 if test x
"$bindir" = x
""; then
301 bindir
="${execprefix}/bin"
303 if test x
"$tccdir" = x
""; then
306 if test x
"$docdir" = x
""; then
307 docdir
="${sharedir}/doc/${tccdir}"
309 if test x
"$mandir" = x
""; then
310 mandir
="${sharedir}/man"
312 if test x
"$infodir" = x
""; then
313 infodir
="${sharedir}/info"
315 tccdir
="${libdir}/${tccdir}"
318 if test x
"$includedir" = x
""; then
319 includedir
="${prefix}/include"
322 echo "Binary directory $bindir"
323 echo "TinyCC directory $tccdir"
324 echo "Library directory $libdir"
325 echo "Include directory $includedir"
326 echo "Manual directory $mandir"
327 echo "Info directory $infodir"
328 echo "Doc directory $docdir"
329 echo "Target root prefix $sysroot"
330 echo "Source path $source_path"
331 echo "C compiler $cc"
333 echo "Big Endian $bigendian"
334 echo "gprof enabled $gprof"
335 echo "cross compilers $build_cross"
336 echo "use libgcc $use_libgcc"
338 echo "Creating config.mak and config.h"
340 echo "# Automatically generated by configure - do not modify" > config.mak
341 echo "/* Automatically generated by configure - do not modify */" > $TMPH
343 echo "prefix=$prefix" >> config.mak
344 echo "bindir=\$(DESTDIR)$bindir" >> config.mak
345 echo "tccdir=\$(DESTDIR)$tccdir" >> config.mak
346 echo "libdir=\$(DESTDIR)$libdir" >> config.mak
347 echo "ln_libdir=$libdir" >> config.mak
348 echo "includedir=\$(DESTDIR)$includedir" >> config.mak
349 echo "mandir=\$(DESTDIR)$mandir" >> config.mak
350 echo "infodir=\$(DESTDIR)$infodir" >> config.mak
351 echo "docdir=\$(DESTDIR)$docdir" >> config.mak
353 echo "#define CONFIG_SYSROOT \"$sysroot\"" >> $TMPH
354 echo "#ifndef CONFIG_TCCDIR" >> $TMPH
355 echo "#define CONFIG_TCCDIR \"$tccdir\"" >> $TMPH
356 echo "#endif" >> $TMPH
357 echo "CC=$cc" >> config.mak
358 echo "GCC_MAJOR=$gcc_major" >> config.mak
359 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
360 echo "HOST_CC=$host_cc" >> config.mak
361 echo "AR=$ar" >> config.mak
362 echo "STRIP=$strip -s -R .comment -R .note" >> config.mak
363 echo "CFLAGS=$CFLAGS" >> config.mak
364 echo "LDFLAGS=$LDFLAGS" >> config.mak
365 echo "LIBSUF=$LIBSUF" >> config.mak
366 echo "EXESUF=$EXESUF" >> config.mak
367 if test "$cpu" = "x86" ; then
368 echo "ARCH=i386" >> config.mak
369 echo "#define HOST_I386 1" >> $TMPH
370 elif test "$cpu" = "x86-64" ; then
371 echo "ARCH=x86-64" >> config.mak
372 echo "#define HOST_X86_64 1" >> $TMPH
373 elif test "$cpu" = "armv4l" ; then
374 echo "ARCH=arm" >> config.mak
375 echo "#define HOST_ARM 1" >> $TMPH
376 elif test "$cpu" = "powerpc" ; then
377 echo "ARCH=ppc" >> config.mak
378 echo "#define HOST_PPC 1" >> $TMPH
379 elif test "$cpu" = "mips" ; then
380 echo "ARCH=mips" >> config.mak
381 echo "#define HOST_MIPS 1" >> $TMPH
382 elif test "$cpu" = "s390" ; then
383 echo "ARCH=s390" >> config.mak
384 echo "#define HOST_S390 1" >> $TMPH
385 elif test "$cpu" = "alpha" ; then
386 echo "ARCH=alpha" >> config.mak
387 echo "#define HOST_ALPHA 1" >> $TMPH
389 echo "Unsupported CPU"
392 if test "$noldl" = "yes" ; then
393 echo "CONFIG_NOLDL=yes" >> config.mak
395 if test "$mingw32" = "yes" ; then
396 echo "CONFIG_WIN32=yes" >> config.mak
397 echo "#define CONFIG_WIN32 1" >> $TMPH
399 if test "$cygwin" = "yes" ; then
400 echo "#ifndef _WIN32" >> $TMPH
401 echo "#define _WIN32" >> $TMPH
402 echo "#endif" >> $TMPH
403 echo "AR=ar" >> config.mak
405 if test "$bigendian" = "yes" ; then
406 echo "WORDS_BIGENDIAN=yes" >> config.mak
407 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
409 if test "$gprof" = "yes" ; then
410 echo "TARGET_GPROF=yes" >> config.mak
411 echo "#define HAVE_GPROF 1" >> $TMPH
413 if test "$build_cross" = "yes" ; then
414 echo "CONFIG_CROSS=yes" >> config.mak
416 if test "$disable_static" = "yes" ; then
417 echo "DISABLE_STATIC=yes" >> config.mak
419 if test "$disable_rpath" = "yes" ; then
420 echo "DISABLE_RPATH=yes" >> config.mak
422 if test "$use_libgcc" = "yes" ; then
423 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
424 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
426 if test "$have_selinux" = "yes" ; then
427 echo "#define HAVE_SELINUX" >> $TMPH
428 echo "HAVE_SELINUX=yes" >> config.mak
430 version
=`head $source_path/VERSION`
431 echo "VERSION=$version" >>config.mak
432 echo "#define TCC_VERSION \"$version\"" >> $TMPH
433 echo "@set VERSION $version" > config.texi
435 # build tree in object directory if source path is different from current one
436 if test "$source_path_used" = "yes" ; then
438 FILES
="Makefile tests/Makefile"
439 for dir
in $DIRS ; do
443 ln -sf $source_path/$f $f
446 echo "SRC_PATH=$source_path" >> config.mak
448 diff $TMPH config.h
>/dev
/null
2>&1
449 if test $?
-ne 0 ; then
452 echo "config.h is unchanged"