# ``The contents of this file are subject to the Erlang Public License,
# Version 1.1, (the "License"); you may not use this file except in
# compliance with the License. You should have received a copy of the
# Erlang Public License along with this software. If not, it can be
# retrieved via the world wide web at http://www.erlang.org/.
# 
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
# 
# The Initial Developer of the Original Code is Ericsson Utvecklings AB.
# Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
# AB. All Rights Reserved.''
# 
#     $Id$
#
include $(ERL_TOP)/make/target.mk
include $(ERL_TOP)/make/$(TARGET)/otp.mk

# ----------------------------------------------------
# Application version
# ----------------------------------------------------
include ../vsn.mk
VSN=$(SNMPEA_VSN)

# ----------------------------------------------------
# Release directory specification
# ----------------------------------------------------
RELSYSDIR = $(RELEASE_PATH)/lib/snmp-$(VSN)

# ----------------------------------------------------
# Common macros
# ----------------------------------------------------
MIB_FILES = \
	RFC1213-MIB.mib \
	STANDARD-MIB.mib \
	SNMP-COMMUNITY-MIB.mib \
	SNMPv2-TC.mib \
	SNMPv2-TM.mib \
	SNMPv2-MIB.mib \
	SNMP-FRAMEWORK-MIB.mib \
	SNMP-MPD-MIB.mib \
	SNMP-NOTIFICATION-MIB.mib \
	SNMP-TARGET-MIB.mib \
	SNMP-USER-BASED-SM-MIB.mib \
	SNMP-VIEW-BASED-ACM-MIB.mib \
	OTP-SNMPEA-MIB.mib

STD_v1_MIB_FILES = \
	RFC1155-SMI.mib \
	RFC-1212.mib \
	RFC-1215.mib

STD_v2_MIB_FILES = \
	SNMPv2-SMI.mib \
	SNMPv2-CONF.mib 

FUNCS_FILES = \
	STANDARD-MIB.funcs \
	SNMPv2-MIB.funcs \
	SNMP-COMMUNITY-MIB.mib \
	SNMP-FRAMEWORK-MIB.mib \
	SNMP-MPD-MIB.mib \
	SNMP-NOTIFICATION-MIB.funcs \
	SNMP-TARGET-MIB.funcs \
	SNMP-USER-BASED-SM-MIB.mib \
	SNMP-VIEW-BASED-ACM-MIB.mib

V1_MIB_FILES= v1/OTP-SNMPEA-MIB.mib.v1

BIN_TARGETS= $(MIB_FILES:%.mib=$(SNMP_BIN_TARGET_DIR)/%.bin)
HRL_TARGETS= $(MIB_FILES:%.mib=$(SNMP_HRL_TARGET_DIR)/%.hrl)

# NOTE: Order is important; some MIBs include others
BUILD_MIBS = RFC1213-MIB STANDARD-MIB SNMPv2-TC SNMPv2-TM SNMPv2-MIB SNMP-FRAMEWORK-MIB SNMP-MPD-MIB SNMP-TARGET-MIB SNMP-NOTIFICATION-MIB SNMP-COMMUNITY-MIB SNMP-USER-BASED-SM-MIB SNMP-VIEW-BASED-ACM-MIB OTP-REG OTP-SNMPEA-MIB
TARGET_FILES= $(BUILD_MIBS:%=$(SNMP_BIN_TARGET_DIR)/%.bin) $(HRL_TARGETS)  $(V1_MIB_FILES)


# ----------------------------------------------------
# FLAGS
# ----------------------------------------------------
#SNMP_FLAGS = -I $(ERL_TOP)/lib/sasl/priv/mibs -I ../priv/mibs

# ----------------------------------------------------
# Targets
# ----------------------------------------------------

debug opt: $(TARGET_FILES)

$(SNMP_BIN_TARGET_DIR)/OTP-REG.bin:	$(ERL_TOP)/lib/sasl/mibs/OTP-REG.mib
	$(ERLC) -pa $(SNMP_TOOLKIT)/ebin -I $(SNMP_TOOLKIT)/priv/mibs $(SNMP_FLAGS) -o $(SNMP_BIN_TARGET_DIR) $<

clean:
	rm -f $(TARGET_FILES)

docs:

v1/%.mib.v1: %.mib
	$(ERL_TOP)/lib/snmp/bin/snmp-v2tov1 -o $@ $<


# ----------------------------------------------------
# Release Target
# ---------------------------------------------------- 
include $(ERL_TOP)/make/otp_release_targets.mk

release_spec: opt
	$(INSTALL_DIR) $(RELSYSDIR)/mibs
	$(INSTALL_DIR) $(RELSYSDIR)/mibs/v1
	$(INSTALL_DATA) $(STD_v2_MIB_FILES) $(MIB_FILES) $(FUNCS_FILES) $(RELSYSDIR)/mibs
	$(INSTALL_DATA) $(STD_v1_MIB_FILES) $(V1_MIB_FILES) $(RELSYSDIR)/mibs/v1
	$(INSTALL_DIR) $(RELSYSDIR)/include
	$(INSTALL_DATA) $(HRL_TARGETS) $(RELSYSDIR)/include
	$(INSTALL_DIR) $(RELSYSDIR)/priv/mibs
	$(INSTALL_DATA) $(BIN_TARGETS) $(RELSYSDIR)/priv/mibs

release_docs_spec:
