From: Andrew Ruthven Date: Wed, 19 Dec 2007 21:52:21 +0000 (+1300) Subject: Add support for using DESTDIR. X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c635828c3a82cb9ce6d17ac495f7d0e5ad42e46f;p=spong.git Add support for using DESTDIR. --- diff --git a/Makefile b/Makefile index f025fb7..86ee9ef 100644 --- a/Makefile +++ b/Makefile @@ -57,28 +57,27 @@ client: $(SYSTEM)-client $(SYSTEM)-test: @[ -f ./config/spong.conf.$(SYSTEM) ] || \ ( echo "No such system $(SYSTEM)" && false ) - mkdir -p $(SYSTEM)-client/lib/Spong + mkdir -p $(DESTDIR)$(SYSTEM)-client/lib/Spong -$(SYSTEM)-client: $(SYSTEM)-test clientdir clientlib clientetc clientbin - -find $(SYSTEM)-client -name CVS -exec rm -rf '{}' \; +$(SYSTEM)-client: $(DESTDIR)$(SYSTEM)-test clientdir clientlib clientetc clientbin + -find $(DESTDIR)$(SYSTEM)-client -name CVS -exec rm -rf '{}' \; -clientdir: $(SYSTEM)-client/lib/Spong - [ -d ./$(SYSTEM)-client/lib/Spong ] || \ - mkdir -p ./$(SYSTEM)-client/lib/Spong - [ -d ./$(SYSTEM)-client/etc ] || mkdir ./$(SYSTEM)-client/etc - [ -d ./$(SYSTEM)-client/bin ] || mkdir ./$(SYSTEM)-client/bin - [ -d ./$(SYSTEM)-client/tmp ] || mkdir ./$(SYSTEM)-client/tmp +clientdir: $(DESTDIR)$(SYSTEM)-client/lib/Spong + mkdir -p $(DESTDIR)$(SYSTEM)-client/lib/Spong &> /dev/null + mkdir $(DESTDIR)$(SYSTEM)-client/etc &> /dev/null + mkdir $(DESTDIR)$(SYSTEM)-client/bin &> /dev/null + mkdir $(DESTDIR)$(SYSTEM)-client/tmp &> /dev/null clientlib: - mkdir -p ./$(SYSTEM)-client/lib/Spong - for f in $(CLIENT_LIBS) ; do cp ./src/lib/Spong/$$f $(SYSTEM)-client/lib/Spong/; done - cp -rp ./src/lib/Spong/Client $(SYSTEM)-client/lib/Spong/ - chmod 644 $(SYSTEM)-client/lib/Spong/* - chmod 755 $(SYSTEM)-client/lib/Spong/Client - chown -R $(ADMUSER) ./$(SYSTEM)-client/lib - chgrp -R $(ADMGROUP) ./$(SYSTEM)-client/lib + mkdir -p $(DESTDIR)$(SYSTEM)-client/lib/Spong + for f in $(CLIENT_LIBS) ; do cp ./src/lib/Spong/$$f $(DESTDIR)$(SYSTEM)-client/lib/Spong/; done + cp -rp ./src/lib/Spong/Client $(DESTDIR)$(SYSTEM)-client/lib/Spong/ + chmod 644 $(DESTDIR)$(SYSTEM)-client/lib/Spong/* + chmod 755 $(DESTDIR)$(SYSTEM)-client/lib/Spong/Client + chown -R $(ADMUSER) $(DESTDIR)$(SYSTEM)-client/lib + chgrp -R $(ADMGROUP) $(DESTDIR)$(SYSTEM)-client/lib -clientbin: $(SYSTEM)-client/bin/spong-client +clientbin: $(DESTDIR)$(SYSTEM)-client/bin/spong-client $(SYSTEM)-client/bin/%: ./src/%.pl sed -e "s%@@PERL@@%$(PERL)%g" \ @@ -87,15 +86,15 @@ $(SYSTEM)-client/bin/%: ./src/%.pl -e "s%@@ETCDIR@@%$(ETCDIR)%g" \ -e "s%@@WWWDIR@@%$(WWWDIR)%g" \ $< > $@ - chmod +x ./$(SYSTEM)-client/bin/* - chown $(ADMUSER) ./$(SYSTEM)-client/bin/* - chgrp $(ADMGROUP) ./$(SYSTEM)-client/bin/* + chmod +x $(DESTDIR)$(SYSTEM)-client/bin/* + chown $(ADMUSER) $(DESTDIR)$(SYSTEM)-client/bin/* + chgrp $(ADMGROUP) $(DESTDIR)$(SYSTEM)-client/bin/* clientetc: ./config/spong.conf - for f in $(CCONFIGS) ; do cp ./config/$$f $(SYSTEM)-client/etc; done - cat ./config/spong.conf.$(SYSTEM) >> ./$(SYSTEM)-client/etc/spong.conf - chown -R $(ADMUSER) ./$(SYSTEM)-client/etc - chgrp -R $(ADMGROUP) ./$(SYSTEM)-client/etc + for f in $(CCONFIGS) ; do cp ./config/$$f $(DESTDIR)$(SYSTEM)-client/etc; done + cat ./config/spong.conf.$(SYSTEM) >> $(DESTDIR)$(SYSTEM)-client/etc/spong.conf + chown -R $(ADMUSER) $(DESTDIR)(SYSTEM)-client/etc + chgrp -R $(ADMGROUP) $(DESTDIR)$(SYSTEM)-client/etc client-install: @@ -113,7 +112,7 @@ bindir: $(BINDIR) daemons daemons: $(DAEMONS) $(BINDIR): - mkdir -p $@ + mkdir -p $(DESTDIR)$@ daemons: $(DAEMONS) @@ -123,35 +122,35 @@ $(BINDIR)/%: ./src/%.pl -e "s%@@LIBDIR@@%$(LIBDIR)%g" \ -e "s%@@ETCDIR@@%$(ETCDIR)%g" \ -e "s%@@WWWDIR@@%$(WWWDIR)%g" \ - $< > $@ - chmod -R 755 $(BINDIR) - chown -R $(ADMUSER) $(BINDIR) - chgrp -R $(ADMGROUP) $(BINDIR) + $< > $(DESTDIR)$@ + chmod -R 755 $(DESTDIR)$(BINDIR) + chown -R $(ADMUSER) $(DESTDIR)$(BINDIR) + chgrp -R $(ADMGROUP) $(DESTDIR)$(BINDIR) # --- configs --- etcdir: $(ETCDIR) configs etcown $(ETCDIR): - mkdir -p $@ - chmod 751 $(ETCDIR) + mkdir -p $(DESTDIR)$@ + chmod 751 $(DESTDIR)$(ETCDIR) etcown: - chown -R $(ADMUSER) $(ETCDIR) - chgrp -R $(ADMGROUP) $(ETCDIR) + chown -R $(ADMUSER) $(DESTDIR)$(ETCDIR) + chgrp -R $(ADMGROUP) $(DESTDIR)$(ETCDIR) configs: $(CONFIGS) $(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 $@ + cat $< > $(DESTDIR)$@.dist + cat ./config/spong.conf.$(SYSTEM) >> $(DESTDIR)$@.dist + chmod 644 $(DESTDIR)$@.dist + [ -f $(DESTDIR)$@ ] || mv $(DESTDIR)$@.dist $(DESTDIR)$@ + touch $(DESTDIR)$@ $(ETCDIR)/%: ./config/% - cat $< > $@.dist - [ -f $@ ] || mv $@.dist $@ - touch $@ + cat $< > $(DESTDIR)$@.dist + [ -f $(DESTDIR)$@ ] || mv $(DESTDIR)$@.dist $(DESTDIR)$@ + touch $(DESTDIR)$@ ./config/spong.conf: ./config/spong.conf.in ./utils/mkTarg $< > ./spong.conf.mk @@ -163,59 +162,58 @@ $(ETCDIR)/%: ./config/% libdir: $(LIBDIR) library $(LIBDIR): - mkdir -p $@ + mkdir -p $(DESTDIR)$@ library: $(LIBDIR)/Spong $(LIBDIR)/Spong: ./src/lib/Spong - cp -rp ./src/lib/Spong $(LIBDIR) - cp -rp ./src/lib/List $(LIBDIR) - chmod -R ugo+rwX,go-w $(LIBDIR)/Spong/ - chmod -R ugo+rwX,go-w $(LIBDIR)/List/ - chown -R $(ADMUSER) $(LIBDIR) - chgrp -R $(ADMGROUP) $(LIBDIR) + cp -rp ./src/lib/Spong $(DESTDIR)$(LIBDIR) + cp -rp ./src/lib/List $(DESTDIR)$(LIBDIR) + chmod -R ugo+rwX,go-w $(DESTDIR)$(LIBDIR)/Spong/ + chmod -R ugo+rwX,go-w $(DESTDIR)$(LIBDIR)/List/ + chown -R $(ADMUSER) $(DESTDIR)$(LIBDIR) + chgrp -R $(ADMGROUP) $(DESTDIR)$(LIBDIR) # --- webpages --- webdir: $(WWWDIR) webpages $(WWWDIR): - mkdir -p $@ - mkdir $@/html - chown $(WEBUSER) $@ $@/html - chgrp $(WEBGROUP) $@ $@/html + mkdir -p $(DESTDIR)$@/html + chown -R $(WEBUSER) $(DESTDIR)$@ + chgrp -R $(WEBGROUP) $(DESTDIR)$@ webpages: $(WEBDIRS) $(WEBPAGES) # $(WEBDIRS). Must create WEBDIR first and other directories must be # Subdirectories. $(WWWDIR)/docs: ./www/docs - cp -rp $< $@ - chmod -R ugo+rwX,go-w $@ - chown -R $(WEBUSER) $@ - chgrp -R $(WEBGROUP) $@ + cp -rp $< $(DESTDIR)/$@ + chmod -R ugo+rwX,go-w $(DESTDIR)/$@ + chown -R $(WEBUSER) $(DESTDIR)/$@ + chgrp -R $(WEBGROUP) $(DESTDIR)/$@ $(WWWDIR)/gifs: ./www/gifs - cp -rp $< $@ - chmod -R ugo+rwX,go-w $@ - chown -R $(WEBUSER) $@ - chgrp -R $(WEBGROUP) $@ + 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" $< > $@ - chmod ugo+rwX,go-w $@ - chown $(WEBUSER) $@ - chgrp $(WEBGROUP) $@ + sed -e "s%__DIR__%$(DOCROOT)%g" $< > $(DESTDIR)/$@ + chmod ugo+rwX,go-w $(DESTDIR)/$@ + chown $(WEBUSER) $(DESTDIR)/$@ + chgrp $(WEBGROUP) $(DESTDIR)/$@ # --- cgiscripts --- cgidir: $(CGIDIR) cgiscripts cgiown $(CGIDIR): - mkdir -p $@ + mkdir -p $(DESTDIR)$@ cgiown: - chown -R $(ADMUSER) $(CGIDIR) - chgrp -R $(ADMGROUP) $(CGIDIR) + chown -R $(ADMUSER) $(DESTDIR)$(CGIDIR) + chgrp -R $(ADMGROUP) $(DESTDIR)$(CGIDIR) cgiscripts: $(CGISCRIPTS) @@ -226,37 +224,37 @@ $(CGIDIR)/%: ./src/%.pl -e "s%@@ETCDIR@@%$(ETCDIR)%g" \ -e "s%@@WWWDIR@@%$(WWWDIR)%g" \ -e "s%@@VER@@%$(SPONGVER)%g" \ - $< > $@ - chmod 0755 $@ - chown $(WEBUSER) $@ - chgrp $(WEBGROUP) $@ + $< > $(DESTDIR)$@ + chmod 0755 $(DESTDIR)$@ + chown $(WEBUSER) $(DESTDIR)$@ + chgrp $(WEBGROUP) $(DESTDIR)$@ # --- misc install directories --- tmpdir: $(TMPDIR) $(TMPDIR): - [ -d $@ ] || mkdir -p $@ - chmod ugo+rwX,go-w $@ - chown $(ADMUSER) $@ - chgrp $(ADMGROUP) $@ + [ -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 $@ - chmod ugo+rwX,go-w $@ - chown $(ADMUSER) $@ - chgrp $(ADMGROUP) $@ + [ -d $@ ] || mkdir -p $(DESTDIR)$@ + chmod ugo+rwX,go-w $(DESTDIR)$@ + chown $(ADMUSER) $(DESTDIR)$@ + chgrp $(ADMGROUP) $(DESTDIR)$@ $(DBDIR): - [ -d $@ ] || mkdir -p $@ - chmod ugo+rwX,go-w $@ - chown $(ADMUSER) $@ - chgrp $(ADMGROUP) $@ + [ -d $@ ] || mkdir -p $(DESTDIR)$@ + chmod ugo+rwX,go-w $(DESTDIR)$@ + chown $(ADMUSER) $(DESTDIR)$@ + chgrp $(ADMGROUP) $(DESTDIR)$@ $(VARDIR)/archives: - [ -d $@ ] || mkdir -p $@ - chmod ugo+rwX,go-w $@ - chown $(ADMUSER) $@ - chgrp $(ADMGROUP) $@ + [ -d $@ ] || mkdir -p $(DESTDIR)$@ + chmod ugo+rwX,go-w $(DESTDIR)$@ + chown $(ADMUSER) $(DESTDIR)$@ + chgrp $(ADMGROUP) $(DESTDIR)$@