diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-12-03 22:01:19 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2019-12-06 20:58:56 +0100 |
commit | 0d4d4dd840e06c18250d73f27de61261ff141944 (patch) | |
tree | 5c515082495983658e22d27b1a838b2598e3ecd8 /Makefile | |
parent | 1ac177febfdd0dfc5a5b40a1b30294de0e2a45e0 (diff) | |
download | vyos-1x-0d4d4dd840e06c18250d73f27de61261ff141944.tar.gz vyos-1x-0d4d4dd840e06c18250d73f27de61261ff141944.zip |
T1843: run interface-definitions though GCC preprocessor
A lot of XML code is duplicated (VLAN, interface address) for instance. Such
XML definitions should be moved to feature.xml.i files and then just pulled in
via GCC preprocessor #include definition in e.g. bond or ethernet definitions.
This will give us the ability to single-source repeating node definitions as:
* Interface Address
* Interface Description
* Interface Disable
* VLAN (both vif-s and vif-c)
The .in suffix of the interface-definitions is a marker that those files are
input files to the GCC preprocessor. They will be rendered into proper XML
files in the build directory.
Some node definitions have been reworder to remove escaped double quote
occurances which would have been warned about by the GCC preprocessor.
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 32 |
1 files changed, 28 insertions, 4 deletions
@@ -1,12 +1,35 @@ TMPL_DIR := templates-cfg OP_TMPL_DIR := templates-op +BUILD_DIR := build +CFLAGS := + +src = $(wildcard interface-definitions/*.xml.in) +obj = $(src:.xml.in=.xml) + +%.xml: %.xml.in + @echo Generating $(BUILD_DIR)/$@ from $< + # -ansi This turns off certain features of GCC that are incompatible + # with ISO C90. Without this regexes containing '/' as in an URL + # won't work + # -x c By default GCC guesses the input language from its file extension, + # thus XML is unknown. Force it to C language + # -E Stop after the preprocessing stage + # -undef Do not predefine any system-specific or GCC-specific macros. + # -nostdinc Do not search the standard system directories for header files + # -P Inhibit generation of linemarkers in the output from the + # preprocessor + @gcc -ansi -x c -E -undef -nostdinc -P -o $(BUILD_DIR)/$@ -c $< + +$(BUILD_DIR): + install -d -m 0755 $(BUILD_DIR)/interface-definitions + install -d -m 0755 $(BUILD_DIR)/op-mode-definitions .PHONY: interface_definitions .ONESHELL: -interface_definitions: +interface_definitions: $(BUILD_DIR) $(obj) mkdir -p $(TMPL_DIR) - find $(CURDIR)/interface-definitions/ -type f -name "*.xml" | xargs -I {} $(CURDIR)/scripts/build-command-templates {} $(CURDIR)/schema/interface_definition.rng $(TMPL_DIR) || exit 1 + find $(BUILD_DIR)/interface-definitions -type f -name "*.xml" | xargs -I {} $(CURDIR)/scripts/build-command-templates {} $(CURDIR)/schema/interface_definition.rng $(TMPL_DIR) || exit 1 # XXX: delete top level node.def's that now live in other packages rm -f $(TMPL_DIR)/firewall/node.def @@ -56,8 +79,9 @@ all: clean interface_definitions op_mode_definitions .PHONY: clean clean: - rm -rf $(TMPL_DIR)/* - rm -rf $(OP_TMPL_DIR)/* + rm -rf $(BUILD_DIR) + rm -rf $(TMPL_DIR) + rm -rf $(OP_TMPL_DIR) .PHONY: test test: |