forked from plfa/plfa.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
208 lines (144 loc) · 5.83 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
SHELL := /bin/bash
AGDA := $(shell find . -type f -and \( -path '*/src/*' -or -path '*/courses/*' \) -and -name '*.lagda.md')
AGDAI := $(shell find . -type f -and \( -path '*/src/*' -or -path '*/courses/*' \) -and -name '*.agdai')
MARKDOWN := $(subst courses/,out/,$(subst src/,out/,$(subst .lagda.md,.md,$(AGDA))))
PLFA_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
AGDA2HTML_FLAGS := --verbose --link-to-local-agda-names --use-jekyll=out/
AGDA_STDLIB_SED := ".agda-stdlib.sed"
ifeq ($(AGDA_STDLIB_VERSION),)
AGDA_STDLIB_URL := https://agda.github.io/agda-stdlib/
else
AGDA_STDLIB_URL := https://agda.github.io/agda-stdlib/v$(AGDA_STDLIB_VERSION)/
endif
# Build PLFA and test hyperlinks
test: build
ruby -S bundle exec htmlproofer _site
# Build PLFA and test hyperlinks offline
test-offline: build
ruby -S bundle exec htmlproofer _site --disable-external
statistics:
hs/agda-count
out/:
mkdir -p out/
# Convert literal Agda to Markdown
define AGDA_template
in := $(1)
out := $(subst courses/,out/,$(subst src/,out/,$(subst .lagda.md,.md,$(1))))
$$(out) : in = $(1)
$$(out) : out = $(subst courses/,out/,$(subst src/,out/,$(subst .lagda.md,.md,$(1))))
$$(out) : $$(in) | out/
@echo "Processing $$(subst ./,,$$(in))"
ifeq (,$$(findstring courses/,$$(in)))
./highlight.sh $$(in) $$(out)
else
# Fix links to the file itself (out/<filename> to out/<filepath>)
./highlight.sh $$(in) $$(out) --include-path $(realpath src) --include-path $$(realpath $$(dir $$(in)))
@sed -i 's|out/$$(notdir $$(out))|$$(subst ./,,$$(out))|g' $$(out)
endif
endef
$(foreach agda,$(AGDA),$(eval $(call AGDA_template,$(agda))))
# Start server
serve:
ruby -S bundle exec jekyll serve --incremental
# Start background server
server-start:
ruby -S bundle exec jekyll serve --no-watch --detach
# Stop background server
server-stop:
pkill -f jekyll
# Build website using jekyll
build: AGDA2HTML_FLAGS += --link-to-agda-stdlib=$(AGDA_STDLIB_URL)
build: $(MARKDOWN)
ruby -S bundle exec jekyll build
# Build website using jekyll offline
build-offline: $(MARKDOWN)
ruby -S bundle exec jekyll build
# Build website using jekyll incrementally
build-incremental: AGDA2HTML_FLAGS += --link-to-agda-stdlib
build-incremental: $(MARKDOWN)
ruby -S bundle exec jekyll build --incremental
# Remove all auxiliary files
clean:
rm -f $(AGDA_STDLIB_SED)
ifneq ($(strip $(AGDAI)),)
rm $(AGDAI)
endif
# Remove all generated files
clobber: clean
ruby -S bundle exec jekyll clean
rm -rf out/
.phony: clobber
# List all .lagda files
ls:
@echo $(AGDA)
.phony: ls
# MacOS Setup (install Bundler)
macos-setup:
brew install libxml2
ruby -S gem install bundler --no-ri --no-rdoc
ruby -S gem install pkg-config --no-ri --no-rdoc -v "~> 1.1"
ruby -S bundle config build.nokogiri --use-system-libraries
ruby -S bundle install
.phony: macos-setup
# Travis Setup (install Agda, the Agda standard library, agda2html, acknowledgements, etc.)
travis-setup:\
$(HOME)/.local/bin/agda\
$(HOME)/.local/bin/acknowledgements\
$(HOME)/agda-stdlib-$(AGDA_STDLIB_VERSION)/src\
$(HOME)/.agda/defaults\
$(HOME)/.agda/libraries
.phony: travis-setup
travis-install-agda2html: $(HOME)/.local/bin/agda2html
$(HOME)/.local/bin/agda2html:
curl -L https://github.com/wenkokke/agda2html/archive/master.zip -o $(HOME)/agda2html-master.zip
unzip -qq $(HOME)/agda2html-master.zip -d $(HOME)
cd $(HOME)/agda2html-master;\
stack install
travis-uninstall-agda2html:
rm -rf $(HOME)/agda2html-master/
rm $(HOME)/.local/bin/agda2html
travis-reinstall-agda2html: travis-uninstall-agda2html travis-install-agda2html
.phony: travis-install-agda2html travis-uninstall-agda2html travis-reinstall-agda2html
travis-install-acknowledgements: $(HOME)/.local/bin/acknowledgements
$(HOME)/.local/bin/acknowledgements:
curl -L https://github.com/plfa/acknowledgements/archive/master.zip -o $(HOME)/acknowledgements-master.zip
unzip -qq $(HOME)/acknowledgements-master.zip -d $(HOME)
cd $(HOME)/acknowledgements-master;\
stack install
travis-uninstall-acknowledgements:
rm -rf $(HOME)/acknowledgements-master/
rm $(HOME)/.local/bin/acknowledgements
travis-reinstall-acknowledgements: travis-uninstall-acknowledgements travis-reinstall-acknowledgements
.phony: travis-install-acknowledgements travis-uninstall-acknowledgements travis-reinstall-acknowledgements
travis-install-agda:\
$(HOME)/.local/bin/agda\
$(HOME)/.agda/defaults\
$(HOME)/.agda/libraries
$(HOME)/.agda/defaults:
echo "standard-library" >> $(HOME)/.agda/defaults
echo "plfa" >> $(HOME)/.agda/defaults
$(HOME)/.agda/libraries:
echo "$(HOME)/agda-stdlib-$(AGDA_STDLIB_VERSION)/standard-library.agda-lib" >> $(HOME)/.agda/libraries
echo "$(PLFA_DIR)/plfa.agda-lib" >> $(HOME)/.agda/libraries
$(HOME)/.local/bin/agda:
curl -L https://github.com/agda/agda/archive/v$(AGDA_VERSION).zip -o $(HOME)/agda-$(AGDA_VERSION).zip
unzip -qq $(HOME)/agda-$(AGDA_VERSION).zip -d $(HOME)
cd $(HOME)/agda-$(AGDA_VERSION);\
stack install --stack-yaml=stack-8.0.2.yaml
travis-uninstall-agda:
rm -rf $(HOME)/agda-$(AGDA_VERSION)/
rm -f $(HOME)/.local/bin/agda
rm -f $(HOME)/.local/bin/agda-mode
travis-reinstall-agda: travis-uninstall-agda travis-install-agda
.phony: travis-install-agda travis-uninstall-agda travis-reinstall-agda
travis-install-agda-stdlib: $(HOME)/agda-stdlib-$(AGDA_STDLIB_VERSION)/src
$(HOME)/agda-stdlib-$(AGDA_STDLIB_VERSION)/src:
curl -L https://github.com/agda/agda-stdlib/archive/v$(AGDA_STDLIB_VERSION).zip -o $(HOME)/agda-stdlib-$(AGDA_STDLIB_VERSION).zip
unzip -qq $(HOME)/agda-stdlib-$(AGDA_STDLIB_VERSION).zip -d $(HOME)
mkdir -p $(HOME)/.agda
travis-uninstall-agda-stdlib:
rm $(HOME)/.agda/defaults
rm $(HOME)/.agda/libraries
rm -rf $(HOME)/agda-stdlib-$(AGDA_STDLIB_VERSION)/
travis-reinstall-agda-stdlib: travis-uninstall-agda-stdlib travis-install-agda-stdlib
.phony: travis-install-agda-stdlib travis-uninstall-agda-stdlib travis-reinstall-agda-stdlib