From 24bd3d1109cb280074d1a23e865a0b35257aa913 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Mon, 27 Jun 2016 12:21:40 +0200 Subject: [PATCH] Improve Makefile. The Makefile now contains the version details which will be substitued in the guardian.in and guardinctrl.in. The Makefile now also supports commands for make clean and to create a distribute-able tarball. All installations path now can be adjusted by overwriting the corresponding variables. Signed-off-by: Stefan Schantl --- Makefile | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 56ebe17..8e8fb66 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,64 @@ -NAME = Guardian +NAME = guardian +VERSION = 2.0 + +PACKAGE_NAME = $(NAME)-$(VERSION) +PACKAGE_VERSION = $(VERSION) DESTDIR = +PREFIX = /usr +BINDIR = $(PREFIX)/bin +SBINDIR = $(PREFIX)/sbin +SYSCONFDIR = $(PREFIX)/etc + PERL_VER := $(shell eval "$$(perl -V:version)"; echo $${version};) PERL_SITELIB_DIR := $(shell eval "$$(perl -V:installsitelib)"; echo $${installsitelib};) PERL_DIR = $(DESTDIR)$(PERL_SITELIB_DIR)/$(NAME)/ -all: +SED = sed + +substitutions = \ + '|PACKAGE_NAME=$(PACKAGE_NAME)|' \ + '|PACKAGE_VERSION=$(PACKAGE_VERSION)|' + +SED_PROCESS = \ + $(SED) $(subst '|,-e 's|@,$(subst =,\@|,$(subst |',|g',$(substitutions)))) \ + < $< > $@ + +all: guardian guardianctrl + +guardian: guardian.in Makefile + $(SED_PROCESS) + +guardianctrl: guardianctrl.in Makefile + $(SED_PROCESS) install: + # Create directory and copy perl modules -mkdir -pv $(PERL_DIR) cp -rvf modules/* $(PERL_DIR) - install -v -m 755 guardian $(DESTDIR)/usr/sbin + # Create sbindir and install guardian daemon + -mkdir -pv $(DESTDIR)/$(SBINDIR) + install -v -m 755 guardian $(DESTDIR)/$(SBINDIR) + # Create bindir and install guardianctrl + -mkdir -pv $(DESTDIR)$(BINDIR) + install -v -m 755 guardianctrl $(DESTDIR)/$(BINDIR) + +clean: + rm -vf guardian + rm -vf guardianctrl + +dist: + # Create temporary dist directory. + -mkdir $(PACKAGE_NAME) + # Copy all required files to the directory. + cp -af \ + Makefile \ + *.in \ + modules \ + README \ + COPYING $(PACKAGE_NAME) + # Create dist tarball. + tar -czf $(PACKAGE_NAME).tar.gz $(PACKAGE_NAME) + # Remove temporary directory again. + rm -rf $(PACKAGE_NAME) -- 2.39.2