aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSusumu Yata <susumu.yata@gmail.com>2018-11-02 16:36:57 +0900
committerSusumu Yata <susumu.yata@gmail.com>2018-11-02 16:36:57 +0900
commit065700b2bedefcb6546e3990934c4c158398e2f2 (patch)
tree0c569bf7ad5ef03208ce1982717344d50f58bf1e
parent52395110681a139590974f34e5937003ecba7e95 (diff)
parent4a23d6da82fc1e0c13cde5a65ea0821fac6c511e (diff)
downloadmarisa-trie-065700b2bedefcb6546e3990934c4c158398e2f2.tar.gz
Merge branch 'autoconf' of https://github.com/jakwings/marisa-trie into
jakwings-autoconf
-rw-r--r--configure.ac104
1 files changed, 80 insertions, 24 deletions
diff --git a/configure.ac b/configure.ac
index bc41b38..fb2b4ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,6 +13,77 @@ AC_PROG_INSTALL
AC_CONFIG_MACRO_DIR([m4])
+# Macros for SSE availability check.
+AC_DEFUN([MARISA_ENABLE_SSE2],
+ [AC_EGREP_CPP([yes], [
+#ifdef __SSE2__
+yes
+#endif
+ ], [enable_sse2="yes"], [enable_sse2="no"])])
+AC_DEFUN([MARISA_ENABLE_SSE3],
+ [AC_EGREP_CPP([yes], [
+#ifdef __SSE3__
+yes
+#endif
+ ], [enable_sse3="yes"], [enable_sse3="no"])])
+AC_DEFUN([MARISA_ENABLE_SSSE3],
+ [AC_EGREP_CPP([yes], [
+#ifdef __SSSE3__
+yes
+#endif
+ ], [enable_ssse3="yes"], [enable_ssse3="no"])])
+AC_DEFUN([MARISA_ENABLE_SSE4_1],
+ [AC_EGREP_CPP([yes], [
+#ifdef __SSE4_1__
+yes
+#endif
+ ], [enable_sse4_1="yes"], [enable_sse4_1="no"])])
+AC_DEFUN([MARISA_ENABLE_SSE4_2],
+ [AC_EGREP_CPP([yes], [
+#ifdef __SSE4_2__
+yes
+#endif
+ ], [enable_sse4_2="yes"], [enable_sse4_2="no"])])
+AC_DEFUN([MARISA_ENABLE_SSE4],
+ [AC_EGREP_CPP([yes], [
+#if defined(__POPCNT__) && defined(__SSE4_2__)
+yes
+#endif
+ ], [enable_sse4="yes"], [enable_sse4="no"])])
+AC_DEFUN([MARISA_ENABLE_SSE4A],
+ [AC_EGREP_CPP([yes], [
+#ifdef __SSE4A__
+yes
+#endif
+ ], [enable_sse4a="yes"], [enable_sse4a="no"])])
+AC_DEFUN([MARISA_ENABLE_POPCNT],
+ [AC_EGREP_CPP([yes], [
+#ifdef __POPCNT__
+yes
+#endif
+ ], [enable_popcnt="yes"], [enable_popcnt="no"])])
+
+# Enable native cpu instructions.
+AC_MSG_CHECKING([whether to enable optimization for native cpu])
+AC_ARG_ENABLE([native-code],
+ [AS_HELP_STRING([--enable-native-code],
+ [generate instructions for native cpu [default=no]])],
+ [],
+ [enable_native_code="no"])
+AS_IF([test "x${enable_native_code}" != "xno"], [
+ CFLAGS="$CPPFLAGS -march=native"
+ CPPFLAGS="$CPPFLAGS -march=native"
+ CXXFLAGS="$CXXFLAGS -march=native"
+ MARISA_ENABLE_SSE2
+ MARISA_ENABLE_SSE3
+ MARISA_ENABLE_SSE4_1
+ MARISA_ENABLE_SSE4_2
+ MARISA_ENABLE_SSE4
+ MARISA_ENABLE_SSE4A
+ MARISA_ENABLE_POPCNT
+])
+AC_MSG_RESULT([${enable_native_code}])
+
# Checks for SSE availability.
AC_MSG_CHECKING([whether to use SSE2])
AC_ARG_ENABLE([sse2],
@@ -20,9 +91,7 @@ AC_ARG_ENABLE([sse2],
[use SSE2 [default=no]])],
[],
[enable_sse2="no"])
-AS_IF([test "x${enable_sse2}" != "xno"], [
- enable_sse2="yes"
-])
+AS_IF([test "x${enable_sse2}" != "xno"], [MARISA_ENABLE_SSE2])
AC_MSG_RESULT([${enable_sse2}])
AC_MSG_CHECKING([whether to use SSE3])
@@ -31,9 +100,7 @@ AC_ARG_ENABLE([sse3],
[use SSE3 [default=no]])],
[],
[enable_sse3="no"])
-AS_IF([test "x${enable_sse3}" != "xno"], [
- enable_sse3="yes"
-])
+AS_IF([test "x${enable_sse3}" != "xno"], [MARISA_ENABLE_SSE3])
AC_MSG_RESULT([${enable_sse3}])
AC_MSG_CHECKING([whether to use SSSE3])
@@ -42,9 +109,7 @@ AC_ARG_ENABLE([ssse3],
[use SSSE3 [default=no]])],
[],
[enable_ssse3="no"])
-AS_IF([test "x${enable_ssse3}" != "xno"], [
- enable_ssse3="yes"
-])
+AS_IF([test "x${enable_ssse3}" != "xno"], [MARISA_ENABLE_SSSE3])
AC_MSG_RESULT([${enable_ssse3}])
AC_MSG_CHECKING([whether to use SSE4.1])
@@ -53,9 +118,7 @@ AC_ARG_ENABLE([sse4.1],
[use SSE4.1 [default=no]])],
[],
[enable_sse4_1="no"])
-AS_IF([test "x${enable_sse4_1}" != "xno"], [
- enable_sse4_1="yes"
-])
+AS_IF([test "x${enable_sse4_1}" != "xno"], [MARISA_ENABLE_SSE4_1])
AC_MSG_RESULT([${enable_sse4_1}])
AC_MSG_CHECKING([whether to use SSE4.2])
@@ -64,9 +127,7 @@ AC_ARG_ENABLE([sse4.2],
[use SSE4.2 [default=no]])],
[],
[enable_sse4_2="no"])
-AS_IF([test "x${enable_sse4_2}" != "xno"], [
- enable_sse4_2="yes"
-])
+AS_IF([test "x${enable_sse4_2}" != "xno"], [MARISA_ENABLE_SSE4_2])
AC_MSG_RESULT([${enable_sse4_2}])
AC_MSG_CHECKING([whether to use SSE4])
@@ -75,9 +136,7 @@ AC_ARG_ENABLE([sse4],
[use SSE4 [default=no]])],
[],
[enable_sse4="no"])
-AS_IF([test "x${enable_sse4}" != "xno"], [
- enable_sse4="yes"
-])
+AS_IF([test "x${enable_sse4}" != "xno"], [MARISA_ENABLE_SSE4])
AC_MSG_RESULT([${enable_sse4}])
AC_MSG_CHECKING([whether to use SSE4a])
@@ -86,9 +145,7 @@ AC_ARG_ENABLE([sse4a],
[use SSE4a [default=no]])],
[],
[enable_sse4a="no"])
-AS_IF([test "x${enable_sse4a}" != "xno"], [
- enable_sse4a="yes"
-])
+AS_IF([test "x${enable_sse4a}" != "xno"], [MARISA_ENABLE_SSE4A])
AC_MSG_RESULT([${enable_sse4a}])
AC_MSG_CHECKING([whether to use popcnt])
@@ -97,9 +154,7 @@ AC_ARG_ENABLE([popcnt],
[use POPCNT [default=no]])],
[],
[enable_popcnt="no"])
-AS_IF([test "x${enable_popcnt}" != "xno"], [
- enable_popcnt="yes"
-])
+AS_IF([test "x${enable_popcnt}" != "xno"], [MARISA_ENABLE_POPCNT])
AC_MSG_RESULT([${enable_popcnt}])
AS_IF([test "x${enable_popcnt}" != "xno"], [
@@ -170,6 +225,7 @@ AS_ECHO([" CXXFLAGS: ${CXXFLAGS}"])
AS_ECHO([" LDFLAGS: ${LDFLAGS}"])
AS_ECHO([" PREFIX: ${prefix}"])
AS_ECHO([])
+AS_ECHO([" NATIVE: ${enable_native_code}"])
AS_ECHO([" SSE2: ${enable_sse2}"])
AS_ECHO([" SSE3: ${enable_sse3}"])
AS_ECHO([" SSSE3: ${enable_ssse3}"])