-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (76 loc) · 2.7 KB
/
Copy pathMakefile
File metadata and controls
101 lines (76 loc) · 2.7 KB
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
93
94
95
96
97
98
99
100
101
.PHONY: default check-archive check-tutorial check clean exercises
MAKEFILE_DIR:=$(dir $(realpath $(lastword $(MAKEFILE_LIST))))
default: build exercises build/tutorial.html build/exercises.zip
all: default
clean:
rm -rf build TAGS
build:
mkdir -p build
mkdir -p build/exercises
mkdir -p build/solutions
##############################################################################
# Exercises
SRC_EXAMPLES=$(shell find src/examples -type f)
SOLUTIONS=$(patsubst src/examples/%, build/solutions/%, $(SRC_EXAMPLES))
EXERCISES=$(patsubst src/examples/%, build/exercises/%, $(SRC_EXAMPLES))
CN=cn verify
exercises: $(EXERCISES) $(SOLUTIONS)
build/exercises/%: src/examples/%
@echo Rebuild $@
@-mkdir -p $(dir $@)
@sed -E '\|^.*--BEGIN--.*$$|,\|^.*--END--.*$$|d' $< > $@
build/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' > $@
build/exercises.zip: $(EXERCISES)
cd build; zip -r exercises.zip exercises > /dev/null
WORKING=$(wildcard src/examples/list_*.c)
WORKING_AUX=$(patsubst src/examples/%, build/solutions/%, $(WORKING))
temp: $(WORKING_AUX) build
# build/tutorial.html
##############################################################################
# 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
build/tutorial.adoc build/style.css build/asciidoctor.css: src/tutorial.adoc
@echo Create build/tutorial.adoc
@sed -E 's/include_example\((.+)\)/.link:\1[\1]\n[source,c]\n----\ninclude::\1\[\]\n----/g' $< > $@
@cp src/style.css build
@cp src/asciidoctor.css build
build/images: src/images
cp -r $< $@
build/tutorial.html: build/tutorial.adoc $(SRC_EXAMPLES) build/images
asciidoctor --doctype book $< -o $@
@rm build/tutorial.adoc
##############################################################################
# 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'