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 TXTDOC
= doc
/tig
.1.asciidoc doc
/tigrc
.5.asciidoc doc
/manual.asciidoc NEWS README INSTALL BUGS
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
65 all: $(PROGS
) $(TESTS
)
66 all-debug
: $(PROGS
) $(TESTS
)
67 all-debug
: CFLAGS
+= $(DFLAGS
)
73 mkdir
-p
$(DESTDIR
)$(bindir) && \
74 for prog in
$(PROGS
); do \
75 install -p
-m
0755 "$$prog" "$(DESTDIR)$(bindir)"; \
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+"; \
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 compat
/*.o
*.xml
123 $(RM
) -r doc
/manual.html-chunked autom4te.cache release-docs
124 $(RM
) doc
/*.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
170 COMPAT_CPPFLAGS
+= -DNO_MKSTEMPS
171 COMPAT_OBJS
+= compat
/mkstemps.o
175 COMPAT_CPPFLAGS
+= -DNO_SETENV
176 COMPAT_OBJS
+= compat
/setenv.o
179 override CPPFLAGS
+= $(COMPAT_CPPFLAGS
)
181 graph.o
: graph.c tig.h graph.h
182 io.o
: io.c tig.h io.h
183 refs.o
: refs.c tig.h io.h refs.h
184 test-graph.o
: test-graph.c tig.h io.h graph.h
185 tig.o
: tig.c tig.h io.h refs.h graph.h git.h
187 tig
: tig.o io.o graph.o refs.o
$(COMPAT_OBJS
)
188 test-graph
: io.o graph.o
190 # To check the above.
192 # NOTE: Assumes GCC, and that no local headers are conditionally
193 # included (with the exception of config.h, which we take care of in
196 @echo
"== without config.h =="
198 @echo
"== with config.h =="
199 $(CC
) -DHAVE_CONFIG_H
-MM
*.c
201 tig.spec
: contrib
/tig.spec.in
202 sed
-e
's/@@VERSION@@/$(RPM_VERSION)/g' \
203 -e
's/@@RELEASE@@/$(RPM_RELEASE)/g' < $< > $@
205 doc
/manual.html
: doc
/manual.toc
206 doc
/manual.html
: ASCIIDOC_FLAGS
+= -ainclude-manual-toc
208 sed
-n
'/^\[\[/,/\(---\|~~~\)/p' < $< | while read line
; do \
210 "----"*) echo
". <<$$ref>>"; ref
= ;; \
211 "~~~~"*) echo
"- <<$$ref>>"; ref
= ;; \
212 "[["*"]]") ref
="$$line" ;; \
213 *) ref
="$$ref, $$line" ;; \
214 esac
; done | sed
's/\[\[\(.*\)\]\]/\1/' > $@
216 README.html
: README doc
/asciidoc.conf
217 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
-a readme
$<
219 INSTALL.html
: INSTALL doc
/asciidoc.conf
220 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
$<
222 NEWS.html
: NEWS doc
/asciidoc.conf
223 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
$<
225 doc
/tigmanual
.7: doc
/manual.asciidoc
227 %.1.html
: %.1.asciidoc doc
/asciidoc.conf
228 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d manpage
$<
230 %.1.xml
: %.1.asciidoc doc
/asciidoc.conf
231 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d manpage
$<
233 %.5.html
: %.5.asciidoc doc
/asciidoc.conf
234 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d manpage
$<
236 %.5.xml
: %.5.asciidoc doc
/asciidoc.conf
237 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d manpage
$<
239 %.7.xml
: %.7.asciidoc doc
/asciidoc.conf
240 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d manpage
$<
242 %.html
: %.asciidoc doc
/asciidoc.conf
243 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b xhtml11
-d article
-n
$<
245 %.xml
: %.asciidoc doc
/asciidoc.conf
246 $(ASCIIDOC
) $(ASCIIDOC_FLAGS
) -b docbook
-d article
$<
249 $(XMLTO
) man
-o doc
$<
251 %.html-chunked
: %.xml
252 $(XMLTO
) html
-o
$@
$<
255 $(DOCBOOK2PDF
) -o doc
$<