sm: fix rebuild errors
[pti/rtp.git] / meta-stx / recipes-core / stx-ha / sm.inc
1 #
2 ## Copyright (C) 2019 Wind River Systems, Inc.
3 #
4 #  Licensed under the Apache License, Version 2.0 (the "License");
5 #  you may not use this file except in compliance with the License.
6 #  You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #  Unless required by applicable law or agreed to in writing, software
11 #  distributed under the License is distributed on an "AS IS" BASIS,
12 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #  See the License for the specific language governing permissions and
14 #  limitations under the License.
15
16 PACKAGES += " sm"
17
18 RDEPENDS_sm += " \
19         bash \
20         python \
21         logrotate \
22         time \
23         systemd \
24         chkconfig \
25         mtce-pmon \
26         "
27
28 do_configure_append () {
29         cd ${S}/service-mgmt/sm/src
30         oe_runmake clean
31
32         # fix the hardcoded path
33         sed -i -e "s|/usr/local/sbin|${sbindir}|" \
34                 ${S}/service-mgmt/sm-common/src/sm_types.h \
35                 ${S}/service-mgmt/sm-common/src/sm_watchdog_nfs.c
36 }
37
38 do_compile_append() {
39         cd ${S}/service-mgmt/sm/src
40         oe_runmake -e -j1 VER=0 VER_MJR=1 \
41                 INCLUDES="-I. -I${S}/service-mgmt/sm-common/src \
42                         -I${S}/service-mgmt/sm-db/src $(pkg-config --cflags glib-2.0)" \
43                 EXTRACCFLAGS="-I. -I${S}/service-mgmt/sm-common/src \
44                         -I${S}/service-mgmt/sm-db/src $(pkg-config --cflags glib-2.0) \
45                         -L${S}/service-mgmt/sm-common/src -L${S}/service-mgmt/sm-db/src \
46                                 $(pkg-config --ldlags glib-2.0)" \
47                 CCFLAGS="${CXXFLAGS} -std=c++11" LDFLAGS="${LDFLAGS} -rdynamic"
48 }
49
50 do_install_append () {
51         cd ${S}/service-mgmt/sm/src
52         oe_runmake -e DEST_DIR=${D} BIN_DIR=${bindir} UNIT_DIR=${systemd_system_unitdir} \
53                 LIB_DIR=${libdir} INC_DIR=${includedir} VER=0 VER_MJR=1 install
54         cd ${S}/service-mgmt/sm/scripts
55
56         install -d ${D}/${sysconfdir}/init.d
57         install sm ${D}/${sysconfdir}/init.d/sm
58         install sm.shutdown ${D}/${sysconfdir}/init.d/sm-shutdown
59         install -d -m0755 ${D}/${sysconfdir}/pmon.d
60         install -m 644 sm.conf ${D}/${sysconfdir}/pmon.d/sm.conf
61         install -d ${D}/${sysconfdir}/logrotate.d
62         install -m 644 sm.logrotate ${D}/${sysconfdir}/logrotate.d/sm.logrotate
63         install -d -m 755 ${D}/${sbindir}
64         install sm.notify ${D}/${sbindir}/stx-ha-sm-notify
65         install sm.troubleshoot ${D}/${sbindir}/sm-troubleshoot
66         install sm.notification ${D}/${sbindir}/sm-notification
67         install -d $(D)${systemd_system_unitdir}
68         install -m 644 *.service ${D}/${systemd_system_unitdir}
69 }
70
71 FILES_sm = " \
72         ${bindir}/sm \
73         ${sysconfdir}/init.d/sm \
74         ${sysconfdir}/init.d/sm-shutdown \
75         ${sysconfdir}/pmon.d/sm.conf \
76         ${sysconfdir}/logrotate.d/sm.logrotate \
77         ${sbindir}/stx-ha-sm-notify \
78         ${sbindir}/sm-troubleshoot \
79         ${sbindir}/sm-notification \
80         ${systemd_system_unitdir}/sm-shutdown.service \
81         ${systemd_system_unitdir}/sm.service \
82         "
83
84 pkg_postinst_ontarget_sm_append () {
85         /usr/bin/update-alternatives --install /usr/sbin/sm-notify sm-notify /usr/sbin/stx-ha-sm-notify 5
86 }
87
88 SYSTEMD_PACKAGES += "sm"
89 SYSTEMD_SERVICE_sm = "sm.service sm-shutdown.service"
90 SYSTEMD_AUTO_ENABLE_sm = "enable"