iconv: Remove unnecessary length argument to encoding_iconv
[tig.git] / Makefile
blobf287a66850c7c96ae94a93c7364a7ea556ac7a91
1 ## Makefile for tig
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.
5 VERSION = 1.1
7 all:
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
14 -include config.make
16 prefix ?= $(HOME)
17 bindir ?= $(prefix)/bin
18 datarootdir ?= $(prefix)/share
19 sysconfdir ?= $(prefix)/etc
20 docdir ?= $(datarootdir)/doc
21 mandir ?= $(datarootdir)/man
22 # DESTDIR=
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)
28 endif
29 ifdef DIST_VERSION
30 VERSION = $(DIST_VERSION)
31 endif
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)
39 LDLIBS ?= -lcurses
40 CFLAGS ?= -Wall -O2
41 DFLAGS = -g -DDEBUG -Werror -O0
42 PROGS = tig
43 TESTS = test-graph
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
51 # versions.
52 ifneq ($(if $(DIST_VERSION),$(words $(RPM_VERLIST))),2)
53 TARNAME = tig-$(RPM_VERSION)-$(RPM_RELEASE)
54 else
55 TARNAME = tig-$(RPM_VERSION)
56 endif
58 override CPPFLAGS += '-DTIG_VERSION="$(VERSION)"'
59 override CPPFLAGS += '-DSYSCONFDIR="$(sysconfdir)"'
61 ASCIIDOC ?= asciidoc
62 ASCIIDOC_FLAGS = -aversion=$(VERSION) -asysconfdir=$(sysconfdir)
63 XMLTO ?= xmlto
64 DOCBOOK2PDF ?= docbook2pdf
66 all: $(PROGS) $(TESTS)
67 all-debug: $(PROGS) $(TESTS)
68 all-debug: CFLAGS += $(DFLAGS)
69 doc: $(ALLDOC)
70 doc-man: $(MANDOC)
71 doc-html: $(HTMLDOC)
73 install: all
74 mkdir -p $(DESTDIR)$(bindir) && \
75 for prog in $(PROGS); do \
76 install -p -m 0755 "$$prog" "$(DESTDIR)$(bindir)"; \
77 done
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+"; \
85 case "$$doc" in \
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" ;; \
89 esac; \
90 $(RM) "$$doc+"; \
91 done
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)
96 rm -f .tmp-doc-index
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 case "$$doc" in \
104 *.html) install -p -m 0644 "$$doc+" "$(DESTDIR)$(docdir)/tig/$$doc" ;; \
105 esac; \
106 $(RM) "$$doc+"; \
107 done
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)
112 rm -f .tmp-doc-index
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
118 clean:
119 $(RM) -r $(TARNAME) *.spec tig-*.tar.gz tig-*.tar.gz.md5
120 $(RM) $(PROGS) $(TESTS) core *.o *.xml
122 distclean: clean
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
127 spell-check:
128 for file in $(TXTDOC) tig.c; do \
129 aspell --lang=en --dont-backup \
130 --personal=./contrib/aspell.dict check $$file; \
131 done
133 strip: $(PROGS)
134 strip $(PROGS)
136 update-headers:
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"; \
143 rm "$$file.tmp"; \
144 echo "Updated $$file"; \
145 done
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
156 @$(RM) -r $(TARNAME)
158 rpm: dist
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
164 ./autogen.sh
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
182 # config.make).
183 show-deps:
184 @echo "== without config.h =="
185 $(CC) -MM *.c
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 \
196 case "$$line" in \
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 $<
232 % : %.xml
233 $(XMLTO) man $<
235 %.html-chunked : %.xml
236 $(XMLTO) html -o $@ $<
238 %.pdf : %.xml
239 $(DOCBOOK2PDF) $<