forked from somasis/musl-wiki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (55 loc) · 2.82 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
# build requirements:
# discount `markdown` (http://www.pell.portland.or.us/~orc/Code/discount/)
# tidy-html5 (https://github.com/htacg/tidy-html5)
# postcss-cli (https://www.npmjs.com/package/postcss-cli)
# cssnano (https://www.npmjs.com/package/cssnano)
# autoprefixer (https://www.npmjs.com/package/autoprefixer)
#
# `check` requirements:
# markdownlint (https://github.com/markdownlint/markdownlint)
#
# `check-links` requirements:
# devd (https://github.com/cortesi/devd)
# linkchecker (https://wummel.github.io/linkchecker)
#
SRCDIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST)))))
WORK ?= ./work
WORK := $(abspath $(WORK))
IMAGE ?= /srv/www/wiki.musl-libc.org
HTML = $(addprefix $(WORK)/,$(addsuffix .html,$(basename $(shell cd $(SRCDIR) && find \( -type f -or -type l \) -and \( -name '*.md' \) -and -not \( -path './work/*' -or -path '$(WORK)/*' -or -path '*/.*/*' \) -prune))))
CSS = $(addprefix $(WORK)/,$(addsuffix .min.css,$(basename $(shell cd $(SRCDIR) && find \( -type f -or -type l \) -and \( -name '*.css' -and -not -name '*.min.css' \) -and -not \( -path './work/*' -or -path '$(WORK)/*' -or -path '*/.*/*' \) -prune))))
AUX = $(addprefix $(WORK)/,$(shell cd $(SRCDIR) && find \( -type f -or -type l \) -and \( -name '*.png' -or -name '*.ico' -or -name '*.conf' \) -and -not \( -path './work/*' -or -path '$(WORK)/*' -or -path '*/.*/*' \) -prune))
all: $(HTML) $(CSS) $(AUX)
clean:
rm -f $(HTML)
rm -f $(CSS)
rm -f $(AUX)
rm -f $(WORK)/devd.*
-find $(WORK) -type d -empty -print -delete
check: lint
lint: all
find $(SRCDIR) -type f -name '*.md' -and -not -name 'bugs-found-by-musl.md' -print0 | xargs -t0 mdl -s "$(SRCDIR)/.mdlstyle.rb"
check-links: all
$(SRCDIR)/scripts/devd.sh "$(WORK)"
$(SRCDIR)/scripts/linkchecker.sh "$(WORK)" "$$(cat $(WORK)/devd.address)"
install:
gem install mdl
$(TRAVIS_SUDO) npm install -g postcss-cli cssnano autoprefixer
# cssnano is ran separately because it likes to take out vendor prefixes we might still need
$(WORK)/%.min.css: $(SRCDIR)/%.css
postcss "$<" -u cssnano -o "$(WORK)/$*.css.tmp"
postcss "$(WORK)/$*.css.tmp" -u autoprefixer -o "$@"
rm -f "$(WORK)/$*.css.tmp"
$(WORK)/%.html: $(SRCDIR)/%.md $(shell $(SRCDIR)/scripts/markdown.sh --template "$<" "$@")
mkdir -p $(dir $@)
$(SRCDIR)/scripts/markdown.sh "$<" "$@"
tidy -w 0 -utf8 -language en -i -m --show-info no "$@"
$(WORK)/%: $(SRCDIR)/%
cp -f "$<" "$@"
watch: all
while true; do \
{ find $(SRCDIR) -not -name '*.min.css' -and -not -name '*.tmp' -and -not -name '*.html' -and -not -path '*/.*'; } | entr -c sh -c '$(MAKE) WORK=$(WORK) check && $(MAKE) WORK=$(WORK)'; \
done
deploy: all
rsync -v -rl --delete-after $(WORK)/ "$(IMAGE)" --exclude '*.git*'
.PHONY: check lint check-links install clean watch deploy