aboutsummaryrefslogtreecommitdiff
path: root/course/Makefile
blob: d74f8303e9015fc38ad5dc0f1878541fdca00a2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# The full path to the Makefile
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
# The path to the directory of the Makefile
MAKEFILE_DIR := $(dir $(MAKEFILE_PATH))

SRC_DIRS := $(shell find "(" -not -path "./pandoc/*" -a "(" -name "*.md" -o -name "*.tex" ")" -printf "%h\n" ")" | uniq)

VERBOSE ?= @

.DEFAULT_GOAL := all
all: $(SRC_DIRS)

define generateRules
$(1):
	$(VERBOSE)echo "## Building $$@ ##"
	$(VERBOSE)if [ -d $$(@)/Makefile ]; then\
		$(MAKE) -C $$(@);\
	else\
		$(MAKE) -C $$(@) -f $(MAKEFILE_DIR)/toplevel-build.mk;\
	fi
endef

$(foreach dir, $(SRC_DIRS), $(eval $(call generateRules, $(dir))))

.PHONY: $(SRC_DIRS)