chapter-sort = $(shell echo -e $(subst $(sp),'\n',$2) | sort $1 --key=1,1 -) books : Book1.pdf Book1.epub Book1.pdf : $(call chapter-sort,-n,$(wildcard Book-1/*.md)) pandoc $^ -o $@ Book1.epub : $(call chapter-sort,-n,$(wildcard Book-1/*.md)) pandoc $^ -o $@ clean: rm -rf Book1.pdf .PHONY: books clean