OSDN Git Service

Fix post/pre-remove conflict in mingw-get.xml scripting.
[mingw/mingw-dist.git] / Makefile.comm.in
1 # @configure_input@
2 #
3 # $Id$
4 #
5 # Written by Keith Marshall <keithmarshall@users.sourceforge.net>
6 # Copyright (C) 2010, 2011, MinGW Project
7 #
8 #
9 # Makefile template for generating mingw-get distribution manifests.
10 #
11 #   Project: @PACKAGE_TARNAME@
12 #   Version: @PACKAGE_VERSION@
13 #
14 #
15 # This is free software.  Permission is granted to copy, modify and
16 # redistribute this software, under the provisions of the GNU General
17 # Public License, Version 3, (or, at your option, any later version),
18 # as published by the Free Software Foundation; see the file COPYING
19 # for licensing details.
20 #
21 # Note, in particular, that this software is provided "as is", in the
22 # hope that it may prove useful, but WITHOUT WARRANTY OF ANY KIND; not
23 # even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY
24 # PARTICULAR PURPOSE.  Under no circumstances will the author, or the
25 # MinGW Project, accept liability for any damages, however caused,
26 # arising from the use of this software.
27 #
28 VPATH = ${srcdir}
29
30 # Define hooks for invoking system tools.
31 #
32 LN_S = @LN_S@
33
34 all: all-distfiles
35
36 # To accommodate a top-level make on just a single subdirectory, we list
37 # each of the managed subdirectories as an independent goal, invoking the
38 # "all" action for the target subdirectory.
39 #
40 @mingw_ac_subdirs@: all
41
42 # We use an automatically generated Makefile.sub to manage the list
43 # of distributable files, ensuring that we automatically capture all
44 # XML files in the source directory, and converting them to serialised
45 # LZMA compressed format for upload to the repository server.
46 #
47 Makefile.sub: ${srcdir}/*.xml
48         echo "auto-distfiles = \\" > $@
49         for file in $^; do echo "$$file.lzma \\" | sed 's,.*/,  ,' >> $@; done
50         echo '  $$(EXTRA_DISTFILES)' >> $@
51
52 include Makefile.sub
53 all-distfiles: unpublished $(DISTFILES) $(auto-distfiles)
54
55 # Distributed manifests are serialised by incorporating a date-stamped
56 # issue number, of the form YYYYMMDDNN; we track issue numbers using the
57 # issue.log file, (which we keep in CVS to ensure that all maintainers
58 # can share a common issue number registry).
59 #
60 issue_number = YYYYMMDDNN
61 issue_key = awk '$$3 == "$*.xml" { print $$1 }' issue.new
62 issue_log = ${srcdir}/issue.log
63
64 # We use SHA1 hashes to determine when source files have been changed
65 # from the last published version, as recorded in `issue.log'; the hash
66 # is computed by openssl, after filtering the source through awk; (this
67 # ensures that the computed hash is not influenced by any unintentional
68 # pollution due to accidental insertion of CRLF line endings).
69 #
70 sha1hash = awk '{ sub( "\r$$", "" ); print }' $< | $(sha1sum)
71 sha1sum = openssl sha1 | awk '{print $$NF}'
72
73 # Formatting within issue.log is controlled by PAD and TAB settings.
74 #
75 TAB = [  ]
76 PAD = "  "
77
78 # The following generic rule processes an XML source template, inserting
79 # the appropriate issue number, and compressing to yield the required LZMA
80 # distribution manifest.  The generated issue number which gets applied is
81 # appropriately serialised relative to the original record for the  source
82 # XML file being processed, as noted in the local copy of issue.log, which
83 # is then updated to record the new issue number; to avoid any regression
84 # of issue numbers, all maintainers are advised to update issue.log from
85 # CVS immediately prior manifest generation, and to commit back as soon
86 # as possible thereafter; any ensuing conflict must be resolved before
87 # any updated manifest is uploaded to the repository server.
88 #
89 %.xml.lzma: %.xml
90         >> $(issue_log)
91         rm -f issue.new issue.tmp
92         sed '/^$(TAB)*$$/d;/^$(TAB)*#/d' $(issue_log) > issue.new
93         issue=`awk '$$3 == "$*.xml" { print $$2 }' issue.new`; \
94         if test x$${hash="`$(sha1hash)`"} != x"`$(issue_key)`"; then \
95           test -n "$$issue" || issue=0; \
96           test $$issue -lt $${mark="`date -u +%Y%m%d`00"} && \
97             issue=$$mark || issue=`expr $$issue + 1`; \
98           awk '$$3 != "$*.xml"' issue.new > issue.tmp; \
99           echo $(PAD)$$hash $$issue $*.xml >> issue.tmp; \
100           fi; \
101         sed "s/@$(issue_number)@/$$issue/" $< | lzma -c > $@
102         if test -f issue.tmp; then \
103           sed -n '/^$(TAB)*$$/q;/^$(TAB)*[^#]/q;p' $(issue_log) > issue.new; \
104           LC_COLLATE=POSIX sort -k3 issue.tmp >> issue.new; \
105           sed -n 's/^$(TAB)*$$/break/;1,/^$(TAB)*[^#]/d;/^$(TAB)*#/p' \
106             $(issue_log) >> issue.new; \
107           rm -f $(issue_log) && mv issue.new $(issue_log); \
108           cd unpublished && $(LN_S) -f ../$@ .; \
109           fi
110         rm -f issue.new issue.tmp
111
112 .PHONY: FORCE
113 # An internal target, to specify a dependency which must always be updated.
114 FORCE:
115
116 # Create a local directory in which to collect files which we have generated,
117 # but we have not yet published; (we make this a prerequisite of all sources,
118 # to ensure that it is created when the source directory is scanned to create
119 # Makefile.sub, so that will always exist when any individual source file is
120 # processed, even on explicit file-by-file request).
121 #
122 ${srcdir}/*.xml: unpublished
123 unpublished: FORCE
124         test -d unpublished || mkdir unpublished
125
126 # $RCSfile$: end of file