blob: 04c48b84e8d7e80ae9c1dc6b637a967bd4f2830f [file] [log] [blame]
Matthew Barth3cff7ed2016-07-27 14:50:51 -05001# Initialization
2AC_PREREQ([2.69])
3AC_INIT([phosphor-host-ipmid], [1.0], [https://github.com/openbmc/phosphor-host-ipmid/issues])
4AC_CONFIG_HEADERS([config.h])
William A. Kennington III5023aa92019-04-04 18:00:09 -07005AM_INIT_AUTOMAKE([subdir-objects -Wall -Wno-portability -Werror foreign dist-xz])
Matthew Barth00b1e5b2016-09-09 12:15:46 -05006AM_SILENT_RULES([yes])
Patrick Venture98c7bfc2018-10-29 18:43:35 -07007AC_LANG([C++])
Matthew Barth3cff7ed2016-07-27 14:50:51 -05008
William A. Kennington III5023aa92019-04-04 18:00:09 -07009# 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.
12AS_IF([test "x$enable_code_coverage" != "xno"], [
13 AS_IF([test "x${CXXFLAGS+set}" != "xset"], [
14 AC_SUBST(CXXFLAGS, [""])
15 ])
16 AS_IF([test "x${CFLAGS+set}" != "xset"], [
17 AC_SUBST(CFLAGS, [""])
18 ])
19])
20
Matthew Barth3cff7ed2016-07-27 14:50:51 -050021# Checks for programs.
22AC_PROG_CXX
Matthew Barth3cff7ed2016-07-27 14:50:51 -050023AC_PROG_CC
Patrick Williams686df742016-09-02 17:52:59 -050024AM_PROG_AR
Matthew Barth3cff7ed2016-07-27 14:50:51 -050025AC_PROG_INSTALL
26AC_PROG_MAKE_SET
27
Yong Libd0503a2019-08-22 17:17:17 +080028# Add an option to enable/disable i2c master write read command white list checking
29AC_ARG_ENABLE([i2c-whitelist-check],
30 AS_HELP_STRING([--disable-i2c-whitelist-check], [Disable I2C master write read command white list check. [default=enable]])
31)
32AS_IF([test "x$enable_i2c_whitelist_check" != "xno"],
33 AC_MSG_NOTICE([Enabling I2C master write read command white list check])
34 [cpp_flags="-DENABLE_I2C_WHITELIST_CHECK"]
35 AC_SUBST([CPPFLAGS], [$cpp_flags]),
36 AC_MSG_WARN([Disabling I2C master write read command white list check])
37)
38
Vishwanatha Subbanna506aa0f2017-01-24 14:58:25 +053039# softoff dir specific ones
40AC_ARG_ENABLE([softoff],
41 AS_HELP_STRING([--enable-softoff], [Builds soft power off])
42)
43AS_IF([test "x$enable_softoff" != "xno"],
44 [AC_PROG_MKDIR_P]
45 [AC_CHECK_PROG([DIRNAME], dirname, dirname)]
46)
47
William A. Kennington III194375f2018-12-14 02:14:33 -080048# Make sure the pkgconfigdata is configured for automake
49PKG_INSTALLDIR
50
Matthew Barth3cff7ed2016-07-27 14:50:51 -050051# Checks for libraries.
Patrick Venture15bc9182018-12-03 12:22:50 -080052AC_CHECK_LIB([pam], [pam_start], [], [AC_MSG_ERROR([libpam not found])])
Matthew Barth80f714b2016-11-09 15:04:48 -060053AC_CHECK_LIB([mapper], [mapper_get_service], ,[AC_MSG_ERROR([Could not find libmapper...openbmc/phosphor-objmgr package required])])
Vishwanatha Subbanna506aa0f2017-01-24 14:58:25 +053054PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221], [], [AC_MSG_ERROR(["systemd required and not found"])])
Richard Marian Thomaiyar4654d992018-04-19 05:38:37 +053055PKG_CHECK_MODULES([CRYPTO], [libcrypto >= 1.0.2g], ,[AC_MSG_ERROR([can't find openssl libcrypto])])
Patrick Venture67195862019-02-13 08:24:00 -080056PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging])
57PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces])
58PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus])
Patrick Venture97c22e12019-02-12 07:39:02 -080059AC_CHECK_HEADER(nlohmann/json.hpp, [], [AC_MSG_ERROR([Could not find nlohmann/json.hpp])])
Matthew Barth3cff7ed2016-07-27 14:50:51 -050060
William A. Kennington III047412c2018-12-10 15:26:19 -080061AS_IF([test "x$enable_softoff" != "xno"], [
Patrick Venture67195862019-02-13 08:24:00 -080062 PKG_CHECK_MODULES([SDEVENTPLUS], [sdeventplus])
William A. Kennington III4f67cc32018-10-18 15:24:49 -070063
Vishwanatha Subbanna506aa0f2017-01-24 14:58:25 +053064 # Check for sdbus++ tool
William A. Kennington III047412c2018-12-10 15:26:19 -080065 AC_PATH_PROG([SDBUSPLUSPLUS], [sdbus++])
Vishwanatha Subbanna506aa0f2017-01-24 14:58:25 +053066 AS_IF([test "x$SDBUSPLUSPLUS" == "x"],
67 AC_MSG_ERROR([Cannot find sdbus++]))
William A. Kennington III047412c2018-12-10 15:26:19 -080068])
Matthew Barth3cff7ed2016-07-27 14:50:51 -050069
70# Checks for typedefs, structures, and compiler characteristics.
William A. Kennington III687a4362018-10-18 15:22:43 -070071AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory])
Matthew Barth00b1e5b2016-09-09 12:15:46 -050072AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CFLAGS])
73AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS])
Matthew Barth3cff7ed2016-07-27 14:50:51 -050074
75# Checks for library functions.
Patrick Williams686df742016-09-02 17:52:59 -050076LT_INIT([dlopen disable-static shared])
Matthew Barth3cff7ed2016-07-27 14:50:51 -050077LT_LIB_DLLOAD
Matthew Barth3cff7ed2016-07-27 14:50:51 -050078
Matthew Barth00b1e5b2016-09-09 12:15:46 -050079# Check/set gtest specific functions.
Peter Hanson4a589852017-06-07 17:40:45 -070080PKG_CHECK_MODULES([GTEST], [gtest], [], [AC_MSG_NOTICE([gtest not found, tests will not build])])
81PKG_CHECK_MODULES([GTEST_MAIN], [gtest_main], [], [AC_MSG_NOTICE([gtest_main not found, tests will not build])])
Matthew Barth00b1e5b2016-09-09 12:15:46 -050082
83AC_ARG_ENABLE([oe-sdk],
84 AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.])
85)
86AC_ARG_VAR(OECORE_TARGET_SYSROOT,
87 [Path to the OE SDK SYSROOT])
88AS_IF([test "x$enable_oe_sdk" == "xyes"],
89 AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"],
90 AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk])
91 )
92 AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT])
93 [
94 testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib"
95 testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib"
96 testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`"
97 ]
98 AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
99)
100
Emily Shafferc07e72c2018-06-18 10:37:31 -0700101# Add code coverage tool
102AX_CODE_COVERAGE
William A. Kennington III5023aa92019-04-04 18:00:09 -0700103AS_IF([test "x$CODE_COVERAGE_ENABLED" = "xyes"], [
104 AX_APPEND_COMPILE_FLAGS([-DHAVE_GCOV], [CODE_COVERAGE_CPPFLAGS])
105])
106m4_ifdef([_AX_CODE_COVERAGE_RULES],
107 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])],
108 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])])
109AX_ADD_AM_MACRO_STATIC([])
110
Emily Shafferc07e72c2018-06-18 10:37:31 -0700111
Tom Joseph51cb8ee2017-02-21 16:22:33 +0530112AC_ARG_VAR(WHITELIST_CONF, [Paths to IPMI whitelisted commands conf files. (default = ${srcdir}/host-ipmid-whitelist.conf)])
113if test -z "$WHITELIST_CONF"; then
114 WHITELIST_CONF=${srcdir}/host-ipmid-whitelist.conf
115fi
116
Brad Bishop2a5d8d12019-06-06 21:43:56 -0400117AS_IF([test "x$SENSOR_YAML_GEN" == "x"], [SENSOR_YAML_GEN="$srcdir/scripts/sensor-example.yaml"])
Ratan Gupta28c2e732017-03-04 08:53:52 +0530118SENSORGEN="$PYTHON ${srcdir}/scripts/sensor_gen.py -i $SENSOR_YAML_GEN"
Vernon Mauery5f7ac712019-04-30 11:19:08 -0700119AC_SUBST(SENSOR_YAML_GEN)
Ratan Gupta28c2e732017-03-04 08:53:52 +0530120AC_SUBST(SENSORGEN)
121
Brad Bishop2a5d8d12019-06-06 21:43:56 -0400122AS_IF([test "x$INVSENSOR_YAML_GEN" == "x"], [INVSENSOR_YAML_GEN="$srcdir/scripts/inventory-sensor-example.yaml"])
Tom Josephe19540e2019-02-04 14:06:58 +0530123INVSENSORGEN="$PYTHON ${srcdir}/scripts/inventory-sensor.py -i $INVSENSOR_YAML_GEN"
Vernon Mauery5f7ac712019-04-30 11:19:08 -0700124AC_SUBST(INVSENSOR_YAML_GEN)
Tom Josephe19540e2019-02-04 14:06:58 +0530125AC_SUBST(INVSENSORGEN)
126
Brad Bishop2a5d8d12019-06-06 21:43:56 -0400127AS_IF([test "x$FRU_YAML_GEN" == "x"], [FRU_YAML_GEN="$srcdir/scripts/fru-read-example.yaml"])
Marri Devender Raoa62bacc2017-06-04 23:40:16 -0500128FRUGEN="$PYTHON $srcdir/scripts/fru_gen.py -i $FRU_YAML_GEN"
Vernon Mauery5f7ac712019-04-30 11:19:08 -0700129AC_SUBST(FRU_YAML_GEN)
Marri Devender Raoa62bacc2017-06-04 23:40:16 -0500130AC_SUBST(FRUGEN)
131
Brad Bishop2a5d8d12019-06-06 21:43:56 -0400132AS_IF([test "x$ENTITY_YAML_GEN" == "x"], [ENTITY_YAML_GEN="$srcdir/scripts/entity-example.yaml"])
Jaghathiswari Rankappagounder Natarajan9c118942019-02-12 13:22:55 -0800133ENTITYGEN="$PYTHON $srcdir/scripts/entity_gen.py -i $ENTITY_YAML_GEN"
Vernon Mauery5f7ac712019-04-30 11:19:08 -0700134AC_SUBST(ENTITY_YAML_GEN)
Jaghathiswari Rankappagounder Natarajan9c118942019-02-12 13:22:55 -0800135AC_SUBST(ENTITYGEN)
136
Tom Joseph6edc8a02017-06-30 18:52:56 +0530137AC_DEFINE(CALLOUT_FWD_ASSOCIATION, "callout", [The name of the callout's forward association.])
138AC_DEFINE(BOARD_SENSOR, "/xyz/openbmc_project/inventory/system/chassis/motherboard", [The inventory path to the motherboard fault sensor.])
139AC_DEFINE(SYSTEM_SENSOR, "/xyz/openbmc_project/inventory/system", [The inventory path to the system event sensor.])
140
Vishwanatha Subbanna506aa0f2017-01-24 14:58:25 +0530141# Soft Power off related.
142AS_IF([test "x$enable_softoff" != "xno"],
143 # Dbus service name
144 [AC_ARG_VAR(SOFTOFF_BUSNAME, [The Dbus busname to own])]
145 AS_IF([test "x$SOFTOFF_BUSNAME" == "x"],
146 [SOFTOFF_BUSNAME="xyz.openbmc_project.Ipmi.Internal.SoftPowerOff"])
147 [AC_DEFINE_UNQUOTED([SOFTOFF_BUSNAME], ["$SOFTOFF_BUSNAME"], [The Dbus busname to own])]
148
149 # Service dbus root
150 [AC_ARG_VAR(SOFTOFF_OBJPATH, [The SoftPowerOff Dbus root])]
151 AS_IF([test "x$SOFTOFF_OBJPATH" == "x"],
Vishwanatha Subbannab891a572017-03-31 11:34:48 +0530152 [SOFTOFF_OBJPATH="/xyz/openbmc_project/ipmi/internal/soft_power_off"])
Vishwanatha Subbanna506aa0f2017-01-24 14:58:25 +0530153 [AC_DEFINE_UNQUOTED([SOFTOFF_OBJPATH], ["$SOFTOFF_OBJPATH"], [The SoftPowerOff Dbus root])]
Vishwanatha Subbannad27e71e2017-02-01 18:02:38 +0530154
155 # Timeouts in SECONDS for SoftPowerOff protocol
Andrew Geissler6fcdc212018-01-26 11:53:46 -0800156 [AC_ARG_VAR(IPMI_SMS_ATN_ACK_TIMEOUT_SECS, \
157 [Initial timeout for host to ack and query SMS_ATN from BMC])]
158 [AC_DEFINE_UNQUOTED([IPMI_SMS_ATN_ACK_TIMEOUT_SECS], [30], \
159 [Timeout for host to ack and query SMS_ATN from BMC])]
Vishwanatha Subbanna31272b82017-02-01 18:53:14 +0530160
Andrew Geissler48ce0722017-08-16 19:51:51 -0500161 [AC_ARG_VAR(IPMI_HOST_SHUTDOWN_COMPLETE_TIMEOUT_SECS, [Wait time for host to shutdown])]
162 [AC_DEFINE_UNQUOTED([IPMI_HOST_SHUTDOWN_COMPLETE_TIMEOUT_SECS], [45*60], [Wait time for host to shutdown])]
Andrew Geisslera6e3a302017-05-31 19:34:00 -0500163
164 # Indicates an in-band power off or reboot request from the host
165 # This file is used to ensure the soft off service does not run for host
166 # initiated shutdown or reboot requests
167 [AC_ARG_VAR(HOST_INBAND_REQUEST_DIR, [Directory used to indicate the host has initiated a shutdown or reboot])]
168 AS_IF([test "x$HOST_INBAND_REQUEST_DIR" == "x"],
169 [HOST_INBAND_REQUEST_DIR="/run/openbmc/"])
170 [AC_DEFINE_UNQUOTED([HOST_INBAND_REQUEST_DIR], ["$HOST_INBAND_REQUEST_DIR"], [Directory to store host initiated shutdown file])]
171
172 [AC_ARG_VAR(HOST_INBAND_REQUEST_FILE, [File which indicates the host has initiated a shutdown or reboot])]
173 AS_IF([test "x$HOST_INBAND_REQUEST_FILE" == "x"],
174 [HOST_INBAND_REQUEST_FILE="host@%u-request"])
175 [AC_DEFINE_UNQUOTED([HOST_INBAND_REQUEST_FILE], ["$HOST_INBAND_REQUEST_FILE"], [File to create if host has initiated shutdown or reboot])]
Vishwanatha Subbanna506aa0f2017-01-24 14:58:25 +0530176)
177
Andrew Geissler62817fa92017-03-20 14:20:49 -0500178# Control Host Interfaces
179# Dbus service name
180AC_ARG_VAR(CONTROL_HOST_BUSNAME, [The Control Host Dbus busname to own])
181AS_IF([test "x$CONTROL_HOST_BUSNAME" == "x"],
182 [CONTROL_HOST_BUSNAME="xyz.openbmc_project.Control.Host"])
183AC_DEFINE_UNQUOTED([CONTROL_HOST_BUSNAME], ["$CONTROL_HOST_BUSNAME"], [The Control Host Dbus busname to own])
184
Vishwanatha Subbanna3eb117a2017-07-12 16:13:49 +0530185# Host object name in the D-Bus
186AC_ARG_VAR(HOST_NAME, [The Host name in the object path])
187AS_IF([test "x$HOST_NAME" == "x"],
188 [HOST_NAME="host"])
189AC_DEFINE_UNQUOTED([HOST_NAME], ["$HOST_NAME"], [The Host name in the object path])
190
191# Service dbus object manager
192AC_ARG_VAR(CONTROL_HOST_OBJ_MGR, [The Control Host D-Bus Object Manager])
193AS_IF([test "x$CONTROL_HOST_OBJ_MGR" == "x"],
194 [CONTROL_HOST_OBJ_MGR="/xyz/openbmc_project/control"])
195AC_DEFINE_UNQUOTED([CONTROL_HOST_OBJ_MGR], ["$CONTROL_HOST_OBJ_MGR"], [The Control Host D-Bus Object Manager])
Andrew Geissler62817fa92017-03-20 14:20:49 -0500196
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600197# Power reading sensor configuration file
198AC_ARG_VAR(POWER_READING_SENSOR, [Power reading sensor configuration file])
199AS_IF([test "x$POWER_READING_SENSOR" == "x"],[POWER_READING_SENSOR="/usr/share/ipmi-providers/power_reading.json"])
200AC_DEFINE_UNQUOTED([POWER_READING_SENSOR], ["$POWER_READING_SENSOR"], [Power reading sensor configuration file])
201
Patrick Venture15e95f22018-11-14 19:25:08 -0800202AC_ARG_VAR(HOST_IPMI_LIB_PATH, [The file path to search for libraries.])
Vernon Mauery41c79e62019-02-04 15:54:28 -0800203AS_IF([test "x$HOST_IPMI_LIB_PATH" == "x"], [HOST_IPMI_LIB_PATH="/usr/lib/ipmid-providers/"])
Patrick Venture15e95f22018-11-14 19:25:08 -0800204AC_DEFINE_UNQUOTED([HOST_IPMI_LIB_PATH], ["$HOST_IPMI_LIB_PATH"], [The file path to search for libraries.])
205
Brandon Kim9cf85622019-06-19 12:05:08 -0700206# When a sensor read fails, hwmon will update the OperationalState interface's Functional property.
207# This will mark the sensor as not functional and we will skip reading from that sensor.
208AC_ARG_ENABLE([update-functional-on-fail],
209 AS_HELP_STRING(
210 [--enable-update-functional-on-fail],
211 [Check functional property to skip reading from faulty sensors.]
212 )
213)
214
215AC_ARG_VAR(UPDATE_FUNCTIONAL_ON_FAIL, [Check functional property to skip reading from faulty sensors.])
216AS_IF(
217 [test "x$enable_update_functional_on_fail" == "xyes"],
218 [UPDATE_FUNCTIONAL_ON_FAIL="yes"]
219 AC_DEFINE_UNQUOTED(
220 [UPDATE_FUNCTIONAL_ON_FAIL],
221 ["$UPDATE_FUNCTIONAL_ON_FAIL"],
222 [Check functional property to skip reading from faulty sensors.]
223 )
224)
225
ofery61d8dcc2019-06-10 16:02:37 -0700226# When disable-libuserlayer flag is set, libuserlayer won't be included in the build.
227AC_ARG_ENABLE([libuserlayer],
228 AS_HELP_STRING([--disable-libuserlayer], [Set a flag to exclude libuserlayer])
229)
230AM_CONDITIONAL(FEATURE_LIBUSERLAYER, [test "x$enable_libuserlayer" != "xno"])
231
Johnathan Manteyb87034e2019-09-16 10:50:50 -0700232# When enable-transport-oem flag is set, the transporthandler_oem.cpp contents
233# are compiled and added to the project. The transporthandler_oem.cpp file is
234# copied from your own customization layer in the
235# phosphor-ipmi-host_%.bbappend file. It is not necessary to create this file
236# unless OEM Parameter extensions are required.
237AC_ARG_ENABLE([transport_oem],
238 [ --enable-transport-oem Enable/disable OEM Parameter extensions],
239 [case "${enableval}" in
240 yes) transport_oem=true ;;
241 no) transport_oem=false ;;
242 *) AC_MSG_ERROR([bad value ${enableval} for --enable-transport_oem]) ;;
243 esac],[transport_oem=false]
244 )
245AM_CONDITIONAL([FEATURE_TRANSPORT_OEM], [test x$transport_oem = xtrue])
246
Matthew Barth00b1e5b2016-09-09 12:15:46 -0500247# Create configured output
William A. Kennington III194375f2018-12-14 02:14:33 -0800248AC_CONFIG_FILES([
249 Makefile
250 include/Makefile
251 libipmid/Makefile
252 libipmid/libipmid.pc
253 libipmid-host/Makefile
254 libipmid-host/libipmid-host.pc
255 softoff/Makefile
256 test/Makefile
257 user_channel/Makefile
258])
Matthew Barth3cff7ed2016-07-27 14:50:51 -0500259AC_OUTPUT