Fix Makefile
[openresolv] / Makefile
index e0b24d7ee0d77744d4e79d63586321a96b7effea..edb3853234a3846a69be1804045d2075d38387f2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,19 +1,53 @@
-INSTALL = install 
+NAME = openresolv
+VERSION = 1.0
+PKG = $(NAME)-$(VERSION)
+
+DESTDIR =
+PREFIX =
+MANPREFIX ?= /usr/share
+ROOT = $(DESTDIR)$(PREFIX)
 ETCDIR = $(ROOT)/etc/resolvconf
-MANDIR = $(ROOT)/usr/share/man/man8
+MANDIR = $(MANPREFIX)/man/man8
 BINDIR = $(ROOT)/sbin
-VARDIR = $(ROOT)/var/run
+VARDIR = $(DESTDIR)/var/run
+UPDATEDIR = $(ETCDIR)/update.d
 
-default:
+RESOLVCONF = resolvconf resolvconf.8
+SUBSCRIBERS = libc dnsmasq named
+TARGET = $(RESOLVCONF) $(SUBSCRIBERS)
 
-install:
-       $(INSTALL) -d $(ETCDIR)/resolv.conf.d
-       $(INSTALL) -d $(ETCDIR)/update.d
-       $(INSTALL) -d $(ETCDIR)/update-libc.d
-       $(INSTALL) -d $(MANDIR)
+INSTALL ?= install
+
+.SUFFIXES: .in
+
+all: $(TARGET)
+
+.in:
+       sed -e s':^PREFIX=.*:PREFIX="$(PREFIX)":' $@.in > $@
+
+resolvconf.8: resolvconf.8.in
+       sed -e 's:%%PREFIX%%:$(PREFIX):g' $@.in > $@
+
+clean:
+       rm -f $(TARGET) openresolv-$(VERSION).tar.bz2
+
+install: $(TARGET)
        $(INSTALL) -d $(BINDIR)
        $(INSTALL) -d $(VARDIR)/resolvconf
-       $(INSTALL) bin/resolvconf $(BINDIR)
-       $(INSTALL) update.d/libc $(ETCDIR)/update.d
-       $(INSTALL) -m 644 man/resolvconf.8 $(MANDIR)
-       ln -snf ../../var/run/resolvconf $(ETCDIR)/run
+       $(INSTALL) resolvconf $(BINDIR)
+       $(INSTALL) -d $(MANDIR)
+       $(INSTALL) -d $(ETCDIR)/resolv.conf.d
+       $(INSTALL) -d $(ETCDIR)/update-libc.d
+       $(INSTALL) -d $(UPDATEDIR)
+       $(INSTALL) $(SUBSCRIBERS) $(UPDATEDIR)
+       $(INSTALL) -m 0644 resolvconf.8 $(MANDIR)
+       ln -snf /var/run/resolvconf $(ETCDIR)/run
+
+dist:
+       $(INSTALL) -d /tmp/$(PKG)
+       cp -RPp . /tmp/$(PKG)
+       (cd /tmp/$(PKG); $(MAKE) clean)
+       rm -rf /tmp/$(PKG)/*.bz2 /tmp/$(PKG)/.git
+       tar cvjpf $(PKG).tar.bz2 -C /tmp $(PKG) 
+       rm -rf /tmp/$(PKG) 
+       ls -l $(PKG).tar.bz2