summaryrefslogtreecommitdiff
path: root/makefiles/gmake/guess_env
diff options
context:
space:
mode:
Diffstat (limited to 'makefiles/gmake/guess_env')
-rwxr-xr-xmakefiles/gmake/guess_env180
1 files changed, 149 insertions, 31 deletions
diff --git a/makefiles/gmake/guess_env b/makefiles/gmake/guess_env
index f11ef5a..2e4f3de 100755
--- a/makefiles/gmake/guess_env
+++ b/makefiles/gmake/guess_env
@@ -1,57 +1,74 @@
#!/bin/sh
+# operating system and major, minor version, more should not be necessary
+
UNAME_SYSTEM=`(uname -s) 2>/dev/null`
UNAME_RELEASE=`(uname -r) 2>/dev/null`
UNAME_VERSION=`(uname -v) 2>/dev/null`
UNAME_MACHINE=`(uname -m) 2>/dev/null`
-# operating system and major, minor version, more should not be necessary
case "$UNAME_SYSTEM.$UNAME_RELEASE" in
Linux*) PLATFORM=LINUX
OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1`
OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2`
- LIBS_DL='-ldl'
+
+ if test -f /etc/arch-release; then
+ LINUX_DIST='arch'
+ LINUX_REV='current'
+ elif test -f /etc/debian_version; then
+ LINUX_DIST='debian'
+ LINUX_REV=`cat /etc/debian_version | cut -d . -f 1`
+ elif test -f /etc/slackware-version; then
+ LINUX_DIST='slackware'
+ LINUX_REV=`cat /etc/slackware-version | cut -d ' ' -f 2 | cut -d . -f 1`
+ elif test -f /etc/redhat-release; then
+ LINUX_DIST='redhat'
+ LINUX_REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*// | cut -f 1 -d .`
+ else
+ LINUX_DIST='unknown'
+ LINUX_REV='unknown'
+ fi
;;
FreeBSD*) PLATFORM=FREEBSD
OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1`
OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2 | cut -d - -f 1`
- LIBS_DL=
- LIBS_SSP=
;;
OpenBSD*) PLATFORM=OPENBSD
OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1`
OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2 | cut -d - -f 1`
- LIBS_DL=
- LIBS_SSP=
+ ;;
+
+ NetBSD*) PLATFORM=NETBSD
+ OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1`
+ OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2 | cut -d - -f 1`
;;
SunOS*) PLATFORM=SUNOS
OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1`
OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2`
- LIBS_DL='-ldl'
- LIBS_SSP=
;;
CYGWIN_NT*) PLATFORM=CYGWIN
_tmp=`echo $UNAME_SYSTEM | cut -d - -f 2`
OS_MAJOR_VERSION=`echo $_tmp | cut -d . -f 1`
OS_MINOR_VERSION=`echo $_tmp | cut -d . -f 2`
- LIBS_SSP=
;;
*)
PLATFORM=UNKNOWN
- echo "Unknown platform '$UNAME_SYSTEM#$UNAME_RELEASE'"
+ echo "Unknown platform '$UNAME_SYSTEM $UNAME_RELEASE'"
exit 1
esac
# the architecture
+
case "$UNAME_MACHINE" in
i*86*) ARCH=x86
;;
-
+ x86_64) ARCH=x86_64
+ ;;
sun4u) ARCH=sun4u
;;
@@ -61,10 +78,82 @@ case "$UNAME_MACHINE" in
esac
+# get last line, old 'tail' syntax and POSIX syntax, both exist out there
+if test "x${PLATFORM}" = "xSUNOS"; then
+ TAIL1='tail -1'
+else
+ TAIL1='tail -n 1'
+fi
+
# the compiler and version
-GCC_VERSION=`gcc -dumpversion`
-GCC_MAJOR_VERSION=`echo $GCC_VERSION | cut -d . -f 1`
-GCC_MINOR_VERSION=`echo $GCC_VERSION | cut -d . -f 2`
+
+# what compiler do we have (we can't relly on it's name as it may be a cc link to the binary!)
+CC=$2
+(( $CC -v 2>&1 | $TAIL1 ) | grep -i GCC ) 2>/dev/null 1>/dev/null
+if test $? = 0; then
+ COMPILER='gcc'
+else
+ ( $CC -v | grep tcc ) 2>/dev/null 1>/dev/null
+ if test $? = 0; then
+ COMPILER='tcc'
+ else
+ ( $CC -V 2>&1 | grep l_cproc_p ) >/dev/null
+ if test $? = 0; then
+ COMPILER='icc'
+ else
+ ( $CC -xhelp=readme | head -n 1 | grep 'Sun Studio' ) >/dev/null
+ if test $? = 0; then
+ COMPILER='spro'
+ else
+ ( $CC -v | head -n 1 | grep 'pcc' ) >/dev/null
+ if test $? = 0; then
+ COMPILER='pcc'
+ else
+ COMPILER='unknown'
+ fi
+ fi
+ fi
+ fi
+fi
+
+# version of gcc (GNU C compiler)
+
+if test $COMPILER = "gcc"; then
+ GCC_VERSION=`gcc -dumpversion`
+ GCC_MAJOR_VERSION=`echo $GCC_VERSION | cut -d . -f 1`
+ GCC_MINOR_VERSION=`echo $GCC_VERSION | cut -d . -f 2`
+fi
+
+# version of tcc (Tiny C compiler)
+
+if test $COMPILER = "tcc"; then
+ TCC_VERSION=`tcc -v | cut -d ' ' -f 3`
+ TCC_MAJOR_VERSION=`echo $ICC_VERSION | cut -d . -f 1`
+ TCC_MINOR_VERSION=`echo $ICC_VERSION | cut -d . -f 2`
+fi
+
+# version of icc (Intel C compiler)
+
+if test $COMPILER = "icc"; then
+ ICC_VERSION=`icc -dumpversion`
+ ICC_MAJOR_VERSION=`echo $ICC_VERSION | cut -d . -f 1`
+ ICC_MINOR_VERSION=`echo $ICC_VERSION | cut -d . -f 2`
+fi
+
+# version of spro (Sun Pro compiler, Sun Studio)
+
+if test $COMPILER = "spro"; then
+ SPRO_VERSION=`$CC -xhelp=readme | head -n 1 | cut -d ' ' -f 3`
+ SPRO_MAJOR_VERSION=`echo $SPRO_VERSION | cut -d : -f 1`
+fi
+
+# version of pcc (Portable C Compiler)
+
+if test $COMPILER = "pcc"; then
+ PCC_VERSION=`$CC -v | head -n 1 | cut -d ' ' -f 2`
+ PCC_MAJOR_VERSION=`echo $PCC_VERSION | cut -d . -f 1`
+ PCC_MINOR_VERSION=`echo $PCC_VERSION | cut -d . -f 2`
+fi
case "$1" in
--platform) echo $PLATFORM
@@ -78,29 +167,58 @@ case "$1" in
--arch) echo $ARCH
;;
-
- --libs-dl) echo $LIBS_DL
+
+ --compiler) echo $COMPILER
;;
- --libs-ssl) echo $LIBS_SSL
- ;;
-
--gcc-major-version) echo $GCC_MAJOR_VERSION
;;
--gcc-minor-version) echo $GCC_MINOR_VERSION
;;
-
- *)
- cat <<EOF
-ARCH = $ARCH
-PLATFORM = $PLATFORM
-OS_MAJOR_VERSION = $OS_MAJOR_VERSION
-OS_MINOR_VERSION = $OS_MINOR_VERSION
-LIBS_DL = $LIBS_DL
-LIBS_SSL = $LIBS_SSL
-GCC_MAJOR_VERSION = $GCC_MAJOR_VERSION
-GCC_MINOR_VERSION = $GCC_MINOR_VERSION
-EOF
+
+ --tcc-major-version) echo $TCC_MAJOR_VERSION
+ ;;
+
+ --tcc-minor-version) echo $TCC_MINOR_VERSION
+ ;;
+
+ --icc-major-version) echo $ICC_MAJOR_VERSION
+ ;;
+
+ --icc-minor-version) echo $ICC_MINOR_VERSION
+ ;;
+
+ --spro-major-version) echo $SPRO_MAJOR_VERSION
+ ;;
+
+ --pcc-major-version) echo $PCC_MAJOR_VERSION
+ ;;
+
+ --pcc-minor-version) echo $PCC_MINOR_VERSION
;;
esac
+
+MAKEFILE_DIR="$3/$4"
+
+# regenerate the cache file, otherwise building is far too slow!
+if test ! -f "${MAKEFILE_DIR}/makefiles/gmake/platform.mk.vars"; then
+ cat >"${MAKEFILE_DIR}/makefiles/gmake/platform.mk.vars" <<EOF
+ARCH=$ARCH
+PLATFORM=$PLATFORM
+OS_MAJOR_VERSION=$OS_MAJOR_VERSION
+OS_MINOR_VERSION=$OS_MINOR_VERSION
+COMPILER=$COMPILER
+GCC_MAJOR_VERSION=$GCC_MAJOR_VERSION
+GCC_MINOR_VERSION=$GCC_MINOR_VERSION
+TCC_MAJOR_VERSION=$TCC_MAJOR_VERSION
+TCC_MINOR_VERSION=$TCC_MINOR_VERSION
+ICC_MAJOR_VERSION=$ICC_MAJOR_VERSION
+ICC_MINOR_VERSION=$ICC_MINOR_VERSION
+SPRO_MAJOR_VERSION=$SPRO_MAJOR_VERSION
+PCC_MAJOR_VERSION=$PCC_MAJOR_VERSION
+PCC_MINOR_VERSION=$PCC_MINOR_VERSION
+LINUX_DIST=$LINUX_DIST
+LINUX_REV=$LINUX_REV
+EOF
+fi