| Justin Thaler | 0ee11c1 | 2020-02-07 15:36:41 -0600 | [diff] [blame] | 1 | #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 Roberts | 649763a | 2020-09-17 18:07:49 +0000 | [diff] [blame] | 13 | VER=1.19 | 
| Andrew Geissler | b4cca00 | 2020-09-28 14:19:55 -0500 | [diff] [blame] | 14 | REL=2 | 
| Justin Thaler | 0ee11c1 | 2020-02-07 15:36:41 -0600 | [diff] [blame] | 15 | ARCH=noarch | 
|  | 16 | PROD=openbmctool | 
| Steven Roberts | de9bd96 | 2020-09-10 21:38:52 +0000 | [diff] [blame] | 17 | RHEL_VER=8 | 
| Justin Thaler | 0ee11c1 | 2020-02-07 15:36:41 -0600 | [diff] [blame] | 18 | NAME=$(PROD)-$(VER)-$(REL).$(ARCH) | 
|  | 19 |  | 
|  | 20 | # Need to test RPMDIR to see if it is set. Otherwise set it. | 
|  | 21 | RPMDIR := $(if $(RPMDIR),$(RPMDIR),$(shell pwd)/build/rpm) | 
|  | 22 |  | 
|  | 23 | # Need to test DEBDIR to see if it is set. Otherwise set it. | 
|  | 24 | DEBDIR := $(if $(DEBDIR),$(DEBDIR),$(shell pwd)/build/deb) | 
|  | 25 |  | 
| Andrew Geissler | a29e66a | 2020-09-28 14:19:20 -0500 | [diff] [blame] | 26 | default: | 
| Justin Thaler | 0ee11c1 | 2020-02-07 15:36:41 -0600 | [diff] [blame] | 27 | mkdir -p ./build | 
|  | 28 | clean: ;rm -rf ./build | 
| Andrew Geissler | a29e66a | 2020-09-28 14:19:20 -0500 | [diff] [blame] | 29 | remove: | 
| Justin Thaler | 0ee11c1 | 2020-02-07 15:36:41 -0600 | [diff] [blame] | 30 | rm -f /usr/bin/openbmctool | 
|  | 31 | rm -f /opt/ibm/ras/bin/openbmctool.py | 
|  | 32 | rm -f /opt/ibm/ras/lib/policyTable.json | 
| Andrew Geissler | a29e66a | 2020-09-28 14:19:20 -0500 | [diff] [blame] | 33 | install: | 
| Justin Thaler | 0ee11c1 | 2020-02-07 15:36:41 -0600 | [diff] [blame] | 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 |  | 
|  | 38 | rpm: 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 |  | 
|  | 48 | deb: 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 |  |