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

View File

@ -66,6 +66,18 @@ 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
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 # Makefiles
CURATE_MAKE ::= ${MAKO_DIR}/curate.mk CURATE_MAKE ::= ${MAKO_DIR}/curate.mk
INDEX_MAKE ::= ${MAKO_DIR}/index.mk INDEX_MAKE ::= ${MAKO_DIR}/index.mk