Makefile: clean egg-info and dist folders
[osm/IM.git] / Makefile
1 # Copyright 2017 Sandvine
2 # All Rights Reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
14 # under the License.
15
16 # NOTE: pyang and pyangbind are required for build
17
18 PYANG:= pyang
19 PYBINDPLUGIN:=$(shell /usr/bin/env python -c \
20 'import pyangbind; import os; print "%s/plugin" % os.path.dirname(pyangbind.__file__)')
21
22 YANG_MODELS := vnfd nsd
23 PYTHON_MODELS := $(addsuffix .py, $(YANG_MODELS))
24 PYTHON_JSONSCHEMAS := $(addsuffix .jsonschema, $(YANG_MODELS))
25
26 OUT_DIR := osm_im
27 MODEL_DIR := models/yang
28 RW_PB_EXT := build/yang/rw-pb-ext.yang
29 Q?=@
30
31 PYANG_OPTIONS := -Werror
32
33 all: $(PYTHON_MODELS) pyangbind $(PYTHON_JSONSCHEMAS)
34 $(MAKE) package
35
36 $(OUT_DIR):
37 $(Q)mkdir -p $(OUT_DIR)
38 $(Q)touch $(OUT_DIR)/__init__.py
39
40 %.py: $(OUT_DIR) $(RW_PB_EXT)
41 $(Q)echo generating $@ from $*.yang
42 $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) --plugindir $(PYBINDPLUGIN) -f pybind -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang
43
44 %.jsonschema: $(OUT_DIR) $(RW_PB_EXT) pyang-json-schema-plugin
45 $(Q)echo generating $@ from $*.yang
46 $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) --plugindir pyang-json-schema-plugin -f json-schema -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang
47
48 $(RW_PB_EXT):
49 $(Q)mkdir -p $$(dirname $@)
50 $(Q)wget -q https://raw.githubusercontent.com/RIFTIO/RIFT.ware/RIFT.ware-4.4.1/modules/core/util/yangtools/yang/rw-pb-ext.yang -O $@
51
52 package:
53 tox -e build
54
55 pyangbind:
56 git clone https://github.com/robshakir/pyangbind
57 cd pyangbind; python setup.py --command-packages=stdeb.command bdist_deb; cd ..
58
59 pyang-json-schema-plugin:
60 git clone https://github.com/cmoberg/pyang-json-schema-plugin
61
62 clean:
63 $(Q)rm -rf build dist osm_im.egg-info deb deb_dist *.gz pyangbind $(OUT_DIR)