ax_generate_changelog.m4 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # ===========================================================================
  2. # http://www.gnu.org/software/autoconf-archive/ax_generate_changelog.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_GENERATE_CHANGELOG()
  8. #
  9. # DESCRIPTION
  10. #
  11. # Builds a rule for generating a ChangeLog file from version control
  12. # system commit messages. Currently, the only supported VCS is git, but
  13. # support for others could be added in future.
  14. #
  15. # Defines GENERATE_CHANGELOG_RULES which should be substituted in your
  16. # Makefile.
  17. #
  18. # Usage example:
  19. #
  20. # configure.ac:
  21. #
  22. # AX_GENERATE_CHANGELOG
  23. #
  24. # Makefile.am:
  25. #
  26. # @GENERATE_CHANGELOG_RULES@
  27. # CHANGELOG_START = 0.2.3^
  28. # dist-hook: dist-ChangeLog
  29. #
  30. # ChangeLog (stub committed to VCS):
  31. #
  32. # The ChangeLog is auto-generated when releasing.
  33. # If you are seeing this, use 'git log' for a detailed list of changes.
  34. #
  35. # This results in a "dist-ChangeLog" rule being added to the Makefile.
  36. # When run, "dist-ChangeLog" will generate a ChangeLog in the
  37. # $(top_distdir), using $(CHANGELOG_GIT_FLAGS) to format the output from
  38. # "git log" being run in $(CHANGELOG_GIT_DIR).
  39. #
  40. # Unless Automake is initialised with the 'foreign' option, a dummy
  41. # ChangeLog file must be committed to VCS in $(top_srcdir), containing the
  42. # text above (for example). It will be substituted by the automatically
  43. # generated ChangeLog during "make dist".
  44. #
  45. # LICENSE
  46. #
  47. # Copyright (c) 2015 David King <amigadave@amigadave.com>
  48. # Copyright (c) 2015 Philip Withnall <philip.withnall@collabora.co.uk>
  49. #
  50. # Copying and distribution of this file, with or without modification, are
  51. # permitted in any medium without royalty provided the copyright notice
  52. # and this notice are preserved. This file is offered as-is, without any
  53. # warranty.
  54. #serial 1
  55. AC_DEFUN([AX_GENERATE_CHANGELOG],[
  56. # Find git, defaulting to the 'missing' script so the user gets a nice
  57. # message if git is missing, rather than a plain 'command not found'.
  58. AC_PATH_PROG([GIT],[git],[${am_missing_run}git])
  59. AC_SUBST([GIT])
  60. # Build the ChangeLog rules.
  61. m4_pattern_allow([AM_V_GEN])
  62. GENERATE_CHANGELOG_RULES='
  63. # Generate ChangeLog
  64. #
  65. # Optional:
  66. # - CHANGELOG_START: git commit ID or tag name to output changelogs from
  67. # (exclusive). (Default: include all commits)
  68. # - CHANGELOG_GIT_FLAGS: General flags to pass to git-log when generating the
  69. # ChangeLog. (Default: various)
  70. # - CHANGELOG_GIT_DIR: .git directory to use. (Default: $(top_srcdir)/.git)
  71. # git-specific
  72. CHANGELOG_GIT_FLAGS ?= --stat -M -C --name-status --no-color
  73. CHANGELOG_GIT_DIR ?= $(top_srcdir)/.git
  74. ifeq ($(CHANGELOG_START),)
  75. CHANGELOG_GIT_RANGE =
  76. else
  77. CHANGELOG_GIT_RANGE = $(CHANGELOG_START)..
  78. endif
  79. # Generate a ChangeLog in $(top_distdir)
  80. dist-ChangeLog:
  81. $(AM_V_GEN)if $(GIT) \
  82. --git-dir=$(CHANGELOG_GIT_DIR) --work-tree=$(top_srcdir) log \
  83. $(CHANGELOG_GIT_FLAGS) $(CHANGELOG_GIT_RANGE) \
  84. | fmt --split-only >.ChangeLog.tmp; \
  85. then mv -f .ChangeLog.tmp "$(top_distdir)/ChangeLog"; \
  86. else rm -f .ChangeLog.tmp; exit 1; fi
  87. .PHONY: dist-ChangeLog
  88. '
  89. AC_SUBST([GENERATE_CHANGELOG_RULES])
  90. m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([GENERATE_CHANGELOG_RULES])])
  91. ])