diff options
author | Thomas Preud'homme <robotux@celest.fr> | 2018-02-21 23:16:20 +0000 |
---|---|---|
committer | Thomas Preud'homme <robotux@celest.fr> | 2018-02-21 23:16:20 +0000 |
commit | e2ccf3981d78dfeb390d22c74625b60310100abb (patch) | |
tree | fc30b3b3fe20cc005634818512dab3514acf8ef4 /configure | |
parent | 3f2e65a51523fbb98a44b71c29ae3a3fcc13854b (diff) |
New upstream version 0.9.27
Diffstat (limited to 'configure')
-rwxr-xr-x | configure | 266 |
1 files changed, 111 insertions, 155 deletions
@@ -17,8 +17,6 @@ TMPN="./conftest-$$" TMPH=$TMPN.h # default parameters -build_cross="no" -use_libgcc="no" prefix="" execprefix="" bindir="" @@ -32,8 +30,6 @@ cross_prefix="" cc="gcc" ar="ar" strip="strip" -cygwin="no" -gprof="no" bigendian="no" mingw32="no" LIBSUF=".a" @@ -46,23 +42,30 @@ tcc_elfinterp="" triplet= tcc_lddir= confvars= +suggest="yes" cpu= +cpuver= +gcc_major=0 +gcc_minor=0 # OS specific targetos=`uname` case $targetos in - MINGW*) mingw32=yes;; - MSYS*) mingw32=yes;; - DragonFly) noldl=yes;; - OpenBSD) noldl=yes;; - FreeBSD) noldl=yes;; - NetBSD) noldl=yes;; - *) ;; + Darwin) + confvars="$confvars OSX" + DLLSUF=".dylib" + ;; + MINGW*|MSYS*|CYGWIN*) + mingw32=yes + ;; + DragonFly|OpenBSD|FreeBSD|NetBSD) + confvars="$confvars ldl=no" + ;; + *) + ;; esac # find source path -# XXX: we assume an absolute path is given when launching configure, -# except in './configure' case. source_path=${0%configure} source_path=${source_path%/} source_path_used="yes" @@ -122,23 +125,23 @@ for opt do ;; --cpu=*) cpu=`echo $opt | cut -d '=' -f 2` ;; - --enable-gprof) gprof="yes" + --enable-cross) confvars="$confvars cross" ;; - --enable-mingw32) mingw32="yes" ; cross_prefix="i686-pc-mingw32-" ; cpu=x86 + --disable-static) confvars="$confvars static=no" ;; - --enable-cygwin) mingw32="yes" ; cygwin="yes" ; cross_prefix="mingw32-" ; cpu=x86 + --enable-static) confvars="$confvars static" ;; - --enable-cross) build_cross="yes" + --disable-rpath) confvars="$confvars rpath=no" ;; - --disable-static) disable_static="yes" + --strip-binaries) confvars="$confvars strip" ;; - --disable-rpath) disable_rpath="yes" + --with-libgcc) confvars="$confvars libgcc" ;; - --strip-binaries) strip_binaries="yes" + --with-selinux) confvars="$confvars selinux" ;; - --with-libgcc) use_libgcc="yes" + --config-mingw32*) mingw32=$(echo "$opt=yes" | cut -d '=' -f 2) ;; - --with-selinux) have_selinux="yes" + --config-*) confvars="$confvars ${opt#--config-}"; suggest="no" ;; --help|-h) show_help="yes" ;; @@ -157,10 +160,10 @@ fi case "$cpu" in x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386) - cpu="x86" + cpu="i386" ;; - x86_64|amd64) - cpu="x86-64" + x86_64|amd64|x86-64) + cpu="x86_64" ;; arm*) case "$cpu" in @@ -177,7 +180,7 @@ case "$cpu" in cpuver=7 ;; esac - cpu="armv4l" + cpu="arm" ;; aarch64) cpu="aarch64" @@ -186,7 +189,7 @@ case "$cpu" in cpu="alpha" ;; "Power Macintosh"|ppc|ppc64) - cpu="powerpc" + cpu="ppc" ;; mips) cpu="mips" @@ -195,7 +198,8 @@ case "$cpu" in cpu="s390" ;; *) - cpu="unknown" + echo "Unsupported CPU" + exit 1 ;; esac @@ -205,22 +209,18 @@ if test -z "$CFLAGS"; then fi if test "$mingw32" = "yes" ; then - if test x"$tccdir" = x""; then - tccdir="tcc" - fi - if test -z "$prefix" ; then - prefix="C:/Program Files/${tccdir}" + if test "$source_path_used" = "no"; then + source_path="." fi - if test -z "$sharedir" ; then - sharedir="${prefix}" + if test "$cc" = gcc; then + test -z "$LDFLAGS" && LDFLAGS="-static" fi - execprefix="$prefix" - bindir="${prefix}" - tccdir="${prefix}" - libdir="${prefix}/lib" - docdir="${sharedir}/doc" - mandir="${sharedir}/man" - infodir="${sharedir}/info" + test -z "$prefix" && prefix="C:/Program Files/tcc" + test -z "$tccdir" && tccdir="${prefix}" + test -z "$bindir" && bindir="${tccdir}" + test -z "$docdir" && docdir="${tccdir}/doc" + test -z "$libdir" && libdir="${tccdir}/libtcc" + confvars="$confvars WIN32" LIBSUF=".lib" EXESUF=".exe" DLLSUF=".dll" @@ -252,12 +252,11 @@ else if test x"$tccdir" = x""; then tccdir="${libdir}/tcc" fi + if test x"$includedir" = x""; then + includedir="${prefix}/include" + fi fi # mingw32 -if test x"$includedir" = x""; then - includedir="${prefix}/include" -fi - if test x"$show_help" = "xyes" ; then cat << EOF Usage: configure [options] @@ -288,17 +287,17 @@ Advanced options (experts only): --cpu=CPU CPU [$cpu] --strip-binaries strip symbol tables from resulting binaries --disable-static make libtcc.so instead of libtcc.a + --enable-static make libtcc.a instead of libtcc.dll (win32) --disable-rpath disable use of -rpath with the above - --with-libgcc use libgcc_s.so.1 instead of libtcc1.a in dynamic link - --enable-mingw32 build windows version on linux with mingw32 - --enable-cygwin build windows version on windows with cygwin + --with-libgcc use libgcc_s.so.1 instead of libtcc1.a --enable-cross build cross compilers - --with-selinux use mmap for exec mem [needs writable /tmp] + --with-selinux use mmap for executable memory (with tcc -run) --sysincludepaths=... specify system include paths, colon separated --libpaths=... specify system library paths, colon separated --crtprefix=... specify locations of crt?.o, colon separated --elfinterp=... specify elf interpreter --triplet=... specify system library/include directory triplet + --config-uClibc,-musl,-mingw32... enable system specific configurations EOF #echo "NOTE: The object files are build at the place where configure is launched" exit 1 @@ -308,16 +307,16 @@ cc="${cross_prefix}${cc}" ar="${cross_prefix}${ar}" strip="${cross_prefix}${strip}" -CONFTEST=./conftest$EXESUF - if test -z "$cross_prefix" ; then + CONFTEST=./conftest$EXESUF if ! $cc -o $CONFTEST $source_path/conftest.c 2>/dev/null ; then echo "configure: error: '$cc' failed to compile conftest.c." else - bigendian="$($CONFTEST bigendian)" gcc_major="$($CONFTEST version)" gcc_minor="$($CONFTEST minor)" - if test "$mingw32" = "no" ; then + fi + bigendian="$($CONFTEST bigendian)" + if test "$mingw32" = "no" ; then if test -z "$triplet"; then tt="$($CONFTEST triplet)" @@ -327,14 +326,14 @@ if test -z "$cross_prefix" ; then fi if test -z "$triplet"; then - if test $cpu = "x86-64" -o $cpu = "aarch64" ; then + if test $cpu = "x86_64" -o $cpu = "aarch64" ; then if test -f "/usr/lib64/crti.o" ; then tcc_lddir="lib64" fi fi fi - if test "$cpu" = "armv4l" ; then + if test "$cpu" = "arm" ; then if test "${triplet%eabihf}" != "$triplet" ; then confvars="$confvars arm_eabihf" elif test "${triplet%eabi}" != "$triplet" ; then @@ -345,58 +344,63 @@ if test -z "$cross_prefix" ; then fi fi - if test -f "/lib/ld-uClibc.so.0" ; then - confvars="$confvars uClibc" + if test "$suggest" = "yes"; then + if test -f "/lib/ld-uClibc.so.0" ; then + echo "Perhaps you want ./configure --config-uClibc" + fi + if test -f "/lib/ld-musl-$cpu.so.1"; then + echo "Perhaps you want ./configure --config-musl" + fi fi - - fi fi else # if cross compiling, cannot launch a program, so make a static guess case $cpu in - powerpc|mips|s390) bigendian=yes;; + ppc|mips|s390) bigendian=yes;; esac fi +if test "$bigendian" = "yes" ; then + confvars="$confvars BIGENDIAN" +fi + # a final configuration tuning -$cc -v --help > cc_help.txt 2>&1 -W_OPTIONS="declaration-after-statement" -for i in $W_OPTIONS; do - O_PRESENT="$(grep -- -W$i cc_help.txt)" - if test -n "$O_PRESENT"; then CFLAGS="$CFLAGS -W$i"; fi -done -W_OPTIONS="deprecated-declarations strict-aliasing pointer-sign sign-compare unused-result uninitialized" -for i in $W_OPTIONS; do - O_PRESENT="$(grep -- -W$i cc_help.txt)" - if test -n "$O_PRESENT"; then CFLAGS="$CFLAGS -Wno-$i"; fi -done -F_OPTIONS="strict-aliasing" -for i in $F_OPTIONS; do - O_PRESENT="$(grep -- -f$i cc_help.txt)" - if test -n "$O_PRESENT"; then CFLAGS="$CFLAGS -fno-$i"; fi -done -rm -f cc_help.txt +if ! echo "$cc" | grep -q "tcc"; then + OPT1="-Wdeclaration-after-statement -fno-strict-aliasing" + # we want -Wno- but gcc does not always reject unknown -Wno- options + OPT2="-Wpointer-sign -Wsign-compare -Wunused-result" + if echo "$cc" | grep -q "clang"; then + OPT1="$OPT1 -fheinous-gnu-extensions" + OPT2="$OPT2 -Wstring-plus-int" + fi + $cc $OPT1 $OPT2 -o a.out -c -xc - < /dev/null > cc_msg.txt 2>&1 + for o in $OPT1; do # enable these options + if ! grep -q -- $o cc_msg.txt; then CFLAGS="$CFLAGS $o"; fi + done + for o in $OPT2; do # disable these options + if ! grep -q -- $o cc_msg.txt; then CFLAGS="$CFLAGS -Wno-${o#-W*}"; fi + done + # cat cc_msg.txt + # echo $CFLAGS + rm -f cc_msg.txt a.out +fi -fcho() { if test -n "$2"; then echo "$1$2"; else echo "$1-"; fi } +fcho() { if test -n "$2"; then echo "$1$2"; fi } -echo "Binary directory $bindir" -echo "TinyCC directory $tccdir" -echo "Library directory $libdir" -echo "Include directory $includedir" -echo "Manual directory $mandir" -echo "Info directory $infodir" -echo "Doc directory $docdir" +fcho "Binary directory " "$bindir" +fcho "TinyCC directory " "$tccdir" +fcho "Library directory " "$libdir" +fcho "Include directory " "$includedir" +fcho "Manual directory " "$mandir" +fcho "Info directory " "$infodir" +fcho "Doc directory " "$docdir" fcho "Target root prefix " "$sysroot" echo "Source path $source_path" -echo "C compiler $cc" +echo "C compiler $cc ($gcc_major.$gcc_minor)" echo "Target OS $targetos" echo "CPU $cpu" -echo "Big Endian $bigendian" -echo "Profiling $gprof" -echo "Cross compilers $build_cross" -echo "Use libgcc $use_libgcc" fcho "Triplet " "$triplet" - +fcho "Config " "${confvars# }" echo "Creating config.mak and config.h" cat >config.mak <<EOF @@ -428,12 +432,19 @@ print_inc() { echo "#endif" >> $TMPH fi } + print_mak() { if test -n "$2"; then echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak fi } +print_mak_int() { + if test -n "$2"; then + echo "NATIVE_DEFINES+=-D$1=$2" >> config.mak + fi +} + echo "/* Automatically generated by configure - do not modify */" > $TMPH print_inc CONFIG_SYSROOT "$sysroot" @@ -444,77 +455,22 @@ print_mak CONFIG_TCC_CRTPREFIX "$tcc_crtprefix" print_mak CONFIG_TCC_ELFINTERP "$tcc_elfinterp" print_mak CONFIG_LDDIR "$tcc_lddir" print_mak CONFIG_TRIPLET "$triplet" +print_mak_int TCC_CPU_VERSION "$cpuver" -echo "#define GCC_MAJOR $gcc_major" >> $TMPH -echo "#define GCC_MINOR $gcc_minor" >> $TMPH - -if test "$cpu" = "x86" ; then - echo "ARCH=i386" >> config.mak -elif test "$cpu" = "x86-64" ; then - echo "ARCH=x86-64" >> config.mak -elif test "$cpu" = "armv4l" ; then - echo "ARCH=arm" >> config.mak - echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH -elif test "$cpu" = "aarch64" ; then +if test "$cpu" = "aarch64" ; then echo "ARCH=arm64" >> config.mak -elif test "$cpu" = "powerpc" ; then - echo "ARCH=ppc" >> config.mak -elif test "$cpu" = "mips" ; then - echo "ARCH=mips" >> config.mak -elif test "$cpu" = "s390" ; then - echo "ARCH=s390" >> config.mak -elif test "$cpu" = "alpha" ; then - echo "ARCH=alpha" >> config.mak else - echo "Unsupported CPU" - exit 1 + echo "ARCH=$cpu" >> config.mak fi - echo "TARGETOS=$targetos" >> config.mak for v in $confvars ; do - echo "CONFIG_$v=yes" >> config.mak + if test "${v%=*}" = "$v"; then + echo "CONFIG_$v=yes" >> config.mak + else + echo "CONFIG_$v" >> config.mak + fi done -if test "$noldl" = "yes" ; then - echo "CONFIG_NOLDL=yes" >> config.mak -fi -if test "$mingw32" = "yes" ; then - echo "CONFIG_WIN32=yes" >> config.mak -fi -if test "$cygwin" = "yes" ; then - echo "#ifndef _WIN32" >> $TMPH - echo "# define _WIN32" >> $TMPH - echo "#endif" >> $TMPH - echo "AR=ar" >> config.mak -fi -if test "$bigendian" = "yes" ; then - echo "WORDS_BIGENDIAN=yes" >> config.mak - echo "#define WORDS_BIGENDIAN 1" >> $TMPH -fi -if test "$gprof" = "yes" ; then - echo "TARGET_GPROF=yes" >> config.mak - echo "#define HAVE_GPROF 1" >> $TMPH -fi -if test "$build_cross" = "yes" ; then - echo "CONFIG_CROSS=yes" >> config.mak -fi -if test "$disable_static" = "yes" ; then - echo "DISABLE_STATIC=yes" >> config.mak -fi -if test "$disable_rpath" = "yes" ; then - echo "DISABLE_RPATH=yes" >> config.mak -fi -if test "$strip_binaries" = "yes" ; then - echo "STRIP_BINARIES=yes" >> config.mak -fi -if test "$use_libgcc" = "yes" ; then - echo "#define CONFIG_USE_LIBGCC" >> $TMPH - echo "CONFIG_USE_LIBGCC=yes" >> config.mak -fi -if test "$have_selinux" = "yes" ; then - echo "#define HAVE_SELINUX" >> $TMPH - echo "HAVE_SELINUX=yes" >> config.mak -fi version=`head $source_path/VERSION` echo "VERSION = $version" >> config.mak |