OSDN Git Service

2012-01-01 Chris Sutcliffe <ir0nh34d@users.sourceforge.net>
[mingw/mingw-dist.git] / Makefile.comm.in
index 3f4ac16..1eae7da 100644 (file)
@@ -3,7 +3,7 @@
 # $Id$
 #
 # Written by Keith Marshall <keithmarshall@users.sourceforge.net>
-# Copyright (C) 2010, MinGW Project
+# Copyright (C) 2010, 2011, MinGW Project
 #
 #
 # Makefile template for generating mingw-get distribution manifests.
 #
 VPATH = ${srcdir}
 
-all: update all-distfiles
+# Define hooks for invoking system tools.
+#
+LN_S = @LN_S@
+
+all: all-distfiles
 
 # To accommodate a top-level make on just a single subdirectory, we list
 # each of the managed subdirectories as an independent goal, invoking the
@@ -46,7 +50,7 @@ Makefile.sub: ${srcdir}/*.xml
        echo '  $$(EXTRA_DISTFILES)' >> $@
 
 include Makefile.sub
-all-distfiles: $(DISTFILES) $(auto-distfiles)
+all-distfiles: unpublished $(DISTFILES) $(auto-distfiles)
 
 # Distributed manifests are serialised by incorporating a date-stamped
 # issue number, of the form YYYYMMDDNN; we track issue numbers using the
@@ -54,11 +58,17 @@ all-distfiles: $(DISTFILES) $(auto-distfiles)
 # can share a common issue number registry).
 #
 issue_number = YYYYMMDDNN
+issue_key = awk '$$3 == "$*.xml" { print $$1 }' issue.new
 issue_log = ${srcdir}/issue.log
 
-update: FORCE
-       cd ${srcdir}; cvs -z3 -Q update -AC issue.log
-       rm -f ${srcdir}'/.#issue.log'*
+# We use SHA1 hashes to determine when source files have been changed
+# from the last published version, as recorded in `issue.log'; the hash
+# is computed by openssl, after filtering the source through awk; (this
+# ensures that the computed hash is not influenced by any unintentional
+# pollution due to accidental insertion of CRLF line endings).
+#
+sha1hash = awk '{ sub( "\r$$", "" ); print }' $< | $(sha1sum)
+sha1sum = openssl sha1 | awk '{print $$NF}'
 
 # Formatting within issue.log is controlled by PAD and TAB settings.
 #
@@ -78,21 +88,39 @@ PAD = "  "
 #
 %.xml.lzma: %.xml
        >> $(issue_log)
-       sed '/^$(TAB)*$$/d;/^$(TAB)*#/d' $(issue_log) > issue.tmp
-       sed -n '/^$(TAB)*$$/q;/^$(TAB)*[^#]/q;p' $(issue_log) > issue.new
-       test x$${issue="`sed -n 's/^$(TAB)*$*.xml://p' $(issue_log)`"} = x && \
-         issue=0 && echo $(PAD)"$*.xml:0" >> issue.tmp; \
-       test $$issue -lt $${mark="`date -u +%Y%m%d`00"} && \
-         issue=$$mark || issue=`expr $$issue + 1`; \
-       sed "s/^\($(TAB)*$*.xml:\).*/\1$$issue/" issue.tmp | sort >> issue.new; \
+       rm -f issue.new issue.tmp
+       sed '/^$(TAB)*$$/d;/^$(TAB)*#/d' $(issue_log) > issue.new
+       issue=`awk '$$3 == "$*.xml" { print $$2 }' issue.new`; \
+       if test x$${hash="`$(sha1hash)`"} != x"`$(issue_key)`"; then \
+         test -n "$$issue" || issue=0; \
+         test $$issue -lt $${mark="`date -u +%Y%m%d`00"} && \
+           issue=$$mark || issue=`expr $$issue + 1`; \
+         awk '$$3 != "$*.xml"' issue.new > issue.tmp; \
+         echo $(PAD)$$hash $$issue $*.xml >> issue.tmp; \
+         fi; \
        sed "s/@$(issue_number)@/$$issue/" $< | lzma -c > $@
-       sed -n 's/^$(TAB)*$$/break/;1,/^$(TAB)*[^#]/d;/^$(TAB)*#/p' \
-         $(issue_log) >> issue.new
-       rm -f $(issue_log) issue.tmp
-       mv issue.new $(issue_log)
+       if test -f issue.tmp; then \
+         sed -n '/^$(TAB)*$$/q;/^$(TAB)*[^#]/q;p' $(issue_log) > issue.new; \
+         LC_COLLATE=POSIX sort -k3 issue.tmp >> issue.new; \
+         sed -n 's/^$(TAB)*$$/break/;1,/^$(TAB)*[^#]/d;/^$(TAB)*#/p' \
+           $(issue_log) >> issue.new; \
+         rm -f $(issue_log) && mv issue.new $(issue_log); \
+         cd unpublished && $(LN_S) -f ../$@ .; \
+         fi
+       rm -f issue.new issue.tmp
 
 .PHONY: FORCE
 # An internal target, to specify a dependency which must always be updated.
 FORCE:
 
+# Create a local directory in which to collect files which we have generated,
+# but we have not yet published; (we make this a prerequisite of all sources,
+# to ensure that it is created when the source directory is scanned to create
+# Makefile.sub, so that will always exist when any individual source file is
+# processed, even on explicit file-by-file request).
+#
+${srcdir}/*.xml: unpublished
+unpublished: FORCE
+       test -d unpublished || mkdir unpublished
+
 # $RCSfile$: end of file