source: EcnlProtoTool/trunk/tcc-0.9.26/configure@ 279

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

ファイルを追加、更新。

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