Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 1 | # Initialization |
| 2 | AC_PREREQ([2.69]) |
Patrick Venture | d752357 | 2018-11-26 09:01:54 -0800 | [diff] [blame] | 3 | AC_INIT([swampd], [0.1], [https://github.com/openbmc/phosphor-pid-control/issues]) |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 4 | AC_LANG([C++]) |
| 5 | AC_CONFIG_HEADERS([config.h]) |
Patrick Venture | 90e9dbc | 2019-03-19 09:10:41 -0700 | [diff] [blame] | 6 | AM_INIT_AUTOMAKE([subdir-objects -Wall -Wno-portability -Werror foreign dist-xz]) |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 7 | AM_SILENT_RULES([yes]) |
| 8 | |
Patrick Venture | 94feffa | 2019-03-06 09:54:49 -0800 | [diff] [blame] | 9 | # Make sure the default CFLAGS of `-O2 -g` don't override CODE_COVERAGE_CFLAGS |
| 10 | # It is important that this comes before AC_PROG_C{C,XX}, as we are attempting |
| 11 | # to stop them from populating default CFLAGS and CXXFLAGS. |
| 12 | AS_IF([test "x$enable_tests" = "xno"], [enable_code_coverage=no]) |
| 13 | AS_IF([test "x$enable_code_coverage" != "xno"], [ |
| 14 | AS_IF([test "x${CXXFLAGS+set}" != "xset"], [ |
| 15 | AC_SUBST(CXXFLAGS, [""]) |
| 16 | ]) |
| 17 | AS_IF([test "x${CFLAGS+set}" != "xset"], [ |
| 18 | AC_SUBST(CFLAGS, [""]) |
| 19 | ]) |
| 20 | ]) |
| 21 | |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 22 | # Checks for programs. |
| 23 | AC_PROG_CXX |
| 24 | AM_PROG_AR |
| 25 | AC_PROG_INSTALL |
| 26 | AC_PROG_MAKE_SET |
| 27 | |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 28 | # Checks for typedefs, structures, and compiler characteristics. |
Patrick Venture | 54c2e5e | 2018-09-10 13:06:38 -0700 | [diff] [blame] | 29 | AX_CXX_COMPILE_STDCXX_17([noext]) |
Patrick Venture | ab28cb3 | 2018-06-20 18:37:48 -0700 | [diff] [blame] | 30 | AX_APPEND_COMPILE_FLAGS([-fpic -Wall -Werror], [CXXFLAGS]) |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 31 | |
| 32 | # Checks for libraries. |
Patrick Venture | e54c7ff | 2018-11-21 21:30:56 -0800 | [diff] [blame] | 33 | PKG_CHECK_MODULES( |
| 34 | [SYSTEMD], |
| 35 | [libsystemd >= 221], |
| 36 | [], |
| 37 | [AC_MSG_ERROR(["systemd required and not found"])] |
| 38 | ) |
Patrick Venture | f72ad44 | 2019-02-13 07:28:58 -0800 | [diff] [blame] | 39 | PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus]) |
| 40 | PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging]) |
| 41 | PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces]) |
William A. Kennington III | 331143c | 2019-02-07 15:52:44 -0800 | [diff] [blame] | 42 | PKG_CHECK_MODULES( |
| 43 | [LIBIPMID], |
| 44 | [libipmid], |
| 45 | [], |
| 46 | [AC_MSG_ERROR([Could not find libipmid...openbmc/phosphor-host-ipmid package required])] |
Patrick Venture | e54c7ff | 2018-11-21 21:30:56 -0800 | [diff] [blame] | 47 | ) |
| 48 | AC_CHECK_HEADER( |
Patrick Venture | 31eebcd | 2019-02-12 07:23:42 -0800 | [diff] [blame] | 49 | nlohmann/json.hpp, |
| 50 | [], |
| 51 | [AC_MSG_ERROR([Could not find nlohmann/json.hpp])] |
| 52 | ) |
Patrick Venture | b5cc37c | 2019-03-11 09:11:55 -0700 | [diff] [blame] | 53 | # We need the header only CLI library |
| 54 | AC_CHECK_HEADERS( |
| 55 | [CLI/CLI.hpp], |
| 56 | [], |
| 57 | [AC_MSG_ERROR([Could not find CLI11 CLI/CLI.hpp])] |
| 58 | ) |
James Feist | ce6a3f3 | 2019-03-12 11:20:16 -0700 | [diff] [blame] | 59 | |
| 60 | # check for boost headers |
| 61 | AC_CHECK_HEADER( |
| 62 | boost/asio/io_context.hpp, |
| 63 | [], |
| 64 | [AC_MSG_ERROR([Could not find boost/asio/io_context.hpp])] |
| 65 | ) |
| 66 | AC_CHECK_HEADER( |
| 67 | boost/asio/steady_timer.hpp, |
| 68 | [], |
| 69 | [AC_MSG_ERROR([Could not find boost/asio/steady_timer.hpp])] |
| 70 | ) |
| 71 | AX_APPEND_COMPILE_FLAGS(["-DBOOST_ASIO_DISABLE_THREADS"], [CPPFLAGS]) |
| 72 | AX_APPEND_COMPILE_FLAGS(["-DBOOST_ERROR_CODE_HEADER_ONLY"], [CPPFLAGS]) |
| 73 | AX_APPEND_COMPILE_FLAGS(["-DBOOST_SYSTEM_NO_DEPRECATED"], [CPPFLAGS]) |
| 74 | AX_APPEND_COMPILE_FLAGS(["-DBOOST_ASIO_NO_DEPRECATED"], [CPPFLAGS]) |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 75 | |
| 76 | # Checks for library functions. |
| 77 | LT_INIT # Required for systemd linking |
| 78 | |
Patrick Venture | 90f9bb5 | 2019-03-06 09:39:11 -0800 | [diff] [blame] | 79 | # Make it possible for users to choose if they want test support |
| 80 | # explicitly or not at all |
| 81 | AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests], |
| 82 | [Build test cases])) |
| 83 | |
Vijay Khemka | 5584543 | 2019-06-19 14:25:40 -0700 | [diff] [blame] | 84 | PKG_PROG_PKG_CONFIG |
| 85 | AC_ARG_WITH([systemdsystemunitdir], |
| 86 | [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])], |
| 87 | [], |
| 88 | [with_systemdsystemunitdir=auto] |
| 89 | ) |
| 90 | AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], |
| 91 | [def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd) |
| 92 | AS_IF([test "x$def_systemdsystemunitdir" = "x"], |
| 93 | [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"], |
| 94 | [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])] |
| 95 | ) |
| 96 | with_systemdsystemunitdir=no], |
| 97 | [with_systemdsystemunitdir="$def_systemdsystemunitdir"] |
| 98 | )] |
| 99 | ) |
| 100 | AS_IF([test "x$with_systemdsystemunitdir" != "xno"], |
| 101 | [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])] |
| 102 | ) |
| 103 | AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"]) |
| 104 | |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 105 | # Check/set gtest specific functions. |
Patrick Venture | 90f9bb5 | 2019-03-06 09:39:11 -0800 | [diff] [blame] | 106 | AS_IF([test "x$enable_tests" != "xno"], [ |
| 107 | PKG_CHECK_MODULES([GTEST], [gtest], [], [true]) |
| 108 | PKG_CHECK_MODULES([GMOCK], [gmock], [], [true]) |
| 109 | AX_PTHREAD |
| 110 | |
| 111 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 112 | AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS]) |
| 113 | AC_LANG_PUSH([C++]) |
| 114 | AC_CHECK_HEADERS([gtest/gtest.h], [ |
| 115 | AS_IF([test "x$GTEST_CFLAGS" = "x"], [ |
| 116 | AS_IF([test "x$PTHREAD_CFLAGS" = "x"], [ |
| 117 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=0"], [GTEST_CFLAGS]) |
| 118 | ], [ |
| 119 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=1"], [GTEST_CFLAGS]) |
| 120 | AX_APPEND_COMPILE_FLAGS([$PTHREAD_CFLAGS], [GTEST_CFLAGS]) |
| 121 | ]) |
| 122 | ]) |
| 123 | ], [ |
| 124 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 125 | AC_MSG_ERROR([Testing enabled but could not find gtest/gtest.h]) |
| 126 | ]) |
| 127 | ]) |
| 128 | AC_LANG_POP([C++]) |
| 129 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 130 | |
| 131 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 132 | AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS]) |
| 133 | AC_LANG_PUSH([C++]) |
| 134 | AC_CHECK_HEADERS([gmock/gmock.h], [], [ |
| 135 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 136 | AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h]) |
| 137 | ]) |
| 138 | ]) |
| 139 | AC_LANG_POP([C++]) |
| 140 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 141 | |
| 142 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 143 | AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS]) |
| 144 | AC_CHECK_LIB([gtest], [main], [ |
| 145 | AS_IF([test "x$GTEST_LIBS" = "x"], [ |
| 146 | AX_APPEND_COMPILE_FLAGS([-lgtest], [GTEST_LIBS]) |
| 147 | ]) |
| 148 | ], [ |
| 149 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 150 | AC_MSG_ERROR([Testing enabled but couldn't find gtest libs]) |
| 151 | ]) |
| 152 | ]) |
| 153 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 154 | |
| 155 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 156 | AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS]) |
| 157 | AC_CHECK_LIB([gmock], [main], [ |
| 158 | AS_IF([test "x$GMOCK_LIBS" = "x"], [ |
| 159 | AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS]) |
| 160 | ]) |
| 161 | ], [ |
| 162 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 163 | AC_MSG_ERROR([Testing enabled but couldn't find gmock libs]) |
| 164 | ]) |
| 165 | ]) |
| 166 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 167 | ]) |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 168 | |
Patrick Venture | 94feffa | 2019-03-06 09:54:49 -0800 | [diff] [blame] | 169 | # Code coverage |
| 170 | AX_CODE_COVERAGE |
Patrick Venture | 94feffa | 2019-03-06 09:54:49 -0800 | [diff] [blame] | 171 | AS_IF([test "x$CODE_COVERAGE_ENABLED" = "xyes"], [ |
| 172 | AX_APPEND_COMPILE_FLAGS([-DHAVE_GCOV], [CODE_COVERAGE_CPPFLAGS]) |
| 173 | ]) |
Patrick Venture | 90e9dbc | 2019-03-19 09:10:41 -0700 | [diff] [blame] | 174 | m4_ifdef([_AX_CODE_COVERAGE_RULES], |
| 175 | [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])], |
| 176 | [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])]) |
| 177 | AX_ADD_AM_MACRO_STATIC([]) |
Patrick Venture | 94feffa | 2019-03-06 09:54:49 -0800 | [diff] [blame] | 178 | |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 179 | AC_ARG_ENABLE([oe-sdk], |
Patrick Venture | f77ecc7 | 2018-11-26 09:08:49 -0800 | [diff] [blame] | 180 | AS_HELP_STRING( |
| 181 | [--enable-oe-sdk], |
| 182 | [Link testcases absolutely against OE SDK so they can be ran within it.] |
| 183 | ) |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 184 | ) |
| 185 | AC_ARG_VAR(OECORE_TARGET_SYSROOT, |
Patrick Venture | f77ecc7 | 2018-11-26 09:08:49 -0800 | [diff] [blame] | 186 | [Path to the OE SDK SYSROOT] |
| 187 | ) |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 188 | AS_IF([test "x$enable_oe_sdk" == "xyes"], |
| 189 | AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"], |
| 190 | AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk]) |
| 191 | ) |
| 192 | AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT]) |
| 193 | [ |
| 194 | testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib" |
| 195 | testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib" |
| 196 | testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`" |
| 197 | ] |
| 198 | AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags]) |
| 199 | ) |
| 200 | |
James Feist | 7136a5a | 2018-07-19 09:52:05 -0700 | [diff] [blame] | 201 | AC_ARG_ENABLE([configure-dbus], |
Patrick Venture | f77ecc7 | 2018-11-26 09:08:49 -0800 | [diff] [blame] | 202 | AS_HELP_STRING( |
| 203 | [--enable-configure-dbus], [Enable configuring pid from D-Bus.] |
| 204 | ) |
| 205 | ) |
James Feist | 7136a5a | 2018-07-19 09:52:05 -0700 | [diff] [blame] | 206 | AM_CONDITIONAL(CONFIGURE_DBUS, [test "x$enable_configure_dbus" = "xyes"]) |
| 207 | AS_IF([test "x$enable_configure_dbus" = "xyes"], |
James Feist | ce15e02 | 2018-09-26 10:01:33 -0700 | [diff] [blame] | 208 | [AC_DEFINE(CONFIGURE_DBUS, [1], [Read configuration from D-Bus.])], |
| 209 | [AC_DEFINE(CONFIGURE_DBUS, [0], [Do not read configuration from D-Bus.])] |
James Feist | 7136a5a | 2018-07-19 09:52:05 -0700 | [diff] [blame] | 210 | ) |
| 211 | |
Vijay Khemka | 5584543 | 2019-06-19 14:25:40 -0700 | [diff] [blame] | 212 | AC_ARG_VAR(SYSTEMD_TARGET, "Target for starting this service") |
| 213 | AS_IF([test "x$SYSTEMD_TARGET" == "x"], [SYSTEMD_TARGET="multi-user.target"]) |
| 214 | |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 215 | # Create configured output |
Patrick Venture | 7a841b6 | 2018-06-13 09:39:46 -0700 | [diff] [blame] | 216 | AC_CONFIG_FILES([Makefile test/Makefile]) |
Vijay Khemka | 5584543 | 2019-06-19 14:25:40 -0700 | [diff] [blame] | 217 | AC_CONFIG_FILES([phosphor-pid-control.service]) |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 218 | AC_OUTPUT |