aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: c1acae24527d36446cc8aec1d7ce89c2a404fab0 (plain)
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
DOCTOOLS=doctools
DOCBUILD=$(DOCTOOLS)/docbuild

VERBOSE=--verbose

FETCHTS=.fetch.ts
LOCALFETCH=.LocalFetch.ts

define GetFromConfig
$(shell node -p "require('./docs.json').$(1)")
endef

DOCTOOLSREPO      := $(call GetFromConfig,doctools.url)
DOCTOOLSBRANCH := $(call GetFromConfig,doctools.version)

all: help

help:
	@echo "Usage:"
	@echo "- make distclean: clean all generated files and repos"
	@echo "- make clean: clean all generated files"
	@echo "- make doctools: clone doctools repository"
	@echo "- make fetch: fetch the site if necessary"
	@echo "- make localFetch: fetch the site if necessary but use local file."
	@echo "- make build: build the site"
	@echo "- make push: push the built site"
	@echo "- make serve: serve the site"

.PHONY: distclean
distclean: clean
	rm -fr $(DOCTOOLS)

.PHONY: clean
clean:
	$(DOCBUILD) $(VERBOSE) --clean
	rm -f $(FETCHTS)
	rm -f $(LOCALFETCH)

$(LOCALFETCH): $(wildcard content/toc/*/fetched_files.yml)
	$(DOCBUILD) $(VERBOSE) --localFetch --fetch --force
	touch $(FETCHTS)
	touch $@

$(FETCHTS): $(wildcard content/toc/*/fetched_files.yml)
	$(DOCBUILD) $(VERBOSE) $(LOCAL_FETCHTS) --fetch --force
	touch $@

prebuild:
	@node -v && [ $$? -eq 0 ] || (echo "Please, make sure nodejs is installed" && false)
	@jekyll -v && [ $$? -eq 0 ] || (echo "Please, make sure jekyll is installed" && false)

.PHONY: doctools
doctools: prebuild
	echo $(DOCTOOLSREPO)
	@test ! -d $(DOCTOOLS) && git clone -b $(DOCTOOLSBRANCH) $(DOCTOOLSREPO) $(DOCTOOLS) || true
	@cd $(DOCTOOLS) && npm install

.PHONY: fetch
fetch: doctools $(FETCHTS)
	@echo "Fetched files up to date."

.PHONY: build
build: doctools $(FETCHTS)
	$(DOCBUILD) $(VERBOSE) --build

.PHONY: push
push: doctools $(FETCHTS)
	$(DOCBUILD) $(VERBOSE) --build --push

.PHONY: serve
serve: doctools $(FETCHTS)
	$(DOCBUILD) $(VERBOSE) --build --serve