Skip to content

Commit

Permalink
More modules at make.d
Browse files Browse the repository at this point in the history
  • Loading branch information
fadado committed Apr 7, 2017
1 parent 74af276 commit 89a5dff
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 62 deletions.
39 changes: 12 additions & 27 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,12 @@ endif # __globals__
ifdef __globals__

# Default target
all: static $(Targets)
@echo 1>&2 'Imprimatur.'

all: $(Targets)
# Copy assets
static: | $(Destination)
@cp --verbose --recursive --update $(Assets)/* $(Destination) \
| sed "s/^.*-> ./==> /;s/.$$//"
# All done
@echo 1>&2 'Imprimatur.'

# Snippets
$(Metadata)/snippets.json: $(Content)/snippets.yaml \
Expand Down Expand Up @@ -217,18 +216,7 @@ endif # __globals__
# Utilities
########################################################################

.PHONY: clean clobber build help

# Show targets
help:
@echo 'Usage: make TARGET [parameter=value...]'
@echo 'Targets:'; \
$(MAKE) --print-data-base --just-print 2>&1 \
| grep -v '^[mM]akefile' \
| awk '/^[^ \t.%][-A-Za-z0-9_]*:/ { print $$1 }' \
| sort --unique \
| sed 's/:\+$$//' \
| pr --omit-pagination --indent=4 --width=80 --columns=4
.PHONY: clean clobber build

ifndef __globals__

Expand All @@ -244,19 +232,16 @@ clobber:

build: clean all

.PHONY: valid lint
endif # __globals__

# Validation using vnu.jar
VNU := /usr/local/vnu/vnu.jar
valid: all
@xmlwf $(Destination)/*.html
@java -jar $(VNU) --errors-only --format gnu $(Destination)/*.html
########################################################################
# External utilities
########################################################################

# Validation with warnings using vnu.jar
lint: all
@xmlwf $(Destination)/*.html
@java -jar $(VNU) --format text $(Destination)/*.html
# help and other targets
include make.d/tools.make

endif # __globals__
# HTML 5 validation
include make.d/vnu.make

# vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make
22 changes: 16 additions & 6 deletions docs/make.d/config.make
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
########################################################################
# Prerequisites
# Configuration
########################################################################

# Exported macros:
# comma
# empty
# space
# rest

#
# 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)))
Expand Down Expand Up @@ -29,9 +39,9 @@ $(error Target "clobber" must be alone)
endif
endif

########################################################################
# Configuration
########################################################################
#
# Parameters
#

# Disable builtins.
MAKEFLAGS += --no-builtin-rules
Expand Down Expand Up @@ -66,9 +76,9 @@ SHELL := /bin/bash
# Enable a second expansion of the prerequisites
.SECONDEXPANSION:

########################################################################
#
# Common macros
########################################################################
#

# Hacks for string manipulation
comma := ,
Expand Down
20 changes: 11 additions & 9 deletions docs/make.d/introspect.make
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# PagesJSON
# Nodes
# NodesJSON
# Targets for:
# Exported targets:
# $(Destination)
# all paths at $(Destination) and $(Metadata)

Expand All @@ -37,22 +37,24 @@ i_paths_meta_pages := $(patsubst $(Content)%,$(Metadata)/pages%,$(i_paths))

$(Destination):
$(info ==> $@)
@mkdir -p $@ >/dev/null 2>&1 || true
@mkdir --parents $@ >/dev/null 2>&1 || true

# TODO: static rules??? Targets are directories...???
$(i_paths_destination): #? $(Destination)/% : $(Content)/%
@mkdir -p $@ >/dev/null 2>&1 || true
$(i_paths_destination): ## $(Destination)/% : $(Content)/%
@mkdir --parents $@ >/dev/null 2>&1 || true

$(i_paths_meta_pages): #? $(Metadata)/pages/% : $(Content)/%
@mkdir -p $@ >/dev/null 2>&1 || true
$(i_paths_meta_pages): ## $(Metadata)/pages/% : $(Content)/%
@mkdir --parents $@ >/dev/null 2>&1 || true

$(i_paths_meta_nodes): #? $(Metadata)/nodes/% : $(Content)/%
@mkdir -p $@ >/dev/null 2>&1 || true
$(i_paths_meta_nodes): ## $(Metadata)/nodes/% : $(Content)/%
@mkdir --parents $@ >/dev/null 2>&1 || true

#
# Global names defined
#

# All pathnames to create
#? Paths := $(i_paths_destination) $(i_paths_meta_pages) $(i_paths_meta_nodes)

# Home page
HomePage := $(Destination)/index.html

Expand Down
60 changes: 40 additions & 20 deletions docs/make.d/metadata.make
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
# Imported variables:
# Metadata
# Version
# Targets for:
# Exported targets:
# $(Metadata)
# $(Metadata)/config.json ==>
# $(Metadata)/site.json ==>
# $(Metadata)/config.json
# $(Metadata)/site.json
# $(Metadata)/globals.make
# Dependencies:
# $(Metadata)/pages/**.json
# Order of dependencies:
# globals.make => site.json => config.json => config.yaml

# Metadata directory
$(Metadata):
$(info ==> $@)
@mkdir -p $@ >/dev/null 2>&1 || true
@mkdir --parents $@ >/dev/null 2>&1 || true

#
# config.json, site.json and globals.make
# Configuration
#

# Create $(Metadata)/config.json
Expand Down Expand Up @@ -79,26 +80,45 @@ endef
# Create globals.make
$(Metadata)/globals.make: $(Metadata)/site.json
$(info ==> $@)
@jq --raw-output \
'$(m_MAKE_GLOBALS)' \
< $< > $@
@jq --raw-output '$(m_MAKE_GLOBALS)' < $< > $@

ifdef __globals__

#md_page_id = $(subst $(MetaDB)/pages/,,$(basename $1))
#md_page_url = $(call md_page_id,$1).html
#md_page_name = $(basename $(notdir $1))
#md_page_path = $(dir $(call md_page_id,$1))
#md_page_section = $(patsubst %/,%,$(call md_page_path,$1))
#md_page_base = $(patsubst ../../%,%,$(subst $(space),,$(patsubst %,../,$(subst /, ,$1))))
#
# TODO: in this file???
# Metadata files built with globals defined
## . is a MarkDown file front matter
#define md_entry_page
# . + { \
# "id": "$(call md_page_id,$1)", \
# "base": "$(call md_page_base,$1)", \
# "filename": "$(call md_page_name,$1)", \
# "path": "$(call md_page_path,$1)", \
# "url": "$(call md_page_url,$1)", \
# "section": "$(call md_page_section,$1)", \
# "isnode": false, \
# "ispage": true \
# } as $$page | \
# $$config[0].defaults as $$defaults | \
# reduce $$defaults[] as $$d \
# ({}; if ("$(call md_page_id,$1)" | test("^" + $$d.idprefix)) \
# then . + $$d.properties \
# else . end) + $$page
#endef

#$(Metadata)/pages/%.json: $(Content)/%.md $(Metadata)config.json | $$(dir $$@) \
# $(info ==> $@)
# sed -n -e '1d;/^---$$/q;/^\.\.\.$$/q;/^\#/d;p' < $< \
# | yaml2json \
# | jq --sort-keys \
# --slurpfile config $(MetaDB)/config.json \
# '$(call md_entry_page,$@)' >$@
#

#########################################################################
# Build all metadata files (utility not called automatically)
.PHONY: metadata
metadata: \
$(Metadata)/globals.make \
$(Metadata)/config.json \
$(Metadata)/site.json
@:

endif # __globals__

# vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make
18 changes: 18 additions & 0 deletions docs/make.d/tools.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Miscelaneous tools

# Exported targets:
# help

# Show targets
.PHONY: help
help:
@echo 'Usage: make TARGET [parameter=value...]'
@echo 'Targets:'; \
$(MAKE) --print-data-base --just-print 2>&1 \
| grep -v '^[mM]akefile' \
| awk '/^[^ \t.%][-A-Za-z0-9_]*:/ { print $$1 }' \
| sort --unique \
| sed 's/:\+$$//' \
| pr --omit-pagination --indent=4 --width=80 --columns=4

# vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make
27 changes: 27 additions & 0 deletions docs/make.d/vnu.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# HTML 5 validation

# Imported variables:
# Destination
# Exported targets:
# valid
# lint

ifdef __globals__

.PHONY: valid lint

VNU := /usr/local/vnu/vnu.jar

# Validation using 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

endif # __globals__

# vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make

0 comments on commit 89a5dff

Please sign in to comment.