]> granicus.if.org Git - icu/commitdiff
ICU-8453 On certain platforms, use static library optimization option when building...
authorMichael Ow <mow@svn.icu-project.org>
Thu, 21 Jul 2011 23:38:15 +0000 (23:38 +0000)
committerMichael Ow <mow@svn.icu-project.org>
Thu, 21 Jul 2011 23:38:15 +0000 (23:38 +0000)
X-SVN-Rev: 30406

icu4c/source/configure
icu4c/source/configure.in

index 796929664431ac48577d9424423f3b8d9baa2ce4..9fedf989fd389116b38e3c945b97d7236841cbbe 100755 (executable)
@@ -5296,6 +5296,56 @@ fi
 $as_echo "$enabled" >&6; }
 
 
+# When building release static library, there might be some optimization flags we can use
+if test "$ENABLE_STATIC" = "YES"; then
+    if test "$ENABLE_SHARED" != "YES"; then
+        if test "$ENABLE_RELEASE" = 1; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can use static library optimization option" >&5
+$as_echo_n "checking whether we can use static library optimization option... " >&6; }
+            CHECK_STATIC_OPT_FLAG=no
+
+            OLD_CPPFLAGS="${CPPFLAGS}"
+            OLD_LDFLAGS="${LDFLAGS}"
+
+            case "${host}" in
+            *-linux*|i*86-*-*bsd*|i*86-pc-gnu)
+                if test "$ac_cv_c_compiler_gnu" = yes; then
+                    CPPFLAGS="${CPPFLAGS} -ffunction-sections -fdata-sections"
+                    LDFLAGS="${LDFLAGS} -Wl,--gc-sections"
+                fi
+                ;;
+            *)
+                ;;
+            esac
+
+            cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  CHECK_STATIC_OPT_FLAG=yes
+else
+  CHECK_STATIC_OPT_FLAG=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CHECK_STATIC_OPT_FLAG" >&5
+$as_echo "$CHECK_STATIC_OPT_FLAG" >&6; }
+            if test "$CHECK_STATIC_OPT_FLAG" = no; then
+                CPPFLAGS="${OLD_CPPFLAGS}"
+                LDFLAGS="${OLD_LDFLAGS}"
+            fi
+        fi
+    fi
+fi
+
 # Check whether to enable auto cleanup of libraries
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable auto cleanup of libraries" >&5
 $as_echo_n "checking whether to enable auto cleanup of libraries... " >&6; }
index e95182831c6e0e93fa0dea216d017acf83ce0c6e..62728a3bd4c6b5480806d7a2a936475f6f294e15 100644 (file)
@@ -261,6 +261,37 @@ AC_ARG_ENABLE(static,
 AC_MSG_RESULT($enabled)
 AC_SUBST(ENABLE_STATIC)
 
+# When building release static library, there might be some optimization flags we can use
+if test "$ENABLE_STATIC" = "YES"; then
+    if test "$ENABLE_SHARED" != "YES"; then
+        if test "$ENABLE_RELEASE" = 1; then
+            AC_MSG_CHECKING([whether we can use static library optimization option])
+            CHECK_STATIC_OPT_FLAG=no
+            
+            OLD_CPPFLAGS="${CPPFLAGS}"
+            OLD_LDFLAGS="${LDFLAGS}"
+            
+            case "${host}" in
+            *-linux*|i*86-*-*bsd*|i*86-pc-gnu)
+                if test "$ac_cv_c_compiler_gnu" = yes; then
+                    CPPFLAGS="${CPPFLAGS} -ffunction-sections -fdata-sections"
+                    LDFLAGS="${LDFLAGS} -Wl,--gc-sections"
+                fi
+                ;;
+            *)
+                ;;
+            esac
+            
+            AC_LINK_IFELSE(AC_LANG_PROGRAM, CHECK_STATIC_OPT_FLAG=yes, CHECK_STATIC_OPT_FLAG=no, )
+            AC_MSG_RESULT($CHECK_STATIC_OPT_FLAG)
+            if test "$CHECK_STATIC_OPT_FLAG" = no; then
+                CPPFLAGS="${OLD_CPPFLAGS}"
+                LDFLAGS="${OLD_LDFLAGS}"
+            fi
+        fi
+    fi
+fi
+
 # Check whether to enable auto cleanup of libraries
 AC_MSG_CHECKING([whether to enable auto cleanup of libraries])
 enabled=no