blob: cd85d39fa0678d8fd8b03399c5863cd5fd2f166d [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
10# Checks for programs.
11AC_PROG_CXX
12AM_PROG_AR
13AC_PROG_INSTALL
14AC_PROG_MAKE_SET
Brad Bishop93919bb2017-04-22 14:58:29 -040015
Matthew Barth681c98d2017-02-17 16:05:57 -060016# Python
17AM_PATH_PYTHON([2.7], [AC_SUBST([PYTHON], [echo "$PYTHON"])],
18[AC_MSG_ERROR([Could not find python-2.7 installed...python-2.7 is required])])
Matthew Barthae0e96c2017-01-20 13:54:59 -060019
20# Checks for typedefs, structures, and compiler characteristics.
21AX_CXX_COMPILE_STDCXX_14([noext])
22AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS])
23
24# Checks for libraries.
Matthew Barth293477d2017-02-17 15:39:36 -060025PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus], ,
26[AC_MSG_ERROR([The openbmc/sdbusplus package is required])])
Matthew Barthfefdc452017-02-22 11:15:56 -060027PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging], ,
28[AC_MSG_ERROR([The openbmc/phosphor-logging package is required])])
Matt Spinlera5763ff2017-06-14 15:54:12 -050029PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221], ,
30[AC_MSG_ERROR([Could not find systemd...systemd developement package required])])
Dinesh Chinari618027a2017-06-26 23:26:50 -050031PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces], ,
32[AC_MSG_ERROR([Could not find phosphor-dbus-interfaces...openbmc/phosphor-dbus-interfaces package required])])
Matthew Barth293477d2017-02-17 15:39:36 -060033
Matthew Barthae0e96c2017-01-20 13:54:59 -060034# Checks for library functions.
35LT_INIT # Required for systemd linking
36
Matt Spinler59c29c72017-04-27 11:17:28 -050037# Check/set gtest specific functions.
38AX_PTHREAD([GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=1"],[GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=0"])
39AC_SUBST(GTEST_CPPFLAGS)
40AC_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)
43AC_ARG_VAR(OECORE_TARGET_SYSROOT,
44 [Path to the OE SDK SYSROOT])
45AS_IF([test "x$enable_oe_sdk" == "xyes"],
46 AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"],
47 AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk])
48 )
49 AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT])
50 [
51 testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib"
52 testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib"
53 testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`"
54 ]
55 AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
56)
57
Brad Bishop93919bb2017-04-22 14:58:29 -040058AC_ARG_ENABLE([presence],
59 AS_HELP_STRING([--disable-presence], [Disable fan presence package.]))
60AC_ARG_ENABLE([control],
61 AS_HELP_STRING([--disable-control], [Disable fan control package.]))
Brandon Wymanca60e102017-03-29 17:06:02 -050062AC_ARG_ENABLE([cooling-type],
63 AS_HELP_STRING([--disable-cooling-type], [Disable cooling-type package.]))
Matt Spinleraf5d4c52017-05-16 10:38:43 -050064AC_ARG_ENABLE([monitor],
65 AS_HELP_STRING([--disable-monitor], [Disable monitor]))
Brad Bishop93919bb2017-04-22 14:58:29 -040066
67AM_CONDITIONAL([WANT_PRESENCE], [test "x$enable_presence" != "xno"])
68AM_CONDITIONAL([WANT_CONTROL], [test "x$enable_control" != "xno"])
Brandon Wymance822442017-04-10 17:48:02 -050069AM_CONDITIONAL([WANT_COOLING_TYPE], [test "x$enable_cooling_type" != "xno"])
Matt Spinlere567dd22017-04-27 12:27:17 -050070AM_CONDITIONAL([WANT_MONITOR], [test "x$enable_monitor" != "xno"])
Brad Bishop93919bb2017-04-22 14:58:29 -040071
72# Package specific checks.
73AS_IF([test "x$enable_presence" != "xno"], [
74 # Add optional yaml file argument
75 AC_ARG_VAR(FAN_DETECT_YAML_FILE,
76 [The fan presence detection definition file to use])
77 AS_IF([test "x$FAN_DETECT_YAML_FILE" == "x"],
Brad Bishop9c2994e2017-06-05 22:06:36 -040078 [FAN_DETECT_YAML_FILE="\${top_srcdir}/presence/example/fan-detect.yaml"])
Brad Bishop93919bb2017-04-22 14:58:29 -040079 AC_DEFINE_UNQUOTED([FAN_DETECT_YAML_FILE], ["$FAN_DETECT_YAML_FILE"],
80 [The fan presence detection definition file to use])
81
82 AC_SUBST([GEN_FAN_DETECT_DEFS],
Brad Bishop9c2994e2017-06-05 22:06:36 -040083 ["$PYTHON \${top_srcdir}/presence/gen-fan-detect-defs.py -y $FAN_DETECT_YAML_FILE"])
Brad Bishop93919bb2017-04-22 14:58:29 -040084 AC_CONFIG_FILES([presence/Makefile])
85 ])
86
87AS_IF([test "x$enable_control" != "xno"], [
Matt Spinler77d32d12017-04-12 09:51:41 -050088 # Add optional yaml file arguments
89 AC_ARG_VAR(FAN_DEF_YAML_FILE,
90 [The fan definition file to use])
91 AS_IF([test "x$FAN_DEF_YAML_FILE" == "x"],
92 [FAN_DEF_YAML_FILE="${srcdir}/control/example/fans.yaml"])
93 AC_DEFINE_UNQUOTED([FAN_DEF_YAML_FILE], ["$FAN_DEF_YAML_FILE"],
94 [The fan definition file to use])
95
96 AC_ARG_VAR(FAN_ZONE_YAML_FILE,
97 [The fan zone definition file to use])
98 AS_IF([test "x$FAN_ZONE_YAML_FILE" == "x"],
99 [FAN_ZONE_YAML_FILE="${srcdir}/control/example/zones.yaml"])
100 AC_DEFINE_UNQUOTED([FAN_ZONE_YAML_FILE], ["$FAN_ZONE_YAML_FILE"],
101 [The fan zone definition file to use])
102
Matthew Barthd4d0f082017-05-16 13:51:10 -0500103 AC_ARG_VAR(ZONE_EVENTS_YAML_FILE,
104 [The zone events definition file to use])
105 AS_IF([test "x$ZONE_EVENTS_YAML_FILE" != "x"], [
106 AC_SUBST([ZONE_EVENTS_ARG], ["-e ${ZONE_EVENTS_YAML_FILE}"])
107 ])
108
Gunnar Mills28c1a092017-06-26 11:16:41 -0500109 AC_ARG_VAR(ZONE_CONDITIONS_YAML_FILE,
110 [The zone conditions definition file to use])
111 AS_IF([test "x$ZONE_CONDITIONS_YAML_FILE" != "x"], [
112 AC_SUBST([ZONE_CONDITIONS_ARG], ["-c ${ZONE_CONDITIONS_YAML_FILE}"])
113 ])
114
Matt Spinler77d32d12017-04-12 09:51:41 -0500115 AC_ARG_VAR(FAN_ZONE_OUTPUT_DIR,
116 [The output directory for the generated fan zone data file])
117 AS_IF([test "x$FAN_ZONE_OUTPUT_DIR" == "x"],
118 [FAN_ZONE_OUTPUT_DIR="${srcdir}/control/"])
119 AC_DEFINE_UNQUOTED([FAN_ZONE_OUTPUT_DIR], ["$FAN_ZONE_OUTPUT_DIR"],
120 [The output directory for the generated fan zone data file])
121
122 AC_SUBST([GEN_FAN_ZONE_DEFS],
123 [$PYTHON ${srcdir}/control/gen-fan-zone-defs.py \
124 -f $FAN_DEF_YAML_FILE \
125 -z $FAN_ZONE_YAML_FILE \
Matthew Barthd4d0f082017-05-16 13:51:10 -0500126 $ZONE_EVENTS_ARG \
Gunnar Mills28c1a092017-06-26 11:16:41 -0500127 $ZONE_CONDITIONS_ARG \
Matt Spinler77d32d12017-04-12 09:51:41 -0500128 -o $FAN_ZONE_OUTPUT_DIR])
Brad Bishop93919bb2017-04-22 14:58:29 -0400129 AC_CONFIG_FILES([control/Makefile])
130])
Matthew Barth681c98d2017-02-17 16:05:57 -0600131
Brandon Wymance822442017-04-10 17:48:02 -0500132AS_IF([test "x$enable_cooling_type" != "xno"], [
Brandon Wymanca60e102017-03-29 17:06:02 -0500133 PKG_CHECK_MODULES([LIBEVDEV], [libevdev], ,
134 [AC_MSG_ERROR([The libevdev package is required])])
Brandon Wymanfef02952017-03-31 18:13:21 -0500135 AC_CONFIG_FILES([cooling-type/Makefile])
Brandon Wymanca60e102017-03-29 17:06:02 -0500136])
Matt Spinlere567dd22017-04-27 12:27:17 -0500137AS_IF([test "x$enable_monitor" != "xno"], [
Matt Spinler14321842017-04-28 15:27:43 -0500138
139 AC_ARG_VAR(FAN_MONITOR_YAML_FILE,
140 [The fan monitor definition file to use])
141 AS_IF([test "x$FAN_MONITOR_YAML_FILE" == "x"],
142 [FAN_MONITOR_YAML_FILE="${srcdir}/monitor/example/monitor.yaml"])
143 AC_DEFINE_UNQUOTED([FAN_MONITOR_YAML_FILE], ["$FAN_MONITOR_YAML_FILE"],
144 [The fan monitor definition file to use])
145
146 AC_ARG_VAR(FAN_MONITOR_OUTPUT_DIR,
147 [The output directory for the generated fan monitor data file])
148 AS_IF([test "x$FAN_MONITOR_OUTPUT_DIR" == "x"],
149 [FAN_MONITOR_OUTPUT_DIR="${srcdir}/monitor/"])
150 AC_DEFINE_UNQUOTED([FAN_MONITOR_OUTPUT_DIR], ["$FAN_MONITOR_OUTPUT_DIR"],
151 [The output directory for the generated fan monitor data file])
152
153 AC_SUBST([GEN_FAN_MONITOR_DEFS],
154 [$PYTHON ${srcdir}/monitor/gen-fan-monitor-defs.py \
155 -m $FAN_MONITOR_YAML_FILE \
156 -o $FAN_MONITOR_OUTPUT_DIR])
157
Matt Spinlere567dd22017-04-27 12:27:17 -0500158 AC_CONFIG_FILES([monitor/Makefile])
159])
Brandon Wymanca60e102017-03-29 17:06:02 -0500160
Matthew Barthae0e96c2017-01-20 13:54:59 -0600161# Create configured output
Matt Spinler59c29c72017-04-27 11:17:28 -0500162AC_CONFIG_FILES([Makefile test/Makefile])
Matthew Barthae0e96c2017-01-20 13:54:59 -0600163AC_OUTPUT