Fix typo
[openresolv] / Makefile
index e0b24d7ee0d77744d4e79d63586321a96b7effea..29af5fcfeb80d5bdc91116b6688c0c38998e6c6e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,19 +1,41 @@
+VERSION = 1.0
+DESTDIR =
+PREFIX =
+MANPREFIX ?= /usr/share
+ROOT = $(DESTDIR)$(PREFIX)
 INSTALL = install 
 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:
+.PHONY: all default clean
 
 install:
-       $(INSTALL) -d $(ETCDIR)/resolv.conf.d
-       $(INSTALL) -d $(ETCDIR)/update.d
-       $(INSTALL) -d $(ETCDIR)/update-libc.d
-       $(INSTALL) -d $(MANDIR)
        $(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) libc dnsmasq named $(UPDATEDIR)
+       $(INSTALL) -m 644 resolvconf.8 $(MANDIR)
+       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