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
43 TOOLS
= test/test-graph tools
/doc-gen
44 TXTDOC
= doc
/tig
.1.adoc doc
/tigrc
.5.adoc doc
/manual.adoc NEWS.adoc README.adoc INSTALL.adoc
45 MANDOC
= doc
/tig
.1 doc
/tigrc
.5 doc
/tigmanual
.7
46 HTMLDOC
= doc
/tig
.1.html doc
/tigrc
.5.html doc
/manual.html README.html INSTALL.html NEWS.html
47 ALLDOC
= $(MANDOC
) $(HTMLDOC
) doc
/manual.html-chunked doc
/manual.pdf
49 # Never include the release number in the tarname for tagged
51 ifneq ($(if
$(DIST_VERSION
),$(words $(RPM_VERLIST
))),2)
52 TARNAME
= tig-
$(RPM_VERSION
)-$(RPM_RELEASE
)
54 TARNAME
= tig-
$(RPM_VERSION
)
57 override CPPFLAGS
+= '-DTIG_VERSION="$(VERSION)"'
58 override CPPFLAGS
+= '-DSYSCONFDIR="$(sysconfdir)"'
61 ASCIIDOC_FLAGS
= -aversion
=$(VERSION
) -asysconfdir
=$(sysconfdir
) -f doc
/asciidoc.conf
63 DOCBOOK2PDF ?
= docbook2pdf
66 all-debug
: $(EXE
) $(TOOLS
)
67 all-debug
: CFLAGS
+= $(DFLAGS
)
73 @mkdir
-p
$(DESTDIR
)$(bindir)
74 install -p
-m
0755 $(EXE
) "$(DESTDIR)$(bindir)"
75 @mkdir
-p
$(DESTDIR
)$(sysconfdir
)
76 install -p
-m
0444 tigrc
"$(DESTDIR)$(sysconfdir)"
78 install-doc-man
: doc-man
79 mkdir
-p
$(DESTDIR
)$(mandir)/man1 \
80 $(DESTDIR
)$(mandir)/man5 \
81 $(DESTDIR
)$(mandir)/man7
82 for doc in
$(MANDOC
); do \
83 sed
's#++SYSCONFDIR++#$(sysconfdir)#' < "$$doc" > "$$doc+"; \
84 bdoc
=$$(basename $$doc); \
86 *.1) install -p
-m
0644 "$$doc+" "$(DESTDIR)$(mandir)/man1/$$bdoc" ;; \
87 *.5) install -p
-m
0644 "$$doc+" "$(DESTDIR)$(mandir)/man5/$$bdoc" ;; \
88 *.7) install -p
-m
0644 "$$doc+" "$(DESTDIR)$(mandir)/man7/$$bdoc" ;; \
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+"; \
103 bdoc
=$$(basename $$doc); \
105 *.html
) install -p
-m
0644 "$$doc+" "$(DESTDIR)$(docdir)/tig/$$bdoc" ;; \
110 install-release-doc-html
:
111 GIT_INDEX_FILE
=.tmp-doc-index git read-tree
origin/release
112 GIT_INDEX_FILE
=.tmp-doc-index git checkout-index
-f
--prefix=.
/ $(HTMLDOC
)
114 $(MAKE
) install-doc-html
116 install-doc
: install-doc-man install-doc-html
117 install-release-doc
: install-release-doc-man install-release-doc-html
120 $(RM
) -r
$(TARNAME
) *.spec tig-
*.
tar.gz tig-
*.
tar.gz.md5 .deps
121 $(RM
) $(EXE
) $(TOOLS
) $(OBJS
) core doc
/*.xml src
/builtin-config.c
124 $(RM
) -r doc
/manual.html-chunked autom4te.cache release-docs
125 $(RM
) doc
/*.toc
$(ALLDOC
) aclocal.m4 configure
126 $(RM
) config.h config.log config.make config.status config.h.in
129 for file in
$(TXTDOC
) src
/tig.c
; do \
130 aspell
--lang
=en
--dont-backup \
131 --personal
=.
/tools
/aspell.dict
check $$file; \
138 @for file in
include/*.h src
/*.c tools
/*.c
; do \
139 grep
-q
'/* Copyright' "$$file" && \
140 sed
'0,/.*\*\//d' < "$$file" | \
141 grep
-v
'/* vim: set' > "$$file.tmp"; \
142 { cat tools
/header.h
"$$file.tmp"; \
143 echo
"/* vim: set ts=8 sw=8 noexpandtab: */"; } > "$$file"; \
145 echo
"Updated $$file"; \
148 update-docs
: tools
/doc-gen
149 doc
="doc/tigrc.5.adoc"; \
150 sed
-n
'0,/ifndef::DOC_GEN_ACTIONS/p' < "$$doc" > "$$doc.gen"; \
151 .
/tools
/doc-gen actions
>> "$$doc.gen"; \
152 sed
-n
'/endif::DOC_GEN_ACTIONS/,$$p' < "$$doc" >> "$$doc.gen" ; \
153 mv
"$$doc.gen" "$$doc"
155 dist: configure tig.spec
156 @mkdir
-p
$(TARNAME
) && \
157 cp Makefile tig.spec configure config.h.in aclocal.m4
$(TARNAME
) && \
158 sed
-i
"s/VERSION\s\+=\s\+[0-9]\+\([.][0-9]\+\)\+/VERSION = $(VERSION)/" $(TARNAME
)/Makefile
159 git archive
--format
=tar --prefix=$(TARNAME
)/ HEAD | \
160 tar --delete
$(TARNAME
)/Makefile
> $(TARNAME
).
tar && \
161 tar rf
$(TARNAME
).
tar `find $(TARNAME)/*` && \
162 gzip
-f
-9 $(TARNAME
).
tar && \
163 md5sum
$(TARNAME
).
tar.gz
> $(TARNAME
).
tar.gz.md5
167 rpmbuild
-ta
$(TARNAME
).
tar.gz
170 test/unit-test-graph.sh
172 # Other autoconf-related rules are hidden in config.make.in so that
173 # they don't confuse Make when we aren't actually using ./configure
174 configure
: configure.ac acinclude.m4 tools
/*.m4
177 .PHONY
: all all-debug doc doc-man doc-html
install install-doc \
178 install-doc-man install-doc-html
clean spell-check
dist rpm
test
181 COMPAT_CPPFLAGS
+= -DNO_MKSTEMPS
182 COMPAT_OBJS
+= compat
/mkstemps.o
186 COMPAT_CPPFLAGS
+= -DNO_SETENV
187 COMPAT_OBJS
+= compat
/setenv.o
190 COMPAT_OBJS
+= compat
/hashtab.o
192 override CPPFLAGS
+= $(COMPAT_CPPFLAGS
)
201 src
/builtin-config.o \
212 TEST_GRAPH_OBJS
= test/test-graph.o src
/util.o src
/io.o src
/graph.o
$(COMPAT_OBJS
)
213 test/test-graph
: $(TEST_GRAPH_OBJS
)
215 DOC_GEN_OBJS
= tools
/doc-gen.o src
/types.o src
/util.o src
/request.o
216 tools
/doc-gen
: $(DOC_GEN_OBJS
)
218 OBJS
= $(sort $(TIG_OBJS
) $(TEST_GRAPH_OBJS
) $(DOC_GEN_OBJS
))
220 DEPS_CFLAGS ?
= -MMD
-MP
-MF .deps
/$*.d
223 $(CC
) $(CFLAGS
) $(CPPFLAGS
) $(LDFLAGS
) $^
$(LDLIBS
) -o
$@
226 @mkdir
-p
$(abspath .deps
/$(*D
))
227 $(CC
) -I.
-Iinclude
$(CFLAGS
) $(DEPS_CFLAGS
) $(CPPFLAGS
) -c
-o
$@
$<
229 -include $(OBJS
:%.o
=.deps
/%.d
)
231 src
/builtin-config.c
: tigrc tools
/make-builtin-config.sh
232 tools
/make-builtin-config.sh
$< > $@
234 tig.spec
: contrib
/tig.spec.in
235 sed
-e
's/@@VERSION@@/$(RPM_VERSION)/g' \
236 -e
's/@@RELEASE@@/$(RPM_RELEASE)/g' < $< > $@
238 doc
/manual.html
: doc
/manual.toc
239 doc
/manual.html
: ASCIIDOC_FLAGS
+= -ainclude-manual-toc
241 sed
-n
'/^\[\[/,/\(---\|~~~\)/p' < $< | while read line
; do \
243 "----"*) echo
". <<$$ref>>"; ref
= ;; \
244 "~~~~"*) echo
"- <<$$ref>>"; ref
= ;; \
245 "[["*"]]") ref
="$$line" ;; \
246 *) ref
="$$ref, $$line" ;; \
247 esac
; done | sed
's/\[\[\(.*\)\]\]/\1/' > $@
249 README.html
: README.adoc doc
/asciidoc.conf
250 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
-a readme
$<
252 INSTALL.html
: INSTALL.adoc doc
/asciidoc.conf
253 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
$<
255 NEWS.html
: NEWS.adoc doc
/asciidoc.conf
256 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
$<
258 doc
/tigmanual
.7: doc
/manual.adoc
260 %.1.html
: %.1.adoc doc
/asciidoc.conf
261 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d manpage
$<
263 %.1.xml
: %.1.adoc doc
/asciidoc.conf
264 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d manpage
$<
266 %.5.html
: %.5.adoc doc
/asciidoc.conf
267 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d manpage
$<
269 %.5.xml
: %.5.adoc doc
/asciidoc.conf
270 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d manpage
$<
272 %.7.xml
: %.7.adoc doc
/asciidoc.conf
273 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d manpage
$<
275 %.html
: ASCIIDOC_FLAGS
+= -adocext
=html
276 %.html
: %.adoc doc
/asciidoc.conf
277 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
-n
$<
279 %.xml
: %.adoc doc
/asciidoc.conf
280 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d article
$<
283 $(XMLTO
) man
-o doc
$<
285 %.html-chunked
: %.xml
286 $(XMLTO
) html
-o
$@
$<
289 $(DOCBOOK2PDF
) -o doc
$<