Only update our files if PREFIX is non null and not /
[openresolv] / Makefile
1 VERSION = 1.0
2 DESTDIR =
3 PREFIX =
4 ROOT = $(DESTDIR)$(PREFIX)
5 INSTALL = install 
6 ETCDIR = $(ROOT)/etc/resolvconf
7 SHAREDIR = $(ROOT)/usr/share/man
8 MANDIR = $(SHAREDIR)/man8
9 BINDIR = $(ROOT)/sbin
10 VARDIR = $(DESTDIR)/var/run
11 UPDATEDIR = $(ETCDIR)/update.d
12
13 .PHONY: all default clean
14
15 install:
16         $(INSTALL) -d $(ETCDIR)/resolv.conf.d
17         $(INSTALL) -d $(UPDATEDIR)
18         $(INSTALL) -d $(ETCDIR)/update-libc.d
19         $(INSTALL) -d $(MANDIR)
20         $(INSTALL) -d $(BINDIR)
21         $(INSTALL) -d $(VARDIR)/resolvconf
22         $(INSTALL) resolvconf $(BINDIR)
23         $(INSTALL) libc dnsmasq named $(UPDATEDIR)
24         $(INSTALL) -m 644 resolvconf.8 $(MANDIR)
25         if test "$(PREFIX)" "!=" "/" && test -n "$(PREFIX)"; then \
26                 for x in $(BINDIR)/resolvconf $(UPDATEDIR)/libc $(UPDATEDIR)/dnsmasq $(UPDATEDIR)/named; do \
27                 sed -i.bak -e s':^PREFIX=.*:PREFIX="$(PREFIX)":' "$$x"; rm "$$x".bak; \
28                 done; \
29         fi;
30         sed -i.bak -e 's:%%PREFIX%%:$(PREFIX):g' $(MANDIR)/resolvconf.8
31         rm $(MANDIR)/resolvconf.8.bak; \
32         ln -snf /var/run/resolvconf $(ETCDIR)/run
33
34 dist:
35         $(INSTALL) -m 0755 -d /tmp/openresolv-$(VERSION)
36         cp -RPp . /tmp/openresolv-$(VERSION)
37         (cd /tmp/openresolv-$(VERSION); $(MAKE) clean)
38         rm -rf /tmp/openresolv-$(VERSION)/*.bz2 /tmp/openresolv-$(VERSION)/.git
39         tar cvjpf openresolv-$(VERSION).tar.bz2 -C /tmp openresolv-$(VERSION)
40         rm -rf /tmp/openresolv-$(VERSION)
41         ls -l openresolv-$(VERSION).tar.bz2