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