Matthew Barth | 6292aee | 2016-10-06 10:15:48 -0500 | [diff] [blame] | 1 | # Initialization |
| 2 | AC_PREREQ([2.69]) |
| 3 | AC_INIT([phosphor-hwmon], [1.0], [https://github.com/openbmc/phosphor-hwmon/issues]) |
Brad Bishop | 20938e4 | 2016-12-19 08:58:31 -0500 | [diff] [blame] | 4 | AC_LANG([C++]) |
Matthew Barth | 6292aee | 2016-10-06 10:15:48 -0500 | [diff] [blame] | 5 | AC_CONFIG_HEADERS([config.h]) |
Patrick Venture | 69a68ed | 2019-03-06 10:37:30 -0800 | [diff] [blame] | 6 | AM_INIT_AUTOMAKE([subdir-objects -Wall -Wno-portability -Werror foreign dist-xz]) |
Matthew Barth | 6292aee | 2016-10-06 10:15:48 -0500 | [diff] [blame] | 7 | AM_SILENT_RULES([yes]) |
| 8 | |
Patrick Venture | 69a68ed | 2019-03-06 10:37:30 -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 | |
Matthew Barth | 6292aee | 2016-10-06 10:15:48 -0500 | [diff] [blame] | 22 | # Checks for programs. |
| 23 | AC_PROG_CXX |
| 24 | AM_PROG_AR |
| 25 | AC_PROG_INSTALL |
| 26 | AC_PROG_MAKE_SET |
| 27 | |
| 28 | # Checks for libraries. |
Patrick Venture | 09d9c23 | 2019-02-13 07:40:21 -0800 | [diff] [blame] | 29 | PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus]) |
| 30 | PKG_CHECK_MODULES([SDEVENTPLUS], [sdeventplus]) |
| 31 | PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces]) |
| 32 | PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging]) |
| 33 | PKG_CHECK_MODULES([GPIOPLUS], [gpioplus]) |
William A. Kennington III | 2227bd5 | 2019-06-19 11:32:22 -0700 | [diff] [blame^] | 34 | PKG_CHECK_MODULES([STDPLUS], [stdplus]) |
Patrick Venture | 17cfad6 | 2019-03-11 14:14:30 -0700 | [diff] [blame] | 35 | # We need the header only CLI library |
| 36 | AC_CHECK_HEADERS( |
| 37 | [CLI/CLI.hpp], |
| 38 | [], |
| 39 | [AC_MSG_ERROR([Could not find CLI11 CLI/CLI.hpp])] |
| 40 | ) |
Patrick Venture | 9f51481 | 2018-06-27 10:19:32 -0700 | [diff] [blame] | 41 | AX_PTHREAD([], [AC_MSG_ERROR(["pthread required and not found"])]) |
Matthew Barth | 6292aee | 2016-10-06 10:15:48 -0500 | [diff] [blame] | 42 | |
| 43 | # Checks for typedefs, structures, and compiler characteristics. |
Patrick Venture | 619190d | 2018-09-10 13:07:40 -0700 | [diff] [blame] | 44 | AX_CXX_COMPILE_STDCXX_17([noext]) |
Brad Bishop | 3b1b5d4 | 2016-12-05 15:05:57 -0500 | [diff] [blame] | 45 | AX_APPEND_COMPILE_FLAGS([-fpic -Wall -Werror], [CXXFLAGS]) |
Matthew Barth | 6292aee | 2016-10-06 10:15:48 -0500 | [diff] [blame] | 46 | |
| 47 | # Checks for library functions. |
Brad Bishop | 0be1f8d | 2017-03-06 21:52:00 -0500 | [diff] [blame] | 48 | LT_INIT |
Matthew Barth | 6292aee | 2016-10-06 10:15:48 -0500 | [diff] [blame] | 49 | |
Patrick Venture | 5d8f570 | 2019-03-06 10:24:04 -0800 | [diff] [blame] | 50 | # Make it possible for users to choose if they want test support |
| 51 | # explicitly or not at all |
| 52 | AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests], |
| 53 | [Build test cases])) |
| 54 | |
Matthew Barth | 6292aee | 2016-10-06 10:15:48 -0500 | [diff] [blame] | 55 | # Check/set gtest specific functions. |
Patrick Venture | 5d8f570 | 2019-03-06 10:24:04 -0800 | [diff] [blame] | 56 | AS_IF([test "x$enable_tests" != "xno"], [ |
| 57 | PKG_CHECK_MODULES([GTEST], [gtest], [], [true]) |
| 58 | PKG_CHECK_MODULES([GMOCK], [gmock], [], [true]) |
| 59 | AX_PTHREAD |
| 60 | |
| 61 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 62 | AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS]) |
| 63 | AC_LANG_PUSH([C++]) |
| 64 | AC_CHECK_HEADERS([gtest/gtest.h], [ |
| 65 | AS_IF([test "x$GTEST_CFLAGS" = "x"], [ |
| 66 | AS_IF([test "x$PTHREAD_CFLAGS" = "x"], [ |
| 67 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=0"], [GTEST_CFLAGS]) |
| 68 | ], [ |
| 69 | AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=1"], [GTEST_CFLAGS]) |
| 70 | AX_APPEND_COMPILE_FLAGS([$PTHREAD_CFLAGS], [GTEST_CFLAGS]) |
| 71 | ]) |
| 72 | ]) |
| 73 | ], [ |
| 74 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 75 | AC_MSG_ERROR([Testing enabled but could not find gtest/gtest.h]) |
| 76 | ]) |
| 77 | ]) |
| 78 | AC_LANG_POP([C++]) |
| 79 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 80 | |
| 81 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 82 | AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS]) |
| 83 | AC_LANG_PUSH([C++]) |
| 84 | AC_CHECK_HEADERS([gmock/gmock.h], [], [ |
| 85 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 86 | AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h]) |
| 87 | ]) |
| 88 | ]) |
| 89 | AC_LANG_POP([C++]) |
| 90 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS]) |
| 91 | |
| 92 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 93 | AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS]) |
| 94 | AC_CHECK_LIB([gtest], [main], [ |
| 95 | AS_IF([test "x$GTEST_LIBS" = "x"], [ |
| 96 | AX_APPEND_COMPILE_FLAGS([-lgtest], [GTEST_LIBS]) |
| 97 | ]) |
| 98 | ], [ |
| 99 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 100 | AC_MSG_ERROR([Testing enabled but couldn't find gtest libs]) |
| 101 | ]) |
| 102 | ]) |
| 103 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 104 | |
| 105 | AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 106 | AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS]) |
| 107 | AC_CHECK_LIB([gmock], [main], [ |
| 108 | AS_IF([test "x$GMOCK_LIBS" = "x"], [ |
| 109 | AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS]) |
| 110 | ]) |
| 111 | ], [ |
| 112 | AS_IF([test "x$enable_tests" = "xyes"], [ |
| 113 | AC_MSG_ERROR([Testing enabled but couldn't find gmock libs]) |
| 114 | ]) |
| 115 | ]) |
| 116 | AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS]) |
| 117 | ]) |
Matthew Barth | 6292aee | 2016-10-06 10:15:48 -0500 | [diff] [blame] | 118 | |
Patrick Venture | caac77d | 2018-04-17 17:38:02 -0700 | [diff] [blame] | 119 | # Add --enable-oe-sdk flag to configure script |
Matthew Barth | 6292aee | 2016-10-06 10:15:48 -0500 | [diff] [blame] | 120 | AC_ARG_ENABLE([oe-sdk], |
Patrick Venture | 9a7ef7c | 2018-11-21 21:37:23 -0800 | [diff] [blame] | 121 | AS_HELP_STRING( |
| 122 | [--enable-oe-sdk], |
| 123 | [Link testcases absolutely against OE SDK so they can be ran within it.] |
| 124 | ) |
Matthew Barth | 6292aee | 2016-10-06 10:15:48 -0500 | [diff] [blame] | 125 | ) |
Patrick Venture | caac77d | 2018-04-17 17:38:02 -0700 | [diff] [blame] | 126 | |
Patrick Venture | 7e27665 | 2019-03-13 08:17:03 -0700 | [diff] [blame] | 127 | # Check for valgrind |
| 128 | AS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no]) |
| 129 | m4_foreach([vgtool], [valgrind_tool_list], |
| 130 | [AX_VALGRIND_DFLT(vgtool, [off])]) |
| 131 | AX_VALGRIND_DFLT([memcheck], [on]) |
| 132 | AX_VALGRIND_CHECK |
| 133 | AM_EXTRA_RECURSIVE_TARGETS([check-valgrind]) |
| 134 | m4_foreach([vgtool], [valgrind_tool_list], |
| 135 | [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)]) |
| 136 | |
Patrick Venture | 69a68ed | 2019-03-06 10:37:30 -0800 | [diff] [blame] | 137 | # Code coverage |
| 138 | AX_CODE_COVERAGE |
| 139 | m4_ifdef([_AX_CODE_COVERAGE_RULES], |
| 140 | [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])], |
| 141 | [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])]) |
| 142 | AX_ADD_AM_MACRO_STATIC([]) |
| 143 | |
Patrick Venture | caac77d | 2018-04-17 17:38:02 -0700 | [diff] [blame] | 144 | # Check for OECORE_TARGET_SYSROOT in the environment. |
Matthew Barth | 6292aee | 2016-10-06 10:15:48 -0500 | [diff] [blame] | 145 | AC_ARG_VAR(OECORE_TARGET_SYSROOT, |
Patrick Venture | 9a7ef7c | 2018-11-21 21:37:23 -0800 | [diff] [blame] | 146 | [Path to the OE SDK SYSROOT] |
| 147 | ) |
Patrick Venture | caac77d | 2018-04-17 17:38:02 -0700 | [diff] [blame] | 148 | |
| 149 | # Configure OESDK_TESTCASE_FLAGS environment variable, which will be later |
| 150 | # used in test/Makefile.am |
Matthew Barth | 6292aee | 2016-10-06 10:15:48 -0500 | [diff] [blame] | 151 | AS_IF([test "x$enable_oe_sdk" == "xyes"], |
| 152 | AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"], |
| 153 | AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk]) |
| 154 | ) |
| 155 | AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT]) |
| 156 | [ |
| 157 | testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib" |
| 158 | testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib" |
| 159 | testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`" |
| 160 | ] |
| 161 | AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags]) |
| 162 | ) |
| 163 | |
Patrick Venture | c1cece7 | 2017-11-07 12:09:49 -0800 | [diff] [blame] | 164 | # When a sensor read fails, set the Value on dbus with -errno. |
Brandon Kim | 79205b2 | 2019-06-20 12:18:24 -0700 | [diff] [blame] | 165 | # It will also skip the "Remove RCs" check. |
| 166 | # Incompatible with update-functional-on-fail. |
Patrick Venture | c1cece7 | 2017-11-07 12:09:49 -0800 | [diff] [blame] | 167 | AC_ARG_ENABLE([negative-errno-on-fail], |
Brandon Kim | 79205b2 | 2019-06-20 12:18:24 -0700 | [diff] [blame] | 168 | AS_HELP_STRING( |
| 169 | [--enable-negative-errno-on-fail], |
| 170 | [Set sensor value to -errno on read failures. Incompatible with update-functional-on-fail] |
| 171 | ) |
Patrick Venture | c1cece7 | 2017-11-07 12:09:49 -0800 | [diff] [blame] | 172 | ) |
| 173 | |
| 174 | AC_ARG_VAR(NEGATIVE_ERRNO_ON_FAIL, [Set sensor value to -errno on read failures]) |
Patrick Venture | 9a7ef7c | 2018-11-21 21:37:23 -0800 | [diff] [blame] | 175 | AS_IF( |
| 176 | [test "x$enable_negative_errno_on_fail" == "xyes"], |
| 177 | [NEGATIVE_ERRNO_ON_FAIL="yes"] |
| 178 | AC_DEFINE_UNQUOTED( |
| 179 | [NEGATIVE_ERRNO_ON_FAIL], |
Brandon Kim | 79205b2 | 2019-06-20 12:18:24 -0700 | [diff] [blame] | 180 | ["$NEGATIVE_ERRNO_ON_FAIL"], |
| 181 | [Set sensor value to -errno on read failures] |
Patrick Venture | 9a7ef7c | 2018-11-21 21:37:23 -0800 | [diff] [blame] | 182 | ) |
Patrick Venture | c1cece7 | 2017-11-07 12:09:49 -0800 | [diff] [blame] | 183 | ) |
| 184 | |
Brandon Kim | 79205b2 | 2019-06-20 12:18:24 -0700 | [diff] [blame] | 185 | # When a sensor read fails, update the OperationalState interface's Functional property. |
| 186 | # This will mark the sensor as not functional and skip reading from that sensor. |
| 187 | # It will skip the "Remove RCs" check during value interface creation in MainLoop::getObject. |
| 188 | # However, it will perform the "Remove RCs" checks during MainLoop::read. |
| 189 | # Incompatible with negative-errno-on-fail. |
| 190 | AC_ARG_ENABLE([update-functional-on-fail], |
| 191 | AS_HELP_STRING( |
| 192 | [--enable-update-functional-on-fail], |
| 193 | [Update functional property on read failures. Incompatible with negative-errno-on-fail] |
| 194 | ) |
| 195 | ) |
| 196 | |
| 197 | AC_ARG_VAR(UPDATE_FUNCTIONAL_ON_FAIL, [Update functional property on read failures]) |
| 198 | AS_IF( |
| 199 | [test "x$enable_update_functional_on_fail" == "xyes"], |
| 200 | [UPDATE_FUNCTIONAL_ON_FAIL="yes"] |
| 201 | AC_DEFINE_UNQUOTED( |
| 202 | [UPDATE_FUNCTIONAL_ON_FAIL], |
| 203 | ["$UPDATE_FUNCTIONAL_ON_FAIL"], |
| 204 | [Update functional property on sensor read failures] |
| 205 | ) |
| 206 | ) |
| 207 | |
| 208 | AS_IF([test "x$enable_negative_errno_on_fail" == "xyes"], [ |
| 209 | AS_IF([test "x$enable_update_functional_on_fail" == "xyes"], [ |
| 210 | AC_MSG_ERROR([Invalid configuration enabling both negative-errno-on-fail and update-functional-on-fail.]) |
| 211 | ]) |
| 212 | ]) |
| 213 | |
Brad Bishop | b9e2b07 | 2016-12-19 13:47:10 -0500 | [diff] [blame] | 214 | AC_ARG_VAR(BUSNAME_PREFIX, [The DBus busname prefix.]) |
| 215 | AC_ARG_VAR(SENSOR_ROOT, [The DBus sensors namespace root.]) |
Patrick Venture | 9a7ef7c | 2018-11-21 21:37:23 -0800 | [diff] [blame] | 216 | AS_IF( |
| 217 | [test "x$BUSNAME_PREFIX" == "x"], |
| 218 | [BUSNAME_PREFIX="xyz.openbmc_project.Hwmon"] |
| 219 | ) |
| 220 | AS_IF( |
| 221 | [test "x$SENSOR_ROOT" == "x"], |
| 222 | [SENSOR_ROOT="/xyz/openbmc_project/sensors"] |
| 223 | ) |
| 224 | AC_DEFINE_UNQUOTED( |
| 225 | [BUSNAME_PREFIX], |
| 226 | ["$BUSNAME_PREFIX"], |
| 227 | [The DBus busname prefix.] |
| 228 | ) |
| 229 | AC_DEFINE_UNQUOTED( |
| 230 | [SENSOR_ROOT], |
| 231 | ["$SENSOR_ROOT"], |
| 232 | [The DBus sensors namespace root.] |
| 233 | ) |
Brad Bishop | b9e2b07 | 2016-12-19 13:47:10 -0500 | [diff] [blame] | 234 | |
Matthew Barth | 6292aee | 2016-10-06 10:15:48 -0500 | [diff] [blame] | 235 | # Create configured output |
Patrick Venture | 609fe98 | 2018-04-17 17:51:56 -0700 | [diff] [blame] | 236 | AC_CONFIG_FILES([Makefile test/Makefile tools/Makefile msl/Makefile]) |
Matthew Barth | 6292aee | 2016-10-06 10:15:48 -0500 | [diff] [blame] | 237 | AC_OUTPUT |