0ff9e5d03fbba57470b1e8472bb74a536f737832
1 ## Makefile for tig
3 all:
5 # Include setting from the configure script
6 -include config.make
8 prefix ?= $(HOME)
9 bindir ?= $(prefix)/bin
10 mandir ?= $(prefix)/man
11 datarootdir ?= $(prefix)/share
12 docdir ?= $(datarootdir)/doc
13 # DESTDIR=
15 # Get version either via git or from VERSION file. Allow either
16 # to be overwritten by setting DIST_VERSION on the command line.
17 ifneq (,$(wildcard .git))
18 GITDESC = $(subst tig-,,$(shell git describe))
19 WTDIRTY = $(if $(shell git diff-index HEAD 2>/dev/null),-dirty)
20 VERSION = $(GITDESC)$(WTDIRTY)
21 else
22 VERSION = $(shell test -f VERSION && cat VERSION || echo "unknown-version")
23 endif
24 ifdef DIST_VERSION
25 VERSION = $(DIST_VERSION)
26 endif
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)
34 LDLIBS ?= -lcurses
35 CFLAGS ?= -Wall -O2
36 DFLAGS = -g -DDEBUG -Werror
37 PROGS = tig
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
41 TARNAME = tig-$(RPM_VERSION)-$(RPM_RELEASE)
43 override CFLAGS += '-DVERSION="$(VERSION)"'
45 AUTOHEADER ?= autoheader
46 AUTOCONF ?= autoconf
47 ASCIIDOC ?= asciidoc
48 XMLTO ?= xmlto
49 DOCBOOK2PDF ?= docbook2pdf
51 all: $(PROGS)
52 all-debug: $(PROGS)
53 all-debug: CFLAGS += $(DFLAGS)
54 doc: $(ALLDOC)
55 doc-man: $(MANDOC)
56 doc-html: $(HTMLDOC)
58 install: all
59 mkdir -p $(DESTDIR)$(bindir) && \
60 for prog in $(PROGS); do \
61 install -p -m 0755 $$prog $(DESTDIR)$(bindir); \
62 done
64 install-doc-man: doc-man
65 mkdir -p $(DESTDIR)$(mandir)/man1 \
66 $(DESTDIR)$(mandir)/man5
67 for doc in $(MANDOC); do \
68 case "$$doc" in \
69 *.1) install -p -m 0644 $$doc $(DESTDIR)$(mandir)/man1 ;; \
70 *.5) install -p -m 0644 $$doc $(DESTDIR)$(mandir)/man5 ;; \
71 esac \
72 done
74 install-doc-html: doc-html
75 mkdir -p $(DESTDIR)$(docdir)/tig
76 for doc in $(HTMLDOC); do \
77 case "$$doc" in \
78 *.html) install -p -m 0644 $$doc $(DESTDIR)$(docdir)/tig ;; \
79 esac \
80 done
82 install-doc: install-doc-man install-doc-html
84 clean:
85 rm -rf manual.html-chunked $(TARNAME)
86 rm -f $(PROGS) $(ALLDOC) core *.xml *.toc
87 rm -f *.spec tig-*.tar.gz tig-*.tar.gz.md5
89 spell-check:
90 aspell --lang=en --check tig.1.txt tigrc.5.txt manual.txt
92 strip: all
93 strip $(PROGS)
95 dist: tig.spec
96 @mkdir -p $(TARNAME) && \
97 cp tig.spec $(TARNAME) && \
98 echo $(VERSION) > $(TARNAME)/VERSION
99 git archive --format=tar --prefix=$(TARNAME)/ HEAD | \
100 tar --delete $(TARNAME)/VERSION > $(TARNAME).tar && \
101 tar rf $(TARNAME).tar $(TARNAME)/tig.spec $(TARNAME)/VERSION && \
102 gzip -f -9 $(TARNAME).tar && \
103 md5sum $(TARNAME).tar.gz > $(TARNAME).tar.gz.md5
104 @rm -rf $(TARNAME)
106 rpm: dist
107 rpmbuild -ta $(TARNAME).tar.gz
109 configure: configure.ac
110 $(AUTOHEADER)
111 $(AUTOCONF)
113 # Maintainer stuff
114 release-doc:
115 git checkout release && \
116 git merge master && \
117 $(MAKE) clean doc-man doc-html && \
118 git add $(MANDOC) $(HTMLDOC) && \
119 git commit -m "Sync docs" && \
120 git checkout master
122 release-dist: release-doc
123 git checkout release && \
124 $(MAKE) dist && \
125 git checkout master
127 .PHONY: all all-debug doc doc-man doc-html install install-doc \
128 install-doc-man install-doc-html clean spell-check dist rpm
130 tig.spec: contrib/tig.spec.in
131 sed -e 's/@@VERSION@@/$(RPM_VERSION)/g' \
132 -e 's/@@RELEASE@@/$(RPM_RELEASE)/g' < $< > $@
134 tig: tig.c
136 manual.html: manual.toc
137 manual.toc: manual.txt
138 sed -n '/^\[\[/,/\(---\|~~~\)/p' < $< | while read line; do \
139 case "$$line" in \
140 "-----"*) echo ". <<$$ref>>"; ref= ;; \
141 "~~~~~"*) echo "- <<$$ref>>"; ref= ;; \
142 "[["*"]]") ref="$$line" ;; \
143 *) ref="$$ref, $$line" ;; \
144 esac; done | sed 's/\[\[\(.*\)\]\]/\1/' > $@
146 README.html: README
147 $(ASCIIDOC) -b xhtml11 -d article -a readme $<
149 %.pdf : %.xml
150 $(DOCBOOK2PDF) $<
152 %.1.html : %.1.txt
153 $(ASCIIDOC) -b xhtml11 -d manpage $<
155 %.1.xml : %.1.txt
156 $(ASCIIDOC) -b docbook -d manpage -aversion=$(VERSION) $<
158 %.1 : %.1.xml
159 $(XMLTO) -m manpage.xsl man $<
161 %.5.html : %.5.txt
162 $(ASCIIDOC) -b xhtml11 -d manpage $<
164 %.5.xml : %.5.txt
165 $(ASCIIDOC) -b docbook -d manpage -aversion=$(VERSION) $<
167 %.5 : %.5.xml
168 $(XMLTO) -m manpage.xsl man $<
170 %.html : %.txt
171 $(ASCIIDOC) -b xhtml11 -d article -n $<
173 %.xml : %.txt
174 $(ASCIIDOC) -b docbook -d article $<
176 %.html-chunked : %.xml
177 $(XMLTO) html -o $@ $<