-
Notifications
You must be signed in to change notification settings - Fork 37
/
Makefile
130 lines (93 loc) · 3.29 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
### Coq website : generation of static pages ###
DST:=dest
PP:=yamlpp-0.3/yamlpp
INCLS:=incl/header.html incl/footer.html incl/news/recent.html incl/macros.html
DEPS:=$(INCLS) $(PP)
all: pages news conf assets
aliases: newsaliases
clean:
rm -rf $(DST)/*
rm -rf .*.stamp
rm -f incl/news/recent.html
rm -f $(PP) $(PP).cm* $(PP).o
## In case we need to regenerate yamlpp.ml from its .mll.
$(PP).ml: $(PP).mll
ocamllex $<
$(PP): $(PP).ml
ocamlopt -o $@ $<
chmod +x $@
.PHONY: all pages news conf assets newsaliases clean
## We generate html pages from all .html files in pages
PAGES:= $(shell find pages -name *.html)
PAGESDST:=$(patsubst pages/%,$(DST)/%, $(PAGES))
pages: $(PAGESDST)
$(DST)/%: pages/% $(DEPS)
mkdir -p $(dir $@) && $(PP) $< -o $@
## Page aliases through Apache RewriteRule...
conf: $(DST)/aliases.conf
# L flags are needed because we don't want to add a .html suffix to the
# original requested URL if it has been rewritten. Note after an L rule is
# triggered, another pass of rewriting will be performed on the new URL
# unless we specify E=END.
$(DST)/aliases.conf: NEWSINDEX aliases.footer.conf
sed -n -e "s|\(..*\):\(.*\)|RewriteRule ^news/\2$$ /news/\1.html [E=END:1,L]|p" NEWSINDEX > $@
sed -n -e "s|\(..*\):\(.*\)|RewriteRule ^news/\1$$ /news/\2 [L,R=301]|p" NEWSINDEX >> $@
sed -n -e "s|\(..*\):\(.*\)|RewriteRule ^\2$$ /news/\2 [L,R=301]|p" NEWSINDEX >> $@
cat aliases.footer.conf >> $@
assets: $(DST)/styles \
$(DST)/sites \
$(DST)/modules \
$(DST)/files \
$(DST)/scripts \
$(DST)/coq-workshop/files
$(DST)/files:
cp -r files $@
$(DST)/styles:
cp -r styles $@
$(DST)/sites:
cp -r sites $@
$(DST)/modules:
cp -r modules $@
$(DST)/scripts:
cp -r scripts $@
$(DST)/coq-workshop/files:
mkdir -p $(dir $@) && cp -r files $@
## News, listed in the NEWSINDEX file
NEWS:= $(shell cat NEWSINDEX)
RECENTNEWS:= $(shell head -n 3 NEWSINDEX)
NEWSSRC:=$(addprefix news/,$(NEWS))
NEWSDST:=$(patsubst %,$(DST)/news/%.html,$(NEWS))
news: $(DST)/news/index.html $(DST)/rss.xml $(NEWSDST)
incl/news/recent.html: NEWSINDEX Makefile $(PP) $(addprefix news/,$(RECENTNEWS))
$(PP) -o $@ $(patsubst %,news/% incl/news/li.html,$(RECENTNEWS))
$(DST)/news/index.html: NEWSINDEX $(NEWSSRC) $(DEPS) incl/news/item.html incl/news/title.html
mkdir -p $(dir $@)
$(PP) -o $@ \
incl/news/title.html \
incl/header.html \
$(patsubst %,% incl/news/item.html,$(NEWSSRC)) \
incl/footer.html
$(DST)/news/%.html: news/% $(DEPS) incl/news/solo.html
mkdir -p $(dir $@)
$(PP) $< incl/news/solo.html -o $@
$(DST)/rss.xml: $(NEWSSRC) incl/rss/header.xml incl/rss/footer.xml incl/rss/item.xml $(PP)
$(PP) -o $@ \
incl/rss/header.xml \
$(patsubst %,% incl/rss/item.xml,$(NEWSSRC)) \
incl/rss/footer.xml
newsaliases: .newsaliases.stamp
.newsaliases.stamp: NEWSINDEX
IFS=':'; while read a b; \
do [ -n "$$b" ] && mkdir -p $(DST)/news/$$b && \
cp ../$$a.html $(DST)/news/$$b/index.html; \
done < NEWSINDEX; touch $@
printenv:
@echo "### PAGES ###"
@echo $(PAGES) | tr " " "\n"
@echo "### NEWS ###"
@echo $(NEWS) | tr " " "\n"
# Needs python 2.x (this exists also for python 3, with a different syntax)
run: aliases
@echo "Starting a local web server for test"
@echo "It is accessible at: http://localhost:8000"
cd $(DST) && (python3 ../srv/server.py)