aboutsummaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure188
1 files changed, 72 insertions, 116 deletions
diff --git a/configure b/configure
index 3f8ace7..7708b53 100755
--- a/configure
+++ b/configure
@@ -17,9 +17,6 @@ TMPN="./conftest-$$"
TMPH=$TMPN.h
# default parameters
-build_cross="no"
-use_libgcc="no"
-disable_static=""
prefix=""
execprefix=""
bindir=""
@@ -33,11 +30,8 @@ cross_prefix=""
cc="gcc"
ar="ar"
strip="strip"
-noldl="no"
-gprof="no"
bigendian="no"
mingw32="no"
-osx="no"
LIBSUF=".a"
EXESUF=""
DLLSUF=".so"
@@ -48,19 +42,25 @@ tcc_elfinterp=""
triplet=
tcc_lddir=
confvars=
+suggest="yes"
cpu=
+cpuver=
+gcc_major=0
+gcc_minor=0
# OS specific
targetos=`uname`
case $targetos in
Darwin)
- osx=yes
+ confvars="$confvars OSX"
+ DLLSUF=".dylib"
;;
MINGW*|MSYS*|CYGWIN*)
+ confvars="$confvars WIN32"
mingw32=yes
;;
DragonFly|OpenBSD|FreeBSD|NetBSD)
- noldl=yes
+ confvars="$confvars ldl=no"
;;
*)
;;
@@ -126,23 +126,23 @@ for opt do
;;
--cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
;;
- --enable-gprof) gprof="yes"
+ --enable-mingw32) confvars="$confvars WIN32"; mingw32="yes"
;;
- --enable-mingw32) mingw32="yes"
+ --enable-cross) confvars="$confvars cross"
;;
- --enable-cross) build_cross="yes"
+ --disable-static) confvars="$confvars static=no"
;;
- --disable-static) disable_static="yes"
+ --enable-static) confvars="$confvars static"
;;
- --enable-static) disable_static="no"
+ --disable-rpath) confvars="$confvars rpath=no"
;;
- --disable-rpath) disable_rpath="yes"
+ --strip-binaries) confvars="$confvars strip"
;;
- --strip-binaries) strip_binaries="yes"
+ --with-libgcc) confvars="$confvars libgcc"
;;
- --with-libgcc) use_libgcc="yes"
+ --with-selinux) confvars="$confvars selinux"
;;
- --with-selinux) have_selinux="yes"
+ --config-*) confvars="$confvars ${opt#--config-}"; suggest="no"
;;
--help|-h) show_help="yes"
;;
@@ -181,16 +181,16 @@ case "$cpu" in
cpuver=7
;;
esac
- cpu="armv4l"
+ cpu="arm"
;;
aarch64)
- cpu="aarch64"
+ cpu="arm64"
;;
alpha)
cpu="alpha"
;;
"Power Macintosh"|ppc|ppc64)
- cpu="powerpc"
+ cpu="ppc"
;;
mips)
cpu="mips"
@@ -199,7 +199,8 @@ case "$cpu" in
cpu="s390"
;;
*)
- cpu="unknown"
+ echo "Unsupported CPU"
+ exit 1
;;
esac
@@ -262,9 +263,6 @@ else
if test x"$tccdir" = x""; then
tccdir="${libdir}/tcc"
fi
- if test "$osx" = "yes" ; then
- DLLSUF=".dylib"
- fi
fi # mingw32
if test x"$includedir" = x""; then
@@ -312,6 +310,7 @@ Advanced options (experts only):
--crtprefix=... specify locations of crt?.o, colon separated
--elfinterp=... specify elf interpreter
--triplet=... specify system library/include directory triplet
+ --config-uClibc,-musl... enable specific configuration for some systems
EOF
#echo "NOTE: The object files are build at the place where configure is launched"
exit 1
@@ -341,14 +340,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 = "arm64" ; 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
@@ -359,46 +358,48 @@ if test -z "$cross_prefix" ; then
fi
fi
- # Enable uClibc or musl native support only if GNU ld is not already present
- if test -f "/lib/ld-linux.so.2"; then
- :
- elif test -f "/lib64/ld-linux-x86-64.so.2"; then
- :
- elif test -f "/lib64/ld-linux-aarch64.so.1"; then
- :
- elif test -f "/lib/ld-uClibc.so.0" ; then
- confvars="$confvars uClibc"
- elif test -f "/lib/ld-musl-$cpu.so.1"; then
- confvars="$confvars musl"
+ 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
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 undef strict-prototypes write-strings"
-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="pointer-sign sign-compare unused-result"
-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"
@@ -412,12 +413,8 @@ echo "Source path $source_path"
echo "C compiler $cc"
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
@@ -449,12 +446,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"
@@ -465,74 +469,26 @@ 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
- 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 "$osx" = "yes" ; then
- echo "CONFIG_OSX=yes" >> 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 -n "$disable_static" ; then
- echo "DISABLE_STATIC=$disable_static" >> 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