blob: b60d0329a30ac0c0746e9b277ac26a2f7a732817 [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
21AM_PATH_PYTHON([2.7], [AC_SUBST([PYTHON], [echo "$PYTHON"])],
22[AC_MSG_ERROR([Could not find python-2.7 installed...python-2.7 is required])])
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.
Matthew Barth293477d2017-02-17 15:39:36 -060029PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus], ,
30[AC_MSG_ERROR([The openbmc/sdbusplus package is required])])
William A. Kennington III1cfc2f12018-10-19 17:29:46 -070031PKG_CHECK_MODULES([SDEVENTPLUS], [sdeventplus], ,
32[AC_MSG_ERROR([The openbmc/sdeventplus package is required])])
Matthew Barthfefdc452017-02-22 11:15:56 -060033PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging], ,
34[AC_MSG_ERROR([The openbmc/phosphor-logging package is required])])
Matt Spinlera5763ff2017-06-14 15:54:12 -050035PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221], ,
Gunnar Mills9a7688a2017-10-25 17:06:04 -050036[AC_MSG_ERROR([Could not find systemd...systemd development package required])])
Dinesh Chinari618027a2017-06-26 23:26:50 -050037PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces], ,
38[AC_MSG_ERROR([Could not find phosphor-dbus-interfaces...openbmc/phosphor-dbus-interfaces package required])])
Brad Bishop8a502f52017-06-14 23:46:15 -040039PKG_CHECK_MODULES([LIBEVDEV], [libevdev], ,
40[AC_MSG_ERROR([The libevdev package is required])])
Matthew Barth293477d2017-02-17 15:39:36 -060041
Matthew Barthae0e96c2017-01-20 13:54:59 -060042# Checks for library functions.
43LT_INIT # Required for systemd linking
44
Matt Spinler59c29c72017-04-27 11:17:28 -050045# Check/set gtest specific functions.
46AX_PTHREAD([GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=1"],[GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=0"])
47AC_SUBST(GTEST_CPPFLAGS)
48AC_ARG_ENABLE([oe-sdk],
49 AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.])
50)
51AC_ARG_VAR(OECORE_TARGET_SYSROOT,
52 [Path to the OE SDK SYSROOT])
53AS_IF([test "x$enable_oe_sdk" == "xyes"],
54 AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"],
55 AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk])
56 )
57 AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT])
58 [
59 testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib"
60 testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib"
61 testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`"
62 ]
63 AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
64)
65
Brad Bishop93919bb2017-04-22 14:58:29 -040066AC_ARG_ENABLE([presence],
67 AS_HELP_STRING([--disable-presence], [Disable fan presence package.]))
68AC_ARG_ENABLE([control],
69 AS_HELP_STRING([--disable-control], [Disable fan control package.]))
Brandon Wymanca60e102017-03-29 17:06:02 -050070AC_ARG_ENABLE([cooling-type],
71 AS_HELP_STRING([--disable-cooling-type], [Disable cooling-type package.]))
Matt Spinleraf5d4c52017-05-16 10:38:43 -050072AC_ARG_ENABLE([monitor],
73 AS_HELP_STRING([--disable-monitor], [Disable monitor]))
Brad Bishop93919bb2017-04-22 14:58:29 -040074
75AM_CONDITIONAL([WANT_PRESENCE], [test "x$enable_presence" != "xno"])
76AM_CONDITIONAL([WANT_CONTROL], [test "x$enable_control" != "xno"])
Brandon Wymance822442017-04-10 17:48:02 -050077AM_CONDITIONAL([WANT_COOLING_TYPE], [test "x$enable_cooling_type" != "xno"])
Matt Spinlere567dd22017-04-27 12:27:17 -050078AM_CONDITIONAL([WANT_MONITOR], [test "x$enable_monitor" != "xno"])
Brad Bishop93919bb2017-04-22 14:58:29 -040079
80# Package specific checks.
81AS_IF([test "x$enable_presence" != "xno"], [
82 # Add optional yaml file argument
Brad Bishop76596b22017-06-13 14:39:13 -040083 AC_ARG_VAR(PRESENCE_CONFIG,
84 [The fan presence config file.])
85
Brad Bishop76596b22017-06-13 14:39:13 -040086 AS_IF([test "x$PRESENCE_CONFIG" == "x"],
87 [PRESENCE_CONFIG="\${top_srcdir}/presence/example/example.yaml"])
88
Brad Bishop76596b22017-06-13 14:39:13 -040089 AC_DEFINE_UNQUOTED([PRESENCE_CONFIG], ["$PRESENCE_CONFIG"],
90 [The fan presence config file.])
Brad Bishop93919bb2017-04-22 14:58:29 -040091
Brad Bishop76596b22017-06-13 14:39:13 -040092 AC_SUBST([PFPGEN],
93 ["$PYTHON \${top_srcdir}/presence/pfpgen.py generate-cpp -i $PRESENCE_CONFIG"])
94
Brad Bishop93919bb2017-04-22 14:58:29 -040095 AC_CONFIG_FILES([presence/Makefile])
96 ])
97
98AS_IF([test "x$enable_control" != "xno"], [
Matt Spinler77d32d12017-04-12 09:51:41 -050099 # Add optional yaml file arguments
100 AC_ARG_VAR(FAN_DEF_YAML_FILE,
101 [The fan definition file to use])
102 AS_IF([test "x$FAN_DEF_YAML_FILE" == "x"],
Brandon Wymanc5f53512017-07-25 16:31:57 -0500103 [FAN_DEF_YAML_FILE="\${top_srcdir}/control/example/fans.yaml"])
Matt Spinler77d32d12017-04-12 09:51:41 -0500104 AC_DEFINE_UNQUOTED([FAN_DEF_YAML_FILE], ["$FAN_DEF_YAML_FILE"],
105 [The fan definition file to use])
106
107 AC_ARG_VAR(FAN_ZONE_YAML_FILE,
108 [The fan zone definition file to use])
109 AS_IF([test "x$FAN_ZONE_YAML_FILE" == "x"],
Brandon Wymanc5f53512017-07-25 16:31:57 -0500110 [FAN_ZONE_YAML_FILE="\${top_srcdir}/control/example/zones.yaml"])
Matt Spinler77d32d12017-04-12 09:51:41 -0500111 AC_DEFINE_UNQUOTED([FAN_ZONE_YAML_FILE], ["$FAN_ZONE_YAML_FILE"],
112 [The fan zone definition file to use])
113
Matthew Barthd4d0f082017-05-16 13:51:10 -0500114 AC_ARG_VAR(ZONE_EVENTS_YAML_FILE,
115 [The zone events definition file to use])
Brandon Wymanc5f53512017-07-25 16:31:57 -0500116 AS_IF([test "x$ZONE_EVENTS_YAML_FILE" == "x"],
117 [ZONE_EVENTS_YAML_FILE="\${top_srcdir}/control/example/events.yaml"])
118 AC_DEFINE_UNQUOTED([ZONE_EVENTS_YAML_FILE], ["$ZONE_EVENTS_YAML_FILE"],
119 [The zone events definition file to use])
Matthew Barthd4d0f082017-05-16 13:51:10 -0500120
Gunnar Mills28c1a092017-06-26 11:16:41 -0500121 AC_ARG_VAR(ZONE_CONDITIONS_YAML_FILE,
122 [The zone conditions definition file to use])
Brandon Wymanc5f53512017-07-25 16:31:57 -0500123 AS_IF([test "x$ZONE_CONDITIONS_YAML_FILE" == "x"],
124 [ZONE_CONDITIONS_YAML_FILE="\${top_srcdir}/control/example/zone_conditions.yaml"])
125 AC_DEFINE_UNQUOTED([ZONE_CONDITIONS_YAML_FILE], ["$ZONE_CONDITIONS_YAML_FILE"],
126 [The zone conditions definition file to use])
Gunnar Mills28c1a092017-06-26 11:16:41 -0500127
Matt Spinler77d32d12017-04-12 09:51:41 -0500128 AC_ARG_VAR(FAN_ZONE_OUTPUT_DIR,
129 [The output directory for the generated fan zone data file])
130 AS_IF([test "x$FAN_ZONE_OUTPUT_DIR" == "x"],
Brandon Wymanc5f53512017-07-25 16:31:57 -0500131 [FAN_ZONE_OUTPUT_DIR="\${top_srcdir}/control/"])
Matt Spinler77d32d12017-04-12 09:51:41 -0500132 AC_DEFINE_UNQUOTED([FAN_ZONE_OUTPUT_DIR], ["$FAN_ZONE_OUTPUT_DIR"],
133 [The output directory for the generated fan zone data file])
134
135 AC_SUBST([GEN_FAN_ZONE_DEFS],
Brandon Wymanc5f53512017-07-25 16:31:57 -0500136 ["$PYTHON \${top_srcdir}/control/gen-fan-zone-defs.py \
Matt Spinler77d32d12017-04-12 09:51:41 -0500137 -f $FAN_DEF_YAML_FILE \
138 -z $FAN_ZONE_YAML_FILE \
Brandon Wymanc5f53512017-07-25 16:31:57 -0500139 -e $ZONE_EVENTS_YAML_FILE \
140 -c $ZONE_CONDITIONS_YAML_FILE \
141 -o $FAN_ZONE_OUTPUT_DIR"])
Brad Bishop93919bb2017-04-22 14:58:29 -0400142 AC_CONFIG_FILES([control/Makefile])
143])
Matthew Barth681c98d2017-02-17 16:05:57 -0600144
Brandon Wymance822442017-04-10 17:48:02 -0500145AS_IF([test "x$enable_cooling_type" != "xno"], [
Brandon Wymanfef02952017-03-31 18:13:21 -0500146 AC_CONFIG_FILES([cooling-type/Makefile])
Brandon Wymanca60e102017-03-29 17:06:02 -0500147])
Matt Spinlere567dd22017-04-27 12:27:17 -0500148AS_IF([test "x$enable_monitor" != "xno"], [
Matt Spinler14321842017-04-28 15:27:43 -0500149
150 AC_ARG_VAR(FAN_MONITOR_YAML_FILE,
151 [The fan monitor definition file to use])
152 AS_IF([test "x$FAN_MONITOR_YAML_FILE" == "x"],
153 [FAN_MONITOR_YAML_FILE="${srcdir}/monitor/example/monitor.yaml"])
154 AC_DEFINE_UNQUOTED([FAN_MONITOR_YAML_FILE], ["$FAN_MONITOR_YAML_FILE"],
155 [The fan monitor definition file to use])
156
157 AC_ARG_VAR(FAN_MONITOR_OUTPUT_DIR,
158 [The output directory for the generated fan monitor data file])
159 AS_IF([test "x$FAN_MONITOR_OUTPUT_DIR" == "x"],
160 [FAN_MONITOR_OUTPUT_DIR="${srcdir}/monitor/"])
161 AC_DEFINE_UNQUOTED([FAN_MONITOR_OUTPUT_DIR], ["$FAN_MONITOR_OUTPUT_DIR"],
162 [The output directory for the generated fan monitor data file])
163
164 AC_SUBST([GEN_FAN_MONITOR_DEFS],
165 [$PYTHON ${srcdir}/monitor/gen-fan-monitor-defs.py \
166 -m $FAN_MONITOR_YAML_FILE \
167 -o $FAN_MONITOR_OUTPUT_DIR])
168
Matt Spinlere567dd22017-04-27 12:27:17 -0500169 AC_CONFIG_FILES([monitor/Makefile])
170])
Brandon Wymanca60e102017-03-29 17:06:02 -0500171
Matthew Barthae0e96c2017-01-20 13:54:59 -0600172# Create configured output
Brad Bishop135a47f2017-07-13 00:12:17 -0400173AC_CONFIG_FILES([Makefile test/Makefile sdevent/test/Makefile evdevpp/test/Makefile presence/test/Makefile])
Matthew Barthae0e96c2017-01-20 13:54:59 -0600174AC_OUTPUT