blob: 5277a82a020e63f8b73e82e21cb93c64ca01215d [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
13VER=1.18
14REL=1
15ARCH=noarch
16PROD=openbmctool
17RHEL_VER=7
18NAME=$(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
26default:
27 mkdir -p ./build
28clean: ;rm -rf ./build
29remove:
30 rm -f /usr/bin/openbmctool
31 rm -f /opt/ibm/ras/bin/openbmctool.py
32 rm -f /opt/ibm/ras/lib/policyTable.json
33install:
34 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