From da637599b1d42a0deba8198ebf1a3d4b9ce15880 Mon Sep 17 00:00:00 2001 From: Joan Josep Ordinas Rosa Date: Mon, 5 Nov 2018 21:10:03 +0100 Subject: [PATCH] Moved rule for jqt.1.gz --- Makefile | 96 ++++++++++++++++++++++++++++++++++-------------- docs/Makefile | 11 +----- docs/config.make | 51 ++----------------------- 3 files changed, 73 insertions(+), 85 deletions(-) diff --git a/Makefile b/Makefile index 355f95e..3f637cb 100644 --- a/Makefile +++ b/Makefile @@ -61,18 +61,12 @@ MAKEFLAGS += --warn-undefined-variables # When it is time to consider phony targets, make will run its recipe # unconditionally, regardless of whether a file with that name exists or # what its last-modification time is. -.PHONY: all - -# When a target is built all lines of the recipe will be given to a -# single invocation of the shell. -# !!!Does not work in make <= 3.82 event it is documented!!! -#.ONESHELL: +.PHONY: all clean # Default shell: if we require GNU Make, why not require Bash? SHELL := /bin/bash -# The argument(s) passed to the shell are taken from the variable -# .SHELLFLAGS. +# Argument(s) passed to the shell. .SHELLFLAGS := -o errexit -o pipefail -o nounset -c # Make will delete the target of a rule if it has changed and its recipe @@ -80,10 +74,25 @@ SHELL := /bin/bash .DELETE_ON_ERROR: ######################################################################## -# Rules +# Targets and variables +######################################################################## + +# The only "productive" target... +ManPage := jqt.1.gz + +# Dependencies from documentations files +DOCS := docs +CONTENT := $(DOCS)/content + +######################################################################## +# Install `jqt` dependencies. +# +# Warning: only with `dnf`! +# Modify this rule as a template to your own script. ######################################################################## -# Warning: only `dnf`! Use this rule as template to your own script. +.PHONY: setup + setup: @rpm -q --quiet general-purpose-preprocessor || sudo dnf -y install general-purpose-preprocessor @test -e /usr/bin/jq || test -e /usr/local/bin/jq || sudo dnf -y install jq @@ -91,39 +100,34 @@ setup: @rpm -q --quiet python2-pyyaml || sudo dnf -y install python2-pyyaml @echo Done! -# Default target -all: check - ######################################################################## -# Utilities +# Install scripts and data ######################################################################## -.PHONY: clean clobber install uninstall - -clean:: - rm -f tests/*/generated/* jqt.1.gz - -clobber: clean +.PHONY: install uninstall -install: - [[ -e jqt.1.gz ]] || { cd docs && make ../jqt.1.gz; } +install: all test -d $(bindir) || mkdir --verbose --parents $(bindir) test -d $(datadir)/$(PROJECT) || mkdir --verbose --parents $(datadir)/$(PROJECT) test -d $(mandir)/man1 || mkdir --verbose --parents $(mandir)/man1 install --verbose --compare --mode 555 bin/* $(bindir) install --verbose --compare --mode 644 share/* $(datadir)/$(PROJECT) - install --verbose --compare --mode 644 jqt.1.gz $(mandir)/man1 + install --verbose --compare --mode 644 $(ManPage) $(mandir)/man1 sed -i -e "s#DATADIR='.*'#DATADIR='$(datadir)'#" $(bindir)/jqt uninstall: rm --verbose --force -- $(addprefix $(prefix)/,$(wildcard bin/*)) - rm --verbose --force -- $(mandir)/man1/jqt.1.gz + rm --verbose --force -- $(mandir)/man1/$(ManPage) test -d $(datadir)/$(PROJECT) \ && rm --verbose --force --recursive $(datadir)/$(PROJECT) \ || true +######################################################################## # Show targets +######################################################################## + .PHONY: help + help: echo 'Usage: make TARGET [parameter=value...]' echo 'Targets:'; \ @@ -145,27 +149,61 @@ help: # Independent target: helps generating text for `jqt -h` # Needs explicit call: `make /tmp/help` -/tmp/help: docs/content/help.text +/tmp/help: $(CONTENT)/help.text $(info ==> $@) - jqt -P MarkDown -Idocs < $< \ + jqt -P MarkDown -I$(DOCS) < $< \ | pandoc --from markdown --to plain - \ | sed '1,7b;/^$$/d;s/_\([A-Z]\+\)_/\1/g;/^[^A-Z]/s/^/ /' \ > $@ -clean:: - @rm -f /tmp/help +clean:: ; @rm -f /tmp/help + +######################################################################## +# Generate man page for jqt +######################################################################## + +# gpp for the man page (to be build without calling jqt!) +GPP_MD := gpp \ + -U '<%' '>' '\B' '\B' '\W>' '<' '>' '$$' '' \ + -M '<%' '>' '\B' '\B' '\W>' '<' '>' \ + +sccc '&\n' '' '' \ + +sccc '\\n' '' '' \ + +sccc '<\#' '\#>\n' '' \ + +siqi "'" "'" '\' \ + +siQi '"' '"' '\' \ + +ssss '' '' \ + +ssss '`' '`' '' \ + +ssss '\n```' '\n```' '' \ + +ssss '\n~~~' '\n~~~' '' \ + +# Man page: jqt(1) +$(ManPage): $(CONTENT)/jqt.1.text + $(info ==> $@) + @$(GPP_MD) -I$(DOCS) < $< \ + | pandoc --standalone --from markdown --to man \ + | gzip > $@ + +# Default target +all: $(ManPage) + +# Add prerequisites and recipes to common targets +clean:: ; @rm -f $(ManPage) ######################################################################## # Tests ######################################################################## .PHONY: check + check: test-jqt test-expand test-format +clean:: ; rm -f tests/*/generated/* + # # Test JQT # .PHONY: test-jqt test-cond test-expr test-loop test-macros test-syntax + test-jqt: test-cond test-expr test-loop test-macros test-syntax define TestJQT @@ -194,6 +232,7 @@ $(eval $(call TestJQT,syntax)) # Test macro expansion # .PHONY: test-expand test-mpjqt test-mpmd test-mpjson test-mpcss + test-expand: test-mpjqt test-mpmd test-mpjson test-mpcss define TestMacroExpand @@ -217,6 +256,7 @@ $(eval $(call TestMacroExpand,css,mpcss)) # Test file format conversions # .PHONY: test-format test-csv test-yaml + test-format: test-csv test-yaml define TestFileFormat diff --git a/docs/Makefile b/docs/Makefile index 5f2811c..4ad3d7a 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -128,15 +128,8 @@ include make.d/tools.make include config.make # # Project specific makefile. All the previous modules are expected to be -# independent, valid for any project without any change. -# -# Defined rules for: -# $(ManPage) -# /tmp/help -# Defined targets: -# all -# clean -# clobber +# independent, valid for any project without any change. This file must +# exist but can be empty. ######################################################################## endif # __phase_3 diff --git a/docs/config.make b/docs/config.make index 4998a42..19843a5 100644 --- a/docs/config.make +++ b/docs/config.make @@ -1,21 +1,13 @@ ######################################################################## # # Specific makefile for this web site. -# This should be the only file to edit by hand! +# This should be the only makefile to edit by hand! # # Variables imported: -# Content # Metadata -# JQTFLAGS -# -# Define new rules for: -# $(ManPage) -# /tmp/help # -# Add double-colon recipes for targets: -# all -# clean -# clobber +# Variables modified: +# JQTFLAGS ######################################################################## # Build pages options @@ -30,41 +22,4 @@ JQTFLAGS += -5 --toc-depth=4 # Extra dependencies #?$(DestinationPages): $(Blocks)/filters.jq $(Blocks)/*/*.html $(Blocks)/*/*/*.html -######################################################################## -# Generate man page for jqt -######################################################################## - -# gpp for the man page (to be build without calling jqt!) -GPP_MD := gpp \ - -U '<%' '>' '\B' '\B' '\W>' '<' '>' '$$' '' \ - -M '<%' '>' '\B' '\B' '\W>' '<' '>' \ - +sccc '&\n' '' '' \ - +sccc '\\n' '' '' \ - +sccc '<\#' '\#>\n' '' \ - +siqi "'" "'" '\' \ - +siQi '"' '"' '\' \ - +ssss '' '' \ - +ssss '`' '`' '' \ - +ssss '\n```' '\n```' '' \ - +ssss '\n~~~' '\n~~~' '' \ - -# -ManPage := ../jqt.1.gz - -# Man page: jqt(1) -$(ManPage): $(Content)/jqt.1.text - $(info ==> $@) - @$(GPP_MD) -I$(Content) < $< \ - | pandoc --standalone --from markdown --to man \ - | gzip > $@ - -# Add prerequisites and recipes to common targets -all:: $(ManPage) - -clean:: - @rm -f $(ManPage) - -clobber:: - @rm -f $(ManPage) - # vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make