-
Notifications
You must be signed in to change notification settings - Fork 50
/
Makefile
84 lines (67 loc) · 2.25 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
SHELL := /bin/bash
PYTHON=python3
PIP=pip3
PIPENV=pipenv
TESTPYTHON:=$(shell $(PYTHON) --version 2>/dev/null)
PIPENVOPTS=
NIKOLA?=nikola
PORT?=8000
BASEDIR=$(CURDIR)
VENVDIR=$(BASEDIR)/venv
ACTIVATE=$(VENVDIR)/bin/activate
MODE?=dev
ifeq ($(MODE), dev)
PIPENVOPTS+=--dev
endif
help:
@echo 'Makefile for AskOmics website'
@echo ''
@echo 'Usage:'
@echo ' make help Display help'
@echo ' make install [MODE=dev] Install Python dependencies in a virtual environment'
@echo ' make build (Re)generate the web site '
@echo ' make clean Remove the generated files '
@echo ' make serve [PORT=8000] Serve site at http://localhost:8000 '
@echo ' make uninstall Uninstall python dependencies'
check-python:
ifndef TESTPYTHON
$(error $(PYTHON) not found. Abording)
endif
check-venv:
test -s $(ACTIVATE) || { echo "$(ACTIVATE) not found. Run make install first"; exit 1; }
install: check-python
@echo -n 'Building python virtual environment... '
$(PYTHON) -m venv $(VENVDIR)
@echo 'Done'
@echo -n 'Sourcing Python virtual environment... '
. $(ACTIVATE)
@echo 'Done'
@echo -n 'Upgrading pip... '
$(PIP) install --upgrade pip > /dev/null
@echo 'Done'
@echo 'Installing Python dependencies inside virtual environment... '
$(PIP) install -e . > /dev/null
PIPENV_VERBOSITY=-1 $(PIPENV) install $(PIPENVOPTS)
@echo ' Done'
uninstall:
@echo -n 'Uninstall python files... '
$(RM) -rf $(VENVDIR)
$(RM) -rf $(PYCACHE)
@echo 'Done'
build: check-venv
. $(ACTIVATE)
$(NIKOLA) build
post: check-venv
. $(ACTIVATE)
$(NIKOLA) new_post -f markdown
page: check-venv
. $(ACTIVATE)
$(NIKOLA) new_page -f markdown
clean: check-venv
[ ! -d $(OUTPUTDIR) ] || rm -rf $(OUTPUTDIR)
serve: check-venv
. $(ACTIVATE)
$(NIKOLA) auto -p $(PORT)
.PHONY: help check-python check-venv install uninstall build clean serve
.SILENT: help check-python check-venv install uninstall build clean serve
.ONESHELL: