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
=""
54 MINGW32
*) mingw32
=yes;;
55 DragonFly
) noldl
=yes;;
62 # XXX: we assume an absolute path is given when launching configure,
63 # except in './configure' case.
64 source_path
=${0%configure}
65 source_path
=${source_path%/}
66 source_path_used
="yes"
67 if test -z "$source_path" -o "$source_path" = "." ; then
73 i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
99 "Power Macintosh"|ppc|ppc64
)
116 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
118 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
120 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
122 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
124 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
126 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
128 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
130 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
132 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
134 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
136 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
138 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
140 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
142 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
144 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
146 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
148 --extra-libs=*) extralibs
=${opt#--extra-libs=}
150 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2`
152 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2`
154 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2`
156 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2`
158 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
160 --enable-gprof) gprof
="yes"
162 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i686-pc-mingw32-" ; cpu
=x86
164 --enable-cygwin) mingw32
="yes" ; cygwin
="yes" ; cross_prefix
="mingw32-" ; cpu
=x86
166 --enable-cross) build_cross
="yes"
168 --disable-static) disable_static
="yes"
170 --disable-rpath) disable_rpath
="yes"
172 --strip-binaries) strip_binaries
="yes"
174 --with-libgcc) use_libgcc
="yes"
176 --with-selinux) have_selinux
="yes"
178 --help|
-h) show_help
="yes"
180 *) echo "configure: WARNING: unrecognized option $opt"
185 # Checking for CFLAGS
186 if test -z "$CFLAGS"; then
187 CFLAGS
="-Wall -g -O2"
190 if test "$mingw32" = "yes" ; then
191 if test x
"$tccdir" = x
""; then
194 if test -z "$prefix" ; then
195 prefix
="C:/Program Files/${tccdir}"
197 if test -z "$sharedir" ; then
203 libdir
="${prefix}/lib"
204 docdir
="${sharedir}/doc"
205 mandir
="${sharedir}/man"
206 infodir
="${sharedir}/info"
210 if test -z "$prefix" ; then
213 if test -z "$sharedir" ; then
214 sharedir
="${prefix}/share"
216 if test x
"$execprefix" = x
""; then
217 execprefix
="${prefix}"
219 if test x
"$libdir" = x
""; then
220 libdir
="${execprefix}/lib"
222 if test x
"$bindir" = x
""; then
223 bindir
="${execprefix}/bin"
225 if test x
"$tccdir" = x
""; then
228 if test x
"$docdir" = x
""; then
229 docdir
="${sharedir}/doc/${tccdir}"
231 if test x
"$mandir" = x
""; then
232 mandir
="${sharedir}/man"
234 if test x
"$infodir" = x
""; then
235 infodir
="${sharedir}/info"
237 tccdir
="${libdir}/${tccdir}"
240 if test x
"$includedir" = x
""; then
241 includedir
="${prefix}/include"
244 if test x
"$show_help" = "xyes" ; then
246 Usage: configure [options]
247 Options: [defaults in brackets after descriptions]
250 --help print this message
251 --prefix=PREFIX install in PREFIX [$prefix]
252 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
254 --bindir=DIR user executables in DIR [EPREFIX/bin]
255 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
256 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
257 --includedir=DIR C header files in DIR [PREFIX/include]
258 --sharedir=DIR documentation root DIR [PREFIX/share]
259 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
260 --mandir=DIR man documentation in DIR [SHAREDIR/man]
261 --infodir=DIR info documentation in DIR [SHAREDIR/info]
263 Advanced options (experts only):
264 --source-path=PATH path of source code [$source_path]
265 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
266 --sysroot=PREFIX prepend PREFIX to library/include paths []
267 --cc=CC use C compiler CC [$cc]
268 --extra-cflags= specify compiler flags [$CFLAGS]
269 --extra-ldflags= specify linker options []
270 --strip-binaries strip symbol tables from resulting binaries
271 --disable-static make libtcc.so instead of libtcc.a
272 --disable-rpath disable use of -rpath with the above
273 --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc.a
274 --enable-mingw32 build windows version on linux with mingw32
275 --enable-cygwin build windows version on windows with cygwin
276 --enable-cross build cross compilers
277 --with-selinux use mmap for exec mem [needs writable /tmp]
278 --sysincludepaths=... specify system include paths, colon separated
279 --libpaths=... specify system library paths, colon separated
280 --crtprefix=... specify locations of crt?.o, colon separated
281 --elfinterp=... specify elf interpreter
283 #echo "NOTE: The object files are build at the place where configure is launched"
287 cc
="${cross_prefix}${cc}"
288 ar="${cross_prefix}${ar}"
289 strip
="${cross_prefix}${strip}"
291 CONFTEST
=.
/conftest
$EXESUF
293 if test -z "$cross_prefix" ; then
294 if ! $cc -o $CONFTEST $source_path/conftest.c
2>/dev
/null
; then
295 echo "configure: error: '$cc' failed to compile conftest.c."
297 bigendian
="$($CONFTEST bigendian)"
298 gcc_major
="$($CONFTEST version)"
299 gcc_minor
="$($CONFTEST minor)"
300 if test "$mingw32" = "no" ; then
301 triplet
="$($CONFTEST triplet)"
302 if test -f "/usr/lib/$triplet/crti.o" ; then
303 tcc_lddir
="lib/$triplet"
304 multiarch_triplet
="$triplet"
305 elif test -f "/usr/lib64/crti.o" ; then
309 if test "$cpu" = "armv4l" ; then
310 if test "${triplet%eabihf}" != "$triplet" ; then
311 confvars
="$confvars arm_eabihf"
312 elif test "${triplet%eabi}" != "$triplet" ; then
313 confvars
="$confvars arm_eabi"
315 if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
; then
316 confvars
="$confvars arm_vfp"
320 # multiarch_triplet=${libc_dir#*/}
321 # multiarch_triplet=${multiarch_triplet%/}
322 # tcc_lddir="${libc_dir%%/*}"
323 # if test -n "$multiarch_triplet" ; then
324 # tcc_lddir="$tcc_lddir/$multiarch_triplet"
327 if test -f "/lib/ld-uClibc.so.0" ; then
328 confvars
="$confvars uClibc"
330 # gr: maybe for after the release:
331 # tcc_elfinterp="$(ldd $CONFTEST | grep 'ld.*.so' | sed 's,\s*\(\S\+\).*,\1,')"
332 # echo "elfinterp $tcc_elfinterp"
337 # if cross compiling, cannot launch a program, so make a static guess
339 powerpc|mips|s390
) bigendian
=yes;;
344 Binary directory $bindir
345 TinyCC directory $tccdir
346 Library directory $libdir
347 Include directory $includedir
348 Manual directory $mandir
349 Info directory $infodir
350 Doc directory $docdir
351 Target root prefix $sysroot
352 Source path $source_path
356 Big Endian $bigendian
358 cross compilers $build_cross
359 use libgcc $use_libgcc
362 echo "Creating config.mak and config.h"
364 cat >config.mak
<<EOF
365 # Automatically generated by configure - do not modify
367 bindir=\$(DESTDIR)$bindir
368 tccdir=\$(DESTDIR)$tccdir
369 libdir=\$(DESTDIR)$libdir
371 includedir=\$(DESTDIR)$includedir
372 mandir=\$(DESTDIR)$mandir
373 infodir=\$(DESTDIR)$infodir
374 docdir=\$(DESTDIR)$docdir
380 STRIP=$strip -s -R .comment -R .note
388 if test -n "$2"; then
389 echo "#ifndef $1" >> $TMPH
390 echo "# define $1 \"$2\"" >> $TMPH
391 echo "#endif" >> $TMPH
395 if test -n "$2"; then
396 echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak
400 echo "/* Automatically generated by configure - do not modify */" > $TMPH
402 print_inc CONFIG_SYSROOT
"$sysroot"
403 print_inc CONFIG_TCCDIR
"$tccdir"
404 print_mak CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
405 print_mak CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
406 print_mak CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
407 print_mak CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
408 print_mak CONFIG_LDDIR
"$tcc_lddir"
409 print_mak CONFIG_MULTIARCHDIR
"$multiarch_triplet"
411 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
412 echo "#define GCC_MINOR $gcc_minor" >> $TMPH
414 if test "$cpu" = "x86" ; then
415 echo "ARCH=i386" >> config.mak
416 echo "#define HOST_I386 1" >> $TMPH
417 elif test "$cpu" = "x86-64" ; then
418 echo "ARCH=x86-64" >> config.mak
419 echo "#define HOST_X86_64 1" >> $TMPH
420 elif test "$cpu" = "armv4l" ; then
421 echo "ARCH=arm" >> config.mak
422 echo "#define HOST_ARM 1" >> $TMPH
423 echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH
424 elif test "$cpu" = "powerpc" ; then
425 echo "ARCH=ppc" >> config.mak
426 echo "#define HOST_PPC 1" >> $TMPH
427 elif test "$cpu" = "mips" ; then
428 echo "ARCH=mips" >> config.mak
429 echo "#define HOST_MIPS 1" >> $TMPH
430 elif test "$cpu" = "s390" ; then
431 echo "ARCH=s390" >> config.mak
432 echo "#define HOST_S390 1" >> $TMPH
433 elif test "$cpu" = "alpha" ; then
434 echo "ARCH=alpha" >> config.mak
435 echo "#define HOST_ALPHA 1" >> $TMPH
437 echo "Unsupported CPU"
441 echo "TARGETOS=$targetos" >> config.mak
443 for v
in $confvars ; do
444 echo "CONFIG_$v=yes" >> config.mak
446 if test "$noldl" = "yes" ; then
447 echo "CONFIG_NOLDL=yes" >> config.mak
449 if test "$mingw32" = "yes" ; then
450 echo "CONFIG_WIN32=yes" >> config.mak
451 echo "#define CONFIG_WIN32 1" >> $TMPH
453 if test "$cygwin" = "yes" ; then
454 echo "#ifndef _WIN32" >> $TMPH
455 echo "# define _WIN32" >> $TMPH
456 echo "#endif" >> $TMPH
457 echo "AR=ar" >> config.mak
459 if test "$bigendian" = "yes" ; then
460 echo "WORDS_BIGENDIAN=yes" >> config.mak
461 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
463 if test "$gprof" = "yes" ; then
464 echo "TARGET_GPROF=yes" >> config.mak
465 echo "#define HAVE_GPROF 1" >> $TMPH
467 if test "$build_cross" = "yes" ; then
468 echo "CONFIG_CROSS=yes" >> config.mak
470 if test "$disable_static" = "yes" ; then
471 echo "DISABLE_STATIC=yes" >> config.mak
473 if test "$disable_rpath" = "yes" ; then
474 echo "DISABLE_RPATH=yes" >> config.mak
476 if test "$strip_binaries" = "yes" ; then
477 echo "STRIP_BINARIES=yes" >> config.mak
479 if test "$use_libgcc" = "yes" ; then
480 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
481 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
483 if test "$have_selinux" = "yes" ; then
484 echo "#define HAVE_SELINUX" >> $TMPH
485 echo "HAVE_SELINUX=yes" >> config.mak
488 version
=`head $source_path/VERSION`
489 echo "VERSION=$version" >>config.mak
490 echo "#define TCC_VERSION \"$version\"" >> $TMPH
491 echo "@set VERSION $version" > config.texi
492 echo "SRC_PATH=$source_path" >>config.mak
494 if test "$source_path_used" = "yes" ; then
496 /*) echo "top_srcdir=$source_path";;
497 *) echo "top_srcdir=\$(TOP)/$source_path";;
500 echo 'top_srcdir=$(TOP)' >>config.mak
502 echo 'top_builddir=$(TOP)' >>config.mak
504 diff $TMPH config.h
>/dev
/null
2>&1
505 if test $?
-ne 0 ; then
508 echo "config.h is unchanged"
511 rm -f $TMPN* $CONFTEST
513 # ---------------------------------------------------------------------------
514 # build tree in object directory if source path is different from current one
521 test -d $dn || mkdir
-p $dn
524 *) while test $dn ; do
525 tgt
=..
/$tgt; dn
=${dn#${dn%%/*}}; dn=${dn#/}
534 if test "$source_path_used" = "yes" ; then
535 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile"
537 fn_makelink
$source_path $f
541 # ---------------------------------------------------------------------------