summaryrefslogtreecommitdiffstats
path: root/m4/pdns_enable_lto.m4
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--m4/pdns_enable_lto.m439
1 files changed, 39 insertions, 0 deletions
diff --git a/m4/pdns_enable_lto.m4 b/m4/pdns_enable_lto.m4
new file mode 100644
index 0000000..a464231
--- /dev/null
+++ b/m4/pdns_enable_lto.m4
@@ -0,0 +1,39 @@
+AC_DEFUN([PDNS_ENABLE_LTO],[
+ AC_ARG_ENABLE([lto],
+ AS_HELP_STRING([--enable-lto], [enable Link-Time Optimizations (LTO) support @<:@default=no@:>@]),
+ [enable_lto=$enableval],
+ [enable_lto=no]
+ )
+
+ AS_IF([test "x$enable_lto" != "xno"], [
+
+ dnl If thin is not supported, we try to fallback to auto
+ AS_IF([test "x$enable_lto" == "xthin"], [
+ gl_COMPILER_OPTION_IF([-flto=thin], [
+ CFLAGS="-flto=thin $CFLAGS"
+ CXXFLAGS="-flto=thin $CXXFLAGS"
+ LDFLAGS="-flto=thin $LDFLAGS"
+ ], [enable_lto=auto])
+ ])
+
+ dnl If auto is not supported, we try to fallback -flto
+ AS_IF([test "x$enable_lto" == "xauto"], [
+ gl_COMPILER_OPTION_IF([-flto=auto], [
+ CFLAGS="-flto=auto $CFLAGS"
+ CXXFLAGS="-flto=auto $CXXFLAGS"
+ LDFLAGS="-flto=auto $LDFLAGS"
+ ], [enable_lto=yes])
+ ])
+
+ AS_IF([test "x$enable_lto" == "xyes"], [
+ gl_COMPILER_OPTION_IF([-flto], [
+ CFLAGS="-flto $CFLAGS"
+ CXXFLAGS="-flto $CXXFLAGS"
+ LDFLAGS="-flto $LDFLAGS"
+ ], [enable_lto=no])
+ ])
+ ])
+
+ AC_MSG_CHECKING([whether link-time optimization is supported])
+ AC_MSG_RESULT([$enable_lto])
+])