[Libreoffice-commits] .: configure.in

Norbert Thiebaud nthiebaud at kemper.freedesktop.org
Sun Aug 7 16:00:17 PDT 2011


 configure.in |  284 +++++++++++++++++++++++++++++++++++------------------------
 1 file changed, 172 insertions(+), 112 deletions(-)

New commits:
commit 57cf026739a3d707378ca38f59518b018fccca8f
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date:   Sun Aug 7 17:59:42 2011 -0500

    auto-use ccache and use it unless CC/CXX is already set or --disable-ccache

diff --git a/configure.in b/configure.in
index 720dd22..bab743e 100755
--- a/configure.in
+++ b/configure.in
@@ -448,6 +448,14 @@ AC_ARG_ENABLE(zenity,
         [Do not display a build icon in the notification area (on unix) during build.]),
 ,enable_zenity=yes)
 
+AC_ARG_ENABLE(ccache,
+    AS_HELP_STRING([--disable-ccache],
+        [Do not try to use ccache automatically.
+    by default, we will try to detect if ccache is available and if CC/CXX where
+    not already set, we attemtp to use ccache. --disable-ccache prevent this behavior.
+]),
+,enable_ccache=yes)
+
 AC_ARG_ENABLE(cl-x64,
     AS_HELP_STRING([--enable-cl-x64],
         [Build a 64-bit LibreOffice using the Microsoft C/C++ x64 compiler.]),
@@ -1673,6 +1681,49 @@ if test "build_os" = "cygwin" ; then
     fi
 fi
 
+
+
+dnl ===================================================================
+dnl  Checks if ccache is available
+dnl ===================================================================
+if test "$enable_ccache" = "yes" ; then
+    if test -z "$CC" ; then
+        if test -z "$CXX" ; then
+            AC_PATH_PROG([CCACHE],[ccache],[not found])
+            if test "$CCACHE" = "not found" ; then
+                CCACHE=""
+            else
+                CCACHE="ccache"
+                dnl need to check for ccache version: otherwise prevents
+                dnl caching of the results (like "-x objective-c++" for Mac)
+                if test $_os = Darwin -o $_os = iOS; then
+                    # check ccache version
+                    AC_MSG_CHECKING([whether version of ccache is suitable])
+                    CCACHE_VERSION=`"$CCACHE" -V | "$AWK" '/^ccache version/{print $3}'`
+                    CCACHE_NUMVER=`echo $CCACHE_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
+                    if test "$CCACHE_VERSION" = "2.4_OOo" -o "$CCACHE_NUMVER" -ge "030100"; then
+                        AC_MSG_RESULT([yes])
+                        AC_SUBST([USE_CCACHE], [YES])
+                    else
+                        AC_MSG_RESULT([no])
+                        AC_MSG_NOTICE([ccache version $CCACHE_VERSION not accepted. ccache will not be used.])
+                        CCACHE=""
+                    fi
+                fi
+            fi
+        else
+            AC_MSG_NOTICE([Automatic ccache detection ingored: CXX is pre-defined])
+            CCACHE=""
+        fi
+    else
+        AC_MSG_NOTICE([Automatic ccache detection ingored: CC is pre-defined])
+        CCACHE=""
+    fi
+else
+    CCACHE=""
+fi
+
+
 dnl ===================================================================
 dnl  Checks for C compiler,
 dnl  The check for the C++ compiler is later on.
@@ -1704,6 +1755,25 @@ fi
 dnl The following checks for gcc, cc and then cl (if it weren't guarded for win32)
 if test "$_os" != "WINNT" -o "$WITH_MINGW" = "yes"; then
     AC_PROG_CC
+    if test "$CCACHE" != "" ; then
+        AC_MSG_CHECKING([whether $CC is already ccached])
+
+
+        AC_LANG_PUSH([C])
+        save_CFLAGS=$CFLAGS
+        CFLAGS="$CFLAGS --ccache-skip -O2"
+        dnl an empty program will do, we're checking the compiler flags
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
+                          [use_ccache=yes], [use_ccache=no])
+        if test $use_ccache = yes ; then
+            AC_MSG_RESULT([yes])
+        else
+            CC="$CCACHE $CC"
+            AC_MSG_RESULT([no])
+        fi
+        CFLAGS=$save_CFLAGS
+        AC_LANG_POP([C])
+    fi
 fi
 
 COMPATH=`dirname "$CC"`
@@ -1714,6 +1784,9 @@ if test "$COMPATH" = "." ; then
 fi
 COMPATH=`echo $COMPATH | $SED "s@/[[Bb]][[Ii]][[Nn]]\\\$@@"`;
 
+
+
+
 dnl ===================================================================
 dnl  Test MacOSX sdk and version requirement
 dnl ===================================================================
@@ -1849,7 +1922,11 @@ if test \( "$_os" != "WINNT" -o "$WITH_MINGW" = "yes" \) -a "$GCC" = "yes"; then
 
     if test "$_os" = "Darwin" -a "$with_macosx_sdk" = "10.4" -a "$GCCVER" -ge "040100" ; then
         if test -z "$save_CC" -a -x "$GCC_HOME/bin/gcc-4.0" ; then
-            export CC=$GCC_HOME/bin/gcc-4.0
+            if test -z "$CCACHE" ; then
+                export CC="$GCC_HOME/bin/gcc-4.0"
+            else
+                export CC="$CCACHE $GCC_HOME/bin/gcc-4.0"
+            fi
             dnl  export CC to have it available in set_soenv -> config.guess
             GCCVER2=`"$CC" -dumpversion | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
             if test "$GCCVER2" -ge "040000" -a "$GCCVER2" -lt "040100" ; then
@@ -2784,11 +2861,95 @@ if test "$_os" != "WINNT" -o "$WITH_MINGW" = "yes"; then
     AC_HEADER_STDC
 fi
 
+dnl ===================================================================
+dnl Testing for C++ compiler and version...
+dnl ===================================================================
+
+dnl Autoconf 2.53 can do this test for cl.exe, 2.13 can't!
 if test "$_os" != "WINNT" -o "$WITH_MINGW" = "yes"; then
-    dnl ===================================================================
-    dnl Find pre-processors.
-    dnl ===================================================================
+    AC_PROG_CXX
+    if test "$CCACHE" != "" ; then
+        AC_MSG_CHECKING([whether $CXX is already ccached])
+        AC_LANG_PUSH([C++])
+        save_CXXFLAGS=$CXXFLAGS
+        CXXFLAGS="$CXXFLAGS --ccache-skip -O2"
+        dnl an empty program will do, we're checking the compiler flags
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
+                          [use_ccache=yes], [use_ccache=no])
+        if test $use_ccache = yes ; then
+            AC_MSG_RESULT([yes])
+        else
+            CXX="$CCACHE $CXX"
+            AC_MSG_RESULT([no])
+        fi
+        CXXFLAGS=$save_CXXFLAGS
+        AC_LANG_POP([C++])
+    fi
+else
+    if test -n "$CC" -a -z "$CXX"; then
+        CXX="$CC"
+    fi
+fi
+
+dnl check if we are using a buggy version of g++ (currently 3.4.0, 3.4.1 and trunk)
+if test "$GXX" = "yes"; then
+    AC_MSG_CHECKING([the GNU C++ compiler version])
+
+    _gpp_version=`$CXX -dumpversion`
+    _gpp_majmin=`echo $_gpp_version | $AWK -F. '{ print \$1*100+\$2 }'`
+
+    if test "$_os" = "Darwin" -a "$with_macosx_sdk" = "10.4" -a "$_gpp_majmin" -ge "401" ; then
+        if test -z "$save_CXX" -a -x "$GCC_HOME/bin/g++-4.0" ; then
+            if test -z "$CCACHE" ; then
+                export CXX="$GCC_HOME/bin/g++-4.0"
+            else
+                export CXX="$CCACHE $GCC_HOME/bin/g++-4.0"
+            fi
+            _gpp_majmin_2=`"$CXX" -dumpversion | $AWK -F. '{ print \$1*100+\$2 }'`
+            if test "$_gpp_majmin_2" -ge "400" -a "$_gpp_majmin_2" -lt "401" ; then
+                _gpp_majmin=$_gpp_majmin_2
+            fi
+        fi
+        if test "$_gpp_majmin" -ge "401" ; then
+            AC_MSG_ERROR([You need to use the g++-4.0 compiler (g++ $_gpp_version won't work with the MacOSX10.4u.sdk) - set CXX accordingly])
+        else
+            AC_MSG_RESULT([implicitly using CXX=$CXX])
+        fi
+    else
+        AC_MSG_RESULT([checked (g++ $_gpp_version)])
+    fi
+
+    if test "$_gpp_majmin" = "304"; then
+        AC_MSG_CHECKING([whether $CXX has the enum bug])
+        AC_TRY_RUN([
+            extern "C" void abort (void);
+            extern "C" void exit (int status);
+
+            enum E { E0, E1, E2, E3, E4, E5 };
+
+            void test (enum E e)
+            {
+                if (e == E2 || e == E3 || e == E1)
+                    exit (1);
+            }
+
+            int main (void)
+            {
+                test (E4);
+                test (E5);
+                test (E0);
+                return 0;
+            }
+            ],
+            [AC_MSG_ERROR([your version of the GNU C++ compile has a bug which prevents LibreOffice from being compiled correctly - please check http://gcc.gnu.org/ml/gcc-patches/2004-07/msg00968.html for details.])], [AC_MSG_RESULT([no])])
+    fi
+fi
+
+dnl ===================================================================
+dnl Find pre-processors.(should do that _after_ messing with CC/CXX)
+dnl ===================================================================
 
+if test "$_os" != "WINNT" -o "$WITH_MINGW" = "yes"; then
     AC_PROG_CXXCPP
 
     dnl Check whether there's a C pre-processor.
@@ -2802,8 +2963,14 @@ if test "$_os" != "WINNT" -o "$WITH_MINGW" = "yes"; then
     else
         AC_PROG_CPP
     fi
+fi
+
+
+dnl ===================================================================
+dnl Find integral type sizes and alignments
+dnl ===================================================================
 
-    dnl Find integral type sizes and alignments
+if test "$_os" != "WINNT" -o "$WITH_MINGW" = "yes"; then
 
     AC_CHECK_SIZEOF(long)
     AC_CHECK_SIZEOF(short)
@@ -2914,70 +3081,6 @@ fi
 AC_SUBST([VALGRIND_CFLAGS])
 
 dnl ===================================================================
-dnl Testing for C++ compiler and version...
-dnl ===================================================================
-if test "$_os" = "WINNT" -a "$WITH_MINGW" != "yes"; then
-    if test -n "$CC" -a -z "$CXX"; then
-        CXX="$CC"
-    fi
-fi
-
-dnl Autoconf 2.53 can do this test for cl.exe, 2.13 can't!
-if test "$_os" != "WINNT" -o "$WITH_MINGW" = "yes"; then
-    AC_PROG_CXX
-fi
-
-dnl check if we are using a buggy version of g++ (currently 3.4.0, 3.4.1 and trunk)
-if test "$GXX" = "yes"; then
-    AC_MSG_CHECKING([the GNU C++ compiler version])
-
-    _gpp_version=`$CXX -dumpversion`
-    _gpp_majmin=`echo $_gpp_version | $AWK -F. '{ print \$1*100+\$2 }'`
-
-    if test "$_os" = "Darwin" -a "$with_macosx_sdk" = "10.4" -a "$_gpp_majmin" -ge "401" ; then
-        if test -z "$save_CXX" -a -x "$GCC_HOME/bin/g++-4.0" ; then
-            CXX=$GCC_HOME/bin/g++-4.0
-            _gpp_majmin_2=`"$CXX" -dumpversion | $AWK -F. '{ print \$1*100+\$2 }'`
-            if test "$_gpp_majmin_2" -ge "400" -a "$_gpp_majmin_2" -lt "401" ; then
-                _gpp_majmin=$_gpp_majmin_2
-            fi
-        fi
-        if test "$_gpp_majmin" -ge "401" ; then
-            AC_MSG_ERROR([You need to use the g++-4.0 compiler (g++ $_gpp_version won't work with the MacOSX10.4u.sdk) - set CXX accordingly])
-        else
-            AC_MSG_RESULT([implicitly using CXX=$CXX])
-        fi
-    else
-        AC_MSG_RESULT([checked (g++ $_gpp_version)])
-    fi
-
-    if test "$_gpp_majmin" = "304"; then
-        AC_MSG_CHECKING([whether $CXX has the enum bug])
-        AC_TRY_RUN([
-            extern "C" void abort (void);
-            extern "C" void exit (int status);
-
-            enum E { E0, E1, E2, E3, E4, E5 };
-
-            void test (enum E e)
-            {
-                if (e == E2 || e == E3 || e == E1)
-                    exit (1);
-            }
-
-            int main (void)
-            {
-                test (E4);
-                test (E5);
-                test (E0);
-                return 0;
-            }
-            ],
-            [AC_MSG_ERROR([your version of the GNU C++ compile has a bug which prevents LibreOffice from being compiled correctly - please check http://gcc.gnu.org/ml/gcc-patches/2004-07/msg00968.html for details.])], [AC_MSG_RESULT([no])])
-    fi
-fi
-
-dnl ===================================================================
 dnl Set the gcc/gxx include directories
 dnl ===================================================================
 # Removed the special FreeBSD treatment. The problem was that with_gxx_include_path
@@ -3282,49 +3385,6 @@ AC_SUBST(HAVE_CXX0X)
 AC_SUBST(HAVE_GCC_NO_LONG_DOUBLE)
 AC_SUBST(HAVE_GCC_AVX)
 
-# ===================================================================
-# use ccache?
-# ===================================================================
-dnl need to check for ccache version: otherwise prevents
-dnl caching of the results (like "-x objective-c++" for Mac)
-AC_MSG_CHECKING([whether we are able to use --ccache-skip])
-if test $_os != Darwin -a $_os != iOS; then
-    AC_MSG_RESULT([only needed on Mac and iOS currently, skipping])
-else
-    # checking for ccache presence/version
-    AC_MSG_RESULT([probing...])
-    AC_PATH_PROG([CCACHE],[ccache],[not_found])
-    if test "$CCACHE" = "not_found" ; then
-        AC_MSG_NOTICE([not enabling --ccache-skip (ccache not found)])
-    else
-        # check ccache version
-        AC_MSG_CHECKING([whether version of ccache is suitable])
-        CCACHE_VERSION=`"$CCACHE" -V | "$AWK" '/^ccache version/{print $3}'`
-        CCACHE_NUMVER=`echo $CCACHE_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
-        if test "$CCACHE_VERSION" = "2.4_OOo" -o "$CCACHE_NUMVER" -ge "030100"; then
-            AC_MSG_RESULT([yes])
-            AC_MSG_CHECKING([whether ccache is actually used for the build])
-            AC_LANG_PUSH([C++])
-            save_CXXFLAGS=$CXXFLAGS
-            CXXFLAGS="$CXXFLAGS --ccache-skip -O2"
-            dnl an empty program will do, we're checking the compiler flags
-            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
-                [use_ccache=yes], [use_ccache=no])
-            if test $use_ccache = yes ; then
-                AC_MSG_RESULT([yes, will enable --ccache-skip])
-                AC_SUBST([USE_CCACHE], [YES])
-            else
-                AC_MSG_RESULT([no, will not enable --ccache-skip])
-            fi
-            CXXFLAGS=$save_CXXFLAGS
-            AC_LANG_POP([C++])
-        else
-            AC_MSG_RESULT([no])
-            AC_MSG_NOTICE([ccache version $CCACHE_VERSION not accepted. ccache will not be used.])
-        fi
-    fi
-fi
-
 dnl ===================================================================
 dnl system stl sanity tests
 dnl ===================================================================


More information about the Libreoffice-commits mailing list