blob: e47c4f8633a78daf66031b1f4062e7563e87c789 [file] [log] [blame]
Andrew Geissler36529022016-11-29 15:23:54 -06001AC_PREREQ([2.69])
2AC_INIT([phosphor-state-manager], [1.0], [https://github.com/openbmc/phosphor-state-manager/issues])
3AC_LANG([C++])
4AC_CONFIG_HEADERS([config.h])
Andrew Geissler693eaed2019-08-02 14:12:28 -05005AM_INIT_AUTOMAKE([subdir-objects -Wall -Wno-portability -Werror foreign])
Andrew Geissler36529022016-11-29 15:23:54 -06006AM_SILENT_RULES([yes])
7
8# Checks for programs
9AC_PROG_CXX
10AC_PROG_INSTALL #Checks/sets the install variable to be used
11AC_PROG_MAKE_SET
12
13# Check for libraries
14PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221])
Patrick Venture64d60972019-02-13 15:49:27 -080015PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces])
16PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus])
17PKG_CHECK_MODULES([SDEVENTPLUS], [sdeventplus])
18PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging])
Andrew Geissler36529022016-11-29 15:23:54 -060019
Andrew Geissleree3a2c82019-07-30 15:16:20 -050020# We need the header only CLI library
21AC_CHECK_HEADERS(
22 [CLI/CLI.hpp],
23 [],
24 [AC_MSG_ERROR([Could not find CLI11 CLI/CLI.hpp])]
25)
Andrew Geissler693eaed2019-08-02 14:12:28 -050026AC_CHECK_HEADER(nlohmann/json.hpp, ,
27 [AC_MSG_ERROR([Could not find nlohmann/json.hpp... nlohmann/json package required])])
Andrew Geissleree3a2c82019-07-30 15:16:20 -050028
Andrew Geissler36529022016-11-29 15:23:54 -060029# Checks for typedefs, structures, and compiler characteristics.
Vernon Mauery6425ab72018-10-04 10:31:50 -070030AX_CXX_COMPILE_STDCXX_17([noext])
Andrew Geissler36529022016-11-29 15:23:54 -060031AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS])
32
Matthew Barth6e0b5092017-01-19 12:50:25 -060033# Checks for library functions
Josh D. Kingbdd9cb72016-12-19 11:13:43 -060034LT_INIT # Removes WARNING: unrecognized options: --with-libtool-sysroot
Matthew Barth6e0b5092017-01-19 12:50:25 -060035
Andrew Geisslera90a31a2016-12-13 16:16:28 -060036AC_ARG_VAR(HOST_BUSNAME, [The Host Dbus busname to own])
37AS_IF([test "x$HOST_BUSNAME" == "x"], [HOST_BUSNAME="xyz.openbmc_project.State.Host"])
38AC_DEFINE_UNQUOTED([HOST_BUSNAME], ["$HOST_BUSNAME"], [The Host DBus busname to own])
Andrew Geissler36529022016-11-29 15:23:54 -060039
Andrew Geisslera90a31a2016-12-13 16:16:28 -060040AC_ARG_VAR(HOST_OBJPATH, [The host state manager Dbus root])
41AS_IF([test "x$HOST_OBJPATH" == "x"], [HOST_OBJPATH="/xyz/openbmc_project/state/host"])
42AC_DEFINE_UNQUOTED([HOST_OBJPATH], ["$HOST_OBJPATH"], [The host state manager Dbus root])
43
44AC_ARG_VAR(CHASSIS_BUSNAME, [The Chassis Dbus busname to own])
45AS_IF([test "x$CHASSIS_BUSNAME" == "x"], [CHASSIS_BUSNAME="xyz.openbmc_project.State.Chassis"])
46AC_DEFINE_UNQUOTED([CHASSIS_BUSNAME], ["$CHASSIS_BUSNAME"], [The Chassis DBus busname to own])
47
48AC_ARG_VAR(CHASSIS_OBJPATH, [The chassis state manager Dbus root])
49AS_IF([test "x$CHASSIS_OBJPATH" == "x"], [CHASSIS_OBJPATH="/xyz/openbmc_project/state/chassis"])
50AC_DEFINE_UNQUOTED([CHASSIS_OBJPATH], ["$CHASSIS_OBJPATH"], [The chassis state manager Dbus root])
Andrew Geissler36529022016-11-29 15:23:54 -060051
Josh D. Kingbdd9cb72016-12-19 11:13:43 -060052AC_ARG_VAR(BMC_BUSNAME, [The BMC Dbus busname to own])
53AS_IF([test "x$BMC_BUSNAME" == "x"], [BMC_BUSNAME="xyz.openbmc_project.State.BMC"])
54AC_DEFINE_UNQUOTED([BMC_BUSNAME], ["$BMC_BUSNAME"], [The BMC DBus busname to own])
55
56AC_ARG_VAR(BMC_OBJPATH, [The BMC state manager Dbus root])
Josh D. King3362ea52017-02-23 11:32:33 -060057AS_IF([test "x$BMC_OBJPATH" == "x"], [BMC_OBJPATH="/xyz/openbmc_project/state/bmc"])
Josh D. Kingbdd9cb72016-12-19 11:13:43 -060058AC_DEFINE_UNQUOTED([BMC_OBJPATH], ["$BMC_OBJPATH"], [The BMC state manager Dbus root])
59
Andrew Geissler07d0ed52017-03-28 15:44:18 -050060AC_ARG_VAR(HOST_RUNNING_FILE, [File to create if host is running])
Andrew Geisslerb385c432019-09-12 13:35:07 -050061AS_IF([test "x$HOST_RUNNING_FILE" == "x"], [HOST_RUNNING_FILE="/run/openbmc/host@%d-on"])
Andrew Geissler07d0ed52017-03-28 15:44:18 -050062AC_DEFINE_UNQUOTED([HOST_RUNNING_FILE], ["$HOST_RUNNING_FILE"], [File to create if host is running])
63
Dhruvaraj Subhashchandran3f475242017-07-12 00:44:27 -050064AC_ARG_VAR(HOST_STATE_PERSIST_PATH, [Path of file for storing requested host state.])
65AS_IF([test "x$HOST_STATE_PERSIST_PATH" == "x"], \
66 [HOST_STATE_PERSIST_PATH="/var/lib/phosphor-state-manager/requestedHostTransition"])
67AC_DEFINE_UNQUOTED([HOST_STATE_PERSIST_PATH], ["$HOST_STATE_PERSIST_PATH"], \
68 [Path of file for storing requested host state.])
69
Nagaraju Goruganticb781fe2018-04-06 13:41:01 -050070AC_ARG_VAR(POH_COUNTER_PERSIST_PATH, [Path of file for storing POH counter.])
71AS_IF([test "x$POH_COUNTER_PERSIST_PATH" == "x"], \
72 [POH_COUNTER_PERSIST_PATH="/var/lib/phosphor-state-manager/POHCounter"])
73AC_DEFINE_UNQUOTED([POH_COUNTER_PERSIST_PATH], ["$POH_COUNTER_PERSIST_PATH"], \
74 [Path of file for storing POH counter.])
75
Matt Spinler9eab9862018-07-11 14:13:52 -050076AC_ARG_VAR(CHASSIS_STATE_CHANGE_PERSIST_PATH, [Path of file for storing the state change time.])
77AS_IF([test "x$CHASSIS_STATE_CHANGE_PERSIST_PATH" == "x"], \
78 [CHASSIS_STATE_CHANGE_PERSIST_PATH="/var/lib/phosphor-state-manager/chassisStateChangeTime"])
79AC_DEFINE_UNQUOTED([CHASSIS_STATE_CHANGE_PERSIST_PATH], ["$CHASSIS_STATE_CHANGE_PERSIST_PATH"], \
80 [Path of file for storing the state change time.])
81
Dhruvaraj Subhashchandran2710e732017-06-19 06:43:22 -050082AC_ARG_VAR(BOOT_COUNT_MAX_ALLOWED, [The maximum allowed reboot count])
83AS_IF([test "x$BOOT_COUNT_MAX_ALLOWED" == "x"], [BOOT_COUNT_MAX_ALLOWED=3])
84AC_DEFINE_UNQUOTED([BOOT_COUNT_MAX_ALLOWED], [$BOOT_COUNT_MAX_ALLOWED], [The maximum allowed reboot count])
85
Andrew Geissler36529022016-11-29 15:23:54 -060086# Check for header files.
Gunnar Mills31292082017-10-25 20:43:27 -050087AC_CHECK_HEADER(systemd/sd-bus.h, ,[AC_MSG_ERROR([Could not find systemd/sd-bus.h...systemd development package required])])
Andrew Geissler36529022016-11-29 15:23:54 -060088AC_CHECK_HEADER(sdbusplus/server.hpp, ,[AC_MSG_ERROR([Could not find sdbusplus/server.hpp...openbmc/sdbusplus package required])])
Saqib Khana8006a22017-02-14 11:37:08 -060089AC_CHECK_HEADER(phosphor-logging/log.hpp, ,[AC_MSG_ERROR([Could not find phosphor-logging/log.hpp...openbmc/phosphor-logging package required])])
Andrew Geissler1e3bf942016-12-13 15:32:22 -060090
Vishwanatha Subbanna0a838732017-10-05 12:43:19 +053091AC_ARG_VAR(CLASS_VERSION, [Class version to register with Cereal])
92AS_IF([test "x$CLASS_VERSION" == "x"], [CLASS_VERSION=1])
93AC_DEFINE_UNQUOTED([CLASS_VERSION], [$CLASS_VERSION], [Class version to register with Cereal])
94
Andrew Geissler693eaed2019-08-02 14:12:28 -050095# Make it possible for users to choose if they want test support
96# explicitly or not at all
97AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests],
98 [Build test cases]))
99
100 # Check/set gtest specific functions
101AS_IF([test "x$enable_tests" != "xno"], [
102 PKG_CHECK_MODULES([GTEST], [gtest], [], [true])
103 PKG_CHECK_MODULES([GMOCK], [gmock], [], [true])
104 AX_PTHREAD
105
106 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
107 AX_APPEND_COMPILE_FLAGS([$GTEST_CFLAGS], [CPPFLAGS])
108 AC_CHECK_HEADERS([gtest/gtest.h], [
109 AS_IF([test "x$GTEST_CFLAGS" = "x"], [
110 AS_IF([test "x$PTHREAD_CFLAGS" = "x"], [
111 AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=0"], [GTEST_CFLAGS])
112 ], [
113 AX_APPEND_COMPILE_FLAGS(["-DGTEST_HAS_PTHREAD=1"], [GTEST_CFLAGS])
114 AX_APPEND_COMPILE_FLAGS([$PTHREAD_CFLAGS], [GTEST_CFLAGS])
115 ])
116 ])
117 ], [
118 AS_IF([test "x$enable_tests" = "xyes"], [
119 AC_MSG_ERROR([Testing enabled but could not find gtest/gtest.h])
120 ])
121 ])
122 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
123
124 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
125 AX_APPEND_COMPILE_FLAGS([$GMOCK_CFLAGS], [CPPFLAGS])
126 AC_CHECK_HEADERS([gmock/gmock.h], [], [
127 AS_IF([test "x$enable_tests" = "xyes"], [
128 AC_MSG_ERROR([Testing enabled but could not find gmock/gmock.h])
129 ])
130 ])
131 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [CPPFLAGS])
132
133 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
134 AX_APPEND_COMPILE_FLAGS([$GTEST_LIBS], [LDFLAGS])
135 AC_CHECK_LIB([gtest], [main], [
136 AS_IF([test "x$GTEST_LIBS" = "x"], [
137 AX_APPEND_COMPILE_FLAGS([-lgtest], [GTEST_LIBS])
138 ])
139 ], [
140 AS_IF([test "x$enable_tests" = "xyes"], [
141 AC_MSG_ERROR([Testing enabled but couldn't find gtest libs])
142 ])
143 ])
144 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
145
146 AX_SAVE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
147 AX_APPEND_COMPILE_FLAGS([$GMOCK_LIBS], [LDFLAGS])
148 AC_CHECK_LIB([gmock], [main], [
149 AS_IF([test "x$GMOCK_LIBS" = "x"], [
150 AX_APPEND_COMPILE_FLAGS([-lgmock], [GMOCK_LIBS])
151 ])
152 ], [
153 AS_IF([test "x$enable_tests" = "xyes"], [
154 AC_MSG_ERROR([Testing enabled but couldn't find gmock libs])
155 ])
156 ])
157 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
158])
159
160# Check for valgrind
161AS_IF([test "x$enable_tests" = "xno"], [enable_valgrind=no])
162m4_foreach([vgtool], [valgrind_tool_list],
163 [AX_VALGRIND_DFLT(vgtool, [off])])
164AX_VALGRIND_DFLT([memcheck], [on])
165AX_VALGRIND_CHECK
166AM_EXTRA_RECURSIVE_TARGETS([check-valgrind])
167m4_foreach([vgtool], [valgrind_tool_list],
168 [AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)])
169
170# Code coverage
171AX_CODE_COVERAGE
172
173m4_ifdef([_AX_CODE_COVERAGE_RULES],
174 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])],
175 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])])
176AX_ADD_AM_MACRO_STATIC([])
177
Andrew Geissler64400062019-08-13 13:43:23 -0500178PKG_PROG_PKG_CONFIG
179AC_ARG_WITH([systemdsystemunitdir],
180 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
181 [with_systemdsystemunitdir=auto])
182AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
183 def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
184 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
185 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
186 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
187 with_systemdsystemunitdir=no],
188 [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
189AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
190[AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
191
Andrew Geissler36529022016-11-29 15:23:54 -0600192AC_CONFIG_FILES([Makefile])
Andrew Geissler64400062019-08-13 13:43:23 -0500193AC_CONFIG_FILES([phosphor-systemd-target-monitor.service])
Andrew Geissler1e3bf942016-12-13 15:32:22 -0600194AC_OUTPUT