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 TMPC
="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.c"
15 TMPO
="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.o"
16 TMPE
="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}"
17 TMPS
="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.S"
18 TMPH
="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.h"
37 i386|i486|i586|i686|i86pc|BePC
)
46 "Power Macintosh"|ppc|ppc64
)
81 # XXX: we assume an absolute path is given when launching configure,
82 # except in './configure' case.
83 source_path
=${0%configure}
84 source_path
=${source_path%/}
85 source_path_used
="yes"
86 if test -z "$source_path" -o "$source_path" = "." ; then
93 --prefix=*) prefix
=`echo $opt | cut -d '=' -f 2`
95 --exec-prefix=*) execprefix
=`echo $opt | cut -d '=' -f 2`
97 --bindir=*) bindir
=`echo $opt | cut -d '=' -f 2`
99 --libdir=*) libdir
=`echo $opt | cut -d '=' -f 2`
101 --includedir=*) includedir
=`echo $opt | cut -d '=' -f 2`
103 --mandir=*) mandir
=`echo $opt | cut -d '=' -f 2`
105 --source-path=*) source_path
=`echo $opt | cut -d '=' -f 2`
107 --cross-prefix=*) cross_prefix
=`echo $opt | cut -d '=' -f 2`
109 --cc=*) cc
=`echo $opt | cut -d '=' -f 2`
111 --make=*) make=`echo $opt | cut -d '=' -f 2`
113 --extra-cflags=*) CFLAGS
="${opt#--extra-cflags=}"
115 --extra-ldflags=*) LDFLAGS
="${opt#--extra-ldflags=}"
117 --extra-libs=*) extralibs
=${opt#--extra-libs=}
119 --cpu=*) cpu
=`echo $opt | cut -d '=' -f 2`
121 --enable-gprof) gprof
="yes"
123 --enable-mingw32) mingw32
="yes" ; cross_prefix
="i386-mingw32-"
125 --enable-cross) build_cross
="yes"
130 # Checking for CFLAGS
131 if test -z "$CFLAGS"; then
135 cc
="${cross_prefix}${cc}"
136 ar="${cross_prefix}${ar}"
137 strip
="${cross_prefix}${strip}"
139 if test "$mingw32" = "yes" ; then
144 if test -z "$cross_prefix" ; then
147 # big/little endian test
149 #include <inttypes.h>
150 int main(int argc, char ** argv){
151 volatile uint32_t i=0x01234567;
152 return (*((uint8_t*)(&i))) == 0x67;
156 if $cc -o $TMPE $TMPC 2>/dev
/null
; then
157 $TMPE && bigendian
="yes"
159 echo big
/little
test failed
164 # if cross compiling, cannot launch a program, so make a static guess
165 if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" ; then
174 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
183 if $cc -o $TMPO $TMPC 2> /dev
/null
; then
187 if test x
"$1" = x
"-h" -o x
"$1" = x
"--help" ; then
190 Usage: configure [options]
191 Options: [defaults in brackets after descriptions]
194 echo "Standard options:"
195 echo " --help print this message"
196 echo " --prefix=PREFIX install in PREFIX [$prefix]"
197 echo " --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX"
198 echo " [same as prefix]"
199 echo " --bindir=DIR user executables in DIR [EPREFIX/bin]"
200 echo " --libdir=DIR object code libraries in DIR [EPREFIX/lib]"
201 echo " --includedir=DIR C header files in DIR [PREFIX/include]"
202 echo " --mandir=DIR man documentation in DIR [PREFIX/man]"
203 echo " --enable-cross build cross compilers"
205 echo "Advanced options (experts only):"
206 echo " --source-path=PATH path of source code [$source_path]"
207 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
208 echo " --cc=CC use C compiler CC [$cc]"
209 echo " --make=MAKE use specified make [$make]"
211 #echo "NOTE: The object files are build at the place where configure is launched"
215 if test "$mingw32" = "yes" ; then
216 if test -z "$prefix" ; then
217 prefix
="/c/Program Files/tcc"
224 if test -z "$prefix" ; then
227 if test x
"$execprefix" = x
""; then
228 execprefix
="${prefix}"
230 if test x
"$bindir" = x
""; then
231 bindir
="${execprefix}/bin"
233 if test x
"$docdir" = x
""; then
234 docdir
="$prefix/share/doc/tcc"
238 if test x
"$libdir" = x
""; then
239 libdir
="${execprefix}/lib"
241 if test x
"$tccdir" = x
""; then
242 tccdir
="${execprefix}/lib/tcc"
244 if test x
"$mandir" = x
""; then
245 mandir
="${prefix}/man"
247 if test x
"$includedir" = x
""; then
248 includedir
="${prefix}/include"
251 echo "Binary directory $bindir"
252 echo "TinyCC directory $tccdir"
253 echo "Library directory $libdir"
254 echo "Include directory $includedir"
255 echo "Manual directory $mandir"
256 echo "Doc directory $docdir"
257 echo "Source path $source_path"
258 echo "C compiler $cc"
261 echo "Big Endian $bigendian"
262 echo "gprof enabled $gprof"
263 echo "cross compilers $build_cross"
265 echo "Creating config.mak and config.h"
267 echo "# Automatically generated by configure - do not modify" > config.mak
268 echo "/* Automatically generated by configure - do not modify */" > $TMPH
270 echo "prefix=$prefix" >> config.mak
271 echo "bindir=$bindir" >> config.mak
272 echo "tccdir=$tccdir" >> config.mak
273 echo "libdir=$libdir" >> config.mak
274 echo "includedir=$includedir" >> config.mak
275 echo "mandir=$mandir" >> config.mak
276 echo "docdir=$docdir" >> config.mak
277 echo "#define CONFIG_TCCDIR \"$tccdir\"" >> $TMPH
278 echo "MAKE=$make" >> config.mak
279 echo "CC=$cc" >> config.mak
280 echo "GCC_MAJOR=$gcc_major" >> config.mak
281 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
282 echo "HOST_CC=$host_cc" >> config.mak
283 echo "AR=$ar" >> config.mak
284 echo "STRIP=$strip -s -R .comment -R .note" >> config.mak
285 echo "CFLAGS=$CFLAGS" >> config.mak
286 echo "LDFLAGS=$LDFLAGS" >> config.mak
287 echo "LIBSUF=$LIBSUF" >> config.mak
288 echo "EXESUF=$EXESUF" >> config.mak
289 if test "$cpu" = "x86" ; then
290 echo "ARCH=i386" >> config.mak
291 echo "#define HOST_I386 1" >> $TMPH
292 elif test "$cpu" = "armv4l" ; then
293 echo "ARCH=arm" >> config.mak
294 echo "#define HOST_ARM 1" >> $TMPH
295 elif test "$cpu" = "powerpc" ; then
296 echo "ARCH=ppc" >> config.mak
297 echo "#define HOST_PPC 1" >> $TMPH
298 elif test "$cpu" = "mips" ; then
299 echo "ARCH=mips" >> config.mak
300 echo "#define HOST_MIPS 1" >> $TMPH
301 elif test "$cpu" = "s390" ; then
302 echo "ARCH=s390" >> config.mak
303 echo "#define HOST_S390 1" >> $TMPH
304 elif test "$cpu" = "alpha" ; then
305 echo "ARCH=alpha" >> config.mak
306 echo "#define HOST_ALPHA 1" >> $TMPH
308 echo "Unsupported CPU"
311 if test "$noldl" = "yes" ; then
312 echo "CONFIG_NOLDL=yes" >> config.mak
314 if test "$mingw32" = "yes" ; then
315 echo "CONFIG_WIN32=yes" >> config.mak
316 echo "#define CONFIG_WIN32 1" >> $TMPH
318 if test "$bigendian" = "yes" ; then
319 echo "WORDS_BIGENDIAN=yes" >> config.mak
320 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
322 if test "$gprof" = "yes" ; then
323 echo "TARGET_GPROF=yes" >> config.mak
324 echo "#define HAVE_GPROF 1" >> $TMPH
326 if test "$build_cross" = "yes" ; then
327 echo "CONFIG_CROSS=yes" >> config.mak
329 version
=`head $source_path/VERSION`
330 echo "VERSION=$version" >>config.mak
331 echo "#define TCC_VERSION \"$version\"" >> $TMPH
332 echo "@set VERSION $version" > config.texi
334 # build tree in object directory if source path is different from current one
335 if test "$source_path_used" = "yes" ; then
337 FILES
="Makefile tests/Makefile"
338 for dir
in $DIRS ; do
342 ln -sf $source_path/$f $f
345 echo "SRC_PATH=$source_path" >> config.mak
347 diff $TMPH config.h
>/dev
/null
2>&1
348 if test $?
-ne 0 ; then
351 echo "config.h is unchanged"
354 rm -f $TMPO $TMPC $TMPE $TMPS $TMPH