From: Andrew Ruthven Date: Wed, 19 Dec 2007 22:19:30 +0000 (+1300) Subject: Fix up DESTDIR to work even if spong files exist in $PREFIX. X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40a6428755e9f0795ec47722bdd09baff13710fe;p=spong.git Fix up DESTDIR to work even if spong files exist in $PREFIX. --- diff --git a/Makefile b/Makefile index 86ee9ef..eea3a22 100644 --- a/Makefile +++ b/Makefile @@ -107,50 +107,51 @@ cvsclean: # --- daemons --- -bindir: $(BINDIR) daemons +bindir: $(DESTDIR)$(BINDIR) daemons daemons: $(DAEMONS) -$(BINDIR): - mkdir -p $(DESTDIR)$@ +$(DESTDIR)$(BINDIR): + mkdir -p $@ -daemons: $(DAEMONS) +daemons: $(foreach daemon, $(DAEMONS), $(DESTDIR)$(daemon)) -$(BINDIR)/%: ./src/%.pl +$(DESTDIR)$(BINDIR)/%: ./src/%.pl sed -e "s%@@PERL@@%$(PERL)%g" \ -e "s%@@BINDIR@@%$(BINDIR)%g" \ -e "s%@@LIBDIR@@%$(LIBDIR)%g" \ -e "s%@@ETCDIR@@%$(ETCDIR)%g" \ -e "s%@@WWWDIR@@%$(WWWDIR)%g" \ - $< > $(DESTDIR)$@ - chmod -R 755 $(DESTDIR)$(BINDIR) - chown -R $(ADMUSER) $(DESTDIR)$(BINDIR) - chgrp -R $(ADMGROUP) $(DESTDIR)$(BINDIR) + $< > $@ + chmod -R 755 $(@D) + chown -R $(ADMUSER) $(@D) + chgrp -R $(ADMGROUP) $(@D) # --- configs --- -etcdir: $(ETCDIR) configs etcown +etcdir: $(DESTDIR)$(ETCDIR) configs etcown + +$(DESTDIR)$(ETCDIR): + mkdir -p $@ + chmod 751 $(ETCDIR) -$(ETCDIR): - mkdir -p $(DESTDIR)$@ - chmod 751 $(DESTDIR)$(ETCDIR) etcown: chown -R $(ADMUSER) $(DESTDIR)$(ETCDIR) chgrp -R $(ADMGROUP) $(DESTDIR)$(ETCDIR) -configs: $(CONFIGS) +configs: $(foreach config, $(CONFIGS), $(DESTDIR)$(config)) -$(ETCDIR)/spong.conf: ./config/spong.conf ./config/spong.conf.$(SYSTEM) - cat $< > $(DESTDIR)$@.dist - cat ./config/spong.conf.$(SYSTEM) >> $(DESTDIR)$@.dist - chmod 644 $(DESTDIR)$@.dist - [ -f $(DESTDIR)$@ ] || mv $(DESTDIR)$@.dist $(DESTDIR)$@ - touch $(DESTDIR)$@ +$(DESTDIR)$(ETCDIR)/spong.conf: ./config/spong.conf ./config/spong.conf.$(SYSTEM) + cat $< > $@.dist + cat ./config/spong.conf.$(SYSTEM) >> $@.dist + chmod 644 $@.dist + [ -f $@ ] || mv $@.dist $@ + touch $@ -$(ETCDIR)/%: ./config/% - cat $< > $(DESTDIR)$@.dist - [ -f $(DESTDIR)$@ ] || mv $(DESTDIR)$@.dist $(DESTDIR)$@ - touch $(DESTDIR)$@ +$(DESTDIR)$(ETCDIR)/%: ./config/% + cat $< > $@.dist + [ -f $@ ] || mv $@.dist $@ + touch $@ ./config/spong.conf: ./config/spong.conf.in ./utils/mkTarg $< > ./spong.conf.mk @@ -159,14 +160,14 @@ $(ETCDIR)/%: ./config/% # --- library --- -libdir: $(LIBDIR) library +libdir: $(DESTDIR)$(LIBDIR) library -$(LIBDIR): - mkdir -p $(DESTDIR)$@ +$(DESTDIR)$(LIBDIR): + mkdir -p $@ -library: $(LIBDIR)/Spong +library: $(DESTDIR)$(LIBDIR)/Spong -$(LIBDIR)/Spong: ./src/lib/Spong +$(DESTDIR)$(LIBDIR)/Spong: ./src/lib/Spong cp -rp ./src/lib/Spong $(DESTDIR)$(LIBDIR) cp -rp ./src/lib/List $(DESTDIR)$(LIBDIR) chmod -R ugo+rwX,go-w $(DESTDIR)$(LIBDIR)/Spong/ @@ -176,85 +177,85 @@ $(LIBDIR)/Spong: ./src/lib/Spong # --- webpages --- -webdir: $(WWWDIR) webpages +webdir: $(DESTDIR)$(WWWDIR) webpages -$(WWWDIR): - mkdir -p $(DESTDIR)$@/html - chown -R $(WEBUSER) $(DESTDIR)$@ - chgrp -R $(WEBGROUP) $(DESTDIR)$@ +$(DESTDIR)$(WWWDIR): + mkdir -p $@/html + chown -R $(WEBUSER) $@ + chgrp -R $(WEBGROUP) $@ -webpages: $(WEBDIRS) $(WEBPAGES) +webpages: $(foreach webdir, $(WEBDIRS), $(DESTDIR)$(webdir)) $(foreach webpage, $(WEBPAGES), $(DESTDIR)$(webpage)) # $(WEBDIRS). Must create WEBDIR first and other directories must be # Subdirectories. -$(WWWDIR)/docs: ./www/docs - cp -rp $< $(DESTDIR)/$@ - chmod -R ugo+rwX,go-w $(DESTDIR)/$@ - chown -R $(WEBUSER) $(DESTDIR)/$@ - chgrp -R $(WEBGROUP) $(DESTDIR)/$@ - -$(WWWDIR)/gifs: ./www/gifs - cp -rp $< $(DESTDIR)/$@ - chmod -R ugo+rwX,go-w $(DESTDIR)/$@ - chown -R $(WEBUSER) $(DESTDIR)/$@ - chgrp -R $(WEBGROUP) $(DESTDIR)/$@ - -$(WWWDIR)/html/%: ./www/html/% - sed -e "s%__DIR__%$(DOCROOT)%g" $< > $(DESTDIR)/$@ - chmod ugo+rwX,go-w $(DESTDIR)/$@ - chown $(WEBUSER) $(DESTDIR)/$@ - chgrp $(WEBGROUP) $(DESTDIR)/$@ +$(DESTDIR)$(WWWDIR)/docs: ./www/docs + cp -rp $< $@ + chmod -R ugo+rwX,go-w $@ + chown -R $(WEBUSER) $@ + chgrp -R $(WEBGROUP) $@ + +$(DESTDIR)$(WWWDIR)/gifs: ./www/gifs + cp -rp $< $@ + chmod -R ugo+rwX,go-w $@ + chown -R $(WEBUSER) $@ + chgrp -R $(WEBGROUP) $@ + +$(DESTDIR)$(WWWDIR)/html/%: ./www/html/% + sed -e "s%__DIR__%$(DOCROOT)%g" $< > $@ + chmod ugo+rwX,go-w $@ + chown $(WEBUSER) $@ + chgrp $(WEBGROUP) $@ # --- cgiscripts --- -cgidir: $(CGIDIR) cgiscripts cgiown +cgidir: $(DESTDIR)$(CGIDIR) cgiscripts cgiown -$(CGIDIR): - mkdir -p $(DESTDIR)$@ +$(DESTDIR)$(CGIDIR): + mkdir -p $@ cgiown: chown -R $(ADMUSER) $(DESTDIR)$(CGIDIR) chgrp -R $(ADMGROUP) $(DESTDIR)$(CGIDIR) -cgiscripts: $(CGISCRIPTS) +cgiscripts: $(foreach script, $(CGISCRIPTS), $(DESTDIR)$(script)) -$(CGIDIR)/%: ./src/%.pl +$(DESTDIR)$(CGIDIR)/%: ./src/%.pl sed -e "s%@@PERL@@%$(PERL)%g" \ -e "s%@@BINDIR@@%$(BINDIR)%g" \ -e "s%@@LIBDIR@@%$(LIBDIR)%g" \ -e "s%@@ETCDIR@@%$(ETCDIR)%g" \ -e "s%@@WWWDIR@@%$(WWWDIR)%g" \ -e "s%@@VER@@%$(SPONGVER)%g" \ - $< > $(DESTDIR)$@ - chmod 0755 $(DESTDIR)$@ - chown $(WEBUSER) $(DESTDIR)$@ - chgrp $(WEBGROUP) $(DESTDIR)$@ + $< > $@ + chmod 0755 $@ + chown $(WEBUSER) $@ + chgrp $(WEBGROUP) $@ # --- misc install directories --- -tmpdir: $(TMPDIR) - -$(TMPDIR): - [ -d $@ ] || mkdir -p $(DESTDIR)$@ - chmod ugo+rwX,go-w $(DESTDIR)$@ - chown $(ADMUSER) $(DESTDIR)$@ - chgrp $(ADMGROUP) $(DESTDIR)$@ - -vardir: $(VARDIR) $(VARDIR)/archives $(DBDIR) - -$(VARDIR): - [ -d $@ ] || mkdir -p $(DESTDIR)$@ - chmod ugo+rwX,go-w $(DESTDIR)$@ - chown $(ADMUSER) $(DESTDIR)$@ - chgrp $(ADMGROUP) $(DESTDIR)$@ - -$(DBDIR): - [ -d $@ ] || mkdir -p $(DESTDIR)$@ - chmod ugo+rwX,go-w $(DESTDIR)$@ - chown $(ADMUSER) $(DESTDIR)$@ - chgrp $(ADMGROUP) $(DESTDIR)$@ - -$(VARDIR)/archives: - [ -d $@ ] || mkdir -p $(DESTDIR)$@ - chmod ugo+rwX,go-w $(DESTDIR)$@ - chown $(ADMUSER) $(DESTDIR)$@ - chgrp $(ADMGROUP) $(DESTDIR)$@ +tmpdir: $(DESTDIR)$(TMPDIR) + +$(DESTDIR)$(TMPDIR): + [ -d $@ ] || mkdir -p $@ + chmod ugo+rwX,go-w $@ + chown $(ADMUSER) $@ + chgrp $(ADMGROUP) $@ + +vardir: $(DESTDIR)$(VARDIR) $(DESTDIR)$(VARDIR)/archives $(DESTDIR)$(DBDIR) + +$(DESTDIR)$(VARDIR): + [ -d $@ ] || mkdir -p $@ + chmod ugo+rwX,go-w $@ + chown $(ADMUSER) $@ + chgrp $(ADMGROUP) $@ + +$(DESTDIR)$(DBDIR): + [ -d $@ ] || mkdir -p $@ + chmod ugo+rwX,go-w $@ + chown $(ADMUSER) $@ + chgrp $(ADMGROUP) $@ + +$(DESTDIR)$(VARDIR)/archives: + [ -d $@ ] || mkdir -p $@ + chmod ugo+rwX,go-w $@ + chown $(ADMUSER) $@ + chgrp $(ADMGROUP) $@