Makefile 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. IN = src/
  2. OUT = dist/
  3. TMP = temp/
  4. sources = $(shell find $(IN) -type f)
  5. sourcedirs = $(shell find $(IN) -type d)
  6. targetdirs = $(subst $(IN),$(OUT),$(sourcedirs))
  7. texsources = $(shell find $(IN) -type f -name *.tex)
  8. textargets = $(subst $(IN),$(OUT),$(texsources:.tex=.pdf))
  9. copysources = $(filter-out $(texsources),$(sources))
  10. copytargets = $(subst $(IN),$(OUT),$(copysources))
  11. all: $(copytargets) $(textargets)
  12. # the | means that if the timestamp of anything on the right changes, no need to rebuild
  13. # the two :'s mean that the implicit rule of "$(list): %.pdf: %.tex" is applied only to the targets in $(list)
  14. $(copytargets): $(OUT)%: $(IN)% | $(targetdirs)
  15. cp $< $@
  16. $(targetdirs):
  17. mkdir -p $@
  18. $(textargets): $(OUT)%.pdf: $(IN)%.tex | $(targetdirs)
  19. # $< is the name of the first prerequisit,
  20. # $@ is the name of the target
  21. mkdir -p $(TMP) && \
  22. texfot pdflatex -output-directory=$(TMP) $< && \
  23. texfot pdflatex -output-directory=$(TMP) $< && \
  24. mv $(TMP)$(@F) $(subst $(IN),$(OUT),$@)
  25. clean:
  26. rm -rf $(OUT) $(TMP)