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