-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
92 lines (68 loc) · 2.41 KB
/
Makefile
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
.PHONY: default check-archive check-tutorial check clean exercises
MAKEFILE_DIR:=$(dir $(realpath $(lastword $(MAKEFILE_LIST))))
default: tutorial
all: default
clean:
rm -rf docs/exercises docs/solutions docs/exercises.zip build TAGS
##############################################################################
# Exercises
SRC_EXAMPLES=$(shell find src/examples -type f)
SOLUTIONS=$(patsubst src/examples/%, docs/solutions/%, $(SRC_EXAMPLES))
EXERCISES=$(patsubst src/examples/%, docs/exercises/%, $(SRC_EXAMPLES))
CN=cn verify
exercises: docs-exercises-dirs $(EXERCISES) $(SOLUTIONS)
docs-exercises-dirs:
mkdir -p docs/exercises
mkdir -p docs/solutions
docs/exercises/%: src/examples/%
@echo Rebuild $@
@-mkdir -p $(dir $@)
@sed -E '\|^.*--BEGIN--.*$$|,\|^.*--END--.*$$|d' $< > $@
docs/solutions/%: src/examples/%
@-mkdir -p $(dir $@)
@if [ `which cn` ]; then \
if [[ "$<" = *".c"* ]]; then \
if [[ "$<" != *"broken"* ]]; then \
echo $(CN) $< && $(CN) $<; \
fi; \
fi \
fi
@echo Rebuild $@
@cat $< | sed '\|^.*--BEGIN--.*$$|d' | sed '\|^.*--END--.*$$|d' > $@
docs/exercises.zip: $(EXERCISES)
cd docs; zip -r exercises.zip exercises > /dev/null
WORKING=$(wildcard src/examples/list_*.c)
WORKING_AUX=$(patsubst src/examples/%, docs/solutions/%, $(WORKING))
temp: $(WORKING_AUX) docs-exercises-dirs
##############################################################################
# Check that the examples all run correctly
CN_PATH?=cn verify
check-archive:
@echo Check archive examples
@$(MAKEFILE_DIR)/src/example-archive/check-all.sh "$(CN_PATH)"
check-tutorial:
@echo Check tutorial examples
@$(MAKEFILE_DIR)/check.sh "$(CN_PATH)"
check: check-tutorial check-archive
##############################################################################
# Tutorial document
tutorial: exercises mkdocs.yml $(shell find docs -type f)
mkdocs build --strict
serve: exercises mkdocs.yml $(shell find docs -type f)
mkdocs serve
##############################################################################
# Misc
TAGS:
@echo Rebuilding TAGS
@etags src/tutorial.adoc $(SRC_EXAMPLES)
##############################################################################
# Personal and site-specific stuff
bcp: TAGS
$(MAKE) default
osascript \
-e 'tell application "Safari"' \
-e 'tell its first document' \
-e 'set its URL to (get its URL)' \
-e 'end tell' \
-e 'activate' \
-e 'end tell'