blob: 0c8fc09ec5da5bbcd31bb6c81e984764ce43eb30 [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.
Patrick Venture09d9c232019-02-13 07:40:21 -080016PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus])
17PKG_CHECK_MODULES([SDEVENTPLUS], [sdeventplus])
18PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces])
19PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging])
20PKG_CHECK_MODULES([GPIOPLUS], [gpioplus])
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.
Patrick Venture9a7ef7c2018-11-21 21:37:23 -080028AC_CHECK_HEADER(
29 experimental/filesystem,
30 [],
31 [AC_MSG_ERROR(
32 [Could not find experimental/filesystem...libstdc++fs development package required])
33 ]
34)
Brad Bishop20938e42016-12-19 08:58:31 -050035
Matthew Barth6292aee2016-10-06 10:15:48 -050036# Checks for library functions.
Brad Bishop0be1f8d2017-03-06 21:52:00 -050037LT_INIT
Matthew Barth6292aee2016-10-06 10:15:48 -050038
39# Check/set gtest specific functions.
Patrick Venture9a7ef7c2018-11-21 21:37:23 -080040PKG_CHECK_MODULES(
41 [GTEST],
42 [gtest],
43 [],
44 [AC_MSG_NOTICE([gtest not found, tests will not build])]
45)
46PKG_CHECK_MODULES(
47 [GMOCK],
48 [gmock],
49 [],
50 [AC_MSG_NOTICE([gmock not found, tests will not build])]
51)
52PKG_CHECK_MODULES(
53 [GTEST_MAIN],
54 [gtest_main],
55 [],
56 [AC_MSG_NOTICE([gtest_main not found, tests will not build])]
57)
Matthew Barth6292aee2016-10-06 10:15:48 -050058
Patrick Venturecaac77d2018-04-17 17:38:02 -070059# Add --enable-oe-sdk flag to configure script
Matthew Barth6292aee2016-10-06 10:15:48 -050060AC_ARG_ENABLE([oe-sdk],
Patrick Venture9a7ef7c2018-11-21 21:37:23 -080061 AS_HELP_STRING(
62 [--enable-oe-sdk],
63 [Link testcases absolutely against OE SDK so they can be ran within it.]
64 )
Matthew Barth6292aee2016-10-06 10:15:48 -050065)
Patrick Venturecaac77d2018-04-17 17:38:02 -070066
67# Check for OECORE_TARGET_SYSROOT in the environment.
Matthew Barth6292aee2016-10-06 10:15:48 -050068AC_ARG_VAR(OECORE_TARGET_SYSROOT,
Patrick Venture9a7ef7c2018-11-21 21:37:23 -080069 [Path to the OE SDK SYSROOT]
70)
Patrick Venturecaac77d2018-04-17 17:38:02 -070071
72# Configure OESDK_TESTCASE_FLAGS environment variable, which will be later
73# used in test/Makefile.am
Matthew Barth6292aee2016-10-06 10:15:48 -050074AS_IF([test "x$enable_oe_sdk" == "xyes"],
75 AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"],
76 AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk])
77 )
78 AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT])
79 [
80 testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib"
81 testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib"
82 testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`"
83 ]
84 AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
85)
86
Patrick Venturec1cece72017-11-07 12:09:49 -080087# When a sensor access fails, just remove the sensor from dbus instead of exiting the daemon.
Matt Spinlerf9c83c42017-08-10 08:51:45 -050088AC_ARG_ENABLE([remove-from-dbus-on-fail],
Patrick Venture9a7ef7c2018-11-21 21:37:23 -080089 AS_HELP_STRING(
90 [--enable-remove-from-dbus-on-fail],
91 [Remove properties from D-Bus on access failures]
92 )
Matt Spinlerf9c83c42017-08-10 08:51:45 -050093)
94
95AC_ARG_VAR(REMOVE_ON_FAIL, [Remove properties from D-Bus on access failures])
96
Patrick Venture9a7ef7c2018-11-21 21:37:23 -080097AS_IF(
98 [test "x$enable_remove_from_dbus_on_fail" == "xyes"],
99 [REMOVE_ON_FAIL="yes"]
100 AC_DEFINE_UNQUOTED(
101 [REMOVE_ON_FAIL],
102 ["$REMOVE_ON_FAIL"],
103 [Remove properties from D-Bus on access failures]
104 )
Matt Spinlerf9c83c42017-08-10 08:51:45 -0500105)
106
Patrick Venturec1cece72017-11-07 12:09:49 -0800107# When a sensor read fails, set the Value on dbus with -errno.
108# Incompatible with remove-from-dbus-on-fail.
109AC_ARG_ENABLE([negative-errno-on-fail],
110 AS_HELP_STRING([--enable-negative-errno-on-fail], [Set sensor value to -errno on read failures])
111)
112
113AC_ARG_VAR(NEGATIVE_ERRNO_ON_FAIL, [Set sensor value to -errno on read failures])
Patrick Venture9a7ef7c2018-11-21 21:37:23 -0800114AS_IF(
115 [test "x$enable_negative_errno_on_fail" == "xyes"],
116 [NEGATIVE_ERRNO_ON_FAIL="yes"]
117 AC_DEFINE_UNQUOTED(
118 [NEGATIVE_ERRNO_ON_FAIL],
119 ["$NEGATIVE_ERRNO_ON_FAIL"], [Set sensor value to -errno on read failures]
120 )
Patrick Venturec1cece72017-11-07 12:09:49 -0800121)
122
Brad Bishopb9e2b072016-12-19 13:47:10 -0500123AC_ARG_VAR(BUSNAME_PREFIX, [The DBus busname prefix.])
124AC_ARG_VAR(SENSOR_ROOT, [The DBus sensors namespace root.])
Patrick Venture9a7ef7c2018-11-21 21:37:23 -0800125AS_IF(
126 [test "x$BUSNAME_PREFIX" == "x"],
127 [BUSNAME_PREFIX="xyz.openbmc_project.Hwmon"]
128)
129AS_IF(
130 [test "x$SENSOR_ROOT" == "x"],
131 [SENSOR_ROOT="/xyz/openbmc_project/sensors"]
132)
133AC_DEFINE_UNQUOTED(
134 [BUSNAME_PREFIX],
135 ["$BUSNAME_PREFIX"],
136 [The DBus busname prefix.]
137)
138AC_DEFINE_UNQUOTED(
139 [SENSOR_ROOT],
140 ["$SENSOR_ROOT"],
141 [The DBus sensors namespace root.]
142)
Brad Bishopb9e2b072016-12-19 13:47:10 -0500143
Matthew Barth6292aee2016-10-06 10:15:48 -0500144# Create configured output
Patrick Venture609fe982018-04-17 17:51:56 -0700145AC_CONFIG_FILES([Makefile test/Makefile tools/Makefile msl/Makefile])
Matthew Barth6292aee2016-10-06 10:15:48 -0500146AC_OUTPUT