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]) |
| 6 | AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz]) |
| 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( |
| 49 | experimental/filesystem, |
| 50 | [], |
| 51 | [AC_MSG_ERROR([Could not find experimental/filesystem...libstdc++fs development package required])] |
| 52 | ) |
Patrick Venture | 31eebcd | 2019-02-12 07:23:42 -0800 | [diff] [blame] | 53 | AC_CHECK_HEADER( |
| 54 | nlohmann/json.hpp, |
| 55 | [], |
| 56 | [AC_MSG_ERROR([Could not find nlohmann/json.hpp])] |
| 57 | ) |
Patrick Venture | 2e3ecb5 | 2018-06-22 08:18:19 -0700 | [diff] [blame] | 58 | AX_PTHREAD([], [AC_MSG_ERROR(["pthread required and not found"])]) |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 59 | |
| 60 | # Checks for library functions. |
| 61 | LT_INIT # Required for systemd linking |
| 62 | |
Patrick Venture | 90f9bb5 | 2019-03-06 09:39:11 -0800 | [diff] [blame] | 63 | # Make it possible for users to choose if they want test support |
| 64 | # explicitly or not at all |
| 65 | AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests], |
| 66 | [Build test cases])) |
| 67 | |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 68 | # Check/set gtest specific functions. |
Patrick Venture | 90f9bb5 | 2019-03-06 09:39:11 -0800 | [diff] [blame] | 69 | AS_IF([test "x$enable_tests" != "xno"], [ |
| 70 | PKG_CHECK_MODULES([GTEST], [gtest], [], [true]) |
| 71 | PKG_CHECK_MODULES([GMOCK], [gmock], [], [true]) |
| 72 | AX_PTHREAD |
| 73 | |
| 74 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 75 | AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS]) |
| 76 | AC_LANG_PUSH([C++]) |
| 77 | AC_CHECK_HEADERS([gtest/gtest.h], [ |
| 78 | AS_IF([test "x$GTEST_CFLAGS" = "x"], [ |
| 79 | AS_IF([test "x$PTHREAD_CFLAGS" = "x"], [ |
| 80 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=0"], [GTEST_CFLAGS]) |
| 81 | ], [ |
| 82 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=1"], [GTEST_CFLAGS]) |
| 83 | AX_APPEND_COMPILE_FLAGS([$PTHREAD_CFLAGS], [GTEST_CFLAGS]) |
| 84 | ]) |
| 85 | ]) |
| 86 | ], [ |
| 87 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 88 | AC_MSG_ERROR([Testing enabled but could not find gtest/gtest.h]) |
| 89 | ]) |
| 90 | ]) |
| 91 | AC_LANG_POP([C++]) |
| 92 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 93 | |
| 94 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 95 | AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS]) |
| 96 | AC_LANG_PUSH([C++]) |
| 97 | AC_CHECK_HEADERS([gmock/gmock.h], [], [ |
| 98 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 99 | AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h]) |
| 100 | ]) |
| 101 | ]) |
| 102 | AC_LANG_POP([C++]) |
| 103 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 104 | |
| 105 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 106 | AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS]) |
| 107 | AC_CHECK_LIB([gtest], [main], [ |
| 108 | AS_IF([test "x$GTEST_LIBS" = "x"], [ |
| 109 | AX_APPEND_COMPILE_FLAGS([-lgtest], [GTEST_LIBS]) |
| 110 | ]) |
| 111 | ], [ |
| 112 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 113 | AC_MSG_ERROR([Testing enabled but couldn't find gtest libs]) |
| 114 | ]) |
| 115 | ]) |
| 116 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 117 | |
| 118 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 119 | AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS]) |
| 120 | AC_CHECK_LIB([gmock], [main], [ |
| 121 | AS_IF([test "x$GMOCK_LIBS" = "x"], [ |
| 122 | AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS]) |
| 123 | ]) |
| 124 | ], [ |
| 125 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 126 | AC_MSG_ERROR([Testing enabled but couldn't find gmock libs]) |
| 127 | ]) |
| 128 | ]) |
| 129 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 130 | ]) |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 131 | |
Patrick Venture | 94feffa | 2019-03-06 09:54:49 -0800 | [diff] [blame^] | 132 | # Code coverage |
| 133 | AX_CODE_COVERAGE |
| 134 | AM_EXTRA_RECURSIVE_TARGETS([check-code-coverage]) |
| 135 | AS_IF([test "x$CODE_COVERAGE_ENABLED" = "xyes"], [ |
| 136 | AX_APPEND_COMPILE_FLAGS([-DHAVE_GCOV], [CODE_COVERAGE_CPPFLAGS]) |
| 137 | ]) |
| 138 | |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 139 | AC_ARG_ENABLE([oe-sdk], |
Patrick Venture | f77ecc7 | 2018-11-26 09:08:49 -0800 | [diff] [blame] | 140 | AS_HELP_STRING( |
| 141 | [--enable-oe-sdk], |
| 142 | [Link testcases absolutely against OE SDK so they can be ran within it.] |
| 143 | ) |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 144 | ) |
| 145 | AC_ARG_VAR(OECORE_TARGET_SYSROOT, |
Patrick Venture | f77ecc7 | 2018-11-26 09:08:49 -0800 | [diff] [blame] | 146 | [Path to the OE SDK SYSROOT] |
| 147 | ) |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 148 | AS_IF([test "x$enable_oe_sdk" == "xyes"], |
| 149 | AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"], |
| 150 | AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk]) |
| 151 | ) |
| 152 | AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT]) |
| 153 | [ |
| 154 | testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib" |
| 155 | testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib" |
| 156 | testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`" |
| 157 | ] |
| 158 | AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags]) |
| 159 | ) |
| 160 | |
James Feist | 7136a5a | 2018-07-19 09:52:05 -0700 | [diff] [blame] | 161 | AC_ARG_ENABLE([configure-dbus], |
Patrick Venture | f77ecc7 | 2018-11-26 09:08:49 -0800 | [diff] [blame] | 162 | AS_HELP_STRING( |
| 163 | [--enable-configure-dbus], [Enable configuring pid from D-Bus.] |
| 164 | ) |
| 165 | ) |
James Feist | 7136a5a | 2018-07-19 09:52:05 -0700 | [diff] [blame] | 166 | AM_CONDITIONAL(CONFIGURE_DBUS, [test "x$enable_configure_dbus" = "xyes"]) |
| 167 | AS_IF([test "x$enable_configure_dbus" = "xyes"], |
James Feist | ce15e02 | 2018-09-26 10:01:33 -0700 | [diff] [blame] | 168 | [AC_DEFINE(CONFIGURE_DBUS, [1], [Read configuration from D-Bus.])], |
| 169 | [AC_DEFINE(CONFIGURE_DBUS, [0], [Do not read configuration from D-Bus.])] |
James Feist | 7136a5a | 2018-07-19 09:52:05 -0700 | [diff] [blame] | 170 | ) |
| 171 | |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 172 | # Create configured output |
Patrick Venture | 7a841b6 | 2018-06-13 09:39:46 -0700 | [diff] [blame] | 173 | AC_CONFIG_FILES([Makefile test/Makefile]) |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 174 | AC_OUTPUT |