diff --git a/funcs.mk b/funcs.mk index 075e900..fea7d45 100644 --- a/funcs.mk +++ b/funcs.mk @@ -50,4 +50,23 @@ $(3)$(1).cddl: $(2) CLEANFILES += $(3)$(1).cddl -endef # cddl_exp_template \ No newline at end of file +endef # cddl_exp_template + +# $(1) - imported cddl file name without .cddl +# $(2) - github url +# $(3) - download location +# $(4) - cddl-xxxx tag name +define get_cddl_release + +get-$(1): $(1).cddl + echo "Fetched cddl-release: " $$^ + +$(1).cddl: + @{ \ + $$(curl) -LO $$(join $(2), $$(join $(3), $$(join $(4)/, $$@))); \ + sed -i.bak 's/^@\.start\.@//' $$@; \ + } + +.PHONY: get-$(1) +CLEANFILES += $(1).cddl.bak +endef # get_cddl_release \ No newline at end of file diff --git a/imports/Makefile b/imports/Makefile index 7878793..8bdc3eb 100644 --- a/imports/Makefile +++ b/imports/Makefile @@ -5,15 +5,15 @@ SHELL := /bin/bash include ../tools.mk include ../funcs.mk -check:: corim-autogen.cddl +check:: get-corim-autogen # Get corim-autogen.cddl -github := https://github.com/ietf-rats-wg/ -corim_rel_dl := draft-ietf-rats-corim/releases/download/ -corim_tag := cddl-8c267cd -corim_url := $(join $(github), $(join $(corim_rel_dl), $(corim_tag))) +CORIM := corim-autogen +CORIM_REPO := https://github.com/ietf-rats-wg/ +CORIM_DL := draft-ietf-rats-corim/releases/download/ +CORIM_TAG := cddl-8c267cd +$(eval $(call get_cddl_release,$(CORIM),$(CORIM_REPO),$(CORIM_DL),$(CORIM_TAG))) -corim-autogen.cddl: ; $(curl) -LO $(corim_url)/$@ ; grep -v '^@\.start\.@' $@ > $@.tmp ; mv $@.tmp $@ CLEANFILES += corim-autogen.cddl