This repository has been archived by the owner on Apr 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
153 lines (127 loc) · 4.07 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# This is <Makefile>
# -----------------------------------------------------------------------------
#
# REVISION AND CHANGES
# 2017/11/26 V0.1 Daniel Armbruster
# =============================================================================
#
# PURPOSE:
# --------
# Install EIDA NG Mediator/Federator webservices.
#
# USAGE:
# ------
# Display a list of EIDA NG webservices available to be installed:
#
# $ make ls
#
# ----
# To install a specific EIDA NG webservice invoke:
#
# $ make install \
# SERVICES="whitespace separated list of EIDA NG services to install"
#
# To install all EIDA NG webservices available invoke:
#
# $ make install
#
# ----
# Invoke
#
# $ make test [SERVICES=list of services]
#
# to run unittest facilities.
#
# ----
# To create a sphinx documentation run
#
# $ pip install sphinx
# $ make doc [SERVICES=list of services]
#
# NOTE:
# -----
# Since *virtualenv* is the preferred installation method, make sure the
# appropriate Python interpreter was activated before.
#
# =============================================================================
SERVICES_ALL=federator stationlite
# TODO(damb): Provide installation for all services
#SERVICES_ALL=federator mediator stationlite
SERVICES?=$(SERVICES_ALL)
PATH_EIDANGSERVICES=eidangservices
PATH_DOCS=docs
BASENAME_DOC=docs
SPHINX_BUILDER=html
SPHINX_CHECK:=$(strip \
$(shell python setup.py --help-commands | grep build_sphinx))
SPHINX_PKGS=$(sort $(dir $(wildcard $(PATH_EIDANGSERVICES)/*/)))
SPHINX_EXCLUDE=$(addsuffix /,$(addprefix $(PATH_EIDANGSERVICES)/,\
__pycache__ utils/tests))
SPHINX_INCLUDE=$(addsuffix /,$(addprefix $(PATH_EIDANGSERVICES)/,\
utils))
TOXENVS=py35 py36
# -----------------------------------------------------------------------------
#
CHECKVAR=$(if $(filter $(1),$(SERVICES_ALL)),, \
$(error ERROR: Invalid SERVICES parameter value: $(1)))
CHECKVARS=$(foreach var,$(1),$(call CHECKVAR,$(var)))
$(call CHECKVARS, $(SERVICES))
null :=
space := $(null) #
comma := ,
COMMA_LIST=$(subst $(space),$(comma),$(strip $(1)))
# -----------------------------------------------------------------------------
install: $(patsubst %,%.install,$(SERVICES))
develop: $(patsubst %,%.develop,$(SERVICES))
sdist: $(patsubst %,%.sdist,$(SERVICES))
test: $(patsubst %,%.test,$(SERVICES))
doc: $(patsubst %,%.doc,$(SERVICES))
tox: $(patsubst %,%.tox,$(SERVICES))
.PHONY: clean build-clean doc-clean tox-clean
clean: build-clean doc-clean tox-clean
build-clean:
rm -rfv build
rm -rfv *.egg-info
doc-clean:
rm -rvf $(wildcard $(PATH_DOCS)/docs.*)
rm -rvf $(wildcard $(PATH_DOCS)/sphinx.*/source/eidangservices*rst)
rm -rvf $(wildcard $(PATH_DOCS)/sphinx.*/source/modules.rst)
tox-clean:
rm -rfv .tox
.PHONY: ls
ls:
@echo "SERVICES available: \n$(SERVICES_ALL)"
.PHONY: pep8
pep8:
tox -e pep8
# install services
%.install: clean
python setup.py $(@:.install=) install
%.develop: clean
python setup.py $(@:.develop=) develop
%.sdist: clean
python setup.py $(@:.sdist=) sdist
%.test: %.install
python setup.py $(@:.test=) test
%.tox:
tox -e $(call COMMA_LIST,$(addsuffix -$(@:.tox=),$(TOXENVS)))
%.doc: $(PATH_DOCS)/sphinx.% %.make_docs_dest %.sphinx-apidoc
python setup.py $(@:.doc=) build_sphinx \
--build-dir $(PATH_DOCS)/$(BASENAME_DOC).$(@:.doc=)/ \
-s $(word 1,$^)/source/ -b $(SPHINX_BUILDER)
# -----------------------------------------------------------------------------
# utility pattern rules
%.sphinx-apidoc: $(PATH_DOCS)/sphinx.%/source %.sphinx-service-exclude
$(if $(SPHINX_CHECK),,$(error ERROR: sphinx not installed))
sphinx-apidoc -M -o $< $(PATH_EIDANGSERVICES) \
$(filter-out $(PATH_EIDANGSERVICES)/$(@:.sphinx-apidoc=)/ \
$(SPHINX_INCLUDE), $(SPHINX_PKGS)) \
$(SPHINX_EXCLUDE) $(SPHINX_SERVICE_EXCLUDE)
%.sphinx-service-exclude:
$(eval SPHINX_SERVICE_EXCLUDE := $(addsuffix /tests/, \
$(addprefix $(PATH_EIDANGSERVICES)/,$(@:.sphinx-service-exclude=))))
%.make_docs_dest:
mkdir -pv $(PATH_DOCS)/$(BASENAME_DOC).$(@:.make_docs_dest=)
# ---- END OF <Makefile> ----