126 lines
3.2 KiB
Makefile
126 lines
3.2 KiB
Makefile
|
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
|
||
|
#> environment.mk
|
||
|
#>
|
||
|
#> Define global environment variables
|
||
|
#>
|
||
|
#> This file is typically included from the main Makefile rather called
|
||
|
#> directly. Its purpose is to keep the responsbility of the main Mainfile
|
||
|
#> compact. The responsbility of this Makefile is to define global
|
||
|
#> environment variables, some of which it read from a user created file.
|
||
|
#>
|
||
|
#
|
||
|
# © 2023 Andrew Stryker <axs@sdf.org>
|
||
|
#
|
||
|
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
|
||
|
|
||
|
# Track file name of caller
|
||
|
ifdef self
|
||
|
caller ::= self
|
||
|
endif
|
||
|
|
||
|
self ::= $(notdir $(lastword ${MAKEFILE_LIST}))
|
||
|
|
||
|
#-----------------------------------------------------------------------------#
|
||
|
#
|
||
|
# Configuration
|
||
|
#
|
||
|
#-----------------------------------------------------------------------------#
|
||
|
|
||
|
ifndef ENV_LOADED
|
||
|
|
||
|
# Track loading the environment
|
||
|
ENV_LOADED ::= 1
|
||
|
export ENV_LOADED
|
||
|
|
||
|
# Avoid an unexpected shell environment
|
||
|
SHELL = /bin/sh
|
||
|
export SHELL
|
||
|
|
||
|
# Base/root directory of the build system. Allows us to use absolute paths.
|
||
|
MAKO_DIR ?= ${CURDIR}
|
||
|
export MAKO_DIR
|
||
|
|
||
|
# Place for user content
|
||
|
CONTENT ?= ${MAKO_DIR}/content
|
||
|
CONTENT ::= $(strip ${CONTENT})
|
||
|
export CONTENT
|
||
|
|
||
|
# User-defined configuration file
|
||
|
site_env ?= ${CONTENT}/site-env
|
||
|
site_env ::= $(strip ${site_env})
|
||
|
|
||
|
ifeq ($(strip $(shell [ -r ${site_env} ] && echo ${site_env})),)
|
||
|
$(info Generate a site configuration file first via `make configure`)
|
||
|
$(error Configuration file ${site_env} not readable.)
|
||
|
else
|
||
|
include ${site_env}
|
||
|
endif
|
||
|
|
||
|
# Place for intermediate files
|
||
|
WORKING ?= ${MAKO_DIR}/workspace
|
||
|
WORKING ::= $(strip ${WORKING})
|
||
|
export WORKING
|
||
|
|
||
|
# Place for site files ready to be transferred to the site
|
||
|
STAGING ?= ${MAKO_DIR}/staging
|
||
|
STAGING ::= $(strip ${STAGING})
|
||
|
export STAGING
|
||
|
|
||
|
# Makefiles
|
||
|
CURATE_MAKE ::= ${MAKO_DIR}/curate.mk
|
||
|
INDEX_MAKE ::= ${MAKO_DIR}/index.mk
|
||
|
|
||
|
# M4 fencing for raw text
|
||
|
FENCE ::= ${MAKO_DIR}/fence.m4
|
||
|
export FENCE
|
||
|
|
||
|
# Help generation
|
||
|
AWKHELP ::= ${MAKO_DIR}/generate-help.awk
|
||
|
export AWKHELP
|
||
|
|
||
|
endif
|
||
|
|
||
|
#-----------------------------------------------------------------------------#
|
||
|
#
|
||
|
# User interface targets
|
||
|
#
|
||
|
#> User facing targets:
|
||
|
#>
|
||
|
#-----------------------------------------------------------------------------#
|
||
|
|
||
|
# Only define targets if called directly
|
||
|
ifeq ($(firstword ${MAKEFILE_LIST}), ${self})
|
||
|
|
||
|
.PHONY: default show help
|
||
|
|
||
|
default: show
|
||
|
|
||
|
show: #> Show key variables
|
||
|
@echo "Key variables defined in ${self}:"
|
||
|
@echo
|
||
|
@echo "\tBase/root directory of the build system..... ${MAKO_DIR}"
|
||
|
@echo "\tUsef-defined configuration.................. ${site_env}"
|
||
|
@echo
|
||
|
# future location for templates
|
||
|
@echo "\tLocation of user content.................... ${CONTENT}"
|
||
|
@echo "\tWorking area for intermediate files......... ${WORKING}"
|
||
|
@echo "\tStaging area for site....................... ${STAGING}"
|
||
|
@echo
|
||
|
@echo "\tM4 macro for raw text....................... ${FENCE}"
|
||
|
@echo "\tHelp generation AWK file.................... ${AWKHELP}"
|
||
|
|
||
|
help: #> Show this help message
|
||
|
@awk -f ${AWKHELP} ${self}
|
||
|
|
||
|
endif
|
||
|
|
||
|
#-----------------------------------------------------------------------------#
|
||
|
|
||
|
# Restore value of self to the caller's file name if possible
|
||
|
ifdef caller
|
||
|
self ::= ${caller}
|
||
|
endif
|
||
|
|
||
|
#>
|
||
|
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
|