diff --git a/Makefile.am b/Makefile.am index bac4f8eb2b..e1c62d90c6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -321,14 +321,24 @@ GITLOG_START_POINT=v2.6.0 # the current dir, and defaults to generate a "ChangeLog" in the current dir. # The script itself is generated from a template, so resides in builddir. dummy-stamp: -ChangeLog: tools/gitlog2changelog.py dummy-stamp - cd $(abs_top_srcdir) && \ +ChangeLog: dummy-stamp + +@$(MAKE) $(AM_MAKEFLAGS) $(abs_top_builddir)/ChangeLog + +# Be sure to not confuse with a DIST'ed file (and so try to overwrite it): +$(abs_top_builddir)/ChangeLog: tools/gitlog2changelog.py dummy-stamp + @cd $(abs_top_srcdir) && \ if test -e .git ; then \ CHANGELOG_FILE="$@" $(abs_top_builddir)/tools/gitlog2changelog.py $(GITLOG_START_POINT) || \ { printf "gitlog2changelog.py failed to generate the ChangeLog.\n\nNOTE: See https://github.com/networkupstools/nut/commits/master for change history.\n\n" > "$@" ; } ; \ else \ - if ! test -s "$@" ; then \ - printf "Failed to generate the ChangeLog.\n\nNOTE: See https://github.com/networkupstools/nut/commits/master for change history.\n\n" > "$@" ; \ + if test x"$(abs_top_srcdir)" != x"$(abs_top_builddir)" -a -s ./ChangeLog ; then \ + echo "Using distributed ChangeLog file from sources" >&2 ; \ + rm -f "$@" || true ; \ + cat ./ChangeLog > "$@" ; \ + else \ + if ! test -s "$@" ; then \ + printf "Failed to generate the ChangeLog.\n\nNOTE: See https://github.com/networkupstools/nut/commits/master for change history.\n\n" > "$@" ; \ + fi ; \ fi ; \ fi diff --git a/docs/Makefile.am b/docs/Makefile.am index 33f0ff5d77..c2fba72854 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -240,7 +240,7 @@ $(top_builddir)/ChangeLog.adoc: $(top_builddir)/ChangeLog || { \ MSG="FAILED to resolve input or output filename with this make implementation, or input was not generated!"; \ echo " DOC-CHANGELOG-ASCIIDOC SKIP: $${MSG}" >&2; \ - test -n "$@" && echo "$${MSG}" > "$@" ; \ + test -n "$@" && { printf '=== Failed to generate the ChangeLog\n\n%s\n\nNOTE: See https://github.com/networkupstools/nut/commits/master for change history.\n\n' "$${MSG}" > "$@" ; } ; \ exit ; \ } ; \ echo " DOC-CHANGELOG-ASCIIDOC $${INPUT} => $@" \