Factorize some code
[scilab.git] / scilab / m4 / macosx.m4
index 2c50dbd..8c10c79 100644 (file)
@@ -2,26 +2,24 @@
 # Return MacOSX version using system_profile tool.
 #
 AC_DEFUN([AC_GET_MACOSX_VERSION],[
-        AC_MSG_CHECKING([MacOSX Version])
-        if eval system_profiler SPSoftwareDataType | grep "System Version" | grep "10\.8" > /dev/null; then
-        AC_MSG_RESULT([MacOSX 10.8 - Moutain Lion.])
-        macosx_version="10.8"
-        else
-        if eval system_profiler SPSoftwareDataType | grep "System Version" | grep "10\.7" > /dev/null; then
-        AC_MSG_RESULT([MacOSX 10.7 - Lion.])
-        macosx_version="10.7"
-        else
-        if eval system_profiler SPSoftwareDataType | grep "System Version" | grep "10\.6" > /dev/null; then
-        AC_MSG_RESULT([MacOSX 10.6 - Snow Leopard.])
-        macosx_version="10.6"
-        else
-        if eval system_profiler SPSoftwareDataType | grep "System Version" | grep "10\.5" > /dev/null; then
-        AC_MSG_RESULT([MacOSX 10.5 - Leopard.])
-        macosx_version="10.5"
-        else
-        AC_MSG_ERROR([MacOSX 10.5,10.6,10.7 or 10.8 is needed.])
-        fi
-        fi
-       fi
-       fi
+    AC_MSG_CHECKING([Mac OS X Version])
+    [macosx_version=`system_profiler SPSoftwareDataType 2>&1 | grep 'System Version' | sed -e 's/.*\([0-9][0-9]\.[0-9]*\).*/\1/'`]
+    echo $macosx_version
+    case "$macosx_version" in
+         "10.8")
+              AC_MSG_RESULT([Mac OS X 10.8 - Mountain Lion.])
+         ;;
+         "10.7")
+              AC_MSG_RESULT([Mac OS X 10.7 - Lion.])
+         ;;
+         "10.6")
+              AC_MSG_RESULT([Mac OS X 10.6 - Snow Leopard.])
+         ;;
+         "10.5")
+              AC_MSG_RESULT([Mac OS X 10.5 - Leopard.])
+         ;;
+         *)
+              AC_MSG_ERROR([MacOSX 10.5, 10.6, 10.7 or 10.8 are needed. Found $macosx_version])
+         ;;
+        esac
 ])