Matthew Barth | ae0e96c | 2017-01-20 13:54:59 -0600 | [diff] [blame] | 1 | # Initialization |
| 2 | AC_PREREQ([2.69]) |
| 3 | AC_INIT([phosphor-fan-presence], [1.0], |
| 4 | [https://github.com/openbmc/phosphor-fan-presence/issues]) |
| 5 | AC_LANG([C++]) |
| 6 | AC_CONFIG_HEADERS([config.h]) |
| 7 | AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz]) |
| 8 | AM_SILENT_RULES([yes]) |
| 9 | |
Lei YU | bd2e80a | 2018-09-19 11:17:09 +0800 | [diff] [blame] | 10 | # Use gcc-ar and gcc-ranlib for static libraries built with -flto |
| 11 | AC_SUBST([AR], [${ac_tool_prefix}gcc-ar]) |
| 12 | AC_SUBST([RANLIB], [${ac_tool_prefix}gcc-ranlib]) |
| 13 | |
Matthew Barth | ae0e96c | 2017-01-20 13:54:59 -0600 | [diff] [blame] | 14 | # Checks for programs. |
| 15 | AC_PROG_CXX |
| 16 | AM_PROG_AR |
| 17 | AC_PROG_INSTALL |
| 18 | AC_PROG_MAKE_SET |
Brad Bishop | 93919bb | 2017-04-22 14:58:29 -0400 | [diff] [blame] | 19 | |
Matthew Barth | 681c98d | 2017-02-17 16:05:57 -0600 | [diff] [blame] | 20 | # Python |
| 21 | AM_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 Barth | ae0e96c | 2017-01-20 13:54:59 -0600 | [diff] [blame] | 23 | |
| 24 | # Checks for typedefs, structures, and compiler characteristics. |
Vernon Mauery | 48df959 | 2018-10-04 10:08:13 -0700 | [diff] [blame] | 25 | AX_CXX_COMPILE_STDCXX_17([noext]) |
Matthew Barth | ae0e96c | 2017-01-20 13:54:59 -0600 | [diff] [blame] | 26 | AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS]) |
| 27 | |
| 28 | # Checks for libraries. |
Patrick Venture | 4b258ac | 2019-02-13 14:48:21 -0800 | [diff] [blame] | 29 | PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus]) |
| 30 | PKG_CHECK_MODULES([SDEVENTPLUS], [sdeventplus]) |
| 31 | PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging]) |
| 32 | PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221]) |
| 33 | PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces]) |
| 34 | PKG_CHECK_MODULES([LIBEVDEV], [libevdev]) |
Matthew Barth | f3e7047 | 2019-12-03 13:33:20 -0600 | [diff] [blame] | 35 | PKG_CHECK_MODULES([STDPLUS], [stdplus]) |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 36 | |
Matthew Barth | ae0e96c | 2017-01-20 13:54:59 -0600 | [diff] [blame] | 37 | # Checks for library functions. |
| 38 | LT_INIT # Required for systemd linking |
| 39 | |
Matt Spinler | 59c29c7 | 2017-04-27 11:17:28 -0500 | [diff] [blame] | 40 | # Check/set gtest specific functions. |
| 41 | AX_PTHREAD([GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=1"],[GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=0"]) |
| 42 | AC_SUBST(GTEST_CPPFLAGS) |
| 43 | AC_ARG_ENABLE([oe-sdk], |
| 44 | AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.]) |
| 45 | ) |
| 46 | AC_ARG_VAR(OECORE_TARGET_SYSROOT, |
| 47 | [Path to the OE SDK SYSROOT]) |
| 48 | AS_IF([test "x$enable_oe_sdk" == "xyes"], |
| 49 | AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"], |
| 50 | AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk]) |
| 51 | ) |
| 52 | AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT]) |
| 53 | [ |
| 54 | testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib" |
| 55 | testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib" |
| 56 | testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`" |
| 57 | ] |
| 58 | AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags]) |
| 59 | ) |
| 60 | |
Matthew Barth | cc19480 | 2020-01-09 13:55:34 -0600 | [diff] [blame^] | 61 | AC_ARG_ENABLE([json], |
| 62 | AS_HELP_STRING([--enable-json], [Use json at runtime to configure fan packages.])) |
Brad Bishop | 93919bb | 2017-04-22 14:58:29 -0400 | [diff] [blame] | 63 | AC_ARG_ENABLE([presence], |
| 64 | AS_HELP_STRING([--disable-presence], [Disable fan presence package.])) |
| 65 | AC_ARG_ENABLE([control], |
| 66 | AS_HELP_STRING([--disable-control], [Disable fan control package.])) |
Brandon Wyman | ca60e10 | 2017-03-29 17:06:02 -0500 | [diff] [blame] | 67 | AC_ARG_ENABLE([cooling-type], |
| 68 | AS_HELP_STRING([--disable-cooling-type], [Disable cooling-type package.])) |
Matt Spinler | af5d4c5 | 2017-05-16 10:38:43 -0500 | [diff] [blame] | 69 | AC_ARG_ENABLE([monitor], |
| 70 | AS_HELP_STRING([--disable-monitor], [Disable monitor])) |
Brad Bishop | 93919bb | 2017-04-22 14:58:29 -0400 | [diff] [blame] | 71 | |
Matthew Barth | cc19480 | 2020-01-09 13:55:34 -0600 | [diff] [blame^] | 72 | AM_CONDITIONAL([WANT_JSON], [test "x$enable_json" == "xyes"]) |
Brad Bishop | 93919bb | 2017-04-22 14:58:29 -0400 | [diff] [blame] | 73 | AM_CONDITIONAL([WANT_PRESENCE], [test "x$enable_presence" != "xno"]) |
| 74 | AM_CONDITIONAL([WANT_CONTROL], [test "x$enable_control" != "xno"]) |
Brandon Wyman | ce82244 | 2017-04-10 17:48:02 -0500 | [diff] [blame] | 75 | AM_CONDITIONAL([WANT_COOLING_TYPE], [test "x$enable_cooling_type" != "xno"]) |
Matt Spinler | e567dd2 | 2017-04-27 12:27:17 -0500 | [diff] [blame] | 76 | AM_CONDITIONAL([WANT_MONITOR], [test "x$enable_monitor" != "xno"]) |
Brad Bishop | 93919bb | 2017-04-22 14:58:29 -0400 | [diff] [blame] | 77 | |
| 78 | # Package specific checks. |
| 79 | AS_IF([test "x$enable_presence" != "xno"], [ |
Matthew Barth | cc19480 | 2020-01-09 13:55:34 -0600 | [diff] [blame^] | 80 | # Use runtime(json) config, otherwise default to compile time(yaml) config |
| 81 | AM_COND_IF([WANT_JSON], |
| 82 | [ |
| 83 | AC_CHECK_HEADER(nlohmann/json.hpp, , |
| 84 | [AC_MSG_ERROR([Could not find nlohmann/json.hpp... nlohmann/json package required])]) |
| 85 | # Set config flag for runtime json usage |
| 86 | AC_DEFINE([PRESENCE_USE_JSON], [1], [Fan presence use runtime json configuration]) |
| 87 | AC_MSG_NOTICE([Fan presence json configuration usage enabled]) |
| 88 | ], |
| 89 | [ |
| 90 | # Add optional yaml file argument |
| 91 | AC_ARG_VAR(PRESENCE_CONFIG, [The fan presence config file.]) |
Brad Bishop | 76596b2 | 2017-06-13 14:39:13 -0400 | [diff] [blame] | 92 | |
Brad Bishop | 76596b2 | 2017-06-13 14:39:13 -0400 | [diff] [blame] | 93 | AS_IF([test "x$PRESENCE_CONFIG" == "x"], |
| 94 | [PRESENCE_CONFIG="\${top_srcdir}/presence/example/example.yaml"]) |
| 95 | |
Brad Bishop | 76596b2 | 2017-06-13 14:39:13 -0400 | [diff] [blame] | 96 | AC_DEFINE_UNQUOTED([PRESENCE_CONFIG], ["$PRESENCE_CONFIG"], |
| 97 | [The fan presence config file.]) |
Brad Bishop | 93919bb | 2017-04-22 14:58:29 -0400 | [diff] [blame] | 98 | |
Brad Bishop | 76596b2 | 2017-06-13 14:39:13 -0400 | [diff] [blame] | 99 | AC_SUBST([PFPGEN], |
| 100 | ["$PYTHON \${top_srcdir}/presence/pfpgen.py generate-cpp -i $PRESENCE_CONFIG"]) |
Matthew Barth | cc19480 | 2020-01-09 13:55:34 -0600 | [diff] [blame^] | 101 | ]) |
| 102 | AC_CONFIG_FILES([presence/Makefile]) |
| 103 | ]) |
Brad Bishop | 93919bb | 2017-04-22 14:58:29 -0400 | [diff] [blame] | 104 | |
| 105 | AS_IF([test "x$enable_control" != "xno"], [ |
Matthew Barth | 14cc043 | 2019-01-16 15:06:41 -0600 | [diff] [blame] | 106 | # Add fan control Dbus attributes |
| 107 | AC_ARG_VAR(CONTROL_BUSNAME, [The fan control busname to own]) |
| 108 | AS_IF([test "x$CONTROL_BUSNAME" == "x"], |
| 109 | [CONTROL_BUSNAME="xyz.openbmc_project.Control.Thermal"]) |
| 110 | AC_DEFINE_UNQUOTED([CONTROL_BUSNAME], ["$CONTROL_BUSNAME"], |
| 111 | [The fan control busname to own]) |
| 112 | |
| 113 | AC_ARG_VAR(CONTROL_OBJPATH, [The fan control root object path]) |
| 114 | AS_IF([test "x$CONTROL_OBJPATH" == "x"], |
| 115 | [CONTROL_OBJPATH="/xyz/openbmc_project/control/thermal"]) |
| 116 | AC_DEFINE_UNQUOTED([CONTROL_OBJPATH], ["$CONTROL_OBJPATH"], |
| 117 | [The fan control root object path]) |
| 118 | |
Matthew Barth | cc8912e | 2019-01-21 11:35:27 -0600 | [diff] [blame] | 119 | AC_ARG_VAR(CONTROL_PERSIST_ROOT_PATH, [Root path for persisting zone property states]) |
| 120 | AS_IF([test "x$CONTROL_PERSIST_ROOT_PATH" == "x"], |
| 121 | [CONTROL_PERSIST_ROOT_PATH="/var/lib/phosphor-fan-presence/control"]) |
| 122 | AC_DEFINE_UNQUOTED([CONTROL_PERSIST_ROOT_PATH], ["$CONTROL_PERSIST_ROOT_PATH"], |
| 123 | [Root path for persisting zone property states]) |
| 124 | |
Matt Spinler | 77d32d1 | 2017-04-12 09:51:41 -0500 | [diff] [blame] | 125 | # Add optional yaml file arguments |
| 126 | AC_ARG_VAR(FAN_DEF_YAML_FILE, |
| 127 | [The fan definition file to use]) |
| 128 | AS_IF([test "x$FAN_DEF_YAML_FILE" == "x"], |
Brandon Wyman | c5f5351 | 2017-07-25 16:31:57 -0500 | [diff] [blame] | 129 | [FAN_DEF_YAML_FILE="\${top_srcdir}/control/example/fans.yaml"]) |
Matt Spinler | 77d32d1 | 2017-04-12 09:51:41 -0500 | [diff] [blame] | 130 | AC_DEFINE_UNQUOTED([FAN_DEF_YAML_FILE], ["$FAN_DEF_YAML_FILE"], |
| 131 | [The fan definition file to use]) |
| 132 | |
| 133 | AC_ARG_VAR(FAN_ZONE_YAML_FILE, |
| 134 | [The fan zone definition file to use]) |
| 135 | AS_IF([test "x$FAN_ZONE_YAML_FILE" == "x"], |
Brandon Wyman | c5f5351 | 2017-07-25 16:31:57 -0500 | [diff] [blame] | 136 | [FAN_ZONE_YAML_FILE="\${top_srcdir}/control/example/zones.yaml"]) |
Matt Spinler | 77d32d1 | 2017-04-12 09:51:41 -0500 | [diff] [blame] | 137 | AC_DEFINE_UNQUOTED([FAN_ZONE_YAML_FILE], ["$FAN_ZONE_YAML_FILE"], |
| 138 | [The fan zone definition file to use]) |
| 139 | |
Matthew Barth | d4d0f08 | 2017-05-16 13:51:10 -0500 | [diff] [blame] | 140 | AC_ARG_VAR(ZONE_EVENTS_YAML_FILE, |
| 141 | [The zone events definition file to use]) |
Brandon Wyman | c5f5351 | 2017-07-25 16:31:57 -0500 | [diff] [blame] | 142 | AS_IF([test "x$ZONE_EVENTS_YAML_FILE" == "x"], |
| 143 | [ZONE_EVENTS_YAML_FILE="\${top_srcdir}/control/example/events.yaml"]) |
| 144 | AC_DEFINE_UNQUOTED([ZONE_EVENTS_YAML_FILE], ["$ZONE_EVENTS_YAML_FILE"], |
| 145 | [The zone events definition file to use]) |
Matthew Barth | d4d0f08 | 2017-05-16 13:51:10 -0500 | [diff] [blame] | 146 | |
Gunnar Mills | 28c1a09 | 2017-06-26 11:16:41 -0500 | [diff] [blame] | 147 | AC_ARG_VAR(ZONE_CONDITIONS_YAML_FILE, |
| 148 | [The zone conditions definition file to use]) |
Brandon Wyman | c5f5351 | 2017-07-25 16:31:57 -0500 | [diff] [blame] | 149 | AS_IF([test "x$ZONE_CONDITIONS_YAML_FILE" == "x"], |
| 150 | [ZONE_CONDITIONS_YAML_FILE="\${top_srcdir}/control/example/zone_conditions.yaml"]) |
| 151 | AC_DEFINE_UNQUOTED([ZONE_CONDITIONS_YAML_FILE], ["$ZONE_CONDITIONS_YAML_FILE"], |
| 152 | [The zone conditions definition file to use]) |
Gunnar Mills | 28c1a09 | 2017-06-26 11:16:41 -0500 | [diff] [blame] | 153 | |
Matt Spinler | 77d32d1 | 2017-04-12 09:51:41 -0500 | [diff] [blame] | 154 | AC_ARG_VAR(FAN_ZONE_OUTPUT_DIR, |
| 155 | [The output directory for the generated fan zone data file]) |
| 156 | AS_IF([test "x$FAN_ZONE_OUTPUT_DIR" == "x"], |
Brandon Wyman | c5f5351 | 2017-07-25 16:31:57 -0500 | [diff] [blame] | 157 | [FAN_ZONE_OUTPUT_DIR="\${top_srcdir}/control/"]) |
Matt Spinler | 77d32d1 | 2017-04-12 09:51:41 -0500 | [diff] [blame] | 158 | AC_DEFINE_UNQUOTED([FAN_ZONE_OUTPUT_DIR], ["$FAN_ZONE_OUTPUT_DIR"], |
| 159 | [The output directory for the generated fan zone data file]) |
| 160 | |
| 161 | AC_SUBST([GEN_FAN_ZONE_DEFS], |
Brandon Wyman | c5f5351 | 2017-07-25 16:31:57 -0500 | [diff] [blame] | 162 | ["$PYTHON \${top_srcdir}/control/gen-fan-zone-defs.py \ |
Matt Spinler | 77d32d1 | 2017-04-12 09:51:41 -0500 | [diff] [blame] | 163 | -f $FAN_DEF_YAML_FILE \ |
| 164 | -z $FAN_ZONE_YAML_FILE \ |
Brandon Wyman | c5f5351 | 2017-07-25 16:31:57 -0500 | [diff] [blame] | 165 | -e $ZONE_EVENTS_YAML_FILE \ |
| 166 | -c $ZONE_CONDITIONS_YAML_FILE \ |
| 167 | -o $FAN_ZONE_OUTPUT_DIR"]) |
Brad Bishop | 93919bb | 2017-04-22 14:58:29 -0400 | [diff] [blame] | 168 | AC_CONFIG_FILES([control/Makefile]) |
| 169 | ]) |
Matthew Barth | 681c98d | 2017-02-17 16:05:57 -0600 | [diff] [blame] | 170 | |
Brandon Wyman | ce82244 | 2017-04-10 17:48:02 -0500 | [diff] [blame] | 171 | AS_IF([test "x$enable_cooling_type" != "xno"], [ |
Brandon Wyman | fef0295 | 2017-03-31 18:13:21 -0500 | [diff] [blame] | 172 | AC_CONFIG_FILES([cooling-type/Makefile]) |
Brandon Wyman | ca60e10 | 2017-03-29 17:06:02 -0500 | [diff] [blame] | 173 | ]) |
Matt Spinler | e567dd2 | 2017-04-27 12:27:17 -0500 | [diff] [blame] | 174 | AS_IF([test "x$enable_monitor" != "xno"], [ |
Matt Spinler | 1432184 | 2017-04-28 15:27:43 -0500 | [diff] [blame] | 175 | |
| 176 | AC_ARG_VAR(FAN_MONITOR_YAML_FILE, |
| 177 | [The fan monitor definition file to use]) |
| 178 | AS_IF([test "x$FAN_MONITOR_YAML_FILE" == "x"], |
| 179 | [FAN_MONITOR_YAML_FILE="${srcdir}/monitor/example/monitor.yaml"]) |
| 180 | AC_DEFINE_UNQUOTED([FAN_MONITOR_YAML_FILE], ["$FAN_MONITOR_YAML_FILE"], |
| 181 | [The fan monitor definition file to use]) |
| 182 | |
| 183 | AC_ARG_VAR(FAN_MONITOR_OUTPUT_DIR, |
| 184 | [The output directory for the generated fan monitor data file]) |
| 185 | AS_IF([test "x$FAN_MONITOR_OUTPUT_DIR" == "x"], |
| 186 | [FAN_MONITOR_OUTPUT_DIR="${srcdir}/monitor/"]) |
| 187 | AC_DEFINE_UNQUOTED([FAN_MONITOR_OUTPUT_DIR], ["$FAN_MONITOR_OUTPUT_DIR"], |
| 188 | [The output directory for the generated fan monitor data file]) |
| 189 | |
| 190 | AC_SUBST([GEN_FAN_MONITOR_DEFS], |
| 191 | [$PYTHON ${srcdir}/monitor/gen-fan-monitor-defs.py \ |
| 192 | -m $FAN_MONITOR_YAML_FILE \ |
| 193 | -o $FAN_MONITOR_OUTPUT_DIR]) |
| 194 | |
Matt Spinler | e567dd2 | 2017-04-27 12:27:17 -0500 | [diff] [blame] | 195 | AC_CONFIG_FILES([monitor/Makefile]) |
| 196 | ]) |
Brandon Wyman | ca60e10 | 2017-03-29 17:06:02 -0500 | [diff] [blame] | 197 | |
Matthew Barth | ae0e96c | 2017-01-20 13:54:59 -0600 | [diff] [blame] | 198 | # Create configured output |
William A. Kennington III | 8fd879f | 2018-10-30 19:49:29 -0700 | [diff] [blame] | 199 | AC_CONFIG_FILES([Makefile sdevent/test/Makefile evdevpp/test/Makefile presence/test/Makefile]) |
Matthew Barth | ae0e96c | 2017-01-20 13:54:59 -0600 | [diff] [blame] | 200 | AC_OUTPUT |