KF2-SRV/Makefile

93 lines
2.4 KiB
Makefile
Raw Normal View History

2020-07-29 16:16:01 +00:00
# kf2-srv is a command line tool for managing a set of Killing Floor 2 servers.
# Copyright (C) 2019, 2020 GenZmeY
# mailto: genzmey@gmail.com
#
# This file is part of kf2-srv.
#
# kf2-srv is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
2020-08-01 20:05:51 +00:00
NAME := kf2-srv
2020-07-29 16:16:01 +00:00
2020-08-01 20:05:51 +00:00
RPMBUILDDIR := $$HOME/rpmbuild
ACTIVEDIR := $(shell readlink -e $$HOME/rpmbuild)
WORKDIR := $(shell readlink -e .)
2020-07-29 16:16:01 +00:00
BUILDDIR := $(WORKDIR)/BUILD
BUILDROOTDIR := $(WORKDIR)/BUILDROOT
RPMSDIR := $(WORKDIR)/RPMS
SOURCESDIR := $(WORKDIR)/SOURCES
SPECSDIR := $(WORKDIR)/SPECS
SRPMSDIR := $(WORKDIR)/SRPMS
SPEC := $(SPECSDIR)/$(NAME).spec
2020-08-01 20:05:51 +00:00
VERSION := $(shell grep -Fi 'Version:' $(SPEC) | awk '{ print $$2 }')
SOURCETARBALL := $(SOURCESDIR)/$(NAME)-$(VERSION).tar.gz
2020-07-29 16:16:01 +00:00
2020-08-10 11:11:30 +00:00
.PHONY: all prep rpm srpm activate active check-activate clean-tmp clean-pkg clean builddep test
2020-07-29 16:16:01 +00:00
all: check-activate prep
rpmbuild -ba $(SPEC)
$(MAKE) clean-tmp
2020-08-10 11:11:30 +00:00
builddep:
2020-08-10 11:22:07 +00:00
dnf builddep -y $(SPEC)
2020-08-10 11:11:30 +00:00
2020-07-29 16:16:01 +00:00
prep: clean-tmp
cd $(SOURCESDIR) && tar czf $(SOURCETARBALL) \
config \
main \
COPYING \
Makefile
2020-07-29 16:16:01 +00:00
rpm: check-activate prep
rpmbuild -bb $(SPEC)
$(MAKE) clean-tmp
srpm: check-activate prep
rpmbuild -bs $(SPEC)
$(MAKE) clean-tmp
2020-08-08 19:49:40 +00:00
test: check-activate prep
rpmbuild -bi $(SPEC)
$(MAKE) clean-tmp
active: activate
2020-07-29 16:16:01 +00:00
activate:
ifeq ($(shell test -L $(RPMBUILDDIR); echo $$?), 0)
rm -f $(RPMBUILDDIR)
else ifeq ($(shell test -d $(RPMBUILDDIR); echo $$?), 0)
2020-07-29 16:16:01 +00:00
mv -f $(RPMBUILDDIR) $(RPMBUILDDIR).old
else
rm -f $(RPMBUILDDIR)
endif
ln -s $(WORKDIR) $(RPMBUILDDIR)
check-activate:
ifneq ($(ACTIVEDIR), $(WORKDIR))
$(error project is not active)
endif
clean-tmp:
rm -rf $(BUILDDIR)
rm -rf $(BUILDROOTDIR)
2020-08-14 11:59:43 +00:00
rm -f $(SOURCETARBALL)
2020-07-29 16:16:01 +00:00
clean-pkg:
rm -rf $(RPMSDIR)
rm -rf $(SRPMSDIR)
clean: clean-tmp clean-pkg
2020-08-14 11:59:43 +00:00
rm -f $(SOURCESDIR)/$(NAME)-*.tar.gz