Skip to content

Commit

Permalink
Check that configuration variables are defined
Browse files Browse the repository at this point in the history
  • Loading branch information
cdlm committed Oct 19, 2016
1 parent 21bcf93 commit f9246c5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions book/support/makefiles/help.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,18 @@ help: ## Describe the main targets (this list)
@echo "Combined format+volume targets are also defined: pdfbook, htmlchapters…"
@echo "To make a single specific file/format, ask for it explicitly:"
@echo " make $(OUTPUTDIRECTORY)/$(firstword $(CHAPTERS)).pdf"

# Check that given variables are set and all have non-empty values,
# die with an error otherwise.
#
# Params:
# 1. Variable name(s) to test.
# 2. (optional) Error message to print.
#
# See http://stackoverflow.com/questions/10858261/abort-makefile-if-variable-not-set
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined setting $1$(if $2, ($2))))
4 changes: 4 additions & 0 deletions book/support/makefiles/prepare.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
$(call check_defined, OUTPUTDIRECTORY, Directory for build products)
$(call check_defined, MAIN, Base name of the main document)
$(call check_defined, CHAPTERS, Base names of the chapters)

.phony: prepare prepare-build prepare-clean download submodules

FIGURES := $(shell find . \
Expand Down

0 comments on commit f9246c5

Please sign in to comment.