1 # Makefile for HelpMessage
2 # Copyright © 2012-2014 Géraud Meyer <graud@gmx.com>
4 # This file is free software; you can redistribute it and/or modify it under
5 # the terms of the GNU General Public License version 2 as published by the
6 # Free Software Foundation.
8 # This package is distributed in the hope that it will be useful, but WITHOUT
9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 # You should have received a copy of the GNU General Public License along with
14 # this file. If not, see <http://www.gnu.org/licenses/>.
16 # This a GNU Makefile.
18 prefix ?
= $(HOME
)/.local
19 bindir ?
= $(prefix)/bin
20 datarootdir ?
= $(prefix)/share
21 docdir ?
= $(datarootdir
)/doc
/$(PACKAGE_TARNAME
)
22 mandir ?
= $(datarootdir
)/man
23 # DESTDIR = # distributors set this on the command line
26 tab
:= $(empty
) $(empty
)
28 PACKAGE_NAME ?
= HelpMessage
29 PACKAGE_TARNAME ?
= helpmessage
31 # Get the version via git or from the VERSION file or from the project
33 VERSION
= $(shell test -x version.sh
&& .
/version.sh
$(PACKAGE_TARNAME
) \
34 || echo
"unknown_version")
35 # Allow either to be overwritten by setting DIST_VERSION on the command line.
37 VERSION
= $(DIST_VERSION
)
39 PACKAGE_VERSION
= $(VERSION
)
41 # Remove the _g<SHA1> part from the $VERSION
42 RPM_VERSION
= $(shell echo
$(VERSION
) |
$(SED
) -e
's/_g[0-9a-z]\+//')
45 SCRIPTS
= helpm2pod helpm2man helpm2text helpmselect gitparseopt2helpm helpm4sh
47 HELPMDOC
= $(HELPMSWITCH
) $(HELPM4SHDOC
)
48 HELPMSWITCH
= helpm2pod
49 HELPM4SHDOC
= helpm4sh gitparseopt2helpm helpmselect helpm2text helpm2man
50 HELPMESSAGE
= helpmessage
.5.helpm
51 TEXTDOC
= $(HELPMDOC
:%=%.1.txt
) $(HELPMESSAGE
:%.helpm
=%.txt
)
52 MANDOC
= $(HELPMDOC
:%=%.1) $(HELPMESSAGE
:%.helpm
=%)
53 HTMLDOC
= $(HELPMDOC
:%=%.1.html
) $(HELPMESSAGE
:%.helpm
=%.html
) README.html NEWS.html
54 RELEASEDOC
= $(MANDOC
) $(HTMLDOC
)
55 ALLDOC
= $(TEXTDOC
) $(MANDOC
) $(HTMLDOC
)
57 TARNAME
= $(PACKAGE_TARNAME
)-$(RPM_VERSION
)
65 TAR_FLAGS
= --owner root
--group root
--mode a
+rX
,o-w
--mtime .
68 ASCIIDOC_FLAGS
= -apackagename
="$(PACKAGE_NAME)" -aversion
="$(VERSION)"
70 POD2MAN_FLAGS
= --utf8
-c
"HelpMessage Manuals" -r
"$(PACKAGE_NAME) $(VERSION)"
73 HELPM2POD ?
= .
/helpm2pod
74 HELPM4SH ?
= .
/helpm4sh
76 SHA512SUM ?
= sha512sum
80 @echo
"Available targets for $(PACKAGE_NAME) Makefile:"
81 @echo
" .help all configure build clean doc doc-txt doc-helpm doc-man doc-html"
82 @echo
" dist install install-doc install-doc-man install-doc-html"
83 @echo
"Useful variables for $(PACKAGE_NAME) Makefile:"
84 @echo
" prefix DESTDIR MAKE"
86 .PHONY
: .help help
all build
clean doc doc-txt doc-helpm doc-man doc-html \
87 dist install install-doc install-doc-man install-doc-html
89 build
: $(PROGS
) $(TESTS
)
92 doc-helpm
: $(HELPMDOC
:%=%.1.helpm
)
93 doc-pod
: $(HELPMDOC
:%=%.pod
)
97 test: $(TESTS
) $(HELPMDOC
:%=%.pod
) $(HELPMESSAGE
:%.5.helpm
=%.pod
)
98 podchecker
$(HELPMDOC
:%=%.pod
) $(HELPMESSAGE
:%.5.helpm
=%.pod
)
101 $(MKDIR
) -p
$(DESTDIR
)$(bindir)
102 set
-e
; for prog in
$(PROGS
) $(SCRIPTS
); do \
103 $(INSTALL
) -p
-m
0755 "$$prog" "$(DESTDIR)$(bindir)/$$prog"; \
105 install-doc
: install-doc-man install-doc-html
106 install-doc-man
: doc-man
107 $(MKDIR
) -p
$(DESTDIR
)$(mandir)/man1
108 set
-e
; for doc in
$(MANDOC
); do \
109 gzip
-9 <"$$doc" >"$$doc".gz
; \
110 $(INSTALL
) -p
-m
0644 "$$doc".gz
"$(DESTDIR)$(mandir)/man1/"; \
113 install-doc-html
: doc-html
114 $(MKDIR
) -p
$(DESTDIR
)$(docdir
)
115 set
-e
; for doc in
$(HTMLDOC
); do \
116 $(INSTALL
) -p
-m
0644 "$$doc" "$(DESTDIR)$(docdir)/"; \
121 $(RM
) $(PACKAGE_TARNAME
)-*.
tar $(PACKAGE_TARNAME
)-*.
tar.gz \
122 $(PACKAGE_TARNAME
)-*.
tar.gz.md5
$(PACKAGE_TARNAME
)-*.
tar.gz.sha512
123 $(RM
) $(PROGS
) $(TESTS
)
124 $(RM
) *.xml pod2htm
* $(HELPMDOC
:%=%.1.helpm
) \
125 $(HELPMDOC
:%=%.pod
) $(HELPMESSAGE
:%.5.helpm
=%.pod
) *~ .
*~
127 $(RM
) ChangeLog
$(ALLDOC
)
129 $(TARNAME
).
tar : ChangeLog
130 $(MKDIR
) -p
$(TARNAME
)
131 echo
$(VERSION
) > $(TARNAME
)/VERSION
132 $(CP
) -p ChangeLog
$(TARNAME
)
133 git archive
--format
=tar --prefix=$(TARNAME
)/ HEAD
> $(TARNAME
).
tar
134 $(TAR
) $(TAR_FLAGS
) -rf
$(TARNAME
).
tar $(TARNAME
)
136 dist : $(TARNAME
).
tar.gz
137 $(TARNAME
).
tar.gz
: $(TARNAME
).
tar $(RELEASEDOC
)
139 $(CP
) -p
-P
$(RELEASEDOC
) $(TARNAME
)
140 $(TAR
) $(TAR_FLAGS
) -rf
$(TARNAME
).
tar $(TARNAME
)
142 gzip
-f
-9 $(TARNAME
).
tar
143 $(MD5SUM
) $(TARNAME
).
tar.gz
> $(TARNAME
).
tar.gz.md5
144 $(SHA512SUM
) $(TARNAME
).
tar.gz
> $(TARNAME
).
tar.gz.sha512
146 ( echo
"# $@ for $(PACKAGE_NAME) - automatically generated from the VCS's history"; \
148 .
/gitchangelog.sh
--tags --tag-pattern
'version\/[^\n]*' \
149 -- - --date-order
--first-parent
) \
150 |
$(SED
) 's/^\[version/\f\[version/' \
153 README.html
: README asciidoc.conf
154 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
-a readme
$<
155 NEWS.html
: NEWS asciidoc.conf
156 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
$<
158 $(HELPM4SHDOC
:%=%.1.helpm
): %.1.helpm
: %
159 $(HELPM4SH
) helpm
$< >$@
163 $(HELPM2POD
) - <$< >$@
165 $(HELPM2POD
) - <$< >$@
168 $(POD2MAN
) $(POD2MAN_FLAGS
) --section
1 $< >$@
170 $(POD2MAN
) $(POD2MAN_FLAGS
) --section
5 $< >$@
171 %.1.txt
%.5.txt
: %.pod
172 $(POD2TEXT
) --utf8
$< >$@
173 %.1.html
%.5.html
: %.pod
174 $(POD2HTML
) --noindex
--title
"$(shell printf "%s
" "$(@
:%.html
=%)" | sed 's/\.\([0-9]\)$$/(\1)/' | tr a-z A-Z)" \