-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
33 lines (27 loc) · 1.24 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
NAME = culture-hacking
ARCHIVE_NAME = $(NAME)-$(shell date +%Y-%m-%d)
SLIDES = $(NAME)-slides.html
SLIDES_DIST = $(NAME)-slides-standalone.html
SLIDES_STYLESHEET = $(wildcard slides.css)
IMAGES = $(wildcard *.png *.jpg)
ASSETS = $(wildcard $(IMAGES) $(SLIDES_STYLESHEET) book-recommendations.txt)
all: $(SLIDES)
zip: $(ARCHIVE_NAME).zip
dist: $(SLIDES_DIST) $(ASSETS)
mkdir -p dist
# download external references, e.g. slidy CSS and JS
sed -nE 's?.*\b(href|src)="(https\?://[^"]+)".*?\2?p' $< | xargs -Iquux sh -c 'test -f dist/`basename quux` || wget --directory-prefix dist quux'
ls dist/*.gz | xargs --no-run-if-empty gunzip
if [ -n "$(ASSETS)" ]; then cp $(ASSETS) dist; fi
# modify external references to point to downloaded assets
sed -E 's?\b(href|src)="(https\?://[^"]+/([^"]+))"?\1="\3"?; s?\b(href|src)="(.*)\.gz"?\1="\2"?' $< > dist/$<
mv dist/$(SLIDES_DIST) dist/index.html
$(ARCHIVE_NAME).zip: dist
cd $< && zip ../$@ *
$(SLIDES): $(NAME).otl
OTL slidy <$< >$@
if [ -n "$(SLIDES_STYLESHEET)" ]; then sed -i 's|</head>|\n<link href="$(SLIDES_STYLESHEET)" type="text/css" rel="stylesheet" />\n</head>|' $@; fi
$(SLIDES_DIST): $(SLIDES) $(SLIDES_STYLESHEET) splice.sed
sed -f splice.sed $< >$@
clean:
rm -rf $(SLIDES) $(SLIDES_DIST) dist