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