# Makefile for userv-git-daemon
#
-# This was written by Tony Finch <dot@dotat.at>
+# This was written by Tony Finch <dot@dotat.at> and subsequently
+# heavily modified by Ian Jackson <ijackson@chiark.greenend.org.uk>
# You may do anything with it, at your own risk.
# http://creativecommons.org/publicdomain/zero/1.0/
include ../settings.make
-TARGETS= git-upload-pack inetd.conf
+gituser= git
+varloggit= $(varlog)/git
-SUBSTVARS= libuserv etcuserv
-SEDSCRIPT= '$(foreach f, $(SUBSTVARS), s,@$f@,$($f),g; )'
+TARGETS= git-upload-pack inetd.conf git-daemon git-service logrotate
+
+SUBSTVARS= libuserv etcuserv varloggit gituser
+
+CONFIGS= $(services)/git-upload-pack \
+ $(etcuserv)/git-urlmap \
+ $(etcdir)/logrotate.d/userv-git-daemon
all: $(TARGETS)
-%: %.in
- sed $(SEDSCRIPT) <$< >$@.new && mv -f $@.new $@
+sedscript: Makefile read-urlmap
+ echo >$@.new '$(foreach f, $(SUBSTVARS), s,@$f@,$($f),g; )'
+ echo >>$@.new '/@@READ_URLMAP@@/c\'
+ perl >>$@.new -pe 's/\\/\\\\/g; s/$$/\\/' <read-urlmap
+ mv -f $@.new $@
+
+%: %.in sedscript
+ set -e; \
+ sed -f sedscript <$< >$@.new; \
+ if test -x $<; then chmod +x $@.new; fi; \
+ mv -f $@.new $@
install: all
- mkdir -p $(libuserv) $(etcuserv) $(services)
+ mkdir -p $(libuserv) $(etcuserv) $(services) \
+ $(etcdir)/logrotate.d
+ install -d -o $(gituser) -g adm $(varloggit)
cp git-daemon git-service $(libuserv)
- cp git-upload-pack $(services)
- cp git-urlmap $(etcuserv)
-
-clean:
- rm -f $(TARGETS)
+ cp git-upload-pack $(services)/git-upload-pack:new
+ cp git-urlmap $(etcuserv)/git-urlmap:new
+ cp logrotate $(etcdir)/logrotate.d/userv-git-daemon:new
+ set -e; for f in $(CONFIGS); do \
+ if test -f $$f; then continue; fi; \
+ mv $$f:new $$f; \
+ done
+
+distclean clean:
+ rm -f $(TARGETS) *~
# end