blob: c3a92c70330de157497d1e1fa92c643a5d32662c [file] [log] [blame]
Matthew Barth6292aee2016-10-06 10:15:48 -05001# Initialization
2AC_PREREQ([2.69])
3AC_INIT([phosphor-hwmon], [1.0], [https://github.com/openbmc/phosphor-hwmon/issues])
Brad Bishop20938e42016-12-19 08:58:31 -05004AC_LANG([C++])
Matthew Barth6292aee2016-10-06 10:15:48 -05005AC_CONFIG_HEADERS([config.h])
6AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz])
7AM_SILENT_RULES([yes])
8
9# Checks for programs.
10AC_PROG_CXX
11AM_PROG_AR
12AC_PROG_INSTALL
13AC_PROG_MAKE_SET
14
15# Checks for libraries.
Brad Bishopbf86e722017-02-16 11:10:40 -050016PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus], [], [AC_MSG_ERROR(["sdbusplus required and not found."])])
William A. Kennington III0fe4cb32018-10-18 19:19:58 -070017PKG_CHECK_MODULES([SDEVENTPLUS], [sdeventplus], [], [AC_MSG_ERROR(["sdeventplus required and not found."])])
Brad Bishopbf86e722017-02-16 11:10:40 -050018PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces], [], [AC_MSG_ERROR(["phosphor-dbus-interfaces required and not found."])])
Brad Bishop4db64422017-02-16 11:33:32 -050019PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging], [], [AC_MSG_ERROR(["phosphor-logging required and not found."])])
Patrick Ventureb28f4322018-09-14 10:19:14 -070020PKG_CHECK_MODULES([GPIOPLUS], [gpioplus],, [AC_MSG_ERROR([Could not find gpioplus...openbmc/gpioplus package required])])
Patrick Venture9f514812018-06-27 10:19:32 -070021AX_PTHREAD([], [AC_MSG_ERROR(["pthread required and not found"])])
Matthew Barth6292aee2016-10-06 10:15:48 -050022
23# Checks for typedefs, structures, and compiler characteristics.
Patrick Venture619190d2018-09-10 13:07:40 -070024AX_CXX_COMPILE_STDCXX_17([noext])
Brad Bishop3b1b5d42016-12-05 15:05:57 -050025AX_APPEND_COMPILE_FLAGS([-fpic -Wall -Werror], [CXXFLAGS])
Matthew Barth6292aee2016-10-06 10:15:48 -050026
Brad Bishop20938e42016-12-19 08:58:31 -050027# Checks for header files.
Gunnar Millsca64c252017-10-25 17:13:45 -050028AC_CHECK_HEADER(sdbusplus/server.hpp, ,[AC_MSG_ERROR([Could not find sdbusplus/server.hpp...sdbusplus development package required])])
29AC_CHECK_HEADER(experimental/filesystem, ,[AC_MSG_ERROR([Could not find experimental/filesystem...libstdc++fs development package required])])
Brad Bishop20938e42016-12-19 08:58:31 -050030
Matthew Barth6292aee2016-10-06 10:15:48 -050031# Checks for library functions.
Brad Bishop0be1f8d2017-03-06 21:52:00 -050032LT_INIT
Matthew Barth6292aee2016-10-06 10:15:48 -050033
34# Check/set gtest specific functions.
Patrick Venturecaac77d2018-04-17 17:38:02 -070035PKG_CHECK_MODULES([GTEST], [gtest], [], [AC_MSG_NOTICE([gtest not found, tests will not build])])
36PKG_CHECK_MODULES([GMOCK], [gmock], [], [AC_MSG_NOTICE([gmock not found, tests will not build])])
Patrick Venture9f514812018-06-27 10:19:32 -070037PKG_CHECK_MODULES([GTEST_MAIN], [gtest_main], [], [AC_MSG_NOTICE([gtest_main not found, tests will not build])])
Matthew Barth6292aee2016-10-06 10:15:48 -050038
Patrick Venturecaac77d2018-04-17 17:38:02 -070039# Add --enable-oe-sdk flag to configure script
Matthew Barth6292aee2016-10-06 10:15:48 -050040AC_ARG_ENABLE([oe-sdk],
41 AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.])
42)
Patrick Venturecaac77d2018-04-17 17:38:02 -070043
44# Check for OECORE_TARGET_SYSROOT in the environment.
Matthew Barth6292aee2016-10-06 10:15:48 -050045AC_ARG_VAR(OECORE_TARGET_SYSROOT,
46 [Path to the OE SDK SYSROOT])
Patrick Venturecaac77d2018-04-17 17:38:02 -070047
48# Configure OESDK_TESTCASE_FLAGS environment variable, which will be later
49# used in test/Makefile.am
Matthew Barth6292aee2016-10-06 10:15:48 -050050AS_IF([test "x$enable_oe_sdk" == "xyes"],
51 AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"],
52 AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk])
53 )
54 AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT])
55 [
56 testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib"
57 testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib"
58 testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`"
59 ]
60 AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
61)
62
Patrick Venturec1cece72017-11-07 12:09:49 -080063# When a sensor access fails, just remove the sensor from dbus instead of exiting the daemon.
Matt Spinlerf9c83c42017-08-10 08:51:45 -050064AC_ARG_ENABLE([remove-from-dbus-on-fail],
65 AS_HELP_STRING([--enable-remove-from-dbus-on-fail], [Remove properties from D-Bus on access failures])
66)
67
68AC_ARG_VAR(REMOVE_ON_FAIL, [Remove properties from D-Bus on access failures])
69
70AS_IF([test "x$enable_remove_from_dbus_on_fail" == "xyes"],
71 [REMOVE_ON_FAIL="yes"]
72 AC_DEFINE_UNQUOTED([REMOVE_ON_FAIL], ["$REMOVE_ON_FAIL"], [Remove properties from D-Bus on access failures])
73)
74
Patrick Venturec1cece72017-11-07 12:09:49 -080075# When a sensor read fails, set the Value on dbus with -errno.
76# Incompatible with remove-from-dbus-on-fail.
77AC_ARG_ENABLE([negative-errno-on-fail],
78 AS_HELP_STRING([--enable-negative-errno-on-fail], [Set sensor value to -errno on read failures])
79)
80
81AC_ARG_VAR(NEGATIVE_ERRNO_ON_FAIL, [Set sensor value to -errno on read failures])
82
83AS_IF([test "x$enable_negative_errno_on_fail" == "xyes"],
84 [NEGATIVE_ERRNO_ON_FAIL="yes"]
85 AC_DEFINE_UNQUOTED([NEGATIVE_ERRNO_ON_FAIL], ["$NEGATIVE_ERRNO_ON_FAIL"], [Set sensor value to -errno on read failures])
86)
87
Brad Bishopb9e2b072016-12-19 13:47:10 -050088AC_ARG_VAR(BUSNAME_PREFIX, [The DBus busname prefix.])
89AC_ARG_VAR(SENSOR_ROOT, [The DBus sensors namespace root.])
90AS_IF([test "x$BUSNAME_PREFIX" == "x"], [BUSNAME_PREFIX="xyz.openbmc_project.Hwmon"])
Leonel Gonzalez2260efb2017-02-23 10:40:40 -060091AS_IF([test "x$SENSOR_ROOT" == "x"], [SENSOR_ROOT="/xyz/openbmc_project/sensors"])
Brad Bishopb9e2b072016-12-19 13:47:10 -050092AC_DEFINE_UNQUOTED([BUSNAME_PREFIX], ["$BUSNAME_PREFIX"], [The DBus busname prefix.])
93AC_DEFINE_UNQUOTED([SENSOR_ROOT], ["$SENSOR_ROOT"], [The DBus sensors namespace root.])
94
Matthew Barth6292aee2016-10-06 10:15:48 -050095# Create configured output
Patrick Venture609fe982018-04-17 17:51:56 -070096AC_CONFIG_FILES([Makefile test/Makefile tools/Makefile msl/Makefile])
Matthew Barth6292aee2016-10-06 10:15:48 -050097AC_OUTPUT