5 # Include setting from the configure script
9 bindir ?
= $(prefix)/bin
10 datarootdir ?
= $(prefix)/share
11 sysconfdir ?
= $(prefix)/etc
12 docdir ?
= $(datarootdir
)/doc
13 mandir ?
= $(datarootdir
)/man
16 # Get version either via git or from VERSION file. Allow either
17 # to be overwritten by setting DIST_VERSION on the command line.
18 ifneq (,$(wildcard .git
))
19 GITDESC
= $(subst tig-
,,$(shell git describe
))
20 WTDIRTY
= $(if
$(shell git diff-index HEAD
2>/dev
/null
),-dirty
)
21 VERSION
= $(GITDESC
)$(WTDIRTY
)
23 VERSION
= $(shell test -f VERSION
&& cat VERSION || echo
"unknown-version")
26 VERSION
= $(DIST_VERSION
)
29 # Split the version "TAG-OFFSET-gSHA1-DIRTY" into "TAG OFFSET"
30 # and append 0 as a fallback offset for "exact" tagged versions.
31 RPM_VERLIST
= $(filter-out g
% dirty
,$(subst -, ,$(VERSION
))) 0
32 RPM_VERSION
= $(word 1,$(RPM_VERLIST
))
33 RPM_RELEASE
= $(word 2,$(RPM_VERLIST
))$(if
$(WTDIRTY
),.dirty
)
37 DFLAGS
= -g
-DDEBUG
-Werror
-O0
39 TXTDOC
= tig
.1.txt tigrc
.5.txt manual.txt NEWS README INSTALL BUGS TODO
40 MANDOC
= tig
.1 tigrc
.5 tigmanual
.7
41 HTMLDOC
= tig
.1.html tigrc
.5.html manual.html README.html NEWS.html
42 ALLDOC
= $(MANDOC
) $(HTMLDOC
) manual.html-chunked manual.pdf
44 # Never include the release number in the tarname for tagged
46 ifneq ($(if
$(DIST_VERSION
),$(words $(RPM_VERLIST
))),2)
47 TARNAME
= tig-
$(RPM_VERSION
)-$(RPM_RELEASE
)
49 TARNAME
= tig-
$(RPM_VERSION
)
52 override CPPFLAGS
+= '-DTIG_VERSION="$(VERSION)"'
53 override CPPFLAGS
+= '-DSYSCONFDIR="$(sysconfdir)"'
55 AUTORECONF ?
= autoreconf
57 ASCIIDOC_FLAGS
= -aversion
=$(VERSION
) -asysconfdir
=$(sysconfdir
)
59 DOCBOOK2PDF ?
= docbook2pdf
63 all-debug
: CFLAGS
+= $(DFLAGS
)
69 mkdir
-p
$(DESTDIR
)$(bindir) && \
70 for prog in
$(PROGS
); do \
71 install -p
-m
0755 "$$prog" "$(DESTDIR)$(bindir)"; \
74 install-doc-man
: doc-man
75 mkdir
-p
$(DESTDIR
)$(mandir)/man1 \
76 $(DESTDIR
)$(mandir)/man5 \
77 $(DESTDIR
)$(mandir)/man7
78 for doc in
$(MANDOC
); do \
79 sed
's#++SYSCONFDIR++#$(sysconfdir)#' < "$$doc" > "$$doc+"; \
81 *.1) install -p
-m
0644 "$$doc+" "$(DESTDIR)$(mandir)/man1/$$doc" ;; \
82 *.5) install -p
-m
0644 "$$doc+" "$(DESTDIR)$(mandir)/man5/$$doc" ;; \
83 *.7) install -p
-m
0644 "$$doc+" "$(DESTDIR)$(mandir)/man7/$$doc" ;; \
88 install-release-doc-man
:
89 GIT_INDEX_FILE
=.tmp-doc-index git read-tree
origin/release
90 GIT_INDEX_FILE
=.tmp-doc-index git checkout-index
-f
--prefix=.
/ $(MANDOC
)
92 $(MAKE
) install-doc-man
94 install-doc-html
: doc-html
95 mkdir
-p
$(DESTDIR
)$(docdir
)/tig
96 for doc in
$(HTMLDOC
); do \
97 sed
's#++SYSCONFDIR++#$(sysconfdir)#' < "$$doc" > "$$doc+"; \
99 *.html
) install -p
-m
0644 "$$doc+" "$(DESTDIR)$(docdir)/tig/$$doc" ;; \
104 install-release-doc-html
:
105 GIT_INDEX_FILE
=.tmp-doc-index git read-tree
origin/release
106 GIT_INDEX_FILE
=.tmp-doc-index git checkout-index
-f
--prefix=.
/ $(HTMLDOC
)
108 $(MAKE
) install-doc-html
110 install-doc
: install-doc-man install-doc-html
111 install-release-doc
: install-release-doc-man install-release-doc-html
114 $(RM
) -r
$(TARNAME
) *.spec tig-
*.
tar.gz tig-
*.
tar.gz.md5
115 $(RM
) $(PROGS
) core
*.o
*.xml
118 $(RM
) -r manual.html-chunked autom4te.cache
119 $(RM
) *.toc
$(ALLDOC
) aclocal.m4 configure
120 $(RM
) config.h config.log config.make config.status config.h.in
123 for file in
$(TXTDOC
) tig.c
; do \
124 aspell
--lang
=en
--dont-backup \
125 --personal
=.
/contrib
/aspell.dict
check $$file; \
131 dist: configure tig.spec
132 @mkdir
-p
$(TARNAME
) && \
133 cp tig.spec configure config.h.in aclocal.m4
$(TARNAME
) && \
134 echo
$(VERSION
) > $(TARNAME
)/VERSION
135 git archive
--format
=tar --prefix=$(TARNAME
)/ HEAD | \
136 tar --delete
$(TARNAME
)/VERSION
> $(TARNAME
).
tar && \
137 tar rf
$(TARNAME
).
tar `find $(TARNAME)/*` && \
138 gzip
-f
-9 $(TARNAME
).
tar && \
139 md5sum
$(TARNAME
).
tar.gz
> $(TARNAME
).
tar.gz.md5
143 rpmbuild
-ta
$(TARNAME
).
tar.gz
145 configure
: configure.ac acinclude.m4
148 .PHONY
: all all-debug doc doc-man doc-html
install install-doc \
149 install-doc-man install-doc-html
clean spell-check
dist rpm
154 tig.spec
: contrib
/tig.spec.in
155 sed
-e
's/@@VERSION@@/$(RPM_VERSION)/g' \
156 -e
's/@@RELEASE@@/$(RPM_RELEASE)/g' < $< > $@
158 manual.html
: manual.toc
159 manual.toc
: manual.txt
160 sed
-n
'/^\[\[/,/\(---\|~~~\)/p' < $< | while read line
; do \
162 "-----"*) echo
". <<$$ref>>"; ref
= ;; \
163 "~~~~~"*) echo
"- <<$$ref>>"; ref
= ;; \
164 "[["*"]]") ref
="$$line" ;; \
165 *) ref
="$$ref, $$line" ;; \
166 esac
; done | sed
's/\[\[\(.*\)\]\]/\1/' > $@
168 README.html
: README SITES INSTALL asciidoc.conf
169 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
-a readme
$<
171 NEWS.html
: NEWS asciidoc.conf
172 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
$<
174 tigmanual
.7: manual.txt
176 %.1.html
: %.1.txt asciidoc.conf
177 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d manpage
$<
179 %.1.xml
: %.1.txt asciidoc.conf
180 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d manpage
$<
182 %.5.html
: %.5.txt asciidoc.conf
183 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d manpage
$<
185 %.5.xml
: %.5.txt asciidoc.conf
186 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d manpage
$<
188 %.7.xml
: %.7.txt asciidoc.conf
189 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d manpage
$<
191 %.html
: %.txt asciidoc.conf
192 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
-n
$<
194 %.xml
: %.txt asciidoc.conf
195 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d article
$<
200 %.html-chunked
: %.xml
201 $(XMLTO
) html
-o
$@
$<