version/1.3
[gitchangelog.sh.git] / Makefile
blob6af6d7d2934907d1350127ffea28bcdf3daf7d82
1 # GNU Makefile for gitchangelog.sh
3 PACKAGE_NAME = gitchangelog.sh
4 PACKAGE_TARNAME = gitchangelog-sh
6 # Get the version via git or from the VERSION file or from the project
7 # directory name.
8 VERSION = $(shell test -x version.sh && ./version.sh $(PACKAGE_TARNAME) \
9 || echo "unknown_version")
10 # Allow either to be overwritten by setting DIST_VERSION on the command line.
11 PACKAGE_VERSION = $(VERSION)
12 # Remove the _g<SHA1> part from the $VERSION
13 RPM_VERSION = $(shell echo $(VERSION) | $(SED) -e 's/_g[0-9a-z]\+//')
15 prefix = $(HOME)/.local
16 bindir = $(prefix)/bin
17 datarootdir = $(prefix)/share
18 docdir = $(datarootdir)/doc/$(PACKAGE_TARNAME)
19 mandir = $(datarootdir)/man
20 # DESTDIR = # distributors set this on the command line
22 CP = cp
23 MKDIR = mkdir -p
24 INSTALL = install
25 SED = sed
26 TAR = tar
27 TAR_FLAGS = --owner root --group root --mode a+rX,o-w --mtime .
28 HELPM2POD = helpm2pod
29 POD2MAN = pod2man
30 POD2MAN_FLAGS = --utf8 -c "" -r "$(PACKAGE_NAME) $(PACKAGE_VERSION)"
31 POD2TEXT = pod2text
32 POD2HTML = pod2html
33 ASCIIDOC = asciidoc
34 ASCIIDOC_FLAGS = -apackagename="$(PACKAGE_NAME)" -aversion="$(PACKAGE_VERSION)"
35 MD5SUM = md5sum
36 SHA512SUM = sha512sum
38 SCRIPTS = gitchangelog.sh
39 MANDOC = $(SCRIPTS:%=%.1)
40 HELPMDOC = $(SCRIPTS:%=%.1.helpm)
41 PODDOC = $(SCRIPTS:%=%.pod)
42 TEXTDOC = $(SCRIPTS:%=%.1.txt)
43 HTMLDOC = $(SCRIPTS:%=%.1.html) README.html NEWS.html
44 ALLDOC = $(MANDOC) $(TEXTDOC) $(HTMLDOC)
45 RELEASEDOC = $(MANDOC) $(HTMLDOC)
47 TARNAME = $(PACKAGE_TARNAME)-$(RPM_VERSION)
49 .PHONY: .help all clean build doc doc-helpm doc-pod doc-man doc-html dist \
50 install install-doc install-man
52 all: build doc-man
54 .help:
55 @echo "Useful targets:"
56 @echo " doc-man doc clean distclean dist install install-doc"
58 clean:
59 $(RM) $(HELPMDOC) $(PODDOC) pod2htmd.tmp pod2htmi.tmp *~ .*~
60 $(RM) $(PACKAGE_TARNAME)-*.tar.gz*
61 distclean: clean
62 $(RM) ChangeLog $(ALLDOC)
64 install: build install-doc
65 $(MKDIR) $(DESTDIR)$(bindir)
66 $(INSTALL) -m 755 $(SCRIPTS) $(DESTDIR)$(bindir)/
67 install-doc: install-man
68 install-man:
69 $(MKDIR) $(DESTDIR)$(mandir)/man1
70 $(INSTALL) -m 644 $(MANDOC) $(DESTDIR)$(mandir)/man1/
72 build:
73 doc: $(ALLDOC)
74 doc-helpm: $(HELPMDOC)
75 doc-pod: $(PODDOC)
76 doc-man: $(MANDOC)
77 doc-html: $(HTMLDOC)
79 $(TARNAME).tar: ChangeLog
80 $(MKDIR) -p $(TARNAME)
81 echo $(VERSION) > $(TARNAME)/VERSION
82 $(CP) -p ChangeLog $(TARNAME)
83 git archive --format=tar --prefix=$(TARNAME)/ HEAD > $(TARNAME).tar
84 $(TAR) $(TAR_FLAGS) -rf $(TARNAME).tar $(TARNAME)
85 $(RM) -r $(TARNAME)
86 dist: $(TARNAME).tar.gz
87 $(TARNAME).tar.gz: $(TARNAME).tar $(RELEASEDOC)
88 $(MKDIR) $(TARNAME)
89 $(CP) -p -P $(RELEASEDOC) $(TARNAME)
90 $(TAR) $(TAR_FLAGS) -rf $(TARNAME).tar $(TARNAME)
91 $(RM) -r $(TARNAME)
92 gzip -f -9 $(TARNAME).tar
93 $(MD5SUM) $(TARNAME).tar.gz > $(TARNAME).tar.gz.md5
94 $(SHA512SUM) $(TARNAME).tar.gz > $(TARNAME).tar.gz.sha512
95 ChangeLog:
96 ( echo "# $@ for $(PACKAGE_NAME) - automatically generated from the VCS's history"; \
97 echo; \
98 ./gitchangelog.sh --tags --tag-pattern 'version\/[^ ]*' \
99 -- - --date-order --first-parent ) \
100 | $(SED) 's/^\[version/\f\[version/' \
101 > $@
103 README.html: README asciidoc.conf
104 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article -a readme $<
105 NEWS.html: NEWS asciidoc.conf
106 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article $<
108 %.1.helpm: %
109 ./$< --helpm >$@
110 %.pod: %.1.helpm
111 $(HELPM2POD) $< >$@
113 %.1: %.pod
114 $(POD2MAN) $(POD2MAN_FLAGS) --section 1 $< >$@
115 %.1.txt: %.pod
116 $(POD2TEXT) --utf8 $< >$@
117 %.1.html: %.pod
118 $(POD2HTML) --noindex --title "$(shell printf "%s(1)" "$*" | LC_ALL=C tr a-z A-Z)" \
119 $< >$@