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 = . \
EXTRA_DIST = COPYING.LESSER paths
DISTCLEANFILES = pathdefs.h
# Trigger creation of the ChangeLog
noinst_DATA = ChangeLog
gen_start_date = "2008-12-08"
prev_change_log = "doc/ChangeLog.CVS"
amend_file=ChangeLog.amend
.PHONY: ChangeLog
ChangeLog:
@if test -d .git; then \
cmd="$(top_srcdir)/build-aux/gitlog-to-changelog"; \
if test -n "$(amend_file)"; then \
cmd="$$cmd --amend=$(amend_file)"; \
fi; \
if test -n "$(gen_start_date)"; then \
cmd="$$cmd --since=\"$(gen_start_date)\""; \
fi; \
$$cmd --format='%s%n%n%b%n' | \
sed '/<unknown>$$/d' | fmt -s > cl-t; \
if test -n "$(prev_change_log)" && test -f "$(prev_change_log)"; \
then \
echo "" >> cl-t; \
cat "$(prev_change_log)" | \
sed '/^Local Variables:/,/^End:/d' >> cl-t; \
fi; \
echo "Local Variables:" >> cl-t; \
echo "mode: change-log" >> cl-t; \
echo "version-control: never" >> cl-t; \
echo "buffer-read-only: t" >> cl-t; \
echo "End:" >> cl-t; \
rm -f ChangeLog; \
mv cl-t ChangeLog; \
ChangeLog:
$(AM_V_at)if test -d .git; then \
cmd="$(top_srcdir)/mu-aux/gencl --file=ChangeLog --verbose";\
if test -n "$(prev_change_log)" && test -f "$(prev_change_log)"; \
then \
cmd="$$cmd --append=$(prev_change_log)"; \
fi; \
cmd="$$cmd -- $(top_srcdir)/build-aux/gitlog-to-changelog"; \
if test -n "$(amend_file)"; then \
cmd="$$cmd --amend=$(amend_file)"; \
fi; \
if test -n "$(gen_start_date)"; then \
cmd="$$cmd --since=\"$(gen_start_date)\""; \
fi; \
$$cmd --format='%s%n%n%b%n' | fmt -s; \
fi
dist-hook: ChangeLog
@PATCHLEV=`echo "$(PACKAGE_VERSION)" | \
sed -r "s/[0-9]+\.[0-9]+\.?//"`; \
if test $${PATCHLEV:-0} -lt 50; then \
if grep -q FIXME NEWS; then \
echo >&2 "NEWS file contains FIXMEs"; \
exit 1; \
fi; \
@if head -n 6 ChangeLog | grep -q 'Uncommitted changes' ; \
then \
echo >&2 "*** Source tree contains uncommitted changes"; \
echo >&2 "*** Aborting"; \
exit 1; \
fi; \
PATCHLEV=`echo "$(PACKAGE_VERSION)" | sed -r "s/[0-9]+\.[0-9]+\.?//"`;\
if test $${PATCHLEV:-0} -lt 50; then \
if grep -q FIXME NEWS; then \
echo >&2 "*** NEWS file contains FIXMEs"; \
echo >&2 "*** Aborting"; \
exit 1; \
fi; \
fi
alpha:
......
# This file is part of GNU Mailutils.
# Copyright (C) 2009-2012, 2014-2017 Free Software Foundation, Inc.
#
# Written by Sergey Poznyakoff
#
# GNU Mailutils is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
include Makefile
CFLOW_FLAGS=-i^s --brief -v
MAINT_CLEAN_FILES=
define flowgraph_tmpl
MAINT_CLEAN_FILES += $(1).cflow
$(2)_CFLOW_INPUT=$$($(2)_OBJECTS:.$(3)=.c)
$(1).cflow: $$($(2)_CFLOW_INPUT) Makefile
cflow -o$$@ $$(CFLOW_FLAGS) $$(DEFS) \
$$(DEFAULT_INCLUDES) $$(INCLUDES) $$(AM_CPPFLAGS) \
$$(CPPFLAGS) \
$$($(2)_CFLOW_INPUT)
endef
$(foreach prog,$(bin_PROGRAMS) $(sbin_PROGRAMS),\
$(eval $(call flowgraph_tmpl,$(prog),$(subst -,_,$(prog)),$(OBJEXT))))
$(foreach prog,$(lib_LTLIBRARIES),\
$(eval $(call flowgraph_tmpl,$(prog),$(subst .,_,$(prog)),lo)))
all: flowgraph-recursive
flowgraph: $(foreach prog,$(bin_PROGRAMS) $(sbin_PROGRAMS) $(lib_LTLIBRARIES),$(prog).cflow)
maintclean:
-test -n "$(MAINT_CLEAN_FILES)" && rm -f $(MAINT_CLEAN_FILES)
##
MAINT_MK = maint.mk
MAINT_RECURSIVE_TARGETS=flowgraph-recursive maintclean-recursive
$(MAINT_RECURSIVE_TARGETS):
@cwd=`pwd`; \
failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
if test -f $$subdir/$(MAINT_MK); then \
makefile='$(MAINT_MK)'; \
else \
makefile="$$cwd/maint.mk"; \
fi; \
$(MAKE) -C $$subdir -f $$makefile $$local_target \
|| eval $$failcom; \
done; \
test -z "$$fail"
eval '(exit $?0)' && eval 'exec perl -wS "$0" "$@"'
& eval 'exec perl -wS "$0" $argv:q'
if 0;
use strict;
use POSIX qw(strftime);
use Getopt::Long qw(:config gnu_getopt no_ignore_case);
my @append_files;
my $force;
my $verbose;
my $changelog_file = 'ChangeLog';
GetOptions('append|a=s@' => \@append_files,
'file|F=s' => \$changelog_file,
'force|f' => \$force,
'verbose|v' => \$verbose) or exit(1);
if (! -d '.git') {
exit 0;
}
my ($hash, $date) = split / /, `git log --max-count=1 --pretty=format:'%H %ad' --date=short HEAD`;
my @modlines;
if (open(my $fd, '-|', 'git diff-index --name-status HEAD 2>/dev/null')) {
chomp(@modlines = map {chomp; [split /\s+/, $_, 2]} <$fd>);
close $fd;
}
if (@modlines) {
$date = strftime '%Y-%m-%d', localtime;
}
my @header;
push @header, "$date Automatically generated <bug-mailutils\@gnu.org>";
push @header, '';
push @header, "\tHEAD $hash";
push @header, '';
my %status = (
A => 'New file',
C => 'Copied file',
D => 'Removed file',
M => 'Changed',
R => 'Renamed',
T => 'Type change',
U => 'Unmerged',
X => 'Unknown'
);
if (@modlines) {
push @header, "\tUncommitted changes:";
push @header, '';
push @header, map {
"\t* $_->[1]: " . ($status{$_->[0]} || 'Unknown') . ";"
} @modlines;
push @header, '';
}
sub headcmp {
my $file = shift;
if (open(my $fd, '<', $changelog_file)) {
while (<$fd>) {
my $line = shift;
last unless defined($line);
chomp;
return 0 unless $line eq $_;
}
return 1 unless @_;
}
return 0;
}
if (!$force && headcmp($changelog_file, @header)) {
exit 0;
}
print " GEN $changelog_file\n" if $verbose;
close STDOUT;
open(STDOUT, '>', $changelog_file)
or die "Can't open $changelog_file for writing: $!";
for (@header) {
print "$_\n";
}
system(@ARGV);
foreach my $file (@append_files) {
if (open(my $fd, '<', $file)) {
while (<$fd>) {
chomp;
last if /^Local Variables:/;
next if /^\f$/;
print "$_\n";
}
close $fd;
} else {
warn "can't open $file: $!";
}
}
print "\f\nLocal Variables:\n";
print <<'EOT';
mode: change-log
version-control: never
buffer-read-only: t
End:
EOT
;