Commit 6e1a268c 6e1a268c87b1140ded9eaac67bf49d85d7dab2ec by Sergey Poznyakoff

Make sure ChangeLog is built by make

* Makefile.am: Mark ChangeLog as noinst_DATA to trigger
its rule.  Rewrite the ChangeLog rule using a wrapper
over gitlog-to-changelog, which rewrites the file only
when needed.
(dist-hook): Fail if there are uncommitted changes.
* mu-aux/gencl: New file.

* maint.mk: Remove.
1 parent fe4bfde5
...@@ -123,45 +123,45 @@ SUBDIRS = . \ ...@@ -123,45 +123,45 @@ SUBDIRS = . \
123 EXTRA_DIST = COPYING.LESSER paths 123 EXTRA_DIST = COPYING.LESSER paths
124 DISTCLEANFILES = pathdefs.h 124 DISTCLEANFILES = pathdefs.h
125 125
126 # Trigger creation of the ChangeLog
127 noinst_DATA = ChangeLog
128
126 gen_start_date = "2008-12-08" 129 gen_start_date = "2008-12-08"
127 prev_change_log = "doc/ChangeLog.CVS" 130 prev_change_log = "doc/ChangeLog.CVS"
128 amend_file=ChangeLog.amend 131 amend_file=ChangeLog.amend
129 132
130 .PHONY: ChangeLog 133 .PHONY: ChangeLog
131 ChangeLog: 134 ChangeLog:
132 @if test -d .git; then \ 135 $(AM_V_at)if test -d .git; then \
133 cmd="$(top_srcdir)/build-aux/gitlog-to-changelog"; \ 136 cmd="$(top_srcdir)/mu-aux/gencl --file=ChangeLog --verbose";\
134 if test -n "$(amend_file)"; then \ 137 if test -n "$(prev_change_log)" && test -f "$(prev_change_log)"; \
135 cmd="$$cmd --amend=$(amend_file)"; \ 138 then \
136 fi; \ 139 cmd="$$cmd --append=$(prev_change_log)"; \
137 if test -n "$(gen_start_date)"; then \ 140 fi; \
138 cmd="$$cmd --since=\"$(gen_start_date)\""; \ 141 cmd="$$cmd -- $(top_srcdir)/build-aux/gitlog-to-changelog"; \
139 fi; \ 142 if test -n "$(amend_file)"; then \
140 $$cmd --format='%s%n%n%b%n' | \ 143 cmd="$$cmd --amend=$(amend_file)"; \
141 sed '/<unknown>$$/d' | fmt -s > cl-t; \ 144 fi; \
142 if test -n "$(prev_change_log)" && test -f "$(prev_change_log)"; \ 145 if test -n "$(gen_start_date)"; then \
143 then \ 146 cmd="$$cmd --since=\"$(gen_start_date)\""; \
144 echo "" >> cl-t; \ 147 fi; \
145 cat "$(prev_change_log)" | \ 148 $$cmd --format='%s%n%n%b%n' | fmt -s; \
146 sed '/^Local Variables:/,/^End:/d' >> cl-t; \
147 fi; \
148 echo "Local Variables:" >> cl-t; \
149 echo "mode: change-log" >> cl-t; \
150 echo "version-control: never" >> cl-t; \
151 echo "buffer-read-only: t" >> cl-t; \
152 echo "End:" >> cl-t; \
153 rm -f ChangeLog; \
154 mv cl-t ChangeLog; \
155 fi 149 fi
156 150
157 dist-hook: ChangeLog 151 dist-hook: ChangeLog
158 @PATCHLEV=`echo "$(PACKAGE_VERSION)" | \ 152 @if head -n 6 ChangeLog | grep -q 'Uncommitted changes' ; \
159 sed -r "s/[0-9]+\.[0-9]+\.?//"`; \ 153 then \
160 if test $${PATCHLEV:-0} -lt 50; then \ 154 echo >&2 "*** Source tree contains uncommitted changes"; \
161 if grep -q FIXME NEWS; then \ 155 echo >&2 "*** Aborting"; \
162 echo >&2 "NEWS file contains FIXMEs"; \ 156 exit 1; \
163 exit 1; \ 157 fi; \
164 fi; \ 158 PATCHLEV=`echo "$(PACKAGE_VERSION)" | sed -r "s/[0-9]+\.[0-9]+\.?//"`;\
159 if test $${PATCHLEV:-0} -lt 50; then \
160 if grep -q FIXME NEWS; then \
161 echo >&2 "*** NEWS file contains FIXMEs"; \
162 echo >&2 "*** Aborting"; \
163 exit 1; \
164 fi; \
165 fi 165 fi
166 166
167 alpha: 167 alpha:
......
1 # This file is part of GNU Mailutils.
2 # Copyright (C) 2009-2012, 2014-2017 Free Software Foundation, Inc.
3 #
4 # Written by Sergey Poznyakoff
5 #
6 # GNU Mailutils is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3, or (at your option)
9 # any later version.
10 #
11 # GNU Mailutils is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
18
19 include Makefile
20
21 CFLOW_FLAGS=-i^s --brief -v
22
23 MAINT_CLEAN_FILES=
24
25 define flowgraph_tmpl
26 MAINT_CLEAN_FILES += $(1).cflow
27 $(2)_CFLOW_INPUT=$$($(2)_OBJECTS:.$(3)=.c)
28 $(1).cflow: $$($(2)_CFLOW_INPUT) Makefile
29 cflow -o$$@ $$(CFLOW_FLAGS) $$(DEFS) \
30 $$(DEFAULT_INCLUDES) $$(INCLUDES) $$(AM_CPPFLAGS) \
31 $$(CPPFLAGS) \
32 $$($(2)_CFLOW_INPUT)
33 endef
34
35 $(foreach prog,$(bin_PROGRAMS) $(sbin_PROGRAMS),\
36 $(eval $(call flowgraph_tmpl,$(prog),$(subst -,_,$(prog)),$(OBJEXT))))
37
38 $(foreach prog,$(lib_LTLIBRARIES),\
39 $(eval $(call flowgraph_tmpl,$(prog),$(subst .,_,$(prog)),lo)))
40
41 all: flowgraph-recursive
42
43 flowgraph: $(foreach prog,$(bin_PROGRAMS) $(sbin_PROGRAMS) $(lib_LTLIBRARIES),$(prog).cflow)
44
45 maintclean:
46 -test -n "$(MAINT_CLEAN_FILES)" && rm -f $(MAINT_CLEAN_FILES)
47
48 ##
49
50 MAINT_MK = maint.mk
51
52 MAINT_RECURSIVE_TARGETS=flowgraph-recursive maintclean-recursive
53
54 $(MAINT_RECURSIVE_TARGETS):
55 @cwd=`pwd`; \
56 failcom='exit 1'; \
57 for f in x $$MAKEFLAGS; do \
58 case $$f in \
59 *=* | --[!k]*);; \
60 *k*) failcom='fail=yes';; \
61 esac; \
62 done; \
63 dot_seen=no; \
64 target=`echo $@ | sed s/-recursive//`; \
65 list='$(SUBDIRS)'; for subdir in $$list; do \
66 echo "Making $$target in $$subdir"; \
67 if test "$$subdir" = "."; then \
68 dot_seen=yes; \
69 local_target="$$target-am"; \
70 else \
71 local_target="$$target"; \
72 fi; \
73 if test -f $$subdir/$(MAINT_MK); then \
74 makefile='$(MAINT_MK)'; \
75 else \
76 makefile="$$cwd/maint.mk"; \
77 fi; \
78 $(MAKE) -C $$subdir -f $$makefile $$local_target \
79 || eval $$failcom; \
80 done; \
81 test -z "$$fail"
1 eval '(exit $?0)' && eval 'exec perl -wS "$0" "$@"'
2 & eval 'exec perl -wS "$0" $argv:q'
3 if 0;
4
5 use strict;
6 use POSIX qw(strftime);
7 use Getopt::Long qw(:config gnu_getopt no_ignore_case);
8
9 my @append_files;
10 my $force;
11 my $verbose;
12 my $changelog_file = 'ChangeLog';
13
14 GetOptions('append|a=s@' => \@append_files,
15 'file|F=s' => \$changelog_file,
16 'force|f' => \$force,
17 'verbose|v' => \$verbose) or exit(1);
18
19 if (! -d '.git') {
20 exit 0;
21 }
22
23 my ($hash, $date) = split / /, `git log --max-count=1 --pretty=format:'%H %ad' --date=short HEAD`;
24
25 my @modlines;
26 if (open(my $fd, '-|', 'git diff-index --name-status HEAD 2>/dev/null')) {
27 chomp(@modlines = map {chomp; [split /\s+/, $_, 2]} <$fd>);
28 close $fd;
29 }
30
31 if (@modlines) {
32 $date = strftime '%Y-%m-%d', localtime;
33 }
34
35 my @header;
36
37 push @header, "$date Automatically generated <bug-mailutils\@gnu.org>";
38 push @header, '';
39 push @header, "\tHEAD $hash";
40 push @header, '';
41
42 my %status = (
43 A => 'New file',
44 C => 'Copied file',
45 D => 'Removed file',
46 M => 'Changed',
47 R => 'Renamed',
48 T => 'Type change',
49 U => 'Unmerged',
50 X => 'Unknown'
51 );
52
53 if (@modlines) {
54 push @header, "\tUncommitted changes:";
55 push @header, '';
56
57 push @header, map {
58 "\t* $_->[1]: " . ($status{$_->[0]} || 'Unknown') . ";"
59 } @modlines;
60 push @header, '';
61 }
62
63 sub headcmp {
64 my $file = shift;
65 if (open(my $fd, '<', $changelog_file)) {
66 while (<$fd>) {
67 my $line = shift;
68 last unless defined($line);
69 chomp;
70 return 0 unless $line eq $_;
71 }
72 return 1 unless @_;
73 }
74 return 0;
75 }
76
77 if (!$force && headcmp($changelog_file, @header)) {
78 exit 0;
79 }
80
81 print " GEN $changelog_file\n" if $verbose;
82 close STDOUT;
83
84 open(STDOUT, '>', $changelog_file)
85 or die "Can't open $changelog_file for writing: $!";
86
87 for (@header) {
88 print "$_\n";
89 }
90
91 system(@ARGV);
92 foreach my $file (@append_files) {
93 if (open(my $fd, '<', $file)) {
94 while (<$fd>) {
95 chomp;
96 last if /^Local Variables:/;
97 next if /^\f$/;
98 print "$_\n";
99 }
100 close $fd;
101 } else {
102 warn "can't open $file: $!";
103 }
104 }
105
106 print "\f\nLocal Variables:\n";
107 print <<'EOT';
108 mode: change-log
109 version-control: never
110 buffer-read-only: t
111 End:
112 EOT
113 ;