Slidesammlung
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 2.1KB

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