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

View File

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