Skip to content

Instantly share code, notes, and snippets.

@suma
Created January 16, 2013 13:22
Show Gist options
  • Select an option

  • Save suma/4547103 to your computer and use it in GitHub Desktop.

Select an option

Save suma/4547103 to your computer and use it in GitHub Desktop.
mpio m4 patch for clang
diff --git a/configure.in b/configure.in
index 7993816..434b575 100644
--- a/configure.in
+++ b/configure.in
@@ -1,19 +1,23 @@
# Copyright (C) 2013 Preferred Infrastructure and Nippon Telegraph and Telephone Corporation.
AC_INIT(mpsrc/wavy_kernel.h)
+m4_include(m4/ax_check_link_flag.m4)
AC_CONFIG_AUX_DIR(ac)
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE(jubatus_mpio, 0.4.0)
AC_CONFIG_HEADER(config.h)
-AC_SUBST(CFLAGS)
-CFLAGS="-O4 -Wall $CFLAGS"
-
-AC_SUBST(CXXFLAGS)
-CXXFLAGS="-O4 -Wall $CXXFLAGS"
-
-#AC_CHECK_PROG(RUBY, ruby, ruby)
+# Default enabled -O4
+AC_ARG_ENABLE(optimized, AS_HELP_STRING([--disable-optimized], [Compile with optimizations -O4 (default is YES)]))
+# Check -O4 opition for clang
+AS_IF([test "x$enable_optimized" != "xno"], [
+ save_c_flags="-O3 $CFLAGS" # We use O3 or default -O2?
+ save_cxx_flags="-O3 $CXXFLAGS"
+ CFLAGS="-Wall"
+ CXXFLAGS="-Wall"
+ AX_CHECK_LINK_FLAG(-O4, [AM_CXXFLAGS="-O4 -Wall $CXXFLAGS" AM_CFLAGS="-O4 -Wall $CFLAGS"], [CFLAGS="$save_c_flags" CXXFLAGS="$save_cxx_flags"])
+])
AC_PROG_CC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment