3 # The last tagged version. Can be overridden either by the version from
4 # git or from the value of the DIST_VERSION environment variable.
9 # Include kernel specific configuration
10 kernel_name
:= $(shell sh
-c
'uname -s 2>/dev/null || echo unknown')
11 -include contrib
/config.make-
$(kernel_name
)
13 # Include setting from the configure script
17 bindir ?
= $(prefix)/bin
18 datarootdir ?
= $(prefix)/share
19 sysconfdir ?
= $(prefix)/etc
20 docdir ?
= $(datarootdir
)/doc
21 mandir ?
= $(datarootdir
)/man
24 ifneq (,$(wildcard .git
))
25 GITDESC
= $(subst tig-
,,$(shell git describe
))
26 WTDIRTY
= $(if
$(shell git diff-index HEAD
2>/dev
/null
),-dirty
)
27 VERSION
= $(GITDESC
)$(WTDIRTY
)
30 VERSION
= $(DIST_VERSION
)
33 # Split the version "TAG-OFFSET-gSHA1-DIRTY" into "TAG OFFSET"
34 # and append 0 as a fallback offset for "exact" tagged versions.
35 RPM_VERLIST
= $(filter-out g
% dirty
,$(subst -, ,$(VERSION
))) 0
36 RPM_VERSION
= $(word 1,$(RPM_VERLIST
))
37 RPM_RELEASE
= $(word 2,$(RPM_VERLIST
))$(if
$(WTDIRTY
),.dirty
)
41 DFLAGS
= -g
-DDEBUG
-Werror
-O0
44 SOURCE
= tig.c tig.h io.c io.h graph.c graph.h
45 TXTDOC
= tig
.1.txt tigrc
.5.txt manual.txt NEWS README INSTALL BUGS
46 MANDOC
= tig
.1 tigrc
.5 tigmanual
.7
47 HTMLDOC
= tig
.1.html tigrc
.5.html manual.html README.html NEWS.html
48 ALLDOC
= $(MANDOC
) $(HTMLDOC
) manual.html-chunked manual.pdf
50 # Never include the release number in the tarname for tagged
52 ifneq ($(if
$(DIST_VERSION
),$(words $(RPM_VERLIST
))),2)
53 TARNAME
= tig-
$(RPM_VERSION
)-$(RPM_RELEASE
)
55 TARNAME
= tig-
$(RPM_VERSION
)
58 override CPPFLAGS
+= '-DTIG_VERSION="$(VERSION)"'
59 override CPPFLAGS
+= '-DSYSCONFDIR="$(sysconfdir)"'
62 ASCIIDOC_FLAGS
= -aversion
=$(VERSION
) -asysconfdir
=$(sysconfdir
)
64 DOCBOOK2PDF ?
= docbook2pdf
66 all: $(PROGS
) $(TESTS
)
67 all-debug
: $(PROGS
) $(TESTS
)
68 all-debug
: CFLAGS
+= $(DFLAGS
)
74 mkdir
-p
$(DESTDIR
)$(bindir) && \
75 for prog in
$(PROGS
); do \
76 install -p
-m
0755 "$$prog" "$(DESTDIR)$(bindir)"; \
79 install-doc-man
: doc-man
80 mkdir
-p
$(DESTDIR
)$(mandir)/man1 \
81 $(DESTDIR
)$(mandir)/man5 \
82 $(DESTDIR
)$(mandir)/man7
83 for doc in
$(MANDOC
); do \
84 sed
's#++SYSCONFDIR++#$(sysconfdir)#' < "$$doc" > "$$doc+"; \
86 *.1) install -p
-m
0644 "$$doc+" "$(DESTDIR)$(mandir)/man1/$$doc" ;; \
87 *.5) install -p
-m
0644 "$$doc+" "$(DESTDIR)$(mandir)/man5/$$doc" ;; \
88 *.7) install -p
-m
0644 "$$doc+" "$(DESTDIR)$(mandir)/man7/$$doc" ;; \
93 install-release-doc-man
:
94 GIT_INDEX_FILE
=.tmp-doc-index git read-tree
origin/release
95 GIT_INDEX_FILE
=.tmp-doc-index git checkout-index
-f
--prefix=.
/ $(MANDOC
)
97 $(MAKE
) install-doc-man
99 install-doc-html
: doc-html
100 mkdir
-p
$(DESTDIR
)$(docdir
)/tig
101 for doc in
$(HTMLDOC
); do \
102 sed
's#++SYSCONFDIR++#$(sysconfdir)#' < "$$doc" > "$$doc+"; \
104 *.html
) install -p
-m
0644 "$$doc+" "$(DESTDIR)$(docdir)/tig/$$doc" ;; \
109 install-release-doc-html
:
110 GIT_INDEX_FILE
=.tmp-doc-index git read-tree
origin/release
111 GIT_INDEX_FILE
=.tmp-doc-index git checkout-index
-f
--prefix=.
/ $(HTMLDOC
)
113 $(MAKE
) install-doc-html
115 install-doc
: install-doc-man install-doc-html
116 install-release-doc
: install-release-doc-man install-release-doc-html
119 $(RM
) -r
$(TARNAME
) *.spec tig-
*.
tar.gz tig-
*.
tar.gz.md5
120 $(RM
) $(PROGS
) $(TESTS
) core
*.o
*.xml
123 $(RM
) -r manual.html-chunked autom4te.cache
124 $(RM
) *.toc
$(ALLDOC
) aclocal.m4 configure
125 $(RM
) config.h config.log config.make config.status config.h.in
128 for file in
$(TXTDOC
) tig.c
; do \
129 aspell
--lang
=en
--dont-backup \
130 --personal
=.
/contrib
/aspell.dict
check $$file; \
137 @for file in
*.
[ch
]; do \
138 grep
-q
'/* Copyright' "$$file" && \
139 sed
'0,/.*\*\//d' < "$$file" | \
140 grep
-v
'/* vim: set' > "$$file.tmp"; \
141 { cat contrib
/header.h
"$$file.tmp"; \
142 echo
"/* vim: set ts=8 sw=8 noexpandtab: */"; } > "$$file"; \
144 echo
"Updated $$file"; \
147 dist: configure tig.spec
148 @mkdir
-p
$(TARNAME
) && \
149 cp Makefile tig.spec configure config.h.in aclocal.m4
$(TARNAME
) && \
150 sed
-i
"s/VERSION\s=\s[0-9]\+[.][0-9]\+/VERSION = $(VERSION)/" $(TARNAME
)/Makefile
151 git archive
--format
=tar --prefix=$(TARNAME
)/ HEAD | \
152 tar --delete
$(TARNAME
)/Makefile
> $(TARNAME
).
tar && \
153 tar rf
$(TARNAME
).
tar `find $(TARNAME)/*` && \
154 gzip
-f
-9 $(TARNAME
).
tar && \
155 md5sum
$(TARNAME
).
tar.gz
> $(TARNAME
).
tar.gz.md5
159 rpmbuild
-ta
$(TARNAME
).
tar.gz
161 # Other autoconf-related rules are hidden in config.make.in so that
162 # they don't confuse Make when we aren't actually using ./configure
163 configure
: configure.ac acinclude.m4 contrib
/*.m4
166 .PHONY
: all all-debug doc doc-man doc-html
install install-doc \
167 install-doc-man install-doc-html
clean spell-check
dist rpm
169 graph.o
: graph.c tig.h graph.h
170 io.o
: io.c tig.h io.h
171 refs.o
: refs.c tig.h io.h refs.h
172 test-graph.o
: test-graph.c tig.h io.h graph.h
173 tig.o
: tig.c tig.h io.h refs.h graph.h git.h
175 tig
: tig.o io.o graph.o refs.o
176 test-graph
: io.o graph.o
178 # To check the above.
180 # NOTE: Assumes GCC, and that no local headers are conditionally
181 # included (with the exception of config.h, which we take care of in
184 @echo
"== without config.h =="
186 @echo
"== with config.h =="
187 $(CC
) -DHAVE_CONFIG_H
-MM
*.c
189 tig.spec
: contrib
/tig.spec.in
190 sed
-e
's/@@VERSION@@/$(RPM_VERSION)/g' \
191 -e
's/@@RELEASE@@/$(RPM_RELEASE)/g' < $< > $@
193 manual.html
: manual.toc
194 manual.toc
: manual.txt
195 sed
-n
'/^\[\[/,/\(---\|~~~\)/p' < $< | while read line
; do \
197 "----"*) echo
". <<$$ref>>"; ref
= ;; \
198 "~~~~"*) echo
"- <<$$ref>>"; ref
= ;; \
199 "[["*"]]") ref
="$$line" ;; \
200 *) ref
="$$ref, $$line" ;; \
201 esac
; done | sed
's/\[\[\(.*\)\]\]/\1/' > $@
203 README.html
: README SITES INSTALL asciidoc.conf
204 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
-a readme
$<
206 NEWS.html
: NEWS asciidoc.conf
207 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
$<
209 tigmanual
.7: manual.txt
211 %.1.html
: %.1.txt asciidoc.conf
212 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d manpage
$<
214 %.1.xml
: %.1.txt asciidoc.conf
215 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d manpage
$<
217 %.5.html
: %.5.txt asciidoc.conf
218 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d manpage
$<
220 %.5.xml
: %.5.txt asciidoc.conf
221 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d manpage
$<
223 %.7.xml
: %.7.txt asciidoc.conf
224 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d manpage
$<
226 %.html
: %.txt asciidoc.conf
227 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
-n
$<
229 %.xml
: %.txt asciidoc.conf
230 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d article
$<
235 %.html-chunked
: %.xml
236 $(XMLTO
) html
-o
$@
$<