Fix pager mode by always doing the isatty()
[tig] / Makefile
CommitLineData
ec31d0d0
SG
1## Makefile for tig
2
aba0683c
JF
3all:
4
ec31d0d0
SG
5# Include setting from the configure script
6-include config.make
7
8prefix ?= $(HOME)
9bindir ?= $(prefix)/bin
ec31d0d0 10datarootdir ?= $(prefix)/share
b6607e7e 11sysconfdir ?= $(prefix)/etc
ec31d0d0 12docdir ?= $(datarootdir)/doc
3b0d681f 13mandir ?= $(datarootdir)/man
5f7b975a
JH
14# DESTDIR=
15
3f20fe55
JF
16# Get version either via git or from VERSION file. Allow either
17# to be overwritten by setting DIST_VERSION on the command line.
73785605 18ifneq (,$(wildcard .git))
c4c9cd3b 19GITDESC = $(subst tig-,,$(shell git describe))
0e9f95f4 20WTDIRTY = $(if $(shell git diff-index HEAD 2>/dev/null),-dirty)
c4c9cd3b 21VERSION = $(GITDESC)$(WTDIRTY)
73785605 22else
c4c9cd3b 23VERSION = $(shell test -f VERSION && cat VERSION || echo "unknown-version")
73785605 24endif
3f20fe55
JF
25ifdef DIST_VERSION
26VERSION = $(DIST_VERSION)
27endif
28
276346b0
JN
29# Split the version "TAG-OFFSET-gSHA1-DIRTY" into "TAG OFFSET"
30# and append 0 as a fallback offset for "exact" tagged versions.
31RPM_VERLIST = $(filter-out g% dirty,$(subst -, ,$(VERSION))) 0
32RPM_VERSION = $(word 1,$(RPM_VERLIST))
33RPM_RELEASE = $(word 2,$(RPM_VERLIST))$(if $(WTDIRTY),.dirty)
73785605 34
af32b365 35LDLIBS ?= -lcurses
ec31d0d0 36CFLAGS ?= -Wall -O2
19f862bd 37DFLAGS = -g -DDEBUG -Werror
b801d8b2 38PROGS = tig
c4c9cd3b
JF
39MANDOC = tig.1 tigrc.5
40HTMLDOC = tig.1.html tigrc.5.html manual.html README.html
41ALLDOC = $(MANDOC) $(HTMLDOC) manual.html-chunked manual.pdf
201f10e2
JF
42
43# Never include the release number in the tarname for tagged
44# versions.
45ifneq ($(if $(DIST_VERSION),$(words $(RPM_VERLIST))),2)
276346b0 46TARNAME = tig-$(RPM_VERSION)-$(RPM_RELEASE)
201f10e2
JF
47else
48TARNAME = tig-$(RPM_VERSION)
49endif
8cdf5691 50
b6607e7e
DV
51override CPPFLAGS += '-DTIG_VERSION="$(VERSION)"'
52override CPPFLAGS += '-DSYSCONFDIR="$(sysconfdir)"'
89de1d4e 53
26a7f271 54AUTORECONF ?= autoreconf
c692b4e4 55ASCIIDOC ?= asciidoc
b6607e7e 56ASCIIDOC_FLAGS = -aversion=$(VERSION) -asysconfdir=$(sysconfdir)
c692b4e4
JF
57XMLTO ?= xmlto
58DOCBOOK2PDF ?= docbook2pdf
ec31d0d0 59
a7bc4b14 60all: $(PROGS)
82e78006
JF
61all-debug: $(PROGS)
62all-debug: CFLAGS += $(DFLAGS)
c4c9cd3b
JF
63doc: $(ALLDOC)
64doc-man: $(MANDOC)
65doc-html: $(HTMLDOC)
800a900c 66
05f1685b 67install: all
d441a715 68 mkdir -p $(DESTDIR)$(bindir) && \
a7bc4b14 69 for prog in $(PROGS); do \
4eb7501b 70 install -p -m 0755 "$$prog" "$(DESTDIR)$(bindir)"; \
4c6fabc2
JF
71 done
72
ec4b9d91 73install-doc-man: doc-man
bb8afc29 74 mkdir -p $(DESTDIR)$(mandir)/man1 \
ec4b9d91 75 $(DESTDIR)$(mandir)/man5
c4c9cd3b 76 for doc in $(MANDOC); do \
4eb7501b 77 sed 's#++SYSCONFDIR++#$(sysconfdir)#' < "$$doc" > "$$doc+"; \
4c6fabc2 78 case "$$doc" in \
4eb7501b
JF
79 *.1) install -p -m 0644 "$$doc+" "$(DESTDIR)$(mandir)/man1/$$doc" ;; \
80 *.5) install -p -m 0644 "$$doc+" "$(DESTDIR)$(mandir)/man5/$$doc" ;; \
81 esac; \
82 $(RM) "$$doc+"; \
ec4b9d91
GK
83 done
84
85install-doc-html: doc-html
86 mkdir -p $(DESTDIR)$(docdir)/tig
c4c9cd3b 87 for doc in $(HTMLDOC); do \
4eb7501b 88 sed 's#++SYSCONFDIR++#$(sysconfdir)#' < "$$doc" > "$$doc+"; \
ec4b9d91 89 case "$$doc" in \
4eb7501b
JF
90 *.html) install -p -m 0644 "$$doc+" "$(DESTDIR)$(docdir)/tig/$$doc" ;; \
91 esac; \
92 $(RM) "$$doc+"; \
a7bc4b14 93 done
05f1685b 94
ec4b9d91
GK
95install-doc: install-doc-man install-doc-html
96
05f1685b 97clean:
4b551e77
JF
98 $(RM) -r $(TARNAME) *.spec tig-*.tar.gz tig-*.tar.gz.md5
99 $(RM) $(PROGS) core *.o *.xml
100
101distclean: clean
102 $(RM) -r manual.html-chunked *.toc $(ALLDOC)
103 $(RM) -r autom4te.cache aclocal.m4 config.{h,log,make,status} config.h.in configure
05f1685b 104
57bdf034 105spell-check:
8eb62770 106 aspell --lang=en --check tig.1.txt tigrc.5.txt manual.txt
57bdf034 107
88d7f67e 108strip: $(PROGS)
0e92d312
JF
109 strip $(PROGS)
110
e8361135 111dist: configure tig.spec
70a83764 112 @mkdir -p $(TARNAME) && \
e8361135 113 cp tig.spec configure config.h.in aclocal.m4 $(TARNAME) && \
b253ee86 114 echo $(VERSION) > $(TARNAME)/VERSION
4393be9e
JF
115 git archive --format=tar --prefix=$(TARNAME)/ HEAD | \
116 tar --delete $(TARNAME)/VERSION > $(TARNAME).tar && \
e8361135 117 tar rf $(TARNAME).tar `find $(TARNAME)/*` && \
70a83764
JF
118 gzip -f -9 $(TARNAME).tar && \
119 md5sum $(TARNAME).tar.gz > $(TARNAME).tar.gz.md5
4eb7501b 120 @$(RM) -r $(TARNAME)
8cdf5691
JN
121
122rpm: dist
123 rpmbuild -ta $(TARNAME).tar.gz
124
e47afdf2 125configure: configure.ac acinclude.m4
26a7f271 126 $(AUTORECONF) -v
ec31d0d0 127
a49dc471 128# Maintainer stuff
3f20fe55 129release-doc:
a49dc471
JF
130 git checkout release && \
131 git merge master && \
4eb7501b 132 $(MAKE) distclean doc-man doc-html sysconfdir=++SYSCONFDIR++ && \
2f990549 133 git add -f $(MANDOC) $(HTMLDOC) && \
a49dc471
JF
134 git commit -m "Sync docs" && \
135 git checkout master
136
3f20fe55
JF
137release-dist: release-doc
138 git checkout release && \
0e9f95f4 139 $(MAKE) dist && \
3f20fe55
JF
140 git checkout master
141
c4c9cd3b
JF
142.PHONY: all all-debug doc doc-man doc-html install install-doc \
143 install-doc-man install-doc-html clean spell-check dist rpm
8cdf5691 144
88d7f67e
JF
145tig.o: tig.c
146tig: tig.o
147
1b48a10d 148tig.spec: contrib/tig.spec.in
276346b0
JN
149 sed -e 's/@@VERSION@@/$(RPM_VERSION)/g' \
150 -e 's/@@RELEASE@@/$(RPM_RELEASE)/g' < $< > $@
8cdf5691 151
ec4b9d91 152manual.html: manual.toc
9783cb12
JF
153manual.toc: manual.txt
154 sed -n '/^\[\[/,/\(---\|~~~\)/p' < $< | while read line; do \
155 case "$$line" in \
156 "-----"*) echo ". <<$$ref>>"; ref= ;; \
157 "~~~~~"*) echo "- <<$$ref>>"; ref= ;; \
158 "[["*"]]") ref="$$line" ;; \
159 *) ref="$$ref, $$line" ;; \
160 esac; done | sed 's/\[\[\(.*\)\]\]/\1/' > $@
161
c8d92293 162README.html: README asciidoc.conf
3e8b133e 163 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article -a readme $<
b8ae9346 164
c8d92293 165%.1.html : %.1.txt asciidoc.conf
3e8b133e 166 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d manpage $<
a7bc4b14 167
c8d92293
JF
168%.1.xml : %.1.txt asciidoc.conf
169 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d manpage $<
a7bc4b14 170
c8d92293 171%.5.html : %.5.txt asciidoc.conf
3e8b133e 172 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d manpage $<
cb7f42cd 173
c8d92293
JF
174%.5.xml : %.5.txt asciidoc.conf
175 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d manpage $<
d839253b 176
c8d92293 177%.html : %.txt asciidoc.conf
3e8b133e 178 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article -n $<
d839253b 179
c8d92293 180%.xml : %.txt asciidoc.conf
3e8b133e 181 $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d article $<
d839253b 182
c8d92293
JF
183% : %.xml
184 $(XMLTO) man $<
185
d839253b 186%.html-chunked : %.xml
c692b4e4 187 $(XMLTO) html -o $@ $<
c8d92293
JF
188
189%.pdf : %.xml
190 $(DOCBOOK2PDF) $<