2018-08-19 17:41:04 +02:00
|
|
|
|
# Note: this whole makefile is a huge hack, is highly unportable, and probably
|
|
|
|
|
# won’t even do what it’s supposed to do. So, use with care, have fun :)
|
|
|
|
|
|
2018-08-19 15:23:40 +02:00
|
|
|
|
PRESENTATIONS=$(patsubst %.tex, %.pdf, $(wildcard presentations/*.tex))
|
2018-08-19 16:08:47 +02:00
|
|
|
|
BUILD_DIR=build
|
2018-08-19 17:40:27 +02:00
|
|
|
|
BUILD_DECKS=$(subst presentations/,$(BUILD_DIR)/,$(wildcard presentations/content/*))
|
2018-08-19 16:08:47 +02:00
|
|
|
|
LATEX=pdflatex -output-directory $(BUILD_DIR)
|
2018-08-19 15:23:40 +02:00
|
|
|
|
|
2018-08-19 18:11:44 +02:00
|
|
|
|
all: $(PRESENTATIONS)
|
2018-08-19 15:23:40 +02:00
|
|
|
|
|
2018-08-19 15:40:27 +02:00
|
|
|
|
clean:
|
2018-08-19 16:08:47 +02:00
|
|
|
|
rm -fr presentations/$(BUILD_DIR)
|
|
|
|
|
|
|
|
|
|
distclean: clean
|
|
|
|
|
rm -f presentations/*.pdf
|
|
|
|
|
|
2018-08-19 17:03:00 +02:00
|
|
|
|
# Extract dependencies for presentations by looking at the source code and
|
|
|
|
|
# extracting all calls to \includedeck from them; it returns a list of elements
|
|
|
|
|
# like ’presentations/content/ccc/ccc_lokal.tex’
|
|
|
|
|
|
2018-08-19 17:57:34 +02:00
|
|
|
|
# Yes, we are using perl: a system that has make probably also has perl; if not,
|
|
|
|
|
# blame me.
|
|
|
|
|
|
2018-08-19 16:46:01 +02:00
|
|
|
|
define presentation_dependencies
|
2018-08-19 17:02:51 +02:00
|
|
|
|
$(shell perl -ne '/includedeck\{(.*)\}/ && print "presentations/content/", $$1, ".tex "' $(1))
|
2018-08-19 16:46:01 +02:00
|
|
|
|
endef
|
|
|
|
|
|
2018-08-19 18:12:05 +02:00
|
|
|
|
# This template is called with arguments like ‘presentations/xxx.pdf’; it
|
2018-08-19 17:03:00 +02:00
|
|
|
|
# generates a rule that dependes on the corresponding tex file as well as on all
|
|
|
|
|
# decks used in that tex file; dependencies are of the form
|
2018-08-19 18:12:05 +02:00
|
|
|
|
# ‘presentations/content/ccc/ccc_lokal.tex’
|
2018-08-19 17:03:00 +02:00
|
|
|
|
|
2018-08-19 16:37:01 +02:00
|
|
|
|
define PRESENTATION_template
|
|
|
|
|
.ONESHELL: $(1)
|
2018-08-19 16:46:01 +02:00
|
|
|
|
$(1): $(subst .pdf,.tex,$(1)) $(call presentation_dependencies,$(subst .pdf,.tex,$(1)))
|
|
|
|
|
echo $$^
|
2018-08-08 20:25:42 +02:00
|
|
|
|
cd presentations
|
2018-08-19 17:40:27 +02:00
|
|
|
|
mkdir -p $(BUILD_DECKS)
|
2018-08-19 16:37:01 +02:00
|
|
|
|
$(LATEX) $$(notdir $$<)
|
|
|
|
|
$(LATEX) $$(notdir $$<)
|
|
|
|
|
mv $(subst presentations/,$(BUILD_DIR)/,$(1)) .
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
$(foreach presentation, $(PRESENTATIONS), \
|
|
|
|
|
$(eval $(call PRESENTATION_template, $(presentation))))
|
2018-08-19 17:41:29 +02:00
|
|
|
|
|
|
|
|
|
# This template is called with a single argument like
|
2018-08-19 17:54:57 +02:00
|
|
|
|
# ‘presentations/content/ccc/ccc_bundesweit.tex’; it generates a rule that
|
|
|
|
|
# dependes on all images used by the tex file. The actual recipe just checks
|
|
|
|
|
# whether the tex file is existent and updates the timestamp.
|
2018-08-19 17:41:29 +02:00
|
|
|
|
|
|
|
|
|
define DECK_template
|
2018-08-19 17:54:57 +02:00
|
|
|
|
$(1): $(shell perl -ne '/includegraphics[^\{]*\{([^\}]*)\}/ && print "presentations/", $$1, " "' $(1))
|
|
|
|
|
test -f $(1) && touch $(1)
|
2018-08-19 17:41:29 +02:00
|
|
|
|
endef
|
|
|
|
|
|
2018-08-19 17:57:34 +02:00
|
|
|
|
# Files contained in decks are only considered at top-level.
|
2018-08-19 17:41:29 +02:00
|
|
|
|
|
|
|
|
|
$(foreach deck, $(wildcard presentations/content/*/*.tex), \
|
|
|
|
|
$(eval $(call DECK_template, $(deck))))
|