blob: 87c028e988a22a97515d4af53d94cc3f0ebff2d2 [file] [log] [blame]
Justin Thaler0ee11c12020-02-07 15:36:41 -06001#Makefile for openbmctool
2# Copyright (c) 2017 International Business Machines.
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6# http://www.apache.org/licenses/LICENSE-2.0
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS,
9# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10# See the License for the specific language governing permissions and
11# limitations under the License.
12
Steven Roberts649763a2020-09-17 18:07:49 +000013VER=1.19
Andrew Geisslerb4cca002020-09-28 14:19:55 -050014REL=2
Justin Thaler0ee11c12020-02-07 15:36:41 -060015ARCH=noarch
16PROD=openbmctool
Steven Robertsde9bd962020-09-10 21:38:52 +000017RHEL_VER=8
Justin Thaler0ee11c12020-02-07 15:36:41 -060018NAME=$(PROD)-$(VER)-$(REL).$(ARCH)
19
20# Need to test RPMDIR to see if it is set. Otherwise set it.
21RPMDIR := $(if $(RPMDIR),$(RPMDIR),$(shell pwd)/build/rpm)
22
23# Need to test DEBDIR to see if it is set. Otherwise set it.
24DEBDIR := $(if $(DEBDIR),$(DEBDIR),$(shell pwd)/build/deb)
25
Andrew Geisslera29e66a2020-09-28 14:19:20 -050026default:
Justin Thaler0ee11c12020-02-07 15:36:41 -060027 mkdir -p ./build
28clean: ;rm -rf ./build
Andrew Geisslera29e66a2020-09-28 14:19:20 -050029remove:
Justin Thaler0ee11c12020-02-07 15:36:41 -060030 rm -f /usr/bin/openbmctool
31 rm -f /opt/ibm/ras/bin/openbmctool.py
32 rm -f /opt/ibm/ras/lib/policyTable.json
Andrew Geisslera29e66a2020-09-28 14:19:20 -050033install:
Justin Thaler0ee11c12020-02-07 15:36:41 -060034 cp ../openbmctool.py $(DESTDIR)/opt/ibm/ras/bin
35 cp ../policyTable.json $(DESTDIR)/opt/ibm/ras/lib
36 ln -s -f $(DESTDIR)/opt/ibm/ras/bin/openbmctool.py $(DESTDIR)/usr/bin/openbmctool
37
38rpm: default
39 rm -rf $(RPMDIR)
40 mkdir -p $(RPMDIR)
41 mkdir -p $(RPMDIR)/openbmctool
42 for i in BUILD BUILDROOT RPMS SOURCES SPECS SRPMS; do mkdir -p $(RPMDIR)/$$i; done
43 cp openbmctool-rhel$(RHEL_VER).spec $(RPMDIR)/SPECS
44 cp ../openbmctool.py ../policyTable.json $(RPMDIR)/openbmctool/
45 tar -cvzf $(RPMDIR)/SOURCES/openbmctool-$(VER)-$(REL).tgz -C $(RPMDIR) openbmctool
46 rpmbuild --define '_topdir $(RPMDIR)' --define "_version $(VER)" --define "_release $(REL)" -bb $(RPMDIR)/SPECS/openbmctool-rhel$(RHEL_VER).spec
47
48deb: default
49 rm -rf $(DEBDIR)
50 mkdir -p $(DEBDIR)
51 for i in bin lib; do mkdir -p $(DEBDIR)/opt/ibm/ras/$$i; done
52 mkdir -p $(DEBDIR)/usr/bin/
53 make install DESTDIR=$(DEBDIR)
54 mkdir -p $(DEBDIR)/DEBIAN
55 cp control $(DEBDIR)/DEBIAN
56 cd $(DEBDIR); find opt -type f -exec md5sum "{}" + >> DEBIAN/md5sums
57 cd $(DEBDIR); find usr -type f -exec md5sum "{}" + >> DEBIAN/md5sums
58 cd $(DEBDIR); echo "#!/bin/bash" >> DEBIAN/postinst
59 cd $(DEBDIR); echo "ln -s -f /opt/ibm/ras/bin/openbmctool.py /usr/bin/openbmctool" >> DEBIAN/postinst
60 chmod +x $(DEBDIR)/DEBIAN/postinst
61 chmod +x $(DEBDIR)/opt/ibm/ras/bin/openbmctool.py
62 dpkg-deb -b $(DEBDIR) $(DEBDIR)/DEBIAN/openbmctool-$(VER).$(REL)-$(ARCH).deb
63