title: How to make configurable makefile and optional configuration for certain files?
body: <p>I've made makefile that makes printable version of presentations. </p>
  
  <p>How it works:</p>
  
  <ol>
  <li>makes tiles for each presentation</li>
  <li>concatenates presentations into one big file</li>
  <li>not done yet: add numbers to pages</li>
  </ol>
  
  <p>The <code>Makefile</code>:</p>
  
  <pre><code>SLIDES_BASE_NAME := presentation-prefix-
  
  FILES := $(shell ls $(SLIDES_BASE_NAME)*.pdf)
  
  OUT_DIR := generated
  SLIDES_DIR := $(OUT_DIR)/slides
  SLIDES := $(addprefix $(SLIDES_DIR)/, $(FILES))
  SLIDES_CONCAT := $(OUT_DIR)/slides-oneside-print.pdf
  
  CFG_FILE := config.env
  
  TRIM := 0 0.36cm 0 0
  # TODO: read global config
  
  $(SLIDES_DIR)/%.pdf : %.pdf
      @echo Generating: $&lt; "-&gt;" $@
      @# TODO: read optional local config - "$&lt;.cfg"
      @pdfjam --nup 2x4 $&lt; --outfile $@ --delta "0.1cm 0.1cm" --a4paper --frame True --trim "$(TRIM)" --clip True --width '9.45cm'; 
  
  all: $(SLIDES_CONCAT)
  
  $(SLIDES_CONCAT): $(SLIDES)
      @echo Generating: $@ from $^
      @pdfjam $(SLIDES) -o $@
  
  $(SLIDES): | $(SLIDES_DIR)
  
  $(SLIDES_DIR):
      mkdir -p $(SLIDES_DIR)
  
  clean:
      rm -rf $(OUT_DIR)
  </code></pre>
  
  <p>I would like to make it configurable. See "TODO" in Makefile.</p>
  
  <p>How can I add global config file:</p>
  
  <ul>
  <li>reads property TRIM (more properties are about to come, so can't use <code>TRIM := $(shell cat ...)</code> ). </li>
  <li>when global config file changes, and I run <code>make</code>, then everything gets remade.</li>
  </ul>
  
  <p>Some professors have inconsistent style of presentations, so: How can I add optional config for each file:</p>
  
  <ul>
  <li>properties are overridden from config</li>
  <li>not required, but if present and changed - causes rebuild of certain presentation</li>
  </ul>
  
  <p>I've been thinking about changind rule:
  <code>$(SLIDES_DIR)/%.pdf : %.pdf</code> that it will depend on global cfg, and optionaly depend on optional config file for current presentation, then wrap contents of rule into my own script and pass all filenames to that script. </p>
  
  <p>However, I don't know what is the proper way to do that. Thanks for your help :) </p>