diff options
author | Daniel White <[email protected]> | 2014-11-15 02:29:25 +1100 |
---|---|---|
committer | Daniel White <[email protected]> | 2014-11-15 02:36:09 +1100 |
commit | a2af777b6bd0937171acfcd5b7eba2410fa3f8d2 (patch) | |
tree | 6a47d6aeeeeae684c89130c60d6752016d298e93 | |
parent | df5a4779bc3c5a5bffee4186a8f69408262de5d2 (diff) | |
download | erlang.mk-a2af777b6bd0937171acfcd5b7eba2410fa3f8d2.tar.gz erlang.mk-a2af777b6bd0937171acfcd5b7eba2410fa3f8d2.tar.bz2 erlang.mk-a2af777b6bd0937171acfcd5b7eba2410fa3f8d2.zip |
Support for compiling SNMP MIBs
This is unfortunately unsuited as a plugin due to its dependence on erlc
for compilation. The MIBs must be compiled before an Erlang source.
-rw-r--r-- | core/erlc.mk | 20 | ||||
-rw-r--r-- | erlang.mk | 20 |
2 files changed, 38 insertions, 2 deletions
diff --git a/core/erlc.mk b/core/erlc.mk index a7f73f8..6479af7 100644 --- a/core/erlc.mk +++ b/core/erlc.mk @@ -10,6 +10,10 @@ ERLC_OPTS ?= -Werror +debug_info +warn_export_all +warn_export_vars \ COMPILE_FIRST ?= COMPILE_FIRST_PATHS = $(addprefix src/,$(addsuffix .erl,$(COMPILE_FIRST))) +ERLC_MIB_OPTS ?= +COMPILE_MIB_FIRST ?= +COMPILE_MIB_FIRST_PATHS = $(addprefix mibs/,$(addsuffix .mib,$(COMPILE_MIB_FIRST))) + # Verbosity. appsrc_verbose_0 = @echo " APP " $(PROJECT).app.src; @@ -21,6 +25,9 @@ erlc_verbose = $(erlc_verbose_$(V)) xyrl_verbose_0 = @echo " XYRL " $(filter %.xrl %.yrl,$(?F)); xyrl_verbose = $(xyrl_verbose_$(V)) +mib_verbose_0 = @echo " MIB " $(filter %.bin %.mib,$(?F)); +mib_verbose = $(mib_verbose_$(V)) + # Core targets. app:: erlc-include ebin/$(PROJECT).app @@ -47,10 +54,20 @@ define compile_xyrl @rm ebin/*.erl endef +define compile_mib + $(mib_verbose) erlc -v $(ERLC_MIB_OPTS) -o priv/mibs/ \ + -I priv/mibs/ $(COMPILE_MIB_FIRST_PATHS) $(1) + $(mib_verbose) erlc -o include/ -- priv/mibs/*.bin +endef + ifneq ($(wildcard src/),) ebin/$(PROJECT).app:: @mkdir -p ebin/ +ebin/$(PROJECT).app:: $(shell find mibs -type f -name \*.mib) + @mkdir -p priv/mibs/ include + $(if $(strip $?),$(call compile_mib,$?)) + ebin/$(PROJECT).app:: $(shell find src -type f -name \*.erl) \ $(shell find src -type f -name \*.core) $(if $(strip $?),$(call compile_erl,$?)) @@ -70,4 +87,5 @@ erlc-include: fi clean-app: - $(gen_verbose) rm -rf ebin/ + $(gen_verbose) rm -rf ebin/ priv/mibs/ + $(gen_verbose) rm -f $(addprefix include/,$(addsuffix .hrl,$(notdir $(basename $(wildcard mibs/*.mib))))) @@ -211,6 +211,10 @@ ERLC_OPTS ?= -Werror +debug_info +warn_export_all +warn_export_vars \ COMPILE_FIRST ?= COMPILE_FIRST_PATHS = $(addprefix src/,$(addsuffix .erl,$(COMPILE_FIRST))) +ERLC_MIB_OPTS ?= +COMPILE_MIB_FIRST ?= +COMPILE_MIB_FIRST_PATHS = $(addprefix mibs/,$(addsuffix .mib,$(COMPILE_MIB_FIRST))) + # Verbosity. appsrc_verbose_0 = @echo " APP " $(PROJECT).app.src; @@ -222,6 +226,9 @@ erlc_verbose = $(erlc_verbose_$(V)) xyrl_verbose_0 = @echo " XYRL " $(filter %.xrl %.yrl,$(?F)); xyrl_verbose = $(xyrl_verbose_$(V)) +mib_verbose_0 = @echo " MIB " $(filter %.bin %.mib,$(?F)); +mib_verbose = $(mib_verbose_$(V)) + # Core targets. app:: erlc-include ebin/$(PROJECT).app @@ -248,10 +255,20 @@ define compile_xyrl @rm ebin/*.erl endef +define compile_mib + $(mib_verbose) erlc -v $(ERLC_MIB_OPTS) -o priv/mibs/ \ + -I priv/mibs/ $(COMPILE_MIB_FIRST_PATHS) $(1) + $(mib_verbose) erlc -o include/ -- priv/mibs/*.bin +endef + ifneq ($(wildcard src/),) ebin/$(PROJECT).app:: @mkdir -p ebin/ +ebin/$(PROJECT).app:: $(shell find mibs -type f -name \*.mib) + @mkdir -p priv/mibs/ include + $(if $(strip $?),$(call compile_mib,$?)) + ebin/$(PROJECT).app:: $(shell find src -type f -name \*.erl) \ $(shell find src -type f -name \*.core) $(if $(strip $?),$(call compile_erl,$?)) @@ -271,7 +288,8 @@ erlc-include: fi clean-app: - $(gen_verbose) rm -rf ebin/ + $(gen_verbose) rm -rf ebin/ priv/mibs/ + $(gen_verbose) rm -f $(addprefix include/,$(addsuffix .hrl,$(notdir $(basename $(wildcard mibs/*.mib))))) # Copyright (c) 2014, Loïc Hoguin <[email protected]> # This file is part of erlang.mk and subject to the terms of the ISC License. |