#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-# #> content.makefile # #> Build #> #> This Makefile handles creating, building, and publishing posts for a Gemini #> site. #> # The key challenge here is creating the index files. # 1. Create a file with index entries # 2. Extract a list of tags to file # 3. # # © 2023 Andrew Stryker #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-# #-----------------------------------------------------------------------------# # # Configuration # #-----------------------------------------------------------------------------# # Record the name of this Makefile self ::= $(lastword ${MAKEFILE_LIST}) # Load environment variables if needed--not the case when this is called from # the main Makefile ifndef ENV_LOADED # Assume the base directory is two levels up if not defined MAKO_DIR ?= ../.. include ${MAKO_DIR}/environment.mk 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}) gemtext ::= $(wildcard *.gmi) gemtext_copied ::= $(addprefix ${staging_dir}/,${gemtext}) all ::= $(notdir $(filter-out _%,%.m4,%~,.%,$(wildcard *))) #-----------------------------------------------------------------------------# # # User interface # #> This makefile supports the following targets: #> #-----------------------------------------------------------------------------# .PHONY: default build clean show help create # Define the default target explicitly default: create create: #> Create a new post (default) @if [ -z $${EDITOR} ]; then \ python3 create-post.py; \ else \ python3 create-post.py --edit; \ fi build: ${gemtext_copied} ${templates_expanded} @echo "✓ Completed processing ${content_section}" @echo show: #> Show enironment variables with values @echo "Key variables defined in ${self}:" @echo @echo "Makefile list: ${MAKEFILE_LIST}" @echo @echo "Content section............................... ${content_section}" @echo "Staging space................................. ${staging_dir}" @echo @echo "Templates found:" @for x in ${templates}; do echo "\t$$x"; done @echo @echo "Gemtext files found:" @for x in ${gemtext}; do echo "\t\t$$x"; done @echo clean: #> Delete generated files @rm -rf ${staging_dir} @echo "✓ Deleted ${staging_dir} and everything in it" help: #> Display this help message @awk -f ${AWKHELP} ${self} #-----------------------------------------------------------------------------# # # File system interface # #-----------------------------------------------------------------------------# ${staging_dir}: @mkdir -p $@ @echo "\t✓ Created staging space: $@" ${templates_expanded}: ${staging_dir}/%: %.m4 ${staging_dir} ${FENCE} ${all} @m4 --include=${MAKO_DIR} $< > $@ @echo "\t✓ Generated $@" ${gemtext_copied}: ${staging_dir}/%: % ${staging_dir} @cat $< > $@ @echo "\t✓ Copied $@" #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#