source: EcnlProtoTool/trunk/tcc-0.9.27/configure@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

File size: 13.2 KB
RevLine 
[279]1#!/bin/sh
2#
3# tcc configure script (c) 2003 Fabrice Bellard
4
5# set temporary file name
6# 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#
14# bashism: TMPN="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.c"
15
16TMPN="./conftest-$$"
17TMPH=$TMPN.h
18
19# default parameters
20prefix=""
21execprefix=""
22bindir=""
23libdir=""
24tccdir=""
25includedir=""
26mandir=""
27infodir=""
28sysroot=""
29cross_prefix=""
30cc="gcc"
31ar="ar"
32strip="strip"
33bigendian="no"
34mingw32="no"
35LIBSUF=".a"
36EXESUF=""
[331]37DLLSUF=".so"
[279]38tcc_sysincludepaths=""
39tcc_libpaths=""
40tcc_crtprefix=""
41tcc_elfinterp=""
[331]42triplet=
[279]43tcc_lddir=
44confvars=
[331]45suggest="yes"
46cpu=
47cpuver=
48gcc_major=0
49gcc_minor=0
[279]50
51# OS specific
[331]52targetos=`uname`
[279]53case $targetos in
[331]54 Darwin)
55 confvars="$confvars OSX"
56 DLLSUF=".dylib"
57 ;;
58 MINGW*|MSYS*|CYGWIN*)
59 mingw32=yes
60 ;;
61 DragonFly|OpenBSD|FreeBSD|NetBSD)
62 confvars="$confvars ldl=no"
63 ;;
64 *)
65 ;;
[279]66esac
67
68# find source path
69source_path=${0%configure}
70source_path=${source_path%/}
71source_path_used="yes"
72if test -z "$source_path" -o "$source_path" = "." ; then
73 source_path=`pwd`
74 source_path_used="no"
75fi
76
77for opt do
78 eval opt=\"$opt\"
79 case "$opt" in
80 --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
81 ;;
82 --exec-prefix=*) execprefix=`echo $opt | cut -d '=' -f 2`
83 ;;
84 --tccdir=*) tccdir=`echo $opt | cut -d '=' -f 2`
85 ;;
86 --bindir=*) bindir=`echo $opt | cut -d '=' -f 2`
87 ;;
88 --libdir=*) libdir=`echo $opt | cut -d '=' -f 2`
89 ;;
90 --includedir=*) includedir=`echo $opt | cut -d '=' -f 2`
91 ;;
92 --sharedir=*) sharedir=`echo $opt | cut -d '=' -f 2`
93 ;;
94 --mandir=*) mandir=`echo $opt | cut -d '=' -f 2`
95 ;;
96 --infodir=*) infodir=`echo $opt | cut -d '=' -f 2`
97 ;;
98 --docdir=*) docdir=`echo $opt | cut -d '=' -f 2`
99 ;;
100 --sysroot=*) sysroot=`echo $opt | cut -d '=' -f 2`
101 ;;
102 --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
103 ;;
104 --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
105 ;;
106 --cc=*) cc=`echo $opt | cut -d '=' -f 2`
107 ;;
[331]108 --ar=*) ar=`echo $opt | cut -d '=' -f 2`
109 ;;
[279]110 --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
111 ;;
112 --extra-ldflags=*) LDFLAGS="${opt#--extra-ldflags=}"
113 ;;
[331]114 --extra-libs=*) extralibs="${opt#--extra-libs=}"
[279]115 ;;
116 --sysincludepaths=*) tcc_sysincludepaths=`echo $opt | cut -d '=' -f 2`
117 ;;
118 --libpaths=*) tcc_libpaths=`echo $opt | cut -d '=' -f 2`
119 ;;
120 --crtprefix=*) tcc_crtprefix=`echo $opt | cut -d '=' -f 2`
121 ;;
122 --elfinterp=*) tcc_elfinterp=`echo $opt | cut -d '=' -f 2`
123 ;;
[331]124 --triplet=*) triplet=`echo $opt | cut -d '=' -f 2`
125 ;;
[279]126 --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
127 ;;
[331]128 --enable-cross) confvars="$confvars cross"
[279]129 ;;
[331]130 --disable-static) confvars="$confvars static=no"
[279]131 ;;
[331]132 --enable-static) confvars="$confvars static"
[279]133 ;;
[331]134 --disable-rpath) confvars="$confvars rpath=no"
[279]135 ;;
[331]136 --strip-binaries) confvars="$confvars strip"
[279]137 ;;
[331]138 --with-libgcc) confvars="$confvars libgcc"
[279]139 ;;
[331]140 --with-selinux) confvars="$confvars selinux"
[279]141 ;;
[331]142 --config-mingw32*) mingw32=$(echo "$opt=yes" | cut -d '=' -f 2)
[279]143 ;;
[331]144 --config-*) confvars="$confvars ${opt#--config-}"; suggest="no"
[279]145 ;;
146 --help|-h) show_help="yes"
147 ;;
148 *) echo "configure: WARNING: unrecognized option $opt"
149 ;;
150 esac
151done
152
[331]153if test -z "$cpu" ; then
154 if test -n "$ARCH" ; then
155 cpu="$ARCH"
156 else
157 cpu=`uname -m`
158 fi
159fi
160
161case "$cpu" in
162 x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386)
163 cpu="i386"
164 ;;
165 x86_64|amd64|x86-64)
166 cpu="x86_64"
167 ;;
168 arm*)
169 case "$cpu" in
170 arm|armv4l)
171 cpuver=4
172 ;;
173 armv5tel|armv5tejl)
174 cpuver=5
175 ;;
176 armv6j|armv6l)
177 cpuver=6
178 ;;
179 armv7a|armv7l)
180 cpuver=7
181 ;;
182 esac
183 cpu="arm"
184 ;;
185 aarch64)
186 cpu="aarch64"
187 ;;
188 alpha)
189 cpu="alpha"
190 ;;
191 "Power Macintosh"|ppc|ppc64)
192 cpu="ppc"
193 ;;
194 mips)
195 cpu="mips"
196 ;;
197 s390)
198 cpu="s390"
199 ;;
200 *)
201 echo "Unsupported CPU"
202 exit 1
203 ;;
204esac
205
[279]206# Checking for CFLAGS
207if test -z "$CFLAGS"; then
208 CFLAGS="-Wall -g -O2"
209fi
210
211if test "$mingw32" = "yes" ; then
[331]212 if test "$source_path_used" = "no"; then
213 source_path="."
[279]214 fi
[331]215 if test "$cc" = gcc; then
216 test -z "$LDFLAGS" && LDFLAGS="-static"
[279]217 fi
[331]218 test -z "$prefix" && prefix="C:/Program Files/tcc"
219 test -z "$tccdir" && tccdir="${prefix}"
220 test -z "$bindir" && bindir="${tccdir}"
221 test -z "$docdir" && docdir="${tccdir}/doc"
222 test -z "$libdir" && libdir="${tccdir}/libtcc"
223 confvars="$confvars WIN32"
[279]224 LIBSUF=".lib"
225 EXESUF=".exe"
[331]226 DLLSUF=".dll"
[279]227else
228 if test -z "$prefix" ; then
[331]229 prefix="/usr/local"
[279]230 fi
231 if test -z "$sharedir" ; then
[331]232 sharedir="${prefix}/share"
[279]233 fi
234 if test x"$execprefix" = x""; then
[331]235 execprefix="${prefix}"
[279]236 fi
237 if test x"$libdir" = x""; then
[331]238 libdir="${execprefix}/lib"
[279]239 fi
240 if test x"$bindir" = x""; then
[331]241 bindir="${execprefix}/bin"
[279]242 fi
243 if test x"$docdir" = x""; then
[331]244 docdir="${sharedir}/doc"
[279]245 fi
246 if test x"$mandir" = x""; then
[331]247 mandir="${sharedir}/man"
[279]248 fi
249 if test x"$infodir" = x""; then
[331]250 infodir="${sharedir}/info"
[279]251 fi
[331]252 if test x"$tccdir" = x""; then
253 tccdir="${libdir}/tcc"
254 fi
255 if test x"$includedir" = x""; then
256 includedir="${prefix}/include"
257 fi
[279]258fi # mingw32
259
260if test x"$show_help" = "xyes" ; then
261cat << EOF
262Usage: configure [options]
263Options: [defaults in brackets after descriptions]
264
265Standard options:
266 --help print this message
267 --prefix=PREFIX install in PREFIX [$prefix]
268 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[331]269 [same as prefix]
[279]270 --bindir=DIR user executables in DIR [EPREFIX/bin]
271 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
272 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
273 --includedir=DIR C header files in DIR [PREFIX/include]
274 --sharedir=DIR documentation root DIR [PREFIX/share]
275 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
276 --mandir=DIR man documentation in DIR [SHAREDIR/man]
277 --infodir=DIR info documentation in DIR [SHAREDIR/info]
278
279Advanced options (experts only):
280 --source-path=PATH path of source code [$source_path]
281 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
282 --sysroot=PREFIX prepend PREFIX to library/include paths []
283 --cc=CC use C compiler CC [$cc]
[331]284 --ar=AR create archives using AR [$ar]
[279]285 --extra-cflags= specify compiler flags [$CFLAGS]
286 --extra-ldflags= specify linker options []
[331]287 --cpu=CPU CPU [$cpu]
[279]288 --strip-binaries strip symbol tables from resulting binaries
289 --disable-static make libtcc.so instead of libtcc.a
[331]290 --enable-static make libtcc.a instead of libtcc.dll (win32)
[279]291 --disable-rpath disable use of -rpath with the above
[331]292 --with-libgcc use libgcc_s.so.1 instead of libtcc1.a
[279]293 --enable-cross build cross compilers
[331]294 --with-selinux use mmap for executable memory (with tcc -run)
[279]295 --sysincludepaths=... specify system include paths, colon separated
296 --libpaths=... specify system library paths, colon separated
297 --crtprefix=... specify locations of crt?.o, colon separated
298 --elfinterp=... specify elf interpreter
[331]299 --triplet=... specify system library/include directory triplet
300 --config-uClibc,-musl,-mingw32... enable system specific configurations
[279]301EOF
302#echo "NOTE: The object files are build at the place where configure is launched"
303exit 1
304fi
305
306cc="${cross_prefix}${cc}"
307ar="${cross_prefix}${ar}"
308strip="${cross_prefix}${strip}"
309
310if test -z "$cross_prefix" ; then
[331]311 CONFTEST=./conftest$EXESUF
[279]312 if ! $cc -o $CONFTEST $source_path/conftest.c 2>/dev/null ; then
313 echo "configure: error: '$cc' failed to compile conftest.c."
314 else
315 gcc_major="$($CONFTEST version)"
316 gcc_minor="$($CONFTEST minor)"
[331]317 fi
318 bigendian="$($CONFTEST bigendian)"
319 if test "$mingw32" = "no" ; then
320
321 if test -z "$triplet"; then
322 tt="$($CONFTEST triplet)"
323 if test -n "$tt" -a -f "/usr/lib/$tt/crti.o" ; then
324 triplet="$tt"
325 fi
[279]326 fi
327
[331]328 if test -z "$triplet"; then
329 if test $cpu = "x86_64" -o $cpu = "aarch64" ; then
330 if test -f "/usr/lib64/crti.o" ; then
331 tcc_lddir="lib64"
332 fi
[279]333 fi
334 fi
335
[331]336 if test "$cpu" = "arm" ; then
337 if test "${triplet%eabihf}" != "$triplet" ; then
338 confvars="$confvars arm_eabihf"
339 elif test "${triplet%eabi}" != "$triplet" ; then
340 confvars="$confvars arm_eabi"
341 fi
342 if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc/cpuinfo ; then
343 confvars="$confvars arm_vfp"
344 fi
345 fi
[279]346
[331]347 if test "$suggest" = "yes"; then
348 if test -f "/lib/ld-uClibc.so.0" ; then
349 echo "Perhaps you want ./configure --config-uClibc"
350 fi
351 if test -f "/lib/ld-musl-$cpu.so.1"; then
352 echo "Perhaps you want ./configure --config-musl"
353 fi
[279]354 fi
355 fi
356else
357 # if cross compiling, cannot launch a program, so make a static guess
358 case $cpu in
[331]359 ppc|mips|s390) bigendian=yes;;
[279]360 esac
361fi
362
[331]363if test "$bigendian" = "yes" ; then
364 confvars="$confvars BIGENDIAN"
365fi
[279]366
[331]367# a final configuration tuning
368if ! echo "$cc" | grep -q "tcc"; then
369 OPT1="-Wdeclaration-after-statement -fno-strict-aliasing"
370 # we want -Wno- but gcc does not always reject unknown -Wno- options
371 OPT2="-Wpointer-sign -Wsign-compare -Wunused-result"
372 if echo "$cc" | grep -q "clang"; then
373 OPT1="$OPT1 -fheinous-gnu-extensions"
374 OPT2="$OPT2 -Wstring-plus-int"
375 fi
376 $cc $OPT1 $OPT2 -o a.out -c -xc - < /dev/null > cc_msg.txt 2>&1
377 for o in $OPT1; do # enable these options
378 if ! grep -q -- $o cc_msg.txt; then CFLAGS="$CFLAGS $o"; fi
379 done
380 for o in $OPT2; do # disable these options
381 if ! grep -q -- $o cc_msg.txt; then CFLAGS="$CFLAGS -Wno-${o#-W*}"; fi
382 done
383 # cat cc_msg.txt
384 # echo $CFLAGS
385 rm -f cc_msg.txt a.out
386fi
387
388fcho() { if test -n "$2"; then echo "$1$2"; fi }
389
390fcho "Binary directory " "$bindir"
391fcho "TinyCC directory " "$tccdir"
392fcho "Library directory " "$libdir"
393fcho "Include directory " "$includedir"
394fcho "Manual directory " "$mandir"
395fcho "Info directory " "$infodir"
396fcho "Doc directory " "$docdir"
397fcho "Target root prefix " "$sysroot"
398echo "Source path $source_path"
399echo "C compiler $cc ($gcc_major.$gcc_minor)"
400echo "Target OS $targetos"
401echo "CPU $cpu"
402fcho "Triplet " "$triplet"
403fcho "Config " "${confvars# }"
[279]404echo "Creating config.mak and config.h"
405
406cat >config.mak <<EOF
407# Automatically generated by configure - do not modify
408prefix=$prefix
409bindir=\$(DESTDIR)$bindir
410tccdir=\$(DESTDIR)$tccdir
411libdir=\$(DESTDIR)$libdir
412includedir=\$(DESTDIR)$includedir
413mandir=\$(DESTDIR)$mandir
414infodir=\$(DESTDIR)$infodir
415docdir=\$(DESTDIR)$docdir
416CC=$cc
417GCC_MAJOR=$gcc_major
418GCC_MINOR=$gcc_minor
419AR=$ar
420STRIP=$strip -s -R .comment -R .note
421CFLAGS=$CFLAGS
422LDFLAGS=$LDFLAGS
423LIBSUF=$LIBSUF
424EXESUF=$EXESUF
[331]425DLLSUF=$DLLSUF
[279]426EOF
427
428print_inc() {
429 if test -n "$2"; then
430 echo "#ifndef $1" >> $TMPH
431 echo "# define $1 \"$2\"" >> $TMPH
432 echo "#endif" >> $TMPH
433 fi
434}
[331]435
[279]436print_mak() {
437 if test -n "$2"; then
438 echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak
439 fi
440}
441
[331]442print_mak_int() {
443 if test -n "$2"; then
444 echo "NATIVE_DEFINES+=-D$1=$2" >> config.mak
445 fi
446}
447
[279]448echo "/* Automatically generated by configure - do not modify */" > $TMPH
449
450print_inc CONFIG_SYSROOT "$sysroot"
451print_inc CONFIG_TCCDIR "$tccdir"
452print_mak CONFIG_TCC_SYSINCLUDEPATHS "$tcc_sysincludepaths"
453print_mak CONFIG_TCC_LIBPATHS "$tcc_libpaths"
454print_mak CONFIG_TCC_CRTPREFIX "$tcc_crtprefix"
455print_mak CONFIG_TCC_ELFINTERP "$tcc_elfinterp"
456print_mak CONFIG_LDDIR "$tcc_lddir"
[331]457print_mak CONFIG_TRIPLET "$triplet"
458print_mak_int TCC_CPU_VERSION "$cpuver"
[279]459
[331]460if test "$cpu" = "aarch64" ; then
461 echo "ARCH=arm64" >> config.mak
[279]462else
[331]463 echo "ARCH=$cpu" >> config.mak
[279]464fi
465echo "TARGETOS=$targetos" >> config.mak
466
467for v in $confvars ; do
[331]468 if test "${v%=*}" = "$v"; then
469 echo "CONFIG_$v=yes" >> config.mak
470 else
471 echo "CONFIG_$v" >> config.mak
472 fi
[279]473done
474
475version=`head $source_path/VERSION`
[331]476echo "VERSION = $version" >> config.mak
[279]477echo "#define TCC_VERSION \"$version\"" >> $TMPH
478echo "@set VERSION $version" > config.texi
479
480if test "$source_path_used" = "yes" ; then
481 case $source_path in
[331]482 /*) echo "TOPSRC=$source_path";;
483 *) echo "TOPSRC=\$(TOP)/$source_path";;
[279]484 esac >>config.mak
485else
[331]486 echo 'TOPSRC=$(TOP)' >>config.mak
[279]487fi
488
489diff $TMPH config.h >/dev/null 2>&1
490if test $? -ne 0 ; then
491 mv -f $TMPH config.h
492else
493 echo "config.h is unchanged"
494fi
495
496rm -f $TMPN* $CONFTEST
497
498# ---------------------------------------------------------------------------
499# build tree in object directory if source path is different from current one
500
501fn_makelink()
502{
503 tgt=$1/$2
504 case $2 in
505 */*) dn=${2%/*}
[331]506 test -d $dn || mkdir -p $dn
507 case $1 in
508 /*) ;;
509 *) while test $dn ; do
510 tgt=../$tgt; dn=${dn#${dn%%/*}}; dn=${dn#/}
511 done
512 ;;
513 esac
514 ;;
[279]515 esac
[331]516
517 ln -sfn $tgt $2 || ( echo "ln failed. Using cp instead."; cp -f $1/$2 $2 )
[279]518}
519
520if test "$source_path_used" = "yes" ; then
[331]521 FILES="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile tests/pp/Makefile"
[279]522 for f in $FILES ; do
523 fn_makelink $source_path $f
524 done
525fi
526
527# ---------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.