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