From f4b651e9d5e7714a87e6885b09d0a4eda43d4cb8 Mon Sep 17 00:00:00 2001 From: Joan Josep Ordinas Rosa Date: Mon, 3 Apr 2017 20:16:02 +0200 Subject: [PATCH] Makefile subdivided in fragments --- .gitignore | 2 + docs/Makefile | 67 +++++++------------------------- docs/make.d/config.make | 82 +++++++++++++++++++++++++++++++++++++++ docs/make.d/metadata.make | 34 ++++++++++++++++ 4 files changed, 131 insertions(+), 54 deletions(-) create mode 100644 docs/make.d/config.make create mode 100644 docs/make.d/metadata.make diff --git a/.gitignore b/.gitignore index c70d694..bbd95c5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ # cache /docs/.yummy +# built site +/docs/_site # man pages jqt.1.gz # other diff --git a/docs/Makefile b/docs/Makefile index d642567..3d40637 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,49 +1,6 @@ # jqt documentation management -######################################################################## -# Prerequisites -######################################################################## - -# We are using some of the newest GNU Make features... so require GNU -# Make version >= 3.82 -version_test := $(filter 3.82,$(firstword $(sort $(MAKE_VERSION) 3.82))) -ifndef version_test -$(error GNU Make version $(MAKE_VERSION); version >= 3.82 is needed) -endif - -######################################################################## -# Configuration -######################################################################## - -# Disable builtins. -MAKEFLAGS += --no-builtin-rules -MAKEFLAGS += --no-builtin-variables - -# Warn when an undefined variable is referenced. -MAKEFLAGS += --warn-undefined-variables - -# Make will not print the recipe used to remake files. -.SILENT: - -# Eliminate use of the built-in implicit rules. Also clear out the -# default list of suffixes for suffix rules. -.SUFFIXES: - -# Sets the default goal to be used if no targets were specified on the -# command line. -.PHONY: all -.DEFAULT_GOAL := all - -# 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. -.SHELLFLAGS := -o errexit -o pipefail -o nounset -c - -# Make will delete the target of a rule if it has changed and its recipe -# exits with a nonzero exit status. -.DELETE_ON_ERROR: +include make.d/config.make ######################################################################## # Variables @@ -147,23 +104,23 @@ $(Destination)/styles.css: \ all: $(Targets) cp_assets # Directories -$(Metadata) \ $(Destination): + $(info ==> $@) mkdir $@ >/dev/null 2>&1 || true -# Metadata files -$(Metadata)/config.json: config.yaml \ -| $(Metadata) - yaml2json <$< >$@ +# Assets +cp_assets: | $(Destination) + cp --verbose --recursive --update $(Assets)/* $(Destination) + +# META !!!!!!!! +include make.d/metadata.make +# Snippets $(Metadata)/snippets.json: $(Content)/snippets.yaml \ | $(Metadata) + $(info ==> $@) jqt -T <$< | yaml2json > $@ -# Assets -cp_assets: | $(Destination) - cp --verbose --recursive --update $(Assets)/* $(Destination) - # HTML pages define Target $(Destination)/$(1).html: $(Content)/$(1).md $(Layouts)/$(2).html \ @@ -189,6 +146,7 @@ $(ManPage): $(Content)/jqt.1.markdown # Help text /tmp/help: $(Content)/help.markdown + $(info ==> $@) jqt -P MarkDown -I$(Content) <$< \ | pandoc --from markdown --to plain - \ | sed '1,7b;/^$$/d;s/_\([A-Z]\+\)_/\1/g;/^[^A-Z]/s/^/ /' \ @@ -219,12 +177,13 @@ help: | sed 's/:\+$$//' \ | pr --omit-pagination --indent=4 --width=80 --columns=4 -# Validation with vnu.jar +# Validation using vnu.jar VNU := /usr/local/vnu/vnu.jar valid: all xmlwf $(Destination)/*.html java -jar $(VNU) --errors-only --format gnu $(Destination)/*.html +# Validation with warnings using vnu.jar lint: all xmlwf $(Destination)/*.html java -jar $(VNU) --format text $(Destination)/*.html diff --git a/docs/make.d/config.make b/docs/make.d/config.make new file mode 100644 index 0000000..22adcba --- /dev/null +++ b/docs/make.d/config.make @@ -0,0 +1,82 @@ +######################################################################## +# Prerequisites +######################################################################## + +# We are using some of the newest GNU Make features... so require GNU +# Make version >= 3.82 +version_test := $(filter 3.82,$(firstword $(sort $(MAKE_VERSION) 3.82))) +ifndef version_test +$(error GNU Make version $(MAKE_VERSION); version >= 3.82 is needed) +endif + +#!# Only one target at the same time +#!MAKECMDGOALS ?= all +#!ifneq (1,$(words $(MAKECMDGOALS))) +#!$(error Only one target accepted!) +#!endif + +# Check 'root' intentions +ifeq (,$(filter install uninstall,$(MAKECMDGOALS))) +ifeq (0,$(shell id --user)) +$(error Root only can make "(un)install" targets) +endif +endif + +######################################################################## +# Configuration +######################################################################## + +# Disable builtins. +MAKEFLAGS += --no-builtin-rules +MAKEFLAGS += --no-builtin-variables + +# Warn when an undefined variable is referenced. +MAKEFLAGS += --warn-undefined-variables + +# Make will not print the recipe used to remake files. +.SILENT: + +# Eliminate use of the built-in implicit rules. Also clear out the +# default list of suffixes for suffix rules. +.SUFFIXES: + +# Sets the default goal to be used if no targets were specified on the +# command line. +.PHONY: all +.DEFAULT_GOAL := all + +# 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. +.SHELLFLAGS := -o errexit -o pipefail -o nounset -c + +# Make will delete the target of a rule if it has changed and its recipe +# exits with a nonzero exit status. +.DELETE_ON_ERROR: + +#!# Enable a second expansion of the prerequisites +#!.SECONDEXPANSION: + +######################################################################## +# Common macros +######################################################################## + +# Hacks for string manipulation +comma := , +empty := +space := $(empty) $(empty) + +# Hack for list manipulation +rest = $(wordlist 2,2147483648,$1) + +#!# Make a directory if it no exists +#!define mkdir +#! if test ! -d $1; then \ +#! echo 1>&2 '==> $1'; \ +#! mkdir --parents $1; \ +#! fi +#!endef + +# vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make diff --git a/docs/make.d/metadata.make b/docs/make.d/metadata.make new file mode 100644 index 0000000..fc49074 --- /dev/null +++ b/docs/make.d/metadata.make @@ -0,0 +1,34 @@ +######################################################################## +# Metadata +######################################################################## + +# Imported variables: +# Metadata + +# Metadata directory +$(Metadata): + $(info ==> $@) + mkdir $@ >/dev/null 2>&1 || true + +# Main configuration file +ifeq (config.yaml, $(wildcard config.yaml)) + +# Convert config.yaml to $(Metadata)/config.json +$(Metadata)/config.json: config.yaml \ +| $(Metadata) + $(info ==> $@) + yaml2json <$< >$@ + +else ifeq (config.json, $(wildcard config.json)) + +# Convert config.json to $(Metadata)/config.json +$(Metadata)/config.json: config.json \ +| $(Metadata) + $(info ==> $@) + cp $< $@ + +else +$(error Configuration file not found) +endif + +# vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make