]> arthur.barton.de Git - ngircd-alex.git/blobdiff - contrib/platformtest.sh
platformtest.sh: Detect Apple LLVM (clang) compiler
[ngircd-alex.git] / contrib / platformtest.sh
index afe9420699a4c043f26449731d0feb0a0896d67f..765fb3964cfd5c19d2ac7e1ec7fd288334e6e56a 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 #
 # ngIRCd -- The Next Generation IRC Daemon
-# Copyright (c)2001-2011 Alexander Barton (alex@barton.de) and Contributors
+# Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -54,8 +54,8 @@ if [ $? -ne 0 ]; then
        cd ..
 fi
 
-echo "$NAME: Checking for \"./autogen.sh\" script ..."
-if [ -r ./autogen.sh ]; then
+echo "$NAME: Checking for \"./configure\" script ..."
+if [ ! -e ./configure ]; then
        echo "$NAME: Running \"./autogen.sh\" ..."
        [ -n "$VERBOSE" ] && ./autogen.sh || ./autogen.sh >/dev/null
 fi
@@ -76,7 +76,7 @@ if [ -r ./configure ]; then
                                R_RUN=$R_CHECK
                        else
                                ./src/ngircd/ngircd --help 2>/dev/null \
-                                | grep "^ngircd" >/dev/null
+                                | grep "^ngIRCd" >/dev/null
                                [ $? -eq 0 ] && R_RUN=1
                        fi
                fi
@@ -85,9 +85,9 @@ fi
 
 # Get target platform information
 if [ -r "src/config.h" ]; then
-       CPU=`grep "TARGET_CPU" "src/config.h" | cut -d'"' -f2`
-       OS=`grep "TARGET_OS" "src/config.h" | cut -d'"' -f2`
-       VENDOR=`grep "TARGET_VENDOR" "src/config.h" | cut -d'"' -f2`
+       CPU=`grep "HOST_CPU" "src/config.h" | cut -d'"' -f2`
+       OS=`grep "HOST_OS" "src/config.h" | cut -d'"' -f2`
+       VENDOR=`grep "HOST_VENDOR" "src/config.h" | cut -d'"' -f2`
        PLATFORM="$CPU/$VENDOR/$OS"
 fi
 if [ -z "$PLATFORM" ]; then
@@ -108,12 +108,16 @@ if [ -r "Makefile" ]; then
                        COMPILER="gcc $COMPILER"
                fi
        else
-               case "$CC" in
-                 gcc*)
+               $CC --version 2>&1 | grep -i "LLVM" >/dev/null
+               if [ $? -eq 0 ]; then
+                       COMPILER=$($CC --version 2>/dev/null | head -1 \
+                         | cut -d'(' -f1 | sed -e 's/version //g' \
+                         | sed -e 's/Apple /A-/g')
+               fi
+               if [ "$COMPILER" = "unknown" ]; then
                        v="`$CC --version 2>/dev/null | head -1`"
-                       [ -n "$v" ] && COMPILER="gcc $v"
-                       ;;
-               esac
+                       [ -n "$v" ] && COMPILER="$v"
+               fi
        fi
 fi