Code

Make tig.c depend on config.h when using configure
[tig.git] / Makefile
index d5d9695cc8cbee4608ad6222b7c54af1639bb6e1..0ff9e5d03fbba57470b1e8472bb74a536f737832 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,15 @@
-prefix = $(HOME)
-bindir = $(prefix)/bin
-mandir = $(prefix)/man
-docdir = $(prefix)/share/doc
+## Makefile for tig
+
+all:
+
+# Include setting from the configure script
+-include config.make
+
+prefix ?= $(HOME)
+bindir ?= $(prefix)/bin
+mandir ?= $(prefix)/man
+datarootdir ?= $(prefix)/share
+docdir ?= $(datarootdir)/doc
 # DESTDIR=
 
 # Get version either via git or from VERSION file. Allow either
@@ -17,19 +25,29 @@ ifdef DIST_VERSION
 VERSION = $(DIST_VERSION)
 endif
 
-RPM_VERSION = $(subst -,.,$(VERSION))
+# Split the version "TAG-OFFSET-gSHA1-DIRTY" into "TAG OFFSET"
+# and append 0 as a fallback offset for "exact" tagged versions.
+RPM_VERLIST = $(filter-out g% dirty,$(subst -, ,$(VERSION))) 0
+RPM_VERSION = $(word 1,$(RPM_VERLIST))
+RPM_RELEASE = $(word 2,$(RPM_VERLIST))$(if $(WTDIRTY),.dirty)
 
-LDLIBS = -lcurses
-CFLAGS = -Wall -O2
+LDLIBS ?= -lcurses
+CFLAGS ?= -Wall -O2
 DFLAGS = -g -DDEBUG -Werror
 PROGS  = tig
 MANDOC = tig.1 tigrc.5
 HTMLDOC = tig.1.html tigrc.5.html manual.html README.html
 ALLDOC = $(MANDOC) $(HTMLDOC) manual.html-chunked manual.pdf
-TARNAME        = tig-$(RPM_VERSION)
+TARNAME        = tig-$(RPM_VERSION)-$(RPM_RELEASE)
 
 override CFLAGS += '-DVERSION="$(VERSION)"'
 
+AUTOHEADER ?= autoheader
+AUTOCONF ?= autoconf
+ASCIIDOC ?= asciidoc
+XMLTO ?= xmlto
+DOCBOOK2PDF ?= docbook2pdf
+
 all: $(PROGS)
 all-debug: $(PROGS)
 all-debug: CFLAGS += $(DFLAGS)
@@ -88,6 +106,10 @@ dist: tig.spec
 rpm: dist
        rpmbuild -ta $(TARNAME).tar.gz
 
+configure: configure.ac
+       $(AUTOHEADER)
+       $(AUTOCONF)
+
 # Maintainer stuff
 release-doc:
        git checkout release && \
@@ -105,8 +127,9 @@ release-dist: release-doc
 .PHONY: all all-debug doc doc-man doc-html install install-doc \
        install-doc-man install-doc-html clean spell-check dist rpm
 
-tig.spec: tig.spec.in
-       sed -e 's/@@VERSION@@/$(RPM_VERSION)/g' < $< > $@
+tig.spec: contrib/tig.spec.in
+       sed -e 's/@@VERSION@@/$(RPM_VERSION)/g' \
+           -e 's/@@RELEASE@@/$(RPM_RELEASE)/g' < $< > $@
 
 tig: tig.c
 
@@ -121,34 +144,34 @@ manual.toc: manual.txt
                esac; done | sed 's/\[\[\(.*\)\]\]/\1/' > $@
 
 README.html: README
-       asciidoc -b xhtml11 -d article -a readme $<
+       $(ASCIIDOC) -b xhtml11 -d article -a readme $<
 
 %.pdf : %.xml
-       docbook2pdf $<
+       $(DOCBOOK2PDF) $<
 
 %.1.html : %.1.txt
-       asciidoc -b xhtml11 -d manpage $<
+       $(ASCIIDOC) -b xhtml11 -d manpage $<
 
 %.1.xml : %.1.txt
-       asciidoc -b docbook -d manpage -aversion=$(VERSION) $<
+       $(ASCIIDOC) -b docbook -d manpage -aversion=$(VERSION) $<
 
 %.1 : %.1.xml
-       xmlto -m manpage.xsl man $<
+       $(XMLTO) -m manpage.xsl man $<
 
 %.5.html : %.5.txt
-       asciidoc -b xhtml11 -d manpage $<
+       $(ASCIIDOC) -b xhtml11 -d manpage $<
 
 %.5.xml : %.5.txt
-       asciidoc -b docbook -d manpage -aversion=$(VERSION) $<
+       $(ASCIIDOC) -b docbook -d manpage -aversion=$(VERSION) $<
 
 %.5 : %.5.xml
-       xmlto -m manpage.xsl man $<
+       $(XMLTO) -m manpage.xsl man $<
 
 %.html : %.txt
-       asciidoc -b xhtml11 -d article -n $<
+       $(ASCIIDOC) -b xhtml11 -d article -n $<
 
 %.xml : %.txt
-       asciidoc -b docbook -d article $<
+       $(ASCIIDOC) -b docbook -d article $<
 
 %.html-chunked : %.xml
-       xmlto html -o $@ $<
+       $(XMLTO) html -o $@ $<