Makefile 614 B

123456789101112131415161718192021222324
  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. copysources = $(sources)
  8. copytargets = $(subst $(IN),$(OUT),$(filter-out $(IN)Makefile,$(copysources)))
  9. all: $(copytargets)
  10. # the | means that if the timestamp of anything on the right changes, no need to rebuild
  11. # the two :'s mean that the implicit rule of "$(list): %.pdf: %.tex" is applied only to the targets in $(list)
  12. $(copytargets): $(OUT)%: $(IN)% | $(targetdirs)
  13. cp $< $@
  14. $(targetdirs) $(TMP):
  15. mkdir -p $@
  16. clean:
  17. rm -rf $(OUT) $(TMP)