blob: 97f6e3818696947a17ccaba4ccc353bb989424f0 [file] [log] [blame]
Matthew Barthae0e96c2017-01-20 13:54:59 -06001# Initialization
2AC_PREREQ([2.69])
3AC_INIT([phosphor-fan-presence], [1.0],
4[https://github.com/openbmc/phosphor-fan-presence/issues])
5AC_LANG([C++])
6AC_CONFIG_HEADERS([config.h])
7AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz])
8AM_SILENT_RULES([yes])
9
Lei YUbd2e80a2018-09-19 11:17:09 +080010# Use gcc-ar and gcc-ranlib for static libraries built with -flto
11AC_SUBST([AR], [${ac_tool_prefix}gcc-ar])
12AC_SUBST([RANLIB], [${ac_tool_prefix}gcc-ranlib])
13
Matthew Barthae0e96c2017-01-20 13:54:59 -060014# Checks for programs.
15AC_PROG_CXX
16AM_PROG_AR
17AC_PROG_INSTALL
18AC_PROG_MAKE_SET
Brad Bishop93919bb2017-04-22 14:58:29 -040019
Matthew Barth681c98d2017-02-17 16:05:57 -060020# Python
Matthew Barthf24d7742020-03-17 16:12:15 -050021AM_PATH_PYTHON([3], [AC_SUBST([PYTHON], [echo "$PYTHON"])],
22[AC_MSG_ERROR([Minimum python version(3) not found])])
Matthew Barthae0e96c2017-01-20 13:54:59 -060023
24# Checks for typedefs, structures, and compiler characteristics.
Vernon Mauery48df9592018-10-04 10:08:13 -070025AX_CXX_COMPILE_STDCXX_17([noext])
Matthew Barthae0e96c2017-01-20 13:54:59 -060026AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS])
27
28# Checks for libraries.
Patrick Venture4b258ac2019-02-13 14:48:21 -080029PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus])
30PKG_CHECK_MODULES([SDEVENTPLUS], [sdeventplus])
31PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging])
32PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221])
33PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces])
34PKG_CHECK_MODULES([LIBEVDEV], [libevdev])
Matthew Barthf3e70472019-12-03 13:33:20 -060035PKG_CHECK_MODULES([STDPLUS], [stdplus])
Matthew Barth1826c732020-08-28 08:40:59 -050036PKG_CHECK_MODULES([FMT], [fmt])
Matthew Barth293477d2017-02-17 15:39:36 -060037
Matthew Barthae0e96c2017-01-20 13:54:59 -060038# Checks for library functions.
39LT_INIT # Required for systemd linking
40
Matt Spinler59c29c72017-04-27 11:17:28 -050041# Check/set gtest specific functions.
42AX_PTHREAD([GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=1"],[GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=0"])
43AC_SUBST(GTEST_CPPFLAGS)
44AC_ARG_ENABLE([oe-sdk],
45 AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.])
46)
47AC_ARG_VAR(OECORE_TARGET_SYSROOT,
48 [Path to the OE SDK SYSROOT])
49AS_IF([test "x$enable_oe_sdk" == "xyes"],
50 AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"],
51 AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk])
52 )
53 AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT])
54 [
55 testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib"
56 testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib"
57 testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`"
58 ]
59 AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
60)
61
Matthew Barthcc194802020-01-09 13:55:34 -060062AC_ARG_ENABLE([json],
63 AS_HELP_STRING([--enable-json], [Use json at runtime to configure fan packages.]))
Brad Bishop93919bb2017-04-22 14:58:29 -040064AC_ARG_ENABLE([presence],
65 AS_HELP_STRING([--disable-presence], [Disable fan presence package.]))
66AC_ARG_ENABLE([control],
67 AS_HELP_STRING([--disable-control], [Disable fan control package.]))
Brandon Wymanca60e102017-03-29 17:06:02 -050068AC_ARG_ENABLE([cooling-type],
69 AS_HELP_STRING([--disable-cooling-type], [Disable cooling-type package.]))
Matt Spinleraf5d4c52017-05-16 10:38:43 -050070AC_ARG_ENABLE([monitor],
71 AS_HELP_STRING([--disable-monitor], [Disable monitor]))
Brad Bishop93919bb2017-04-22 14:58:29 -040072
Matthew Barthcc194802020-01-09 13:55:34 -060073AM_CONDITIONAL([WANT_JSON], [test "x$enable_json" == "xyes"])
Brad Bishop93919bb2017-04-22 14:58:29 -040074AM_CONDITIONAL([WANT_PRESENCE], [test "x$enable_presence" != "xno"])
75AM_CONDITIONAL([WANT_CONTROL], [test "x$enable_control" != "xno"])
Brandon Wymance822442017-04-10 17:48:02 -050076AM_CONDITIONAL([WANT_COOLING_TYPE], [test "x$enable_cooling_type" != "xno"])
Matt Spinlere567dd22017-04-27 12:27:17 -050077AM_CONDITIONAL([WANT_MONITOR], [test "x$enable_monitor" != "xno"])
Brad Bishop93919bb2017-04-22 14:58:29 -040078
79# Package specific checks.
80AS_IF([test "x$enable_presence" != "xno"], [
Matthew Barthcc194802020-01-09 13:55:34 -060081 # Use runtime(json) config, otherwise default to compile time(yaml) config
82 AM_COND_IF([WANT_JSON],
83 [
84 AC_CHECK_HEADER(nlohmann/json.hpp, ,
85 [AC_MSG_ERROR([Could not find nlohmann/json.hpp... nlohmann/json package required])])
86 # Set config flag for runtime json usage
87 AC_DEFINE([PRESENCE_USE_JSON], [1], [Fan presence use runtime json configuration])
88 AC_MSG_NOTICE([Fan presence json configuration usage enabled])
89 ],
90 [
91 # Add optional yaml file argument
92 AC_ARG_VAR(PRESENCE_CONFIG, [The fan presence config file.])
Brad Bishop76596b22017-06-13 14:39:13 -040093
Brad Bishop76596b22017-06-13 14:39:13 -040094 AS_IF([test "x$PRESENCE_CONFIG" == "x"],
95 [PRESENCE_CONFIG="\${top_srcdir}/presence/example/example.yaml"])
96
Brad Bishop76596b22017-06-13 14:39:13 -040097 AC_DEFINE_UNQUOTED([PRESENCE_CONFIG], ["$PRESENCE_CONFIG"],
98 [The fan presence config file.])
Brad Bishop93919bb2017-04-22 14:58:29 -040099
Brad Bishop76596b22017-06-13 14:39:13 -0400100 AC_SUBST([PFPGEN],
101 ["$PYTHON \${top_srcdir}/presence/pfpgen.py generate-cpp -i $PRESENCE_CONFIG"])
Matthew Barthcc194802020-01-09 13:55:34 -0600102 ])
Matt Spinler635de8c2020-09-24 13:51:40 -0500103
104 AC_ARG_VAR(NUM_PRESENCE_LOG_ENTRIES, [Maximum number of entries in the message log])
105 AS_IF([test "x$NUM_PRESENCE_LOG_ENTRIES" == "x"], [NUM_PRESENCE_LOG_ENTRIES=50])
106 AC_DEFINE_UNQUOTED([NUM_PRESENCE_LOG_ENTRIES], [$NUM_PRESENCE_LOG_ENTRIES],
107 [Maximum number of entries in the message log])
108
Matthew Barthcc194802020-01-09 13:55:34 -0600109 AC_CONFIG_FILES([presence/Makefile])
110])
Brad Bishop93919bb2017-04-22 14:58:29 -0400111
112AS_IF([test "x$enable_control" != "xno"], [
Matthew Barthd87f89f2020-07-30 10:41:32 -0500113 # Add fan control Dbus attributes
114 AC_ARG_VAR(CONTROL_BUSNAME, [The fan control busname to own])
115 AS_IF([test "x$CONTROL_BUSNAME" == "x"],
116 [CONTROL_BUSNAME="xyz.openbmc_project.Control.Thermal"])
117 AC_DEFINE_UNQUOTED([CONTROL_BUSNAME], ["$CONTROL_BUSNAME"],
118 [The fan control busname to own])
Matthew Barth14cc0432019-01-16 15:06:41 -0600119
Matthew Barthd87f89f2020-07-30 10:41:32 -0500120 AC_ARG_VAR(CONTROL_OBJPATH, [The fan control root object path])
121 AS_IF([test "x$CONTROL_OBJPATH" == "x"],
122 [CONTROL_OBJPATH="/xyz/openbmc_project/control/thermal"])
123 AC_DEFINE_UNQUOTED([CONTROL_OBJPATH], ["$CONTROL_OBJPATH"],
124 [The fan control root object path])
Matthew Barth14cc0432019-01-16 15:06:41 -0600125
Matthew Barthd87f89f2020-07-30 10:41:32 -0500126 AC_ARG_VAR(CONTROL_PERSIST_ROOT_PATH, [Root path for persisting zone property states])
127 AS_IF([test "x$CONTROL_PERSIST_ROOT_PATH" == "x"],
128 [CONTROL_PERSIST_ROOT_PATH="/var/lib/phosphor-fan-presence/control"])
129 AC_DEFINE_UNQUOTED([CONTROL_PERSIST_ROOT_PATH], ["$CONTROL_PERSIST_ROOT_PATH"],
130 [Root path for persisting zone property states])
Matthew Barthcc8912e2019-01-21 11:35:27 -0600131
Matthew Barthd87f89f2020-07-30 10:41:32 -0500132 # Use runtime(json) config, otherwise default to compile time(yaml) config
133 AM_COND_IF([WANT_JSON],
134 [
135 AC_CHECK_HEADER(nlohmann/json.hpp, ,
136 [AC_MSG_ERROR([Could not find nlohmann/json.hpp... nlohmann/json package required])])
137 # Set config flag for runtime json usage
138 AC_DEFINE([CONTROL_USE_JSON], [1], [Fan control use runtime json configuration])
139 AC_MSG_NOTICE([Fan control json configuration usage enabled])
140 ],
141 [
142 # Add optional yaml file arguments
143 AC_ARG_VAR(FAN_DEF_YAML_FILE,
144 [The fan definition file to use])
145 AS_IF([test "x$FAN_DEF_YAML_FILE" == "x"],
146 [FAN_DEF_YAML_FILE="\${top_srcdir}/control/example/fans.yaml"])
147 AC_DEFINE_UNQUOTED([FAN_DEF_YAML_FILE], ["$FAN_DEF_YAML_FILE"],
148 [The fan definition file to use])
Matt Spinler77d32d12017-04-12 09:51:41 -0500149
Matthew Barthd87f89f2020-07-30 10:41:32 -0500150 AC_ARG_VAR(FAN_ZONE_YAML_FILE,
151 [The fan zone definition file to use])
152 AS_IF([test "x$FAN_ZONE_YAML_FILE" == "x"],
153 [FAN_ZONE_YAML_FILE="\${top_srcdir}/control/example/zones.yaml"])
154 AC_DEFINE_UNQUOTED([FAN_ZONE_YAML_FILE], ["$FAN_ZONE_YAML_FILE"],
155 [The fan zone definition file to use])
Matt Spinler77d32d12017-04-12 09:51:41 -0500156
Matthew Barthd87f89f2020-07-30 10:41:32 -0500157 AC_ARG_VAR(ZONE_EVENTS_YAML_FILE,
158 [The zone events definition file to use])
159 AS_IF([test "x$ZONE_EVENTS_YAML_FILE" == "x"],
160 [ZONE_EVENTS_YAML_FILE="\${top_srcdir}/control/example/events.yaml"])
161 AC_DEFINE_UNQUOTED([ZONE_EVENTS_YAML_FILE], ["$ZONE_EVENTS_YAML_FILE"],
162 [The zone events definition file to use])
Matthew Barthd4d0f082017-05-16 13:51:10 -0500163
Matthew Barthd87f89f2020-07-30 10:41:32 -0500164 AC_ARG_VAR(ZONE_CONDITIONS_YAML_FILE,
165 [The zone conditions definition file to use])
166 AS_IF([test "x$ZONE_CONDITIONS_YAML_FILE" == "x"],
167 [ZONE_CONDITIONS_YAML_FILE="\${top_srcdir}/control/example/zone_conditions.yaml"])
168 AC_DEFINE_UNQUOTED([ZONE_CONDITIONS_YAML_FILE], ["$ZONE_CONDITIONS_YAML_FILE"],
169 [The zone conditions definition file to use])
Gunnar Mills28c1a092017-06-26 11:16:41 -0500170
Matthew Barthd87f89f2020-07-30 10:41:32 -0500171 AC_SUBST([GEN_FAN_ZONE_DEFS],
172 ["$PYTHON \${top_srcdir}/control/gen-fan-zone-defs.py \
173 -f $FAN_DEF_YAML_FILE \
174 -z $FAN_ZONE_YAML_FILE \
175 -e $ZONE_EVENTS_YAML_FILE \
176 -c $ZONE_CONDITIONS_YAML_FILE"])
177 ])
Matthew Barth167d2dd2020-08-04 12:19:16 -0500178 AC_CONFIG_FILES([control/json/Makefile control/Makefile])
Brad Bishop93919bb2017-04-22 14:58:29 -0400179])
Matthew Barth681c98d2017-02-17 16:05:57 -0600180
Brandon Wymance822442017-04-10 17:48:02 -0500181AS_IF([test "x$enable_cooling_type" != "xno"], [
Brandon Wymanfef02952017-03-31 18:13:21 -0500182 AC_CONFIG_FILES([cooling-type/Makefile])
Brandon Wymanca60e102017-03-29 17:06:02 -0500183])
Matthew Barthbedefd82020-06-02 15:39:56 -0500184
Matt Spinlere567dd22017-04-27 12:27:17 -0500185AS_IF([test "x$enable_monitor" != "xno"], [
Matthew Barthbedefd82020-06-02 15:39:56 -0500186 # Use runtime(json) config, otherwise default to compile time(yaml) config
187 AM_COND_IF([WANT_JSON],
188 [
189 AC_CHECK_HEADER(nlohmann/json.hpp, ,
190 [AC_MSG_ERROR([Could not find nlohmann/json.hpp... nlohmann/json package required])])
191 # Set config flag for runtime json usage
192 AC_DEFINE([MONITOR_USE_JSON], [1], [Fan monitor use runtime json configuration])
193 AC_MSG_NOTICE([Fan monitor json configuration usage enabled])
194 ],
195 [
196 AC_ARG_VAR(FAN_MONITOR_YAML_FILE,
197 [The fan monitor definition file to use])
198 AS_IF([test "x$FAN_MONITOR_YAML_FILE" == "x"],
199 [FAN_MONITOR_YAML_FILE="\${top_srcdir}/monitor/example/monitor.yaml"])
200 AC_DEFINE_UNQUOTED([FAN_MONITOR_YAML_FILE], ["$FAN_MONITOR_YAML_FILE"],
201 [The fan monitor definition file to use])
Matt Spinler14321842017-04-28 15:27:43 -0500202
Matthew Barthbedefd82020-06-02 15:39:56 -0500203 AC_SUBST([GEN_FAN_MONITOR_DEFS],
204 ["$PYTHON \${top_srcdir}/monitor/gen-fan-monitor-defs.py \
205 -m $FAN_MONITOR_YAML_FILE"])
206 ])
207 AC_CONFIG_FILES([monitor/Makefile])
Matt Spinlere567dd22017-04-27 12:27:17 -0500208])
Brandon Wymanca60e102017-03-29 17:06:02 -0500209
Matthew Barthae0e96c2017-01-20 13:54:59 -0600210# Create configured output
Matt Spinler635de8c2020-09-24 13:51:40 -0500211AC_CONFIG_FILES([Makefile test/Makefile presence/test/Makefile])
Matthew Barthae0e96c2017-01-20 13:54:59 -0600212AC_OUTPUT