/
Makefile
83 lines (73 loc) · 2.86 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
# Makefile for DeepDive website maintenance
#
# We use jekyll (http://jekyllrb.com/) to build the website from the Markdown docs.
# You can install jekyll with "gem install jekyll".
#
# Run "make help" to get documentaton.
# Get the deploying user in env var $DEPLOY_USER, default is `whoami`
ifeq ($(origin DEPLOY_USER), undefined)
DEPLOY_USER = `whoami`
endif
DEPLOY_USER_HOST = $(DEPLOY_USER)@whale.stanford.edu
DEPLOY_DIR = /afs/cs/group/infolab/deepdive/www
GITHUB_REPO_URL = https://github.com/HazyResearch/deepdive
WEBSITE_CNAME = deepdive.stanford.edu
WEBSITE_BASEURL = http://$(WEBSITE_CNAME)
TEST_HOST = localhost
TEST_PORT = 4000
# localize required Ruby gems
GEM_HOME ?= $(shell pwd)/.gems
export GEM_HOME
PATH := $(GEM_HOME)/bin:$(PATH)
IGNORE_URL = $(shell sed <.linkchecker.ignore-urls -e 's/[[:space:]]*\#.*$$//' -e '/^[[:space:]]*$$/d')
LINKCHECKER_OPTIONS = --timeout 30 \
--check-extern --anchors \
$(IGNORE_URL:%=--ignore-url='%') \
#
.PHONY: test
ifeq ($(shell PATH="$(PATH)"; jekyll --version | grep -c 'jekyll 3'),1)
define JEKYLL_SERVE
jekyll serve --host $(TEST_HOST) --port $(TEST_PORT) --baseurl ""
endef
else
define JEKYLL_SERVE
jekyll serve --host $(TEST_HOST) --port $(TEST_PORT) --baseurl "" --config _config.yml,_config_2.x.yml
endef
endif
JEKYLL_SERVE_FLAGS = --watch # with watch by default
test: jekyll
# Launching a server for testing and authoring...
$(JEKYLL_SERVE) $(JEKYLL_SERVE_FLAGS)
.PHONY: linkcheck linkcheck-deployed
linkcheck: jekyll linkchecker
# Checking broken links locally
$(JEKYLL_SERVE) & \
trap "kill -TERM $$!" EXIT; sleep 3; \
linkchecker $(LINKCHECKER_OPTIONS) http://$(TEST_HOST):$(TEST_PORT)/
linkcheck-deployed: jekyll linkchecker
# Checking broken links from deployed website
linkchecker $(LINKCHECKER_OPTIONS) $(WEBSITE_BASEURL)/
.PHONY: deploy
deploy: jekyll
######################################################################
# NOTE: `make linkcheck` before every deployment highly recommended! #
######################################################################
# Building site...
echo 'baseurl: $(WEBSITE_BASEURL)' >_config.baseurl.yml
jekyll build --config _config.yml,_config.baseurl.yml
echo $(WEBSITE_CNAME) > _site/CNAME # create a CNAME file to put on server
# Deploying site...
@read -p"WARNING! Continue to overwrite all files in $(DEPLOY_USER_HOST):$(DEPLOY_DIR)? "
ssh $(DEPLOY_USER_HOST) 'mkdir -p $(DEPLOY_DIR)'
rsync -rtlHv --delete-after _site/ $(DEPLOY_USER_HOST):$(DEPLOY_DIR)/
@echo "Deployed to $(WEBSITE_BASEURL)"
rm -f _config.baseurl.yml
.PHONY: jekyll linkchecker
jekyll:
type jekyll || gem2.0 install jekyll redcarpet || gem install jekyll redcarpet || gem install jekyll --version 2.5.3
linkchecker:
type linkchecker >/dev/null || pip install linkchecker --use-mirrors
.PHONY: help
help:
@cat README
.DEFAULT_GOAL := help