Define section variables as recursive

This commit is contained in:
Andrew Stryker 2023-09-20 08:45:11 -07:00
parent 9daaace86c
commit 693c51bbe1
2 changed files with 22 additions and 13 deletions

View File

@ -34,16 +34,13 @@ ifndef ENV_LOADED
endif
# Use the current directory as the content section name
content_section ::= $(shell basename ${CURDIR})
staging_dir ::= ${STAGING}/${content_section}
# Gather file lists
templates ::= $(wildcard *.gmi.m4)
templates_expanded ::= $(addprefix ${staging_dir}/,${templates:.gmi.m4=.gmi})
templates_expanded ::= $(addprefix ${STG_SECTION}/, ${templates:.gmi.m4=.gmi})
gemtext ::= $(wildcard *.gmi)
gemtext_copied ::= $(addprefix ${staging_dir}/,${gemtext})
gemtext_copied ::= $(addprefix ${STG_SECTION}/, ${gemtext})
# Create list of potential dependencies of *.gmi.m4 templates
all ::= $(notdir $(filter-out %.gmi.m4 _% %~, $(wildcard *)))
@ -69,7 +66,7 @@ create: #> Create a new post (default)
fi
build: ${gemtext_copied} ${templates_expanded}
@echo "✓ Completed processing ${content_section}"
@echo "✓ Completed processing ${SECTION}"
@echo
@ -78,8 +75,8 @@ show: #> Show enironment variables with values
@echo
@echo "Makefile list: ${MAKEFILE_LIST}"
@echo
@echo "Content section .............................. ${content_section}"
@echo "Staging space ................................ ${staging_dir}"
@echo "Content section .............................. ${SECTION}"
@echo "Staging space ................................ ${STG_SECTION}"
@echo
@echo "Templates found:"
@for x in ${templates}; do echo "\t$$x"; done
@ -89,8 +86,8 @@ show: #> Show enironment variables with values
@echo
clean: #> Delete generated files
@rm -rf ${staging_dir}
@echo "✓ Deleted ${staging_dir} and everything in it"
@rm -rf ${STG_SECTION}
@echo "✓ Deleted ${STG_SECTION} and everything in it"
help: #> Display this help message
@awk -f ${AWKHELP} ${self}
@ -101,15 +98,15 @@ help: #> Display this help message
#
#-----------------------------------------------------------------------------#
${staging_dir}:
${STG_SECTION}:
@mkdir -p $@
@echo "\t✓ Created staging space: $@"
${templates_expanded}: ${staging_dir}/%: %.m4 ${staging_dir} ${FENCE} ${all}
${templates_expanded}: ${STG_SECTION}/%: %.m4 ${STG_SECTION} ${FENCE} ${all}
@m4 --include=${MAKO_DIR} $< > $@
@echo "\t✓ Generated $@"
${gemtext_copied}: ${staging_dir}/%: % ${staging_dir}
${gemtext_copied}: ${STG_SECTION}/%: % ${STG_SECTION}
@cat $< > $@
@echo "\t✓ Copied $@"

View File

@ -66,6 +66,18 @@ STAGING ?= ${MAKO_DIR}/staging
STAGING ::= $(strip ${STAGING})
export STAGING
# Place for section-specfic working and staging files as recurive variables
SECTION = $(shell basename ${CURDIR})
export SECTION
# Create shortcuts
STG_SECTION = ${STAGING}/${SECTION}
WRK_SECTION = ${WORKING}/${SECTION}
SECTION_DIRS = ${STG_SECTION} ${WRK_SECTION}
export STG_SECTION
export WRK_SECTION
export SECTION_DIRS
# Makefiles
CURATE_MAKE ::= ${MAKO_DIR}/curate.mk
INDEX_MAKE ::= ${MAKO_DIR}/index.mk