X-Git-Url: https://git.distorted.org.uk/~mdw/tig/blobdiff_plain/af32b365896b91225abc97a0cef8263a2e8ff9fa..abc10a73a9d05a8d3c697e83fc4c71f39f4c2e80:/Makefile diff --git a/Makefile b/Makefile index 446fc3e..575c5bf 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,16 @@ ## Makefile for tig +all: + # Include setting from the configure script -include config.make prefix ?= $(HOME) bindir ?= $(prefix)/bin -mandir ?= $(prefix)/man datarootdir ?= $(prefix)/share +sysconfdir ?= $(prefix)/etc docdir ?= $(datarootdir)/doc +mandir ?= $(datarootdir)/man # DESTDIR= # Get version either via git or from VERSION file. Allow either @@ -36,13 +39,21 @@ 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 + +# Never include the release number in the tarname for tagged +# versions. +ifneq ($(if $(DIST_VERSION),$(words $(RPM_VERLIST))),2) TARNAME = tig-$(RPM_VERSION)-$(RPM_RELEASE) +else +TARNAME = tig-$(RPM_VERSION) +endif -override CFLAGS += '-DVERSION="$(VERSION)"' +override CPPFLAGS += '-DTIG_VERSION="$(VERSION)"' +override CPPFLAGS += '-DSYSCONFDIR="$(sysconfdir)"' -AUTOHEADER ?= autoheader -AUTOCONF ?= autoconf +AUTORECONF ?= autoreconf ASCIIDOC ?= asciidoc +ASCIIDOC_FLAGS = -aversion=$(VERSION) -asysconfdir=$(sysconfdir) XMLTO ?= xmlto DOCBOOK2PDF ?= docbook2pdf @@ -56,64 +67,70 @@ doc-html: $(HTMLDOC) install: all mkdir -p $(DESTDIR)$(bindir) && \ for prog in $(PROGS); do \ - install -p -m 0755 $$prog $(DESTDIR)$(bindir); \ + install -p -m 0755 "$$prog" "$(DESTDIR)$(bindir)"; \ done install-doc-man: doc-man mkdir -p $(DESTDIR)$(mandir)/man1 \ $(DESTDIR)$(mandir)/man5 for doc in $(MANDOC); do \ + sed 's#++SYSCONFDIR++#$(sysconfdir)#' < "$$doc" > "$$doc+"; \ case "$$doc" in \ - *.1) install -p -m 0644 $$doc $(DESTDIR)$(mandir)/man1 ;; \ - *.5) install -p -m 0644 $$doc $(DESTDIR)$(mandir)/man5 ;; \ - esac \ + *.1) install -p -m 0644 "$$doc+" "$(DESTDIR)$(mandir)/man1/$$doc" ;; \ + *.5) install -p -m 0644 "$$doc+" "$(DESTDIR)$(mandir)/man5/$$doc" ;; \ + esac; \ + $(RM) "$$doc+"; \ done install-doc-html: doc-html mkdir -p $(DESTDIR)$(docdir)/tig for doc in $(HTMLDOC); do \ + sed 's#++SYSCONFDIR++#$(sysconfdir)#' < "$$doc" > "$$doc+"; \ case "$$doc" in \ - *.html) install -p -m 0644 $$doc $(DESTDIR)$(docdir)/tig ;; \ - esac \ + *.html) install -p -m 0644 "$$doc+" "$(DESTDIR)$(docdir)/tig/$$doc" ;; \ + esac; \ + $(RM) "$$doc+"; \ done install-doc: install-doc-man install-doc-html clean: - rm -rf manual.html-chunked $(TARNAME) - rm -f $(PROGS) $(ALLDOC) core *.xml *.toc - rm -f *.spec tig-*.tar.gz tig-*.tar.gz.md5 + $(RM) -r $(TARNAME) *.spec tig-*.tar.gz tig-*.tar.gz.md5 + $(RM) $(PROGS) core *.o *.xml + +distclean: clean + $(RM) -r manual.html-chunked *.toc $(ALLDOC) + $(RM) -r autom4te.cache aclocal.m4 config.{h,log,make,status} config.h.in configure spell-check: aspell --lang=en --check tig.1.txt tigrc.5.txt manual.txt -strip: all +strip: $(PROGS) strip $(PROGS) -dist: tig.spec +dist: configure tig.spec @mkdir -p $(TARNAME) && \ - cp tig.spec $(TARNAME) && \ + cp tig.spec configure config.h.in aclocal.m4 $(TARNAME) && \ echo $(VERSION) > $(TARNAME)/VERSION git archive --format=tar --prefix=$(TARNAME)/ HEAD | \ tar --delete $(TARNAME)/VERSION > $(TARNAME).tar && \ - tar rf $(TARNAME).tar $(TARNAME)/tig.spec $(TARNAME)/VERSION && \ + tar rf $(TARNAME).tar `find $(TARNAME)/*` && \ gzip -f -9 $(TARNAME).tar && \ md5sum $(TARNAME).tar.gz > $(TARNAME).tar.gz.md5 - @rm -rf $(TARNAME) + @$(RM) -r $(TARNAME) rpm: dist rpmbuild -ta $(TARNAME).tar.gz -configure: configure.ac - $(AUTOHEADER) - $(AUTOCONF) +configure: configure.ac acinclude.m4 + $(AUTORECONF) -v # Maintainer stuff release-doc: git checkout release && \ git merge master && \ - $(MAKE) clean doc-man doc-html && \ - git add $(MANDOC) $(HTMLDOC) && \ + $(MAKE) distclean doc-man doc-html sysconfdir=++SYSCONFDIR++ && \ + git add -f $(MANDOC) $(HTMLDOC) && \ git commit -m "Sync docs" && \ git checkout master @@ -125,12 +142,13 @@ 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.o: tig.c +tig: tig.o + tig.spec: contrib/tig.spec.in sed -e 's/@@VERSION@@/$(RPM_VERSION)/g' \ -e 's/@@RELEASE@@/$(RPM_RELEASE)/g' < $< > $@ -tig: tig.c - manual.html: manual.toc manual.toc: manual.txt sed -n '/^\[\[/,/\(---\|~~~\)/p' < $< | while read line; do \ @@ -141,35 +159,32 @@ manual.toc: manual.txt *) ref="$$ref, $$line" ;; \ esac; done | sed 's/\[\[\(.*\)\]\]/\1/' > $@ -README.html: README - $(ASCIIDOC) -b xhtml11 -d article -a readme $< +README.html: README asciidoc.conf + $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article -a readme $< -%.pdf : %.xml - $(DOCBOOK2PDF) $< - -%.1.html : %.1.txt - $(ASCIIDOC) -b xhtml11 -d manpage $< - -%.1.xml : %.1.txt - $(ASCIIDOC) -b docbook -d manpage -aversion=$(VERSION) $< +%.1.html : %.1.txt asciidoc.conf + $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d manpage $< -%.1 : %.1.xml - $(XMLTO) -m manpage.xsl man $< +%.1.xml : %.1.txt asciidoc.conf + $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d manpage $< -%.5.html : %.5.txt - $(ASCIIDOC) -b xhtml11 -d manpage $< +%.5.html : %.5.txt asciidoc.conf + $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d manpage $< -%.5.xml : %.5.txt - $(ASCIIDOC) -b docbook -d manpage -aversion=$(VERSION) $< +%.5.xml : %.5.txt asciidoc.conf + $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d manpage $< -%.5 : %.5.xml - $(XMLTO) -m manpage.xsl man $< +%.html : %.txt asciidoc.conf + $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article -n $< -%.html : %.txt - $(ASCIIDOC) -b xhtml11 -d article -n $< +%.xml : %.txt asciidoc.conf + $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d article $< -%.xml : %.txt - $(ASCIIDOC) -b docbook -d article $< +% : %.xml + $(XMLTO) man $< %.html-chunked : %.xml $(XMLTO) html -o $@ $< + +%.pdf : %.xml + $(DOCBOOK2PDF) $<