All vars should be upper case and descriptive.
[openresolv] / Makefile
index 594fb12348e95569be2e68baaab3db0eb0d96d65..030ba5a739aad354bb356932126d59d18581da9c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,13 @@
-VERSION = 1.0
-DESTDIR =
-PREFIX =
+NAME = openresolv
+VERSION = 1.2
+PKG = $(NAME)-$(VERSION)
+
+INSTALL ?= install
 MANPREFIX ?= /usr/share
+
 ROOT = $(DESTDIR)$(PREFIX)
-INSTALL = install 
 ETCDIR = $(ROOT)/etc/resolvconf
-MANDIR = $(MANPREFIX)/man/man8
+MANDIR = $(DESTDIR)$(MANPREFIX)/man/man8
 BINDIR = $(ROOT)/sbin
 VARDIR = $(DESTDIR)/var/run
 UPDATEDIR = $(ETCDIR)/update.d
@@ -14,19 +16,18 @@ RESOLVCONF = resolvconf resolvconf.8
 SUBSCRIBERS = libc dnsmasq named
 TARGET = $(RESOLVCONF) $(SUBSCRIBERS)
 
-all: $(TARGET)
+.SUFFIXES: .in
 
-$(SUBSCRIBERS): $*.in
-       sed -e s':^PREFIX=.*:PREFIX="$(PREFIX)":' $*.in > $*
+all: $(TARGET)
 
-resolvconf: $*.in
-       sed -e s':^PREFIX=.*:PREFIX="$(PREFIX)":' $*.in > $*
+.in:
+       sed -e s':^PREFIX=.*:PREFIX="$(PREFIX)":' $@.in > $@
 
-resolvconf.8:
-       sed -e 's:%%PREFIX%%:$(PREFIX):g' $*.in > $*
+resolvconf.8: resolvconf.8.in
+       sed -e 's:@PREFIX@:$(PREFIX):g' $@.in > $@
 
 clean:
-       rm $(TARGET)
+       rm -f $(TARGET) openresolv-$(VERSION).tar.bz2
 
 install: $(TARGET)
        $(INSTALL) -d $(BINDIR)
@@ -37,14 +38,14 @@ install: $(TARGET)
        $(INSTALL) -d $(ETCDIR)/update-libc.d
        $(INSTALL) -d $(UPDATEDIR)
        $(INSTALL) $(SUBSCRIBERS) $(UPDATEDIR)
-       $(INSTALL) -m 644 resolvconf.8 $(MANDIR)
+       $(INSTALL) -m 0644 resolvconf.8 $(MANDIR)
        ln -snf /var/run/resolvconf $(ETCDIR)/run
 
 dist:
-       $(INSTALL) -m 0755 -d /tmp/openresolv-$(VERSION)
-       cp -RPp . /tmp/openresolv-$(VERSION)
-       (cd /tmp/openresolv-$(VERSION); $(MAKE) clean)
-       rm -rf /tmp/openresolv-$(VERSION)/*.bz2 /tmp/openresolv-$(VERSION)/.git
-       tar cvjpf openresolv-$(VERSION).tar.bz2 -C /tmp openresolv-$(VERSION)
-       rm -rf /tmp/openresolv-$(VERSION)
-       ls -l openresolv-$(VERSION).tar.bz2
+       $(INSTALL) -d /tmp/$(PKG)
+       cp -RPp . /tmp/$(PKG)
+       (cd /tmp/$(PKG); $(MAKE) clean)
+       rm -rf /tmp/$(PKG)/*.bz2 /tmp/$(PKG)/.git /tmp/$(PKG)/.gitignore
+       tar cvjpf $(PKG).tar.bz2 -C /tmp $(PKG) 
+       rm -rf /tmp/$(PKG) 
+       ls -l $(PKG).tar.bz2