From: Stefan Schantl Date: Mon, 27 Jun 2016 10:21:40 +0000 (+0200) Subject: Improve Makefile. X-Git-Tag: 2.0~13 X-Git-Url: http://git.ipfire.org/?p=people%2Fstevee%2Fguardian.git;a=commitdiff_plain;h=24bd3d1109cb280074d1a23e865a0b35257aa913;hp=72ab6e2a564c0c9568d1b89f0f87efc2a612f149 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 --- 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)