Enable link time optimization

To enable link time optimization, several configures needs to be
changed:
1. Add -flto in Makefiles
2. Use C++17 to get inline constexpr
3. Use gcc-ar and gcc-ranlib to generate static library, otherwise it
   gets link errors.

Tested: Build OK and unit tests passes.

Change-Id: Ic58cbfb631c97f43c82d5669cbf6ac1ebc5e0ab9
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/configure.ac b/configure.ac
index 2680788..7e7d28c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,6 +6,10 @@
 AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz])
 AM_SILENT_RULES([yes])
 
+# Use gcc-ar and gcc-ranlib for static libraries built with -flto
+AC_SUBST([AR], [${ac_tool_prefix}gcc-ar])
+AC_SUBST([RANLIB], [${ac_tool_prefix}gcc-ranlib])
+
 # Checks for programs
 AC_PROG_CXX
 AM_PROG_AR
@@ -53,7 +57,7 @@
 AS_IF([test "x$SDBUSPLUSPLUS" == "x"], AC_MSG_ERROR([Cannot find sdbus++]))
 
 # Checks for typedefs, structures, and compiler characteristics.
-AX_CXX_COMPILE_STDCXX_14([noext])
+AX_CXX_COMPILE_STDCXX_17([noext])
 AX_APPEND_COMPILE_FLAGS([-fpic -Wall -Werror], [CXXFLAGS])
 
 # DBUS interface