| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 1 | # Copyright 2017 Sandvine |
| garciadeblas | e6ba40a | 2018-09-27 18:07:38 +0200 | [diff] [blame] | 2 | # Copyright 2017-2018 Telefonica |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 3 | # All Rights Reserved. |
| beierlm | 5b3f4b6 | 2021-02-17 07:22:20 -0500 | [diff] [blame] | 4 | # |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | # not use this file except in compliance with the License. You may obtain |
| 7 | # a copy of the License at |
| beierlm | 5b3f4b6 | 2021-02-17 07:22:20 -0500 | [diff] [blame] | 8 | # |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| beierlm | 5b3f4b6 | 2021-02-17 07:22:20 -0500 | [diff] [blame] | 10 | # |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | # License for the specific language governing permissions and limitations |
| 15 | # under the License. |
| 16 | |
| 17 | # NOTE: pyang and pyangbind are required for build |
| 18 | |
| garciadeblas | 90ffed2 | 2024-03-14 19:50:59 +0100 | [diff] [blame] | 19 | .PHONY: all clean package trees yang-ietf openapi_schemas yang2swagger |
| garciadeblas | 91887e0 | 2025-12-02 12:02:00 +0100 | [diff] [blame] | 20 | JAVA := /usr/lib/jvm/java-21-openjdk-amd64/bin/java |
| garciadeblas | 03c0fb7 | 2022-08-29 17:43:10 +0200 | [diff] [blame] | 21 | PYANG := pyang |
| 22 | ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10... |
| 23 | PYTHON_INTERPRETER := python |
| 24 | else |
| 25 | PYTHON_INTERPRETER := python3 |
| 26 | endif |
| 27 | PYBINDPLUGIN := $(shell $(PYTHON_INTERPRETER) -c \ |
| 28 | 'import pyangbind; import os; print(os.path.join(f"{os.path.dirname(pyangbind.__file__)}", "plugin"))') |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 29 | |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 30 | YANG_DESC_MODELS := vnfd nsd nst nsi etsi-nfv-vnfd etsi-nfv-nsd |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 31 | YANG_RECORD_MODELS := vnfr nsr |
| 32 | PYTHON_MODELS := $(addsuffix .py, $(YANG_DESC_MODELS)) |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 33 | YANG_DESC_TREES := $(addsuffix .tree.txt, $(YANG_DESC_MODELS)) |
| 34 | YANG_DESC_JSTREES := $(addsuffix .html, $(YANG_DESC_MODELS)) |
| 35 | YANG_RECORD_TREES := $(addsuffix .rec.tree.txt, $(YANG_RECORD_MODELS)) |
| 36 | YANG_RECORD_JSTREES := $(addsuffix .rec.html, $(YANG_RECORD_MODELS)) |
| garciadeblas | 878dee4 | 2018-10-28 16:12:42 +0100 | [diff] [blame] | 37 | OPENAPI_SCHEMAS := osm.yaml |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 38 | |
| 39 | OUT_DIR := osm_im |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 40 | TREES_DIR := osm_im_trees |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 41 | MODEL_DIR := models/yang |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 42 | SOL006_MODEL_DIR := sol006_model/src/yang |
| 43 | SOL006_AUGMENTS_DIR := models/augments/* |
| 44 | |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 45 | Q?=@ |
| 46 | |
| garciadeblas | 5a20e9b | 2017-08-29 12:25:24 +0200 | [diff] [blame] | 47 | PYANG_OPTIONS := -Werror |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 48 | |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 49 | all: models trees openapi_schemas |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 50 | $(MAKE) package |
| 51 | |
| sousaedu | 048e5e0 | 2021-07-29 14:55:35 +0200 | [diff] [blame] | 52 | models: sol006_deps $(PYTHON_MODELS) rename_etsi_nfv_py |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 53 | |
| garciadeblas | b01ea7f | 2021-06-21 17:57:36 +0200 | [diff] [blame] | 54 | trees: $(YANG_DESC_TREES) $(YANG_DESC_JSTREES) |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 55 | |
| garciadeblas | 878dee4 | 2018-10-28 16:12:42 +0100 | [diff] [blame] | 56 | openapi_schemas: $(OPENAPI_SCHEMAS) |
| 57 | |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 58 | $(TREES_DIR): |
| 59 | $(Q)mkdir -p $(TREES_DIR) |
| 60 | |
| garciadeblas | 361145b | 2019-10-28 11:11:48 +0100 | [diff] [blame] | 61 | %.py: yang-ietf |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 62 | $(Q)echo generating $@ from $*.yang |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 63 | $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR=$(MODEL_DIR))) |
| 64 | $(if $(findstring etsi,$@), $(eval AUGMENTS_DIR=$(SOL006_AUGMENTS_DIR)),$(eval AUGMENTS_DIR=)) |
| garciadeblas | 03c0fb7 | 2022-08-29 17:43:10 +0200 | [diff] [blame] | 65 | $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) --plugindir "$(PYBINDPLUGIN)" -f pybind -o $(OUT_DIR)/$@ $(AUGMENTS_DIR) $(DIR)/$*.yang |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 66 | |
| garciadeblas | a174419 | 2018-10-28 16:05:18 +0100 | [diff] [blame] | 67 | %.tree.txt: $(TREES_DIR) yang-ietf |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 68 | $(Q)echo generating $@ from $*.yang |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 69 | $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR = $(MODEL_DIR))) |
| garciaale | f3c839e | 2021-01-04 15:14:49 -0300 | [diff] [blame] | 70 | $(if $(findstring etsi,$@), $(eval AUGMENTS_DIR=$(SOL006_AUGMENTS_DIR)),$(eval AUGMENTS_DIR=)) |
| 71 | $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) -f tree -o $(TREES_DIR)/$@ $(DIR)/$*.yang $(AUGMENTS_DIR) |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 72 | |
| garciadeblas | a174419 | 2018-10-28 16:05:18 +0100 | [diff] [blame] | 73 | %.html: $(TREES_DIR) yang-ietf |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 74 | $(Q)echo generating $@ from $*.yang |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 75 | $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR = $(MODEL_DIR))) |
| garciaale | f3c839e | 2021-01-04 15:14:49 -0300 | [diff] [blame] | 76 | $(if $(findstring etsi,$@), $(eval AUGMENTS_DIR=$(SOL006_AUGMENTS_DIR)),$(eval AUGMENTS_DIR=)) |
| 77 | $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) -f jstree -o $(TREES_DIR)/$@ $(DIR)/$*.yang $(AUGMENTS_DIR) |
| garciadeblas | e06b0aa | 2017-12-19 09:21:31 +0100 | [diff] [blame] | 78 | $(Q)sed -r -i 's|data\:image/gif\;base64,R0lGODlhS.*RCAA7|https://osm.etsi.org/images/OSM-logo.png\" width=\"175\" height=\"60|g' $(TREES_DIR)/$@ |
| 79 | $(Q)sed -r -i 's|<a href=\"http://www.tail-f.com">|<a href="http://osm.etsi.org">|g' $(TREES_DIR)/$@ |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 80 | |
| garciadeblas | a174419 | 2018-10-28 16:05:18 +0100 | [diff] [blame] | 81 | %.rec.tree.txt: $(TREES_DIR) yang-ietf |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 82 | $(Q)echo generating $@ from $*.yang |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 83 | $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR=$(MODEL_DIR))) |
| 84 | $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) -f tree -o $(TREES_DIR)/$@ $(DIR)/$*.yang |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 85 | $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.tree.txt |
| 86 | |
| garciadeblas | a174419 | 2018-10-28 16:05:18 +0100 | [diff] [blame] | 87 | %.rec.html: $(TREES_DIR) yang-ietf |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 88 | $(Q)echo generating $@ from $*.yang |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 89 | $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR=$(MODEL_DIR))) |
| 90 | $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) -f jstree -o $(TREES_DIR)/$@ $(DIR)/osm-project.yang $(DIR)/$*.yang |
| garciadeblas | e06b0aa | 2017-12-19 09:21:31 +0100 | [diff] [blame] | 91 | $(Q)sed -r -i 's|data\:image/gif\;base64,R0lGODlhS.*RCAA7|https://osm.etsi.org/images/OSM-logo.png\" width=\"175\" height=\"60|g' $(TREES_DIR)/$@ |
| 92 | $(Q)sed -r -i 's|<a href=\"http://www.tail-f.com">|<a href="http://osm.etsi.org">|g' $(TREES_DIR)/$@ |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 93 | $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.html |
| 94 | |
| garciadeblas | 361145b | 2019-10-28 11:11:48 +0100 | [diff] [blame] | 95 | osm.yaml: yang-ietf yang2swagger |
| garciadeblas | 878dee4 | 2018-10-28 16:12:42 +0100 | [diff] [blame] | 96 | $(Q)echo generating $@ |
| garciadeblas | 90ffed2 | 2024-03-14 19:50:59 +0100 | [diff] [blame] | 97 | $(Q)$(JAVA) -jar ${HOME}/.m2/repository/com/mrv/yangtools/swagger-generator-cli/2.1.0/swagger-generator-cli-2.1.0-executable.jar -yang-dir $(MODEL_DIR) -output $(OUT_DIR)/$@ |
| garciadeblas | 878dee4 | 2018-10-28 16:12:42 +0100 | [diff] [blame] | 98 | |
| garciadeblas | a174419 | 2018-10-28 16:05:18 +0100 | [diff] [blame] | 99 | yang-ietf: |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 100 | $(Q)wget -q https://raw.githubusercontent.com/YangModels/yang/master/standard/ietf/RFC/ietf-yang-types%402013-07-15.yang -O $(MODEL_DIR)/ietf-yang-types.yang |
| 101 | $(Q)wget -q https://raw.githubusercontent.com/YangModels/yang/master/standard/ietf/RFC/ietf-inet-types%402013-07-15.yang -O $(MODEL_DIR)/ietf-inet-types.yang |
| 102 | $(Q)cp $(MODEL_DIR)/ietf-yang-types.yang $(SOL006_MODEL_DIR)/ietf-yang-types.yang |
| 103 | $(Q)cp $(MODEL_DIR)/ietf-inet-types.yang $(SOL006_MODEL_DIR)/ietf-inet-types.yang |
| garciadeblas | a174419 | 2018-10-28 16:05:18 +0100 | [diff] [blame] | 104 | |
| garciadeblas | 878dee4 | 2018-10-28 16:12:42 +0100 | [diff] [blame] | 105 | yang2swagger: |
| 106 | $(Q)mkdir -p ${HOME}/.m2 |
| 107 | $(Q)wget -q -O ${HOME}/.m2/settings.xml https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml |
| garciadeblas | 90ffed2 | 2024-03-14 19:50:59 +0100 | [diff] [blame] | 108 | $(Q)git clone https://github.com/bartoszm/yang2swagger.git |
| 109 | $(Q)git -C yang2swagger checkout tags/2.1.0 |
| 110 | $(Q)mvn -f yang2swagger/pom.xml clean install |
| garciadeblas | 878dee4 | 2018-10-28 16:12:42 +0100 | [diff] [blame] | 111 | |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 112 | package: |
| Mike Marchetti | 09a2710 | 2018-09-24 15:05:51 -0400 | [diff] [blame] | 113 | ./build-docs.sh |
| 114 | |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 115 | sol006_deps: |
| 116 | $(Q)git clone --single-branch --branch v2.6.1 https://forge.etsi.org/rep/nfv/SOL006.git sol006_model |
| 117 | $(Q)patch -p2 < patch/deref_warnings.patch |
| 118 | $(Q)patch -p2 < patch/nested_workaround.patch |
| 119 | |
| sousaedu | 048e5e0 | 2021-07-29 14:55:35 +0200 | [diff] [blame] | 120 | rename_etsi_nfv_py: |
| 121 | mv osm_im/etsi-nfv-nsd.py osm_im/etsi_nfv_nsd.py |
| 122 | mv osm_im/etsi-nfv-vnfd.py osm_im/etsi_nfv_vnfd.py |
| 123 | |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 124 | clean: |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 125 | $(Q)rm -rf dist sol006_model osm_im.egg-info deb deb_dist *.gz osm-imdocs* yang2swagger $(TREES_DIR) |
| garciadeblas | 03c0fb7 | 2022-08-29 17:43:10 +0200 | [diff] [blame] | 126 | $(Q)rm -rf debian/osm-imdocs.install |
| 127 | $(Q)rm -rf osm_im/etsi_nfv_nsd.py osm_im/etsi_nfv_vnfd.py |
| 128 | $(Q)rm -rf osm_im/nsd.py osm_im/nsi.py osm_im/nst.py osm_im/osm.yaml osm_im/vnfd.py |