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
40 SOURCE
= tig.c tig.h io.c io.h graph.c graph.h
41 TXTDOC
= tig
.1.txt tigrc
.5.txt manual.txt NEWS README INSTALL BUGS TODO
42 MANDOC
= tig
.1 tigrc
.5 tigmanual
.7
43 HTMLDOC
= tig
.1.html tigrc
.5.html manual.html README.html NEWS.html
44 ALLDOC
= $(MANDOC
) $(HTMLDOC
) manual.html-chunked manual.pdf
46 # Never include the release number in the tarname for tagged
48 ifneq ($(if
$(DIST_VERSION
),$(words $(RPM_VERLIST
))),2)
49 TARNAME
= tig-
$(RPM_VERSION
)-$(RPM_RELEASE
)
51 TARNAME
= tig-
$(RPM_VERSION
)
54 override CPPFLAGS
+= '-DTIG_VERSION="$(VERSION)"'
55 override CPPFLAGS
+= '-DSYSCONFDIR="$(sysconfdir)"'
57 AUTORECONF ?
= autoreconf
59 ASCIIDOC_FLAGS
= -aversion
=$(VERSION
) -asysconfdir
=$(sysconfdir
)
61 DOCBOOK2PDF ?
= docbook2pdf
63 all: $(PROGS
) $(TESTS
)
64 all-debug
: $(PROGS
) $(TESTS
)
65 all-debug
: CFLAGS
+= $(DFLAGS
)
71 mkdir
-p
$(DESTDIR
)$(bindir) && \
72 for prog in
$(PROGS
); do \
73 install -p
-m
0755 "$$prog" "$(DESTDIR)$(bindir)"; \
76 install-doc-man
: doc-man
77 mkdir
-p
$(DESTDIR
)$(mandir)/man1 \
78 $(DESTDIR
)$(mandir)/man5 \
79 $(DESTDIR
)$(mandir)/man7
80 for doc in
$(MANDOC
); do \
81 sed
's#++SYSCONFDIR++#$(sysconfdir)#' < "$$doc" > "$$doc+"; \
83 *.1) install -p
-m
0644 "$$doc+" "$(DESTDIR)$(mandir)/man1/$$doc" ;; \
84 *.5) install -p
-m
0644 "$$doc+" "$(DESTDIR)$(mandir)/man5/$$doc" ;; \
85 *.7) install -p
-m
0644 "$$doc+" "$(DESTDIR)$(mandir)/man7/$$doc" ;; \
90 install-release-doc-man
:
91 GIT_INDEX_FILE
=.tmp-doc-index git read-tree
origin/release
92 GIT_INDEX_FILE
=.tmp-doc-index git checkout-index
-f
--prefix=.
/ $(MANDOC
)
94 $(MAKE
) install-doc-man
96 install-doc-html
: doc-html
97 mkdir
-p
$(DESTDIR
)$(docdir
)/tig
98 for doc in
$(HTMLDOC
); do \
99 sed
's#++SYSCONFDIR++#$(sysconfdir)#' < "$$doc" > "$$doc+"; \
101 *.html
) install -p
-m
0644 "$$doc+" "$(DESTDIR)$(docdir)/tig/$$doc" ;; \
106 install-release-doc-html
:
107 GIT_INDEX_FILE
=.tmp-doc-index git read-tree
origin/release
108 GIT_INDEX_FILE
=.tmp-doc-index git checkout-index
-f
--prefix=.
/ $(HTMLDOC
)
110 $(MAKE
) install-doc-html
112 install-doc
: install-doc-man install-doc-html
113 install-release-doc
: install-release-doc-man install-release-doc-html
116 $(RM
) -r
$(TARNAME
) *.spec tig-
*.
tar.gz tig-
*.
tar.gz.md5
117 $(RM
) $(PROGS
) $(TESTS
) core
*.o
*.xml
120 $(RM
) -r manual.html-chunked autom4te.cache
121 $(RM
) *.toc
$(ALLDOC
) aclocal.m4 configure
122 $(RM
) config.h config.log config.make config.status config.h.in
125 for file in
$(TXTDOC
) tig.c
; do \
126 aspell
--lang
=en
--dont-backup \
127 --personal
=.
/contrib
/aspell.dict
check $$file; \
133 dist: configure tig.spec
134 @mkdir
-p
$(TARNAME
) && \
135 cp tig.spec configure config.h.in aclocal.m4
$(TARNAME
) && \
136 echo
$(VERSION
) > $(TARNAME
)/VERSION
137 git archive
--format
=tar --prefix=$(TARNAME
)/ HEAD | \
138 tar --delete
$(TARNAME
)/VERSION
> $(TARNAME
).
tar && \
139 tar rf
$(TARNAME
).
tar `find $(TARNAME)/*` && \
140 gzip
-f
-9 $(TARNAME
).
tar && \
141 md5sum
$(TARNAME
).
tar.gz
> $(TARNAME
).
tar.gz.md5
145 rpmbuild
-ta
$(TARNAME
).
tar.gz
147 configure
: configure.ac acinclude.m4
148 $(AUTORECONF
) -v
-I contrib
150 .PHONY
: all all-debug doc doc-man doc-html
install install-doc \
151 install-doc-man install-doc-html
clean spell-check
dist rpm
153 io.o
: io.c io.h tig.h
154 graph.o
: graph.c graph.h tig.h
155 tig.o
: tig.c tig.h graph.h io.h git.h
156 tig
: tig.o io.o graph.o
157 test-graph.o
: test-graph.c io.h tig.h graph.h
158 test-graph
: io.o graph.o
160 tig.spec
: contrib
/tig.spec.in
161 sed
-e
's/@@VERSION@@/$(RPM_VERSION)/g' \
162 -e
's/@@RELEASE@@/$(RPM_RELEASE)/g' < $< > $@
164 manual.html
: manual.toc
165 manual.toc
: manual.txt
166 sed
-n
'/^\[\[/,/\(---\|~~~\)/p' < $< | while read line
; do \
168 "----"*) echo
". <<$$ref>>"; ref
= ;; \
169 "~~~~"*) echo
"- <<$$ref>>"; ref
= ;; \
170 "[["*"]]") ref
="$$line" ;; \
171 *) ref
="$$ref, $$line" ;; \
172 esac
; done | sed
's/\[\[\(.*\)\]\]/\1/' > $@
174 README.html
: README SITES INSTALL asciidoc.conf
175 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
-a readme
$<
177 NEWS.html
: NEWS asciidoc.conf
178 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
$<
180 tigmanual
.7: manual.txt
182 %.1.html
: %.1.txt asciidoc.conf
183 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d manpage
$<
185 %.1.xml
: %.1.txt asciidoc.conf
186 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d manpage
$<
188 %.5.html
: %.5.txt asciidoc.conf
189 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d manpage
$<
191 %.5.xml
: %.5.txt asciidoc.conf
192 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d manpage
$<
194 %.7.xml
: %.7.txt asciidoc.conf
195 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d manpage
$<
197 %.html
: %.txt asciidoc.conf
198 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
-n
$<
200 %.xml
: %.txt asciidoc.conf
201 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d article
$<
206 %.html-chunked
: %.xml
207 $(XMLTO
) html
-o
$@
$<