From 693c51bbe1c09ecb7b210beaccbdd9f4ee35f907 Mon Sep 17 00:00:00 2001 From: Andrew Stryker Date: Wed, 20 Sep 2023 08:45:11 -0700 Subject: [PATCH] Define section variables as recursive --- curate.mk | 23 ++++++++++------------- environment.mk | 12 ++++++++++++ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/curate.mk b/curate.mk index b96ca8b..14f8e0d 100644 --- a/curate.mk +++ b/curate.mk @@ -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 $@" diff --git a/environment.mk b/environment.mk index 45e3cab..b79a384 100644 --- a/environment.mk +++ b/environment.mk @@ -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