1SUMMARY = "Phosphor Fan"
2DESCRIPTION = "Phosphor fan provides a set of fan monitoring and \
3control applications."
4PR = "r1"
5PV = "1.0+git${SRCPV}"
6
7require ${BPN}.inc
8
9inherit autotools pkgconfig python3native
10inherit obmc-phosphor-systemd
11inherit phosphor-fan
12
13S = "${WORKDIR}/git"
14
15# Common build dependencies
16DEPENDS += "autoconf-archive-native"
17DEPENDS += "${PYTHON_PN}-pyyaml-native"
18DEPENDS += "${PYTHON_PN}-mako-native"
19DEPENDS += "sdbusplus"
20DEPENDS += "${PYTHON_PN}-sdbus++-native"
21DEPENDS += "sdeventplus"
22DEPENDS += "gpioplus"
23DEPENDS += "phosphor-logging"
24DEPENDS += "libevdev"
25DEPENDS += "nlohmann-json"
26
27# Package configuration
28FAN_PACKAGES = " \
29        ${PN}-presence-tach \
30        ${PN}-control \
31        ${PN}-monitor \
32"
33
34ALLOW_EMPTY_${PN} = "1"
35PACKAGE_BEFORE_PN += "${FAN_PACKAGES}"
36PACKAGECONFIG ?= "presence control monitor"
37SYSTEMD_PACKAGES = "${FAN_PACKAGES}"
38
39# The control, monitor, and presence apps can either be JSON or YAML driven.
40PACKAGECONFIG[json] = "--enable-json, --disable-json"
41
42# --------------------------------------
43# ${PN}-presence-tach specific configuration
44PACKAGECONFIG[presence] = " \
45        --enable-presence \
46        PRESENCE_CONFIG=${STAGING_DIR_HOST}${presence_datadir}/config.yaml, \
47        --disable-presence, \
48        virtual/phosphor-fan-presence-config \
49        , \
50"
51
52MULTI_USR_TGT = "multi-user.target"
53TMPL_TACH = "phosphor-fan-presence-tach@.service"
54INSTFMT_TACH = "phosphor-fan-presence-tach@{0}.service"
55POWERON_TGT = "obmc-chassis-poweron@{0}.target"
56FMT_TACH = "../${TMPL_TACH}:${POWERON_TGT}.requires/${INSTFMT_TACH}"
57FMT_TACH_MUSR = "../${TMPL_TACH}:${MULTI_USR_TGT}.wants/${INSTFMT_TACH}"
58
59FILES_${PN}-presence-tach = "${bindir}/phosphor-fan-presence-tach"
60SYSTEMD_SERVICE_${PN}-presence-tach += "${TMPL_TACH}"
61SYSTEMD_LINK_${PN}-presence-tach += "${@compose_list(d, 'FMT_TACH', 'OBMC_CHASSIS_INSTANCES')}"
62
63# JSON mode also gets linked into multi-user
64SYSTEMD_LINK_${PN}-presence-tach += "${@bb.utils.contains('PACKAGECONFIG', 'json', \
65        compose_list(d, 'FMT_TACH_MUSR', 'OBMC_CHASSIS_INSTANCES'), '', d)}"
66
67# --------------------------------------
68# ${PN}-control specific configuration
69PACKAGECONFIG[control] = "--enable-control \
70     FAN_DEF_YAML_FILE=${STAGING_DIR_HOST}${control_datadir}/fans.yaml \
71     FAN_ZONE_YAML_FILE=${STAGING_DIR_HOST}${control_datadir}/zones.yaml \
72     ZONE_EVENTS_YAML_FILE=${STAGING_DIR_HOST}${control_datadir}/events.yaml \
73     ZONE_CONDITIONS_YAML_FILE=${STAGING_DIR_HOST}${control_datadir}/zone_conditions.yaml, \
74    --disable-control, \
75    virtual/phosphor-fan-control-fan-config \
76    phosphor-fan-control-zone-config \
77    phosphor-fan-control-events-config \
78    phosphor-fan-control-zone-conditions-config \
79    , \
80"
81
82FAN_CONTROL_TGT = "obmc-fan-control-ready@{0}.target"
83
84TMPL_CONTROL = "phosphor-fan-control@.service"
85INSTFMT_CONTROL = "phosphor-fan-control@{0}.service"
86FMT_CONTROL = "../${TMPL_CONTROL}:${FAN_CONTROL_TGT}.requires/${INSTFMT_CONTROL}"
87
88TMPL_CONTROL_INIT = "phosphor-fan-control-init@.service"
89INSTFMT_CONTROL_INIT = "phosphor-fan-control-init@{0}.service"
90FMT_CONTROL_INIT = "../${TMPL_CONTROL_INIT}:${POWERON_TGT}.wants/${INSTFMT_CONTROL_INIT}"
91
92FILES_${PN}-control = "${bindir}/phosphor-fan-control"
93SYSTEMD_SERVICE_${PN}-control += "${TMPL_CONTROL} ${TMPL_CONTROL_INIT}"
94SYSTEMD_LINK_${PN}-control += "${@compose_list(d, 'FMT_CONTROL', 'OBMC_CHASSIS_INSTANCES')}"
95SYSTEMD_LINK_${PN}-control += "${@compose_list(d, 'FMT_CONTROL_INIT', 'OBMC_CHASSIS_INSTANCES')}"
96
97# --------------------------------------
98# ${PN}-monitor specific configuration
99PACKAGECONFIG[monitor] = "--enable-monitor \
100     FAN_MONITOR_YAML_FILE=${STAGING_DIR_HOST}${monitor_datadir}/monitor.yaml, \
101    --disable-monitor, \
102    phosphor-fan-monitor-config \
103    , \
104"
105
106TMPL_MONITOR = "phosphor-fan-monitor@.service"
107INSTFMT_MONITOR = "phosphor-fan-monitor@{0}.service"
108FMT_MONITOR_FANSREADY = "../${TMPL_MONITOR}:${FAN_CONTROL_TGT}.requires/${INSTFMT_MONITOR}"
109FMT_MONITOR_PWRON = "../${TMPL_MONITOR}:${POWERON_TGT}.requires/${INSTFMT_MONITOR}"
110FMT_MONITOR_MUSR = "../${TMPL_MONITOR}:${MULTI_USR_TGT}.wants/${INSTFMT_MONITOR}"
111
112TMPL_MONITOR_INIT = "phosphor-fan-monitor-init@.service"
113INSTFMT_MONITOR_INIT = "phosphor-fan-monitor-init@{0}.service"
114FMT_MONITOR_INIT = "../${TMPL_MONITOR_INIT}:${POWERON_TGT}.wants/${INSTFMT_MONITOR_INIT}"
115
116FILES_${PN}-monitor = "${bindir}/phosphor-fan-monitor"
117SYSTEMD_SERVICE_${PN}-monitor += "${TMPL_MONITOR}"
118SYSTEMD_SERVICE_${PN}-monitor += "${@bb.utils.contains('PACKAGECONFIG', 'json', '', '${TMPL_MONITOR_INIT}', d)}"
119
120# JSON: power on and multi-user links.  YAML: fans-ready and fan monitor init links
121SYSTEMD_LINK_${PN}-monitor += "${@bb.utils.contains('PACKAGECONFIG', 'json', \
122                                compose_list(d, 'FMT_MONITOR_PWRON', 'OBMC_CHASSIS_INSTANCES'), \
123                                compose_list(d, 'FMT_MONITOR_FANSREADY', 'OBMC_CHASSIS_INSTANCES'), d)}"
124
125SYSTEMD_LINK_${PN}-monitor += "${@bb.utils.contains('PACKAGECONFIG', 'json', \
126                                compose_list(d, 'FMT_MONITOR_MUSR', 'OBMC_CHASSIS_INSTANCES'), \
127                                compose_list(d, 'FMT_MONITOR_INIT', 'OBMC_CHASSIS_INSTANCES'), d)}"
128
129# --------------------------------------
130# phosphor-cooling-type specific configuration
131PACKAGECONFIG[cooling-type] = "--enable-cooling-type,--disable-cooling-type,,"
132
133# --------------------------------------
134# ${PN}-sensor-monitor specific configuration
135PACKAGECONFIG[sensor-monitor] = "--enable-sensor-monitor, --disable-sensor-monitor"
136
137FILES_sensor-monitor += " ${bindir}/sensor-monitor"
138SYSTEMD_SERVICE_sensor-monitor += "sensor-monitor.service"
139SYSTEMD_LINK_sensor-monitor += "../sensor-monitor.service:${MULTI_USR_TGT}.wants/sensor-monitor.service"
140