3 # tcc configure script (c) 2003 Fabrice Bellard
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"
47 tcc_sysincludepaths
=""
53 i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
79 "Power Macintosh"|ppc|ppc64
)
101 MINGW32
*) mingw32
=yes;;
102 DragonFly
) noldl
=yes;;
108 # XXX: we assume an absolute path is given when launching configure,
109 # except in './configure' case.
110 source_path
=${0%configure}
111 source_path
=${source_path%/}
112 source_path_used
="yes"
113 if test -z "$source_path" -o "$source_path" = "." ; then
115 source_path_used
="no"
121 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
123 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
125 --tccdir=*) tccdir
=`echo $opt | cut -d '=' -f 2`
127 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
129 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
131 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
133 --sharedir=*) sharedir
=`echo $opt | cut -d '=' -f 2`
135 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
137 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
139 --docdir=*) docdir
=`echo $opt | cut -d '=' -f 2`
141 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
143 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
145 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
147 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
149 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
151 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
153 --extra-libs=*) extralibs
=${opt#--extra-libs=}
155 --sysincludepaths=*) tcc_sysincludepaths
=`echo $opt | cut -d '=' -f 2`
157 --libpaths=*) tcc_libpaths
=`echo $opt | cut -d '=' -f 2`
159 --crtprefix=*) tcc_crtprefix
=`echo $opt | cut -d '=' -f 2`
161 --elfinterp=*) tcc_elfinterp
=`echo $opt | cut -d '=' -f 2`
163 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
165 --enable-gprof) gprof
="yes"
167 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i686-pc-mingw32-" ; cpu
=x86
169 --enable-cygwin) mingw32
="yes" ; cygwin
="yes" ; cross_prefix
="mingw32-" ; cpu
=x86
171 --enable-cross) build_cross
="yes"
173 --disable-static) disable_static
="yes"
175 --disable-rpath) disable_rpath
="yes"
177 --strip-binaries) strip_binaries
="yes"
179 --with-libgcc) use_libgcc
="yes"
181 --with-selinux) have_selinux
="yes"
183 --help|
-h) show_help
="yes"
185 *) echo "configure: WARNING: unrecognized option $opt"
190 # Checking for CFLAGS
191 if test -z "$CFLAGS"; then
192 CFLAGS
="-Wall -g -O2"
195 cc
="${cross_prefix}${cc}"
196 ar="${cross_prefix}${ar}"
197 strip
="${cross_prefix}${strip}"
199 if test "$mingw32" = "yes" ; then
204 if test -z "$cross_prefix" ; then
206 if ! $cc -o config-print config-print.c
2>/dev
/null
; then
207 echo "$cc is not able to compile TCC"
209 bigendian
="$(./config-print e)"
210 gcc_major
="$(./config-print v)"
215 # if cross compiling, cannot launch a program, so make a static guess
217 powerpc|mips|s390
) bigendian
=yes;;
222 if test -z "$cross_prefix" ; then
223 libc_dir
="$(ldd ./config-print | grep libc.so | sed 's|[^/]*/\(.*/\)[^/]*|\1|')"
224 multiarch_triplet
=${libc_dir#*/}
225 multiarch_triplet
=${multiarch_triplet%/}
226 lddir
="${libc_dir%%/*}"
227 if test -n "$multiarch_triplet" ; then
228 lddir
="$lddir/$multiarch_triplet"
233 if test x
"$show_help" = "xyes" ; then
235 Usage: configure [options]
236 Options: [defaults in brackets after descriptions]
239 --help print this message
240 --prefix=PREFIX install in PREFIX [$prefix]
241 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
243 --bindir=DIR user executables in DIR [EPREFIX/bin]
244 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
245 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
246 --includedir=DIR C header files in DIR [PREFIX/include]
247 --sharedir=DIR documentation root DIR [PREFIX]/share
248 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
249 --mandir=DIR man documentation in DIR [SHAREDIR/man]
250 --infodir=DIR info documentation in DIR [SHAREDIR/info]
252 Advanced options (experts only):
253 --source-path=PATH path of source code [$source_path]
254 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
255 --sysroot=PREFIX prepend PREFIX to library/include paths []
256 --cc=CC use C compiler CC [$cc]
257 --disable-static make libtcc.so instead of libtcc.a
258 --disable-rpath disable use of -rpath with the above
259 --strip-binaries strip symbol tables from resulting binaries
260 --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc.a
261 --enable-mingw32 build windows version on linux with mingw32
262 --enable-cygwin build windows version on windows with cygwin
263 [requires cygwin and mingw32-make]
264 --enable-cross build cross compilers
265 --extra-cflags= extra compiler flags
266 --extra-ldflags= extra linker options
267 --with-selinux use mmap instead of exec mem
268 [requires write access to /tmp]
269 --sysincludepaths=... specify system include paths, colon separated
270 --libpaths=... specify system library paths, colon separated
271 --crtprefix=... specify locations of crt?.o, colon separated
272 --elfinterp=... specify elf interpreter
274 #echo "NOTE: The object files are build at the place where configure is launched"
278 if test "$mingw32" = "yes" ; then
279 if test x
"$tccdir" = x
""; then
282 if test -z "$prefix" ; then
283 prefix
="C:/Program Files/${tccdir}"
285 if test -z "$sharedir" ; then
291 libdir
="${prefix}/lib"
292 docdir
="${sharedir}/doc"
293 mandir
="${sharedir}/man"
294 infodir
="${sharedir}/info"
296 if test -z "$prefix" ; then
299 if test -z "$sharedir" ; then
300 sharedir
="${prefix}/share"
302 if test x
"$execprefix" = x
""; then
303 execprefix
="${prefix}"
305 if test x
"$libdir" = x
""; then
306 libdir
="${execprefix}/lib"
308 if test x
"$bindir" = x
""; then
309 bindir
="${execprefix}/bin"
311 if test x
"$tccdir" = x
""; then
314 if test x
"$docdir" = x
""; then
315 docdir
="${sharedir}/doc/${tccdir}"
317 if test x
"$mandir" = x
""; then
318 mandir
="${sharedir}/man"
320 if test x
"$infodir" = x
""; then
321 infodir
="${sharedir}/info"
323 tccdir
="${libdir}/${tccdir}"
326 if test x
"$includedir" = x
""; then
327 includedir
="${prefix}/include"
331 Binary directory $bindir
332 TinyCC directory $tccdir
333 Library directory $libdir
334 Include directory $includedir
335 Manual directory $mandir
336 Info directory $infodir
337 Doc directory $docdir
338 Target root prefix $sysroot
339 Source path $source_path
343 Big Endian $bigendian
345 cross compilers $build_cross
346 use libgcc $use_libgcc
349 echo "Creating config.mak and config.h"
351 cat >config.mak
<<EOF
352 # Automatically generated by configure - do not modify
354 bindir=\$(DESTDIR)$bindir
355 tccdir=\$(DESTDIR)$tccdir
356 libdir=\$(DESTDIR)$libdir
358 includedir=\$(DESTDIR)$includedir
359 mandir=\$(DESTDIR)$mandir
360 infodir=\$(DESTDIR)$infodir
361 docdir=\$(DESTDIR)$docdir
364 echo "/* Automatically generated by configure - do not modify */" > $TMPH
367 echo "#ifndef $1" >> $TMPH
368 echo "# define $1 \"$2\"" >> $TMPH
369 echo "#endif" >> $TMPH
373 if test -n "$2"; then print_var1
$1 "$2"; fi
375 print_var2 CONFIG_SYSROOT
"$sysroot"
376 print_var1 CONFIG_TCCDIR
"$tccdir"
377 print_var2 CONFIG_TCC_SYSINCLUDEPATHS
"$tcc_sysincludepaths"
378 print_var2 CONFIG_TCC_LIBPATHS
"$tcc_libpaths"
379 print_var2 CONFIG_TCC_CRTPREFIX
"$tcc_crtprefix"
380 print_var2 CONFIG_TCC_ELFINTERP
"$tcc_elfinterp"
381 print_var2 CONFIG_MULTIARCHDIR
"$multiarch_triplet"
382 print_var2 CONFIG_LDDIR
"$lddir"
384 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
386 cat >> config.mak
<<EOF
391 STRIP=$strip -s -R .comment -R .note
398 if test "$cpu" = "x86" ; then
399 echo "ARCH=i386" >> config.mak
400 echo "#define HOST_I386 1" >> $TMPH
401 elif test "$cpu" = "x86-64" ; then
402 echo "ARCH=x86-64" >> config.mak
403 echo "#define HOST_X86_64 1" >> $TMPH
404 elif test "$cpu" = "armv4l" ; then
405 echo "ARCH=arm" >> config.mak
406 echo "#define HOST_ARM 1" >> $TMPH
407 echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH
408 elif test "$cpu" = "powerpc" ; then
409 echo "ARCH=ppc" >> config.mak
410 echo "#define HOST_PPC 1" >> $TMPH
411 elif test "$cpu" = "mips" ; then
412 echo "ARCH=mips" >> config.mak
413 echo "#define HOST_MIPS 1" >> $TMPH
414 elif test "$cpu" = "s390" ; then
415 echo "ARCH=s390" >> config.mak
416 echo "#define HOST_S390 1" >> $TMPH
417 elif test "$cpu" = "alpha" ; then
418 echo "ARCH=alpha" >> config.mak
419 echo "#define HOST_ALPHA 1" >> $TMPH
421 echo "Unsupported CPU"
424 echo "TARGETOS=$targetos" >> config.mak
425 if test "$noldl" = "yes" ; then
426 echo "CONFIG_NOLDL=yes" >> config.mak
428 if test "$mingw32" = "yes" ; then
429 echo "CONFIG_WIN32=yes" >> config.mak
430 echo "#define CONFIG_WIN32 1" >> $TMPH
432 if test "$cygwin" = "yes" ; then
433 echo "#ifndef _WIN32" >> $TMPH
434 echo "#define _WIN32" >> $TMPH
435 echo "#endif" >> $TMPH
436 echo "AR=ar" >> config.mak
438 if test "$bigendian" = "yes" ; then
439 echo "WORDS_BIGENDIAN=yes" >> config.mak
440 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
442 if test "$gprof" = "yes" ; then
443 echo "TARGET_GPROF=yes" >> config.mak
444 echo "#define HAVE_GPROF 1" >> $TMPH
446 if test "$build_cross" = "yes" ; then
447 echo "CONFIG_CROSS=yes" >> config.mak
449 if test "$disable_static" = "yes" ; then
450 echo "DISABLE_STATIC=yes" >> config.mak
452 if test "$disable_rpath" = "yes" ; then
453 echo "DISABLE_RPATH=yes" >> config.mak
455 if test "$strip_binaries" = "yes" ; then
456 echo "STRIP_BINARIES=yes" >> config.mak
458 if test "$use_libgcc" = "yes" ; then
459 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
460 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
462 if test "$have_selinux" = "yes" ; then
463 echo "#define HAVE_SELINUX" >> $TMPH
464 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
471 echo "SRC_PATH=$source_path" >>config.mak
473 # build tree in object directory if source path is different from current one
474 if test "$source_path_used" = "yes" ; then
475 FILES
="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile"
477 dir
=`fn_dirname "$f"`
478 test -d "$dir" || mkdir
-p "$dir"
479 # Build a symlink $f that points to $dest, its $source_path
482 /*) dest
=$source_path/$f;;
483 *) dest
=`echo "$dir/" | sed 's,^\./,,;s,[^/]*/,../,g'`
484 dest
=$dest$source_path/$f;;
489 /*) echo "top_srcdir=$source_path";;
490 *) echo "top_srcdir=\$(TOP)/$source_path";;
493 echo 'top_srcdir=$(TOP)' >>config.mak
495 echo 'top_builddir=$(TOP)' >>config.mak
497 diff $TMPH config.h
>/dev
/null
2>&1
498 if test $?
-ne 0 ; then
501 echo "config.h is unchanged"