Improve Makefile.
[people/stevee/guardian.git] / Makefile
CommitLineData
24bd3d11
SS
1NAME = guardian
2VERSION = 2.0
3
4PACKAGE_NAME = $(NAME)-$(VERSION)
5PACKAGE_VERSION = $(VERSION)
88d9af2c
SS
6
7DESTDIR =
24bd3d11
SS
8PREFIX = /usr
9BINDIR = $(PREFIX)/bin
10SBINDIR = $(PREFIX)/sbin
11SYSCONFDIR = $(PREFIX)/etc
12
88d9af2c
SS
13PERL_VER := $(shell eval "$$(perl -V:version)"; echo $${version};)
14PERL_SITELIB_DIR := $(shell eval "$$(perl -V:installsitelib)"; echo $${installsitelib};)
15
16PERL_DIR = $(DESTDIR)$(PERL_SITELIB_DIR)/$(NAME)/
17
24bd3d11
SS
18SED = sed
19
20substitutions = \
21 '|PACKAGE_NAME=$(PACKAGE_NAME)|' \
22 '|PACKAGE_VERSION=$(PACKAGE_VERSION)|'
23
24SED_PROCESS = \
25 $(SED) $(subst '|,-e 's|@,$(subst =,\@|,$(subst |',|g',$(substitutions)))) \
26 < $< > $@
27
28all: guardian guardianctrl
29
30guardian: guardian.in Makefile
31 $(SED_PROCESS)
32
33guardianctrl: guardianctrl.in Makefile
34 $(SED_PROCESS)
88d9af2c
SS
35
36install:
24bd3d11 37 # Create directory and copy perl modules
88d9af2c
SS
38 -mkdir -pv $(PERL_DIR)
39 cp -rvf modules/* $(PERL_DIR)
24bd3d11
SS
40 # Create sbindir and install guardian daemon
41 -mkdir -pv $(DESTDIR)/$(SBINDIR)
42 install -v -m 755 guardian $(DESTDIR)/$(SBINDIR)
43 # Create bindir and install guardianctrl
44 -mkdir -pv $(DESTDIR)$(BINDIR)
45 install -v -m 755 guardianctrl $(DESTDIR)/$(BINDIR)
46
47clean:
48 rm -vf guardian
49 rm -vf guardianctrl
50
51dist:
52 # Create temporary dist directory.
53 -mkdir $(PACKAGE_NAME)
54 # Copy all required files to the directory.
55 cp -af \
56 Makefile \
57 *.in \
58 modules \
59 README \
60 COPYING $(PACKAGE_NAME)
61 # Create dist tarball.
62 tar -czf $(PACKAGE_NAME).tar.gz $(PACKAGE_NAME)
63 # Remove temporary directory again.
64 rm -rf $(PACKAGE_NAME)