Skip to content

Commit

Permalink
Make files reorganized
Browse files Browse the repository at this point in the history
  • Loading branch information
fadado committed Apr 4, 2017
1 parent f4b651e commit 5072abd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 30 deletions.
39 changes: 20 additions & 19 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ include make.d/config.make
# Variables
########################################################################

# Output directories
# Metadata directory
Metadata := .yummy

# Output directory
Destination := /tmp/jqt
Metadata := .yummy

# Input files directories
Assets := ./assets
Expand All @@ -24,7 +26,7 @@ Other := content data engine structure
Static := styles.css

# Target filenames
ManPage := ../jqt.1.gz
ManPage := ../jqt.1.gz
HomePage := $(Destination)/$(Home).html
OtherPages := $(foreach p,$(Other),$(Destination)/$(p).html)
Files := $(foreach f,$(Static),$(Destination)/$(f))
Expand Down Expand Up @@ -103,23 +105,23 @@ $(Destination)/styles.css: \

all: $(Targets) cp_assets

# Directories
# Destination directory
$(Destination):
$(info ==> $@)
mkdir $@ >/dev/null 2>&1 || true

# Assets
# Copy assets
cp_assets: | $(Destination)
cp --verbose --recursive --update $(Assets)/* $(Destination)

# META !!!!!!!!
# Include metadata
include make.d/metadata.make

# Snippets
$(Metadata)/snippets.json: $(Content)/snippets.yaml \
| $(Metadata)
$(info ==> $@)
jqt -T <$< | yaml2json > $@
jqt -T < $< | yaml2json > $@

# HTML pages
define Target
Expand All @@ -135,28 +137,20 @@ $(foreach p,$(Other),$(eval $(call Target,$(p),page-toc)))
# CSS stylesheet
$(Destination)/styles.css: $(Styles)/page.css
$(info ==> $@)
jqt -P CSS-min -I$(Styles) <$< >$@
jqt -P CSS-min -I$(Styles) < $< > $@

# Man page: jqt(1)
$(ManPage): $(Content)/jqt.1.markdown
$(info ==> $@)
$(GPP_MD) -I$(Content) <$< \
$(GPP_MD) -I$(Content) < $< \
| pandoc --standalone --from markdown --to man \
| gzip > $@

# 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/^/ /' \
> $@

########################################################################
# Utilities
########################################################################

.PHONY: clean clobber build
.PHONY: clean clobber build help valid lint

clean:
rm -rf $(Destination)/* $(ManPage)
Expand All @@ -167,7 +161,6 @@ clobber: clean
build: clean all

# Show targets
.PHONY: help
help:
echo 'Targets:'; \
$(MAKE) --print-data-base --just-print 2>&1 \
Expand All @@ -188,4 +181,12 @@ lint: all
xmlwf $(Destination)/*.html
java -jar $(VNU) --format text $(Destination)/*.html

# Generate Help text (need explicit call: `make /tmp/help`)
/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/^/ /' \
> $@

# vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make
11 changes: 3 additions & 8 deletions docs/make.d/config.make
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ ifeq (,$(filter install uninstall,$(MAKECMDGOALS)))
ifeq (0,$(shell id --user))
$(error Root only can make "(un)install" targets)
endif
SUDO :=
else
SUDO := sudo
endif

########################################################################
Expand Down Expand Up @@ -71,12 +74,4 @@ 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
7 changes: 4 additions & 3 deletions docs/make.d/metadata.make
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@ $(Metadata):
$(info ==> $@)
mkdir $@ >/dev/null 2>&1 || true

# Main configuration file
# Main configuration file.
# Must be named config.yaml or config.json and must exist.
ifeq (config.yaml, $(wildcard config.yaml))

# Convert config.yaml to $(Metadata)/config.json
$(Metadata)/config.json: config.yaml \
| $(Metadata)
$(info ==> $@)
yaml2json <$< >$@
yaml2json < $< > $@

else ifeq (config.json, $(wildcard config.json))

# Convert config.json to $(Metadata)/config.json
$(Metadata)/config.json: config.json \
| $(Metadata)
$(info ==> $@)
cp $< $@
jqt -Pjson < $< > $@

else
$(error Configuration file not found)
Expand Down

0 comments on commit 5072abd

Please sign in to comment.