Get the section definition macro working

This commit is contained in:
Andrew Stryker 2023-09-20 21:20:00 -07:00
parent 93c4257149
commit 1dfeffeb0f
2 changed files with 28 additions and 21 deletions

View File

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

View File

@ -66,16 +66,20 @@ 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
# Define a macro that creates the section-specific directory variables
#
# NOTE: Make expand variables when they are exported, meaning that will not
# assume the values appropriate for the current section. This approach defines
# a macro that we can call when we recurse into each section
#
# TODO: not call to the shell repeatedly
define SECTION_DIRS
section = $$(shell basename $${CURDIR})
#working_section ::= ${WORKING}/$${section}
#staging_section = ${STAGING}/$$(value section)
working_section = ${WORKING}/$$(shell basename $${CURDIR})
staging_section ::= ${STAGING}/$$(shell basename $${CURDIR})
endef
export SECTION_DIRS
# Makefiles
@ -113,7 +117,7 @@ show: #> Show key variables
@echo "\tBase/root directory of the build system..... ${MAKO_DIR}"
@echo "\tUsef-defined configuration.................. ${SITE_ENV}"
@echo
# future location for templates
@# TODO: future location for templates
@echo "\tLocation of user content.................... ${CONTENT}"
@echo "\tWorking area for intermediate files......... ${WORKING}"
@echo "\tStaging area for site....................... ${STAGING}"