Update Makefile so we have a better install sytsem and we only change files in our...
authorRoy Marples <roy@marples.name>
Fri, 16 Nov 2007 11:32:22 +0000 (11:32 +0000)
committerRoy Marples <roy@marples.name>
Fri, 16 Nov 2007 11:32:22 +0000 (11:32 +0000)
Makefile

index 29af5fcfeb80d5bdc91116b6688c0c38998e6c6e..594fb12348e95569be2e68baaab3db0eb0d96d65 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,9 +10,25 @@ BINDIR = $(ROOT)/sbin
 VARDIR = $(DESTDIR)/var/run
 UPDATEDIR = $(ETCDIR)/update.d
 
-.PHONY: all default clean
+RESOLVCONF = resolvconf resolvconf.8
+SUBSCRIBERS = libc dnsmasq named
+TARGET = $(RESOLVCONF) $(SUBSCRIBERS)
 
-install:
+all: $(TARGET)
+
+$(SUBSCRIBERS): $*.in
+       sed -e s':^PREFIX=.*:PREFIX="$(PREFIX)":' $*.in > $*
+
+resolvconf: $*.in
+       sed -e s':^PREFIX=.*:PREFIX="$(PREFIX)":' $*.in > $*
+
+resolvconf.8:
+       sed -e 's:%%PREFIX%%:$(PREFIX):g' $*.in > $*
+
+clean:
+       rm $(TARGET)
+
+install: $(TARGET)
        $(INSTALL) -d $(BINDIR)
        $(INSTALL) -d $(VARDIR)/resolvconf
        $(INSTALL) resolvconf $(BINDIR)
@@ -20,15 +36,8 @@ install:
        $(INSTALL) -d $(ETCDIR)/resolv.conf.d
        $(INSTALL) -d $(ETCDIR)/update-libc.d
        $(INSTALL) -d $(UPDATEDIR)
-       $(INSTALL) libc dnsmasq named $(UPDATEDIR)
+       $(INSTALL) $(SUBSCRIBERS) $(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: