Adding two more people to the RELICENSING file.
[tinycc.git] / configure
Commit [+]AuthorDateLineData
dd56ab8c bellard2003-04-13 19:50:35 +00001#!/bin/sh
2#
3# tcc configure script (c) 2003 Fabrice Bellard
10b48028 grischka2010-06-15 17:02:35 +02004
dd56ab8c bellard2003-04-13 19:50:35 +00005# set temporary file name
944627c4 grischka2013-02-14 06:53:07 +01006# if test ! -z "$TMPDIR" ; then
7# TMPDIR1="${TMPDIR}"
8# elif test ! -z "$TEMPDIR" ; then
9# TMPDIR1="${TEMPDIR}"
10# else
11# TMPDIR1="/tmp"
12# fi
13#
5e6fabef Thomas Preud'homme2010-06-23 14:10:22 +020014# bashism: TMPN="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.c"
10b48028 grischka2010-06-15 17:02:35 +020015
944627c4 grischka2013-02-14 06:53:07 +010016TMPN="./conftest-$$"
10b48028 grischka2010-06-15 17:02:35 +020017TMPH=$TMPN.h
dd56ab8c bellard2003-04-13 19:50:35 +000018
19# default parameters
acc4f88e bellard2005-04-14 23:51:24 +000020build_cross="no"
15e0dc08 Daniel Glöckner2008-09-05 21:08:37 +020021use_libgcc="no"
41b3c7a5 James Lyon2013-04-27 20:39:34 +010022enable_assert="no"
13affef3 bellard2004-10-07 21:11:43 +000023prefix=""
dd56ab8c bellard2003-04-13 19:50:35 +000024execprefix=""
25bindir=""
26libdir=""
acc4f88e bellard2005-04-14 23:51:24 +000027tccdir=""
dd56ab8c bellard2003-04-13 19:50:35 +000028includedir=""
29mandir=""
3f829d11 Thomas Preud'homme2010-09-10 21:19:01 +020030infodir=""
256f6e62 Daniel Glöckner2008-09-05 21:08:22 +020031sysroot=""
dd56ab8c bellard2003-04-13 19:50:35 +000032cross_prefix=""
33cc="gcc"
34host_cc="gcc"
35ar="ar"
dd56ab8c bellard2003-04-13 19:50:35 +000036strip="strip"
94e72b16 Henry Kroll III2010-12-02 20:16:32 -080037cygwin="no"
944627c4 grischka2013-02-14 06:53:07 +010038gprof="no"
39bigendian="no"
40mingw32="no"
41LIBSUF=".a"
42EXESUF=""
81cd0cf6 grischka2011-08-06 16:11:12 +020043tcc_sysincludepaths=""
44tcc_libpaths=""
45tcc_crtprefix=""
46tcc_elfinterp=""
944627c4 grischka2013-02-14 06:53:07 +010047tcc_lddir=
c4397b2b grischka2013-02-14 21:15:56 +010048confvars=
149c2a9c seyko2015-03-04 10:03:40 +030049cpu=
7e7e6148 seyko2015-04-10 07:37:31 +030050
2ba7542e Raphael Cohn2015-04-07 15:28:31 +010051host_os=`uname`
7e7e6148 seyko2015-04-10 07:37:31 +030052case $host_os in
53 MINGW32*) host_os=Windows; ;;
54 *) ;;
55esac
944627c4 grischka2013-02-14 06:53:07 +010056
57# OS specific
fa0eff94 Raphael Cohn2015-04-07 15:18:34 +010058targetos=`uname`
944627c4 grischka2013-02-14 06:53:07 +010059case $targetos in
87ec08ec seyko2015-03-10 13:39:26 +030060 MINGW32*) mingw32=yes; host_os=Windows; ;;
944627c4 grischka2013-02-14 06:53:07 +010061 DragonFly) noldl=yes;;
62 OpenBSD) noldl=yes;;
d9dfd9cd Thomas Preud'homme2013-03-14 18:15:32 +010063 FreeBSD) noldl=yes;;
9714d2e7 minux2014-04-12 01:42:46 -040064 NetBSD) noldl=yes;;
944627c4 grischka2013-02-14 06:53:07 +010065 *) ;;
66esac
67
68# find source path
89ad24e7 gus knight2015-07-29 16:53:57 -040069# XXX: we assume an absolute path is given when launching configure,
944627c4 grischka2013-02-14 06:53:07 +010070# except in './configure' case.
71source_path=${0%configure}
72source_path=${source_path%/}
73source_path_used="yes"
74if test -z "$source_path" -o "$source_path" = "." ; then
75 source_path=`pwd`
76 source_path_used="no"
77fi
81cd0cf6 grischka2011-08-06 16:11:12 +020078
0e3d2e0b
TP
Thomas Preud'homme2014-04-12 16:20:12 +080079classify_cpu ()
80{
81 cpu="$1"
82
83 case "$cpu" in
84 x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386)
85 cpu="x86"
86 ;;
87 x86_64|amd64)
88 cpu="x86-64"
89 ;;
90 arm*)
91 case "$cpu" in
92 arm|armv4l)
93 cpuver=4
94 ;;
95 armv5tel|armv5tejl)
96 cpuver=5
97 ;;
98 armv6j|armv6l)
99 cpuver=6
100 ;;
101 armv7a|armv7l)
102 cpuver=7
103 ;;
104 esac
105 cpu="armv4l"
106 ;;
b14ef0e2
EGE
Edmund Grimley Evans2015-02-13 18:58:31 +0000107 aarch64)
108 cpu="aarch64"
109 ;;
0e3d2e0b
TP
Thomas Preud'homme2014-04-12 16:20:12 +0800110 alpha)
111 cpu="alpha"
112 ;;
113 "Power Macintosh"|ppc|ppc64)
114 cpu="powerpc"
115 ;;
116 mips)
117 cpu="mips"
118 ;;
119 s390)
120 cpu="s390"
121 ;;
122 *)
123 echo "Unsupported CPU: $cpu"
124 exit 1
125 ;;
126 esac
127}
dd56ab8c bellard2003-04-13 19:50:35 +0000128
129for opt do
944627c4 grischka2013-02-14 06:53:07 +0100130 eval opt=\"$opt\"
dd56ab8c bellard2003-04-13 19:50:35 +0000131 case "$opt" in
132 --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
133 ;;
134 --exec-prefix=*) execprefix=`echo $opt | cut -d '=' -f 2`
135 ;;
f449f98d Henry Kroll III2010-12-22 04:42:39 -0800136 --tccdir=*) tccdir=`echo $opt | cut -d '=' -f 2`
9a986f37 Henry Kroll III2010-11-28 15:54:27 -0800137 ;;
dd56ab8c bellard2003-04-13 19:50:35 +0000138 --bindir=*) bindir=`echo $opt | cut -d '=' -f 2`
139 ;;
140 --libdir=*) libdir=`echo $opt | cut -d '=' -f 2`
141 ;;
142 --includedir=*) includedir=`echo $opt | cut -d '=' -f 2`
143 ;;
f449f98d
HKI
Henry Kroll III2010-12-22 04:42:39 -0800144 --sharedir=*) sharedir=`echo $opt | cut -d '=' -f 2`
145 ;;
dd56ab8c bellard2003-04-13 19:50:35 +0000146 --mandir=*) mandir=`echo $opt | cut -d '=' -f 2`
147 ;;
3f829d11
TP
Thomas Preud'homme2010-09-10 21:19:01 +0200148 --infodir=*) infodir=`echo $opt | cut -d '=' -f 2`
149 ;;
f449f98d
HKI
Henry Kroll III2010-12-22 04:42:39 -0800150 --docdir=*) docdir=`echo $opt | cut -d '=' -f 2`
151 ;;
256f6e62
DG
Daniel Glöckner2008-09-05 21:08:22 +0200152 --sysroot=*) sysroot=`echo $opt | cut -d '=' -f 2`
153 ;;
dd56ab8c bellard2003-04-13 19:50:35 +0000154 --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
155 ;;
156 --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
157 ;;
81cd0cf6 grischka2011-08-06 16:11:12 +0200158 --sysincludepaths=*) tcc_sysincludepaths=`echo $opt | cut -d '=' -f 2`
159 ;;
160 --libpaths=*) tcc_libpaths=`echo $opt | cut -d '=' -f 2`
161 ;;
162 --crtprefix=*) tcc_crtprefix=`echo $opt | cut -d '=' -f 2`
163 ;;
164 --elfinterp=*) tcc_elfinterp=`echo $opt | cut -d '=' -f 2`
165 ;;
0e3d2e0b
TP
Thomas Preud'homme2014-04-12 16:20:12 +0800166 --cc=*) cc=`echo $opt | cut -d '=' -f 2`
167 ;;
168 --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
169 ;;
170 --extra-ldflags=*) LDFLAGS="${opt#--extra-ldflags=}"
171 ;;
172 --extra-libs=*) extralibs=${opt#--extra-libs=}
173 ;;
149c2a9c seyko2015-03-04 10:03:40 +0300174 --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
dd56ab8c bellard2003-04-13 19:50:35 +0000175 ;;
176 --enable-gprof) gprof="yes"
177 ;;
7e7e6148 seyko2015-04-10 07:37:31 +0300178 --enable-mingw32) mingw32="yes" ; cross_prefix="i686-pc-mingw32-" ; cpu=x86; targetos=Windows;
a2779556 Henry Kroll III2010-12-02 03:08:57 -0800179 ;;
7e7e6148 seyko2015-04-10 07:37:31 +0300180 --enable-cygwin) mingw32="yes" ; cygwin="yes" ; cross_prefix="mingw32-" ; cpu=x86; targetos=Windows;
94e72b16 Henry Kroll III2010-12-02 20:16:32 -0800181 ;;
7e7e6148 seyko2015-04-10 07:37:31 +0300182 --enable-tcc32-mingw) mingw32="yes" ; cross_prefix="i386-win-" ; cpu=x86; cc=tcc; targetos=Windows;
bfb7b0d9 seyko2015-03-04 12:02:13 +0300183 ;;
7e7e6148 seyko2015-04-10 07:37:31 +0300184 --enable-tcc64-mingw) mingw32="yes" ; cross_prefix="x86_64-win-" ; cpu=x86_64; cc=tcc; targetos=Windows;
bfb7b0d9 seyko2015-03-04 12:02:13 +0300185 ;;
acc4f88e bellard2005-04-14 23:51:24 +0000186 --enable-cross) build_cross="yes"
187 ;;
41b3c7a5
JL
James Lyon2013-04-27 20:39:34 +0100188 --enable-assert) enable_assert="yes"
189 ;;
a4ed587f
HKI
Henry Kroll III2010-04-24 02:35:43 -0700190 --disable-static) disable_static="yes"
191 ;;
90355c78
HKI
Henry Kroll III2010-12-20 05:55:54 -0800192 --disable-rpath) disable_rpath="yes"
193 ;;
3511e6e2
TP
Thomas Preud'homme2011-06-17 22:22:04 +0200194 --strip-binaries) strip_binaries="yes"
195 ;;
15e0dc08
DG
Daniel Glöckner2008-09-05 21:08:37 +0200196 --with-libgcc) use_libgcc="yes"
197 ;;
be7e339d
HKI
Henry Kroll III2010-04-20 23:40:33 -0700198 --with-selinux) have_selinux="yes"
199 ;;
d2e12518
BRF
Bernhard Reutner-Fischer2009-09-01 11:24:58 +0200200 --help|-h) show_help="yes"
201 ;;
731e07f1 Thomas Preud'homme2012-05-28 21:16:39 +0200202 *) echo "configure: WARNING: unrecognized option $opt"
74a24d77 grischka2011-08-11 16:55:30 +0200203 ;;
dd56ab8c bellard2003-04-13 19:50:35 +0000204 esac
205done
206
149c2a9c seyko2015-03-04 10:03:40 +0300207if test -z "$cpu" ; then
208 if test -n "$ARCH" ; then
209 cpu="$ARCH"
210 else
211 cpu=`uname -m`
212 fi
213fi
0e3d2e0b
TP
Thomas Preud'homme2014-04-12 16:20:12 +0800214classify_cpu "$cpu"
215
dd56ab8c bellard2003-04-13 19:50:35 +0000216# Checking for CFLAGS
217if test -z "$CFLAGS"; then
7e7e6148 seyko2015-04-10 07:37:31 +0300218 CFLAGS="-Wall -g -O0"
dd56ab8c bellard2003-04-13 19:50:35 +0000219fi
220
13affef3 bellard2004-10-07 21:11:43 +0000221if test "$mingw32" = "yes" ; then
3b3a7cc8
HKI
Henry Kroll III2010-12-20 05:38:59 -0800222 if test x"$tccdir" = x""; then
223 tccdir="tcc"
224 fi
13affef3 bellard2004-10-07 21:11:43 +0000225 if test -z "$prefix" ; then
f449f98d
HKI
Henry Kroll III2010-12-22 04:42:39 -0800226 prefix="C:/Program Files/${tccdir}"
227 fi
228 if test -z "$sharedir" ; then
229 sharedir="${prefix}"
13affef3 bellard2004-10-07 21:11:43 +0000230 fi
231 execprefix="$prefix"
f449f98d
HKI
Henry Kroll III2010-12-22 04:42:39 -0800232 bindir="${prefix}"
233 tccdir="${prefix}"
234 libdir="${prefix}/lib"
235 docdir="${sharedir}/doc"
236 mandir="${sharedir}/man"
237 infodir="${sharedir}/info"
944627c4 grischka2013-02-14 06:53:07 +0100238 LIBSUF=".lib"
239 EXESUF=".exe"
13affef3 bellard2004-10-07 21:11:43 +0000240else
241 if test -z "$prefix" ; then
f449f98d
HKI
Henry Kroll III2010-12-22 04:42:39 -0800242 prefix="/usr/local"
243 fi
244 if test -z "$sharedir" ; then
48e325df Henry Kroll III2010-12-23 06:36:07 -0800245 sharedir="${prefix}/share"
13affef3 bellard2004-10-07 21:11:43 +0000246 fi
247 if test x"$execprefix" = x""; then
f449f98d
HKI
Henry Kroll III2010-12-22 04:42:39 -0800248 execprefix="${prefix}"
249 fi
7ed43415 seyko2015-03-04 10:57:13 +0300250 if test x"$tccdir" = x""; then
251 tccdir="tcc"
252 fi
f449f98d Henry Kroll III2010-12-22 04:42:39 -0800253 if test x"$libdir" = x""; then
7ed43415 seyko2015-03-04 10:57:13 +0300254 libdir="${execprefix}/lib"
255 if test -n "${tccdir}"; then
256 tccdir="${libdir}/${tccdir}"
257 else
258 tccdir="${libdir}"
259 fi
260 if test "$cpu" = "x86-64"; then
261 libdir="${execprefix}/lib64"
262 fi
263 else
264 tccdir="${libdir}/${tccdir}"
13affef3 bellard2004-10-07 21:11:43 +0000265 fi
266 if test x"$bindir" = x""; then
f449f98d
HKI
Henry Kroll III2010-12-22 04:42:39 -0800267 bindir="${execprefix}/bin"
268 fi
13affef3 bellard2004-10-07 21:11:43 +0000269 if test x"$docdir" = x""; then
f449f98d
HKI
Henry Kroll III2010-12-22 04:42:39 -0800270 docdir="${sharedir}/doc/${tccdir}"
271 fi
272 if test x"$mandir" = x""; then
273 mandir="${sharedir}/man"
13affef3 bellard2004-10-07 21:11:43 +0000274 fi
f449f98d
HKI
Henry Kroll III2010-12-22 04:42:39 -0800275 if test x"$infodir" = x""; then
276 infodir="${sharedir}/info"
277 fi
13affef3 bellard2004-10-07 21:11:43 +0000278fi # mingw32
279
13affef3 bellard2004-10-07 21:11:43 +0000280if test x"$includedir" = x""; then
281includedir="${prefix}/include"
282fi
dd56ab8c bellard2003-04-13 19:50:35 +0000283
944627c4 grischka2013-02-14 06:53:07 +0100284if test x"$show_help" = "xyes" ; then
285cat << EOF
286Usage: configure [options]
287Options: [defaults in brackets after descriptions]
288
289Standard options:
290 --help print this message
291 --prefix=PREFIX install in PREFIX [$prefix]
292 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
293 [same as prefix]
294 --bindir=DIR user executables in DIR [EPREFIX/bin]
295 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
296 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
297 --includedir=DIR C header files in DIR [PREFIX/include]
298 --sharedir=DIR documentation root DIR [PREFIX/share]
299 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
300 --mandir=DIR man documentation in DIR [SHAREDIR/man]
301 --infodir=DIR info documentation in DIR [SHAREDIR/info]
302
303Advanced options (experts only):
304 --source-path=PATH path of source code [$source_path]
305 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
306 --sysroot=PREFIX prepend PREFIX to library/include paths []
307 --cc=CC use C compiler CC [$cc]
308 --extra-cflags= specify compiler flags [$CFLAGS]
309 --extra-ldflags= specify linker options []
0e3d2e0b Thomas Preud'homme2014-04-12 16:20:12 +0800310 --cpu=CPU CPU [$cpu]
944627c4 grischka2013-02-14 06:53:07 +0100311 --strip-binaries strip symbol tables from resulting binaries
312 --disable-static make libtcc.so instead of libtcc.a
313 --disable-rpath disable use of -rpath with the above
4ad186c5 grischka2014-01-06 19:07:08 +0100314 --with-libgcc use libgcc_s.so.1 instead of libtcc1.a in dynamic link
bfb7b0d9 seyko2015-03-04 12:02:13 +0300315 --enable-tcc64-mingw build windows version on linux with x86_64-win-tcc
316 --enable-tcc32-mingw build windows version on linux with i386-win-tcc
944627c4 grischka2013-02-14 06:53:07 +0100317 --enable-mingw32 build windows version on linux with mingw32
318 --enable-cygwin build windows version on windows with cygwin
319 --enable-cross build cross compilers
41b3c7a5 James Lyon2013-04-27 20:39:34 +0100320 --enable-assert enable debug assertions
944627c4 grischka2013-02-14 06:53:07 +0100321 --with-selinux use mmap for exec mem [needs writable /tmp]
322 --sysincludepaths=... specify system include paths, colon separated
323 --libpaths=... specify system library paths, colon separated
324 --crtprefix=... specify locations of crt?.o, colon separated
325 --elfinterp=... specify elf interpreter
326EOF
327#echo "NOTE: The object files are build at the place where configure is launched"
328exit 1
329fi
330
bfb7b0d9 seyko2015-03-04 12:02:13 +0300331if test "$cc" != "tcc"; then
332 ar="${cross_prefix}${ar}"
333fi
944627c4 grischka2013-02-14 06:53:07 +0100334cc="${cross_prefix}${cc}"
944627c4 grischka2013-02-14 06:53:07 +0100335strip="${cross_prefix}${strip}"
336
337CONFTEST=./conftest$EXESUF
338
339if test -z "$cross_prefix" ; then
89ad24e7 gus knight2015-07-29 16:53:57 -0400340 if ! $cc -o $CONFTEST $source_path/conftest.c 2>/dev/null ; then
944627c4 grischka2013-02-14 06:53:07 +0100341 echo "configure: error: '$cc' failed to compile conftest.c."
342 else
343 bigendian="$($CONFTEST bigendian)"
344 gcc_major="$($CONFTEST version)"
345 gcc_minor="$($CONFTEST minor)"
346 if test "$mingw32" = "no" ; then
b1a82335
TP
Thomas Preud'homme2013-02-14 15:39:35 +0100347 triplet="$($CONFTEST triplet)"
348 if test -f "/usr/lib/$triplet/crti.o" ; then
9382d6f1 Thomas Preud'homme2013-09-07 19:26:36 +0200349 tcc_lddir="lib"
b1a82335 Thomas Preud'homme2013-02-14 15:39:35 +0100350 multiarch_triplet="$triplet"
7ed43415 seyko2015-03-04 10:57:13 +0300351 elif test "$cpu" != "x86" -a -f "/usr/lib64/crti.o" ; then
b1a82335
TP
Thomas Preud'homme2013-02-14 15:39:35 +0100352 tcc_lddir="lib64"
353 fi
944627c4 grischka2013-02-14 06:53:07 +0100354
c4397b2b grischka2013-02-14 21:15:56 +0100355 if test "$cpu" = "armv4l" ; then
356 if test "${triplet%eabihf}" != "$triplet" ; then
357 confvars="$confvars arm_eabihf"
358 elif test "${triplet%eabi}" != "$triplet" ; then
359 confvars="$confvars arm_eabi"
360 fi
361 if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc/cpuinfo ; then
362 confvars="$confvars arm_vfp"
363 fi
364 fi
365
b1a82335
TP
Thomas Preud'homme2013-02-14 15:39:35 +0100366# multiarch_triplet=${libc_dir#*/}
367# multiarch_triplet=${multiarch_triplet%/}
368# tcc_lddir="${libc_dir%%/*}"
369# if test -n "$multiarch_triplet" ; then
370# tcc_lddir="$tcc_lddir/$multiarch_triplet"
371# fi
944627c4 grischka2013-02-14 06:53:07 +0100372
c4397b2b grischka2013-02-14 21:15:56 +0100373 if test -f "/lib/ld-uClibc.so.0" ; then
374 confvars="$confvars uClibc"
375 fi
944627c4 grischka2013-02-14 06:53:07 +0100376# gr: maybe for after the release:
762a4387 grischka2013-02-14 17:43:24 +0100377# tcc_elfinterp="$(ldd $CONFTEST | grep 'ld.*.so' | sed 's,\s*\(\S\+\).*,\1,')"
378 # echo "elfinterp $tcc_elfinterp"
944627c4 grischka2013-02-14 06:53:07 +0100379
380 fi
381 fi
382else
383 # if cross compiling, cannot launch a program, so make a static guess
384 case $cpu in
385 powerpc|mips|s390) bigendian=yes;;
386 esac
387fi
388
7ed43415 seyko2015-03-04 10:57:13 +0300389# a final configuration tuning
2e51f0ee
P
Philip2015-04-27 13:28:03 +0000390W_OPTIONS="declaration-after-statement"
391for i in $W_OPTIONS; do
392 O_PRESENT="$($cc -v --help 2>&1 | grep -- -W$i)"
393 if test -n "$O_PRESENT"; then CFLAGS="$CFLAGS -W$i"; fi
394done
48d12e42 seyko2015-03-04 11:47:52 +0300395W_OPTIONS="deprecated-declarations strict-aliasing pointer-sign sign-compare unused-result uninitialized"
396for i in $W_OPTIONS; do
397 O_PRESENT="$($cc -v --help 2>&1 | grep -- -W$i)"
398 if test -n "$O_PRESENT"; then CFLAGS="$CFLAGS -Wno-$i"; fi
399done
400F_OPTIONS="strict-aliasing"
401for i in $F_OPTIONS; do
402 O_PRESENT="$($cc -v --help 2>&1 | grep -- -f$i)"
403 if test -n "$O_PRESENT"; then CFLAGS="$CFLAGS -fno-$i"; fi
404done
7ed43415 seyko2015-03-04 10:57:13 +0300405if test -z "$tcc_lddir" -a "$cpu" = "x86-64"; then tcc_lddir="lib64"; fi
406
149c2a9c seyko2015-03-04 10:03:40 +0300407echo "Binary directory $bindir"
408echo "TinyCC directory $tccdir"
409echo "Library directory $libdir"
410echo "Include directory $includedir"
411echo "Manual directory $mandir"
412echo "Info directory $infodir"
413echo "Doc directory $docdir"
414echo "Target root prefix $sysroot"
415echo "Source path $source_path"
416echo "C compiler $cc"
417echo "cross compilers $build_cross"
418if test "$build_cross" = "no"; then
419echo "Target CPU $cpu"
420fi
87ec08ec seyko2015-03-10 13:39:26 +0300421echo "Host OS $host_os"
149c2a9c seyko2015-03-04 10:03:40 +0300422echo "Target OS $targetos"
423echo "Big Endian $bigendian"
424echo "gprof enabled $gprof"
425echo "use libgcc $use_libgcc"
dd56ab8c bellard2003-04-13 19:50:35 +0000426
427echo "Creating config.mak and config.h"
428
d7264e02
AD
Akim Demaille2012-12-21 13:49:15 +0100429cat >config.mak <<EOF
430# Automatically generated by configure - do not modify
431prefix=$prefix
432bindir=\$(DESTDIR)$bindir
433tccdir=\$(DESTDIR)$tccdir
434libdir=\$(DESTDIR)$libdir
435ln_libdir=$libdir
436includedir=\$(DESTDIR)$includedir
437mandir=\$(DESTDIR)$mandir
438infodir=\$(DESTDIR)$infodir
439docdir=\$(DESTDIR)$docdir
17cf0dcf grischka2013-01-30 18:39:09 +0100440CC=$cc
441GCC_MAJOR=$gcc_major
944627c4 grischka2013-02-14 06:53:07 +0100442GCC_MINOR=$gcc_minor
17cf0dcf grischka2013-01-30 18:39:09 +0100443HOST_CC=$host_cc
444AR=$ar
445STRIP=$strip -s -R .comment -R .note
3f09b90d
AD
Akim Demaille2012-12-14 17:18:03 +0100446CFLAGS=$CFLAGS
447LDFLAGS=$LDFLAGS
448LIBSUF=$LIBSUF
449EXESUF=$EXESUF
87ec08ec seyko2015-03-10 13:39:26 +0300450HOST_OS=$host_os
3f09b90d Akim Demaille2012-12-14 17:18:03 +0100451EOF
87a01096 seyko2015-05-10 09:57:11 +0300452if test "$mingw32" = "yes" -a "$host_os" != "Windows" ; then
453cat >>config.mak <<EOF
454XCC=$cc
455XAR=$ar
456EOF
457fi
81cd0cf6 grischka2011-08-06 16:11:12 +0200458
762a4387 grischka2013-02-14 17:43:24 +0100459print_inc() {
944627c4 grischka2013-02-14 06:53:07 +0100460 if test -n "$2"; then
461 echo "#ifndef $1" >> $TMPH
462 echo "# define $1 \"$2\"" >> $TMPH
463 echo "#endif" >> $TMPH
464 fi
465}
762a4387 grischka2013-02-14 17:43:24 +0100466print_mak() {
467 if test -n "$2"; then
468 echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak
469 fi
470}
944627c4 grischka2013-02-14 06:53:07 +0100471
472echo "/* Automatically generated by configure - do not modify */" > $TMPH
473
762a4387 grischka2013-02-14 17:43:24 +0100474print_inc CONFIG_SYSROOT "$sysroot"
475print_inc CONFIG_TCCDIR "$tccdir"
b5d25654 seyko2015-03-21 07:16:33 +0300476if test "$build_cross" = "no"; then
7ed43415 seyko2015-03-04 10:57:13 +0300477print_inc CONFIG_LDDIR "$tcc_lddir"
b5d25654 seyko2015-03-21 07:16:33 +0300478fi
762a4387 grischka2013-02-14 17:43:24 +0100479print_mak CONFIG_TCC_SYSINCLUDEPATHS "$tcc_sysincludepaths"
480print_mak CONFIG_TCC_LIBPATHS "$tcc_libpaths"
481print_mak CONFIG_TCC_CRTPREFIX "$tcc_crtprefix"
482print_mak CONFIG_TCC_ELFINTERP "$tcc_elfinterp"
762a4387 grischka2013-02-14 17:43:24 +0100483print_mak CONFIG_MULTIARCHDIR "$multiarch_triplet"
944627c4 grischka2013-02-14 06:53:07 +0100484
485echo "#define GCC_MAJOR $gcc_major" >> $TMPH
486echo "#define GCC_MINOR $gcc_minor" >> $TMPH
487
dd56ab8c bellard2003-04-13 19:50:35 +0000488if test "$cpu" = "x86" ; then
489 echo "ARCH=i386" >> config.mak
0a9873aa
SH
Shinichiro Hamaji2008-12-02 03:19:25 +0900490elif test "$cpu" = "x86-64" ; then
491 echo "ARCH=x86-64" >> config.mak
dd56ab8c bellard2003-04-13 19:50:35 +0000492elif test "$cpu" = "armv4l" ; then
493 echo "ARCH=arm" >> config.mak
c4a18f47 Thomas Preud'homme2012-12-04 11:17:51 +0100494 echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH
b14ef0e2
EGE
Edmund Grimley Evans2015-02-13 18:58:31 +0000495elif test "$cpu" = "aarch64" ; then
496 echo "ARCH=arm64" >> config.mak
dd56ab8c bellard2003-04-13 19:50:35 +0000497elif test "$cpu" = "powerpc" ; then
498 echo "ARCH=ppc" >> config.mak
dd56ab8c bellard2003-04-13 19:50:35 +0000499elif test "$cpu" = "mips" ; then
500 echo "ARCH=mips" >> config.mak
dd56ab8c bellard2003-04-13 19:50:35 +0000501elif test "$cpu" = "s390" ; then
502 echo "ARCH=s390" >> config.mak
dd56ab8c bellard2003-04-13 19:50:35 +0000503elif test "$cpu" = "alpha" ; then
504 echo "ARCH=alpha" >> config.mak
dd56ab8c bellard2003-04-13 19:50:35 +0000505else
506 echo "Unsupported CPU"
507 exit 1
508fi
944627c4 grischka2013-02-14 06:53:07 +0100509
8ca8b088 Milutin Jovanovic2012-02-09 12:53:17 -0500510echo "TARGETOS=$targetos" >> config.mak
944627c4 grischka2013-02-14 06:53:07 +0100511
c4397b2b grischka2013-02-14 21:15:56 +0100512for v in $confvars ; do
513 echo "CONFIG_$v=yes" >> config.mak
514done
6c96c41e grischka2007-12-16 18:24:44 +0000515if test "$noldl" = "yes" ; then
516 echo "CONFIG_NOLDL=yes" >> config.mak
517fi
13affef3 bellard2004-10-07 21:11:43 +0000518if test "$mingw32" = "yes" ; then
5775911d
AM
Andrew Mulbrook2012-03-03 10:12:06 -0600519 echo "CONFIG_WIN32=yes" >> config.mak
520 echo "#define CONFIG_WIN32 1" >> $TMPH
13affef3 bellard2004-10-07 21:11:43 +0000521fi
94e72b16
HKI
Henry Kroll III2010-12-02 20:16:32 -0800522if test "$cygwin" = "yes" ; then
523 echo "#ifndef _WIN32" >> $TMPH
944627c4 grischka2013-02-14 06:53:07 +0100524 echo "# define _WIN32" >> $TMPH
94e72b16 Henry Kroll III2010-12-02 20:16:32 -0800525 echo "#endif" >> $TMPH
5775911d Andrew Mulbrook2012-03-03 10:12:06 -0600526 echo "AR=ar" >> config.mak
94e72b16 Henry Kroll III2010-12-02 20:16:32 -0800527fi
dd56ab8c bellard2003-04-13 19:50:35 +0000528if test "$bigendian" = "yes" ; then
529 echo "WORDS_BIGENDIAN=yes" >> config.mak
530 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
531fi
532if test "$gprof" = "yes" ; then
533 echo "TARGET_GPROF=yes" >> config.mak
534 echo "#define HAVE_GPROF 1" >> $TMPH
535fi
acc4f88e bellard2005-04-14 23:51:24 +0000536if test "$build_cross" = "yes" ; then
537 echo "CONFIG_CROSS=yes" >> config.mak
538fi
a4ed587f
HKI
Henry Kroll III2010-04-24 02:35:43 -0700539if test "$disable_static" = "yes" ; then
540 echo "DISABLE_STATIC=yes" >> config.mak
541fi
90355c78
HKI
Henry Kroll III2010-12-20 05:55:54 -0800542if test "$disable_rpath" = "yes" ; then
543 echo "DISABLE_RPATH=yes" >> config.mak
544fi
3511e6e2
TP
Thomas Preud'homme2011-06-17 22:22:04 +0200545if test "$strip_binaries" = "yes" ; then
546 echo "STRIP_BINARIES=yes" >> config.mak
547fi
15e0dc08
DG
Daniel Glöckner2008-09-05 21:08:37 +0200548if test "$use_libgcc" = "yes" ; then
549 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
550 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
551fi
be7e339d
HKI
Henry Kroll III2010-04-20 23:40:33 -0700552if test "$have_selinux" = "yes" ; then
553 echo "#define HAVE_SELINUX" >> $TMPH
554 echo "HAVE_SELINUX=yes" >> config.mak
555fi
41b3c7a5
JL
James Lyon2013-04-27 20:39:34 +0100556if test "$enable_assert" = "yes" ; then
557 echo "#define CONFIG_TCC_ASSERT" >> $TMPH
558fi
17cf0dcf grischka2013-01-30 18:39:09 +0100559
fe7bcdef bellard2003-04-13 21:55:37 +0000560version=`head $source_path/VERSION`
561echo "VERSION=$version" >>config.mak
562echo "#define TCC_VERSION \"$version\"" >> $TMPH
89ad24e7 gus knight2015-07-29 16:53:57 -0400563echo "@set VERSION $version" > config.texi
17cf0dcf grischka2013-01-30 18:39:09 +0100564echo "SRC_PATH=$source_path" >>config.mak
dd56ab8c bellard2003-04-13 19:50:35 +0000565
dd56ab8c bellard2003-04-13 19:50:35 +0000566if test "$source_path_used" = "yes" ; then
17cf0dcf grischka2013-01-30 18:39:09 +0100567 case $source_path in
568 /*) echo "top_srcdir=$source_path";;
569 *) echo "top_srcdir=\$(TOP)/$source_path";;
570 esac >>config.mak
571else
572 echo 'top_srcdir=$(TOP)' >>config.mak
dd56ab8c bellard2003-04-13 19:50:35 +0000573fi
17cf0dcf grischka2013-01-30 18:39:09 +0100574echo 'top_builddir=$(TOP)' >>config.mak
dd56ab8c bellard2003-04-13 19:50:35 +0000575
89ad24e7 gus knight2015-07-29 16:53:57 -0400576diff $TMPH config.h >/dev/null 2>&1
dd56ab8c bellard2003-04-13 19:50:35 +0000577if test $? -ne 0 ; then
89ad24e7 gus knight2015-07-29 16:53:57 -0400578 mv -f $TMPH config.h
dd56ab8c bellard2003-04-13 19:50:35 +0000579else
6c96c41e grischka2007-12-16 18:24:44 +0000580 echo "config.h is unchanged"
dd56ab8c bellard2003-04-13 19:50:35 +0000581fi
582
944627c4 grischka2013-02-14 06:53:07 +0100583rm -f $TMPN* $CONFTEST
584
585# ---------------------------------------------------------------------------
586# build tree in object directory if source path is different from current one
587
588fn_makelink()
589{
590 tgt=$1/$2
591 case $2 in
592 */*) dn=${2%/*}
593 test -d $dn || mkdir -p $dn
594 case $1 in
595 /*) ;;
596 *) while test $dn ; do
597 tgt=../$tgt; dn=${dn#${dn%%/*}}; dn=${dn#/}
598 done
599 ;;
600 esac
601 ;;
602 esac
603 ln -sfn $tgt $2
604}
605
606if test "$source_path_used" = "yes" ; then
607 FILES="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile"
608 for f in $FILES ; do
609 fn_makelink $source_path $f
610 done
611fi
612
613# ---------------------------------------------------------------------------