Don't rely on /etc/init.d being OpenRC
[openresolv] / Makefile
index 21406c2056fa15e1e36e86a94c566b7a8995c171..d1a7c58f507e6c11887c892e107a1d2afedb341f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,19 +1,41 @@
+VERSION = 1.0
+DESTDIR =
+PREFIX =
+ROOT = $(DESTDIR)$(PREFIX)
 INSTALL = install 
 ETCDIR = $(ROOT)/etc/resolvconf
-MANDIR = $(ROOT)/usr/share/man/man8
+SHAREDIR = $(ROOT)/usr/share/man
+MANDIR = $(SHAREDIR)/man8
 BINDIR = $(ROOT)/sbin
-VARDIR = $(ROOT)/var/run
+VARDIR = $(DESTDIR)/var/run
+UPDATEDIR = $(ETCDIR)/update.d
 
-default:
+.PHONY: all default clean
 
 install:
        $(INSTALL) -d $(ETCDIR)/resolv.conf.d
-       $(INSTALL) -d $(ETCDIR)/update.d
+       $(INSTALL) -d $(UPDATEDIR)
        $(INSTALL) -d $(ETCDIR)/update-libc.d
        $(INSTALL) -d $(MANDIR)
        $(INSTALL) -d $(BINDIR)
        $(INSTALL) -d $(VARDIR)/resolvconf
        $(INSTALL) resolvconf $(BINDIR)
-       $(INSTALL) libc $(ETCDIR)/update.d
+       $(INSTALL) libc dnsmasq named $(UPDATEDIR)
        $(INSTALL) -m 644 resolvconf.8 $(MANDIR)
-       ln -snf ../../var/run/resolvconf $(ETCDIR)/run
+       if test "$(PREFIX)" "!=" "/" && test -n "$(PREFIX)"; then \
+               for x in $(BINDIR)/resolvconf $(UPDATEDIR)/libc $(UPDATEDIR)/dnsmasq $(UPDATEDIR)/named; do \
+               sed -i.bak -e s':^PREFIX=.*:PREFIX="$(PREFIX)":' "$$x"; rm "$$x".bak; \
+               done; \
+       fi;
+       sed -i.bak -e 's:%%PREFIX%%:$(PREFIX):g' $(MANDIR)/resolvconf.8
+       rm $(MANDIR)/resolvconf.8.bak; \
+       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