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"
41 i386|i486|i586|i686|i86pc|BePC|i686-AT386
)
47 armv4l|armv5tel|armv6j|armv7a
)
53 "Power Macintosh"|ppc|ppc64
)
88 # XXX: we assume an absolute path is given when launching configure,
89 # except in './configure' case.
90 source_path
=${0%configure}
91 source_path
=${source_path%/}
92 source_path_used
="yes"
93 if test -z "$source_path" -o "$source_path" = "." ; then
100 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
102 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
104 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
106 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
108 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
110 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
112 --infodir=*) infodir
=`echo $opt | cut -d '=' -f 2`
114 --sysroot=*) sysroot
=`echo $opt | cut -d '=' -f 2`
116 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
118 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
120 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
122 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
124 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
126 --extra-libs=*) extralibs
=${opt#--extra-libs=}
128 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
130 --enable-gprof) gprof
="yes"
132 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i386-mingw32-"
134 --enable-cross) build_cross
="yes"
136 --disable-static) disable_static
="yes"
138 --with-libgcc) use_libgcc
="yes"
140 --with-selinux) have_selinux
="yes"
142 --help|
-h) show_help
="yes"
147 # Checking for CFLAGS
148 if test -z "$CFLAGS"; then
152 cc
="${cross_prefix}${cc}"
153 ar="${cross_prefix}${ar}"
154 strip
="${cross_prefix}${strip}"
156 if test "$mingw32" = "yes" ; then
161 if test -z "$cross_prefix" ; then
164 # big/little endian test
166 #include <inttypes.h>
167 int main(int argc, char ** argv){
168 volatile uint32_t i=0x01234567;
169 return (*((uint8_t*)(&i))) == 0x67;
173 if $cc -o $TMPE $TMPC 2>/dev
/null
; then
174 $TMPE && bigendian
="yes"
176 echo big
/little
test failed
181 # if cross compiling, cannot launch a program, so make a static guess
182 if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" ; then
191 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
200 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
213 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
217 if test x
"$show_help" = "xyes" ; then
220 Usage: configure [options]
221 Options: [defaults in brackets after descriptions]
224 echo "Standard options:"
225 echo " --help print this message"
226 echo " --prefix=PREFIX install in PREFIX [$prefix]"
227 echo " --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX"
228 echo " [same as prefix]"
229 echo " --bindir=DIR user executables in DIR [EPREFIX/bin]"
230 echo " --libdir=DIR object code libraries in DIR [EPREFIX/lib]"
231 echo " --includedir=DIR C header files in DIR [PREFIX/include]"
232 echo " --mandir=DIR man documentation in DIR [PREFIX/man]"
233 echo " --infodir=DIR info documentation in DIR [PREFIX/info]"
234 echo " --enable-cross build cross compilers"
236 echo "Advanced options (experts only):"
237 echo " --source-path=PATH path of source code [$source_path]"
238 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
239 echo " --sysroot=PREFIX prepend PREFIX to library/include paths []"
240 echo " --cc=CC use C compiler CC [$cc]"
241 echo " --disable-static make libtcc.so instead of libtcc.a"
242 echo " --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc1.a"
243 echo " --with-selinux use mmap instead of exec mem"
244 echo " [requires write access to /tmp]"
246 #echo "NOTE: The object files are build at the place where configure is launched"
250 if test "$mingw32" = "yes" ; then
251 if test -z "$prefix" ; then
252 prefix
="C:/Program Files/tcc"
259 if test -z "$prefix" ; then
262 if test x
"$execprefix" = x
""; then
263 execprefix
="${prefix}"
265 if test x
"$bindir" = x
""; then
266 bindir
="${execprefix}/bin"
268 if test x
"$docdir" = x
""; then
269 docdir
="$prefix/share/doc/tcc"
273 if test x
"$libdir" = x
""; then
274 libdir
="${execprefix}/lib"
276 if test x
"$tccdir" = x
""; then
277 tccdir
="${libdir}/tcc"
279 if test x
"$mandir" = x
""; then
280 mandir
="${prefix}/man"
282 if test x
"$infodir" = x
""; then
283 infodir
="${prefix}/info"
285 if test x
"$includedir" = x
""; then
286 includedir
="${prefix}/include"
289 echo "Binary directory $bindir"
290 echo "TinyCC directory $tccdir"
291 echo "Library directory $libdir"
292 echo "Include directory $includedir"
293 echo "Manual directory $mandir"
294 echo "Info directory $infodir"
295 echo "Doc directory $docdir"
296 echo "Target root prefix $sysroot"
297 echo "Source path $source_path"
298 echo "C compiler $cc"
300 echo "Big Endian $bigendian"
301 echo "gprof enabled $gprof"
302 echo "cross compilers $build_cross"
303 echo "use libgcc $use_libgcc"
305 echo "Creating config.mak and config.h"
307 echo "# Automatically generated by configure - do not modify" > config.mak
308 echo "/* Automatically generated by configure - do not modify */" > $TMPH
310 echo "prefix=$prefix" >> config.mak
311 echo "bindir=\$(DESTDIR)$bindir" >> config.mak
312 echo "tccdir=\$(DESTDIR)$tccdir" >> config.mak
313 echo "libdir=\$(DESTDIR)$libdir" >> config.mak
314 echo "ln_libdir=$libdir" >> config.mak
315 echo "includedir=\$(DESTDIR)$includedir" >> config.mak
316 echo "mandir=\$(DESTDIR)$mandir" >> config.mak
317 echo "infodir=\$(DESTDIR)$infodir" >> config.mak
318 echo "docdir=\$(DESTDIR)$docdir" >> config.mak
320 echo "#define CONFIG_SYSROOT \"$sysroot\"" >> $TMPH
321 echo "#define CONFIG_TCCDIR \"$tccdir\"" >> $TMPH
322 echo "CC=$cc" >> config.mak
323 echo "GCC_MAJOR=$gcc_major" >> config.mak
324 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
325 echo "HOST_CC=$host_cc" >> config.mak
326 echo "AR=$ar" >> config.mak
327 echo "STRIP=$strip -s -R .comment -R .note" >> config.mak
328 echo "CFLAGS=$CFLAGS" >> config.mak
329 echo "LDFLAGS=$LDFLAGS" >> config.mak
330 echo "LIBSUF=$LIBSUF" >> config.mak
331 echo "EXESUF=$EXESUF" >> config.mak
332 if test "$cpu" = "x86" ; then
333 echo "ARCH=i386" >> config.mak
334 echo "#define HOST_I386 1" >> $TMPH
335 elif test "$cpu" = "x86-64" ; then
336 echo "ARCH=x86-64" >> config.mak
337 echo "#define HOST_X86_64 1" >> $TMPH
338 elif test "$cpu" = "armv4l" ; then
339 echo "ARCH=arm" >> config.mak
340 echo "#define HOST_ARM 1" >> $TMPH
341 elif test "$cpu" = "powerpc" ; then
342 echo "ARCH=ppc" >> config.mak
343 echo "#define HOST_PPC 1" >> $TMPH
344 elif test "$cpu" = "mips" ; then
345 echo "ARCH=mips" >> config.mak
346 echo "#define HOST_MIPS 1" >> $TMPH
347 elif test "$cpu" = "s390" ; then
348 echo "ARCH=s390" >> config.mak
349 echo "#define HOST_S390 1" >> $TMPH
350 elif test "$cpu" = "alpha" ; then
351 echo "ARCH=alpha" >> config.mak
352 echo "#define HOST_ALPHA 1" >> $TMPH
354 echo "Unsupported CPU"
357 if test "$noldl" = "yes" ; then
358 echo "CONFIG_NOLDL=yes" >> config.mak
360 if test "$mingw32" = "yes" ; then
361 echo "CONFIG_WIN32=yes" >> config.mak
362 echo "#define CONFIG_WIN32 1" >> $TMPH
364 if test "$bigendian" = "yes" ; then
365 echo "WORDS_BIGENDIAN=yes" >> config.mak
366 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
368 if test "$gprof" = "yes" ; then
369 echo "TARGET_GPROF=yes" >> config.mak
370 echo "#define HAVE_GPROF 1" >> $TMPH
372 if test "$build_cross" = "yes" ; then
373 echo "CONFIG_CROSS=yes" >> config.mak
375 if test "$disable_static" = "yes" ; then
376 echo "DISABLE_STATIC=yes" >> config.mak
378 if test "$use_libgcc" = "yes" ; then
379 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
380 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
382 if test "$have_selinux" = "yes" ; then
383 echo "#define HAVE_SELINUX" >> $TMPH
384 echo "HAVE_SELINUX=yes" >> config.mak
386 version
=`head $source_path/VERSION`
387 echo "VERSION=$version" >>config.mak
388 echo "#define TCC_VERSION \"$version\"" >> $TMPH
389 echo "@set VERSION $version" > config.texi
391 # build tree in object directory if source path is different from current one
392 if test "$source_path_used" = "yes" ; then
394 FILES
="Makefile tests/Makefile"
395 for dir
in $DIRS ; do
399 ln -sf $source_path/$f $f
402 echo "SRC_PATH=$source_path" >> config.mak
404 diff $TMPH config.h
>/dev
/null
2>&1
405 if test $?
-ne 0 ; then
408 echo "config.h is unchanged"