-#############################################################
+################################################################################
#
# netsnmp
#
-#############################################################
+################################################################################
-NETSNMP_URL:=http://aleron.dl.sourceforge.net/sourceforge/net-snmp/
-NETSNMP_DIR:=$(BUILD_DIR)/net-snmp-5.1.2
-NETSNMP_SOURCE:=net-snmp-5.1.2.tar.gz
-NETSNMP_PATCH1:=net-snmp_5.1.2-6.diff.gz
-NETSNMP_PATCH1_URL:=http://ftp.debian.org/debian/pool/main/n/net-snmp/
+NETSNMP_VERSION = 5.7.3
+NETSNMP_SITE = http://downloads.sourceforge.net/project/net-snmp/net-snmp/$(NETSNMP_VERSION)
+NETSNMP_SOURCE = net-snmp-$(NETSNMP_VERSION).tar.gz
+NETSNMP_LICENSE = Various BSD-like
+NETSNMP_LICENSE_FILES = COPYING
+NETSNMP_INSTALL_STAGING = YES
+NETSNMP_CONF_ENV = ac_cv_NETSNMP_CAN_USE_SYSCTL=yes
+NETSNMP_CONF_OPTS = --with-persistent-directory=/var/lib/snmp \
+ --with-defaults --enable-mini-agent --without-rpm \
+ --with-logfile=none --without-kmem-usage $(DISABLE_IPV6) \
+ --enable-as-needed --without-perl-modules \
+ --disable-embedded-perl --disable-perl-cc-checks \
+ --disable-scripts --with-default-snmp-version="1" \
+ --enable-silent-libtool --enable-mfd-rewrites \
+ --with-sys-contact="root@localhost" \
+ --with-sys-location="Unknown" \
+ --with-mib-modules="$(call qstrip,$(BR2_PACKAGE_NETSNMP_WITH_MIB_MODULES))" \
+ --with-out-mib-modules="$(call qstrip,$(BR2_PACKAGE_NETSNMP_WITHOUT_MIB_MODULES))" \
+ --with-out-transports="Unix" \
+ --disable-manuals
+NETSNMP_INSTALL_STAGING_OPTS = DESTDIR=$(STAGING_DIR) LIB_LDCONFIG_CMD=true install
+NETSNMP_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR) LIB_LDCONFIG_CMD=true install
+NETSNMP_MAKE = $(MAKE1)
+NETSNMP_CONFIG_SCRIPTS = net-snmp-config
-$(DL_DIR)/$(NETSNMP_SOURCE):
- $(WGET) -P $(DL_DIR) $(NETSNMP_URL)/$(NETSNMP_SOURCE)
+NETSNMP_BLOAT_MIBS = BRIDGE DISMAN-EVENT DISMAN-SCHEDULE DISMAN-SCRIPT EtherLike RFC-1215 RFC1155-SMI RFC1213 SCTP SMUX
-$(DL_DIR)/$(NETSNMP_PATCH1):
- $(WGET) -P $(DL_DIR) $(NETSNMP_PATCH1_URL)/$(NETSNMP_PATCH1)
+ifeq ($(BR2_ENDIAN),"BIG")
+ NETSNMP_CONF_OPTS += --with-endianness=big
+else
+ NETSNMP_CONF_OPTS += --with-endianness=little
+endif
-$(NETSNMP_DIR)/.unpacked: $(DL_DIR)/$(NETSNMP_SOURCE) $(DL_DIR)/$(NETSNMP_PATCH1)
- zcat $(DL_DIR)/$(NETSNMP_SOURCE) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
- zcat $(DL_DIR)/$(NETSNMP_PATCH1) | patch -p1 -d $(NETSNMP_DIR)
- toolchain/patch-kernel.sh $(NETSNMP_DIR) package/netsnmp/ netsnmp\*.patch
- touch $(NETSNMP_DIR)/.unpacked
+# OpenSSL
+ifeq ($(BR2_PACKAGE_OPENSSL),y)
+ NETSNMP_DEPENDENCIES += openssl
+ NETSNMP_CONF_OPTS += \
+ --with-openssl=$(STAGING_DIR)/usr/include/openssl
+ifeq ($(BR2_STATIC_LIBS),y)
+ # openssl uses zlib, so we need to explicitly link with it when static
+ NETSNMP_CONF_ENV += LIBS=-lz
+endif
+else
+ NETSNMP_CONF_OPTS += --without-openssl
+endif
-# We set CAN_USE_SYSCTL to no and use /proc since the
-# sysctl code in this thing is apparently intended for
-# freebsd or some such thing...
-$(NETSNMP_DIR)/.configured: $(NETSNMP_DIR)/.unpacked
- (cd $(NETSNMP_DIR); autoconf; \
- ac_cv_CAN_USE_SYSCTL=no \
- PATH=$(TARGET_PATH) \
- ./configure \
- --with-cc=$(TARGET_CROSS)gcc \
- --with-ar=$(TARGET_CROSS)ar \
- --target=$(GNU_TARGET_NAME) \
- --host=$(GNU_TARGET_NAME) \
- --build=$(GNU_HOST_NAME) \
- --with-endianness=little \
- --with-persistent-directory=/var/lib/snmp \
- --enable-ucd-snmp-compatibility \
- --enable-shared \
- --disable-static \
- --with-logfile=none \
- --without-rpm \
- --with-openssl \
- --without-dmalloc \
- --without-efence \
- --without-rsaref \
- --with-sys-contact="root" \
- --with-sys-location="Unknown" \
- --with-mib-modules="host smux ucd-snmp/dlmod" \
- --with-defaults \
- --prefix=/usr \
- --sysconfdir=/etc \
- --mandir=/usr/man \
- --infodir=/usr/info \
- );
- touch $(NETSNMP_DIR)/.configured
+ifneq ($(BR2_PACKAGE_NETSNMP_ENABLE_MIBS),y)
+ NETSNMP_CONF_OPTS += --disable-mib-loading
+ NETSNMP_CONF_OPTS += --disable-mibs
+endif
-$(NETSNMP_DIR)/agent/snmpd: $(NETSNMP_DIR)/.configured
- $(MAKE) -C $(NETSNMP_DIR)
+ifneq ($(BR2_PACKAGE_NETSNMP_ENABLE_DEBUGGING),y)
+ NETSNMP_CONF_OPTS += --disable-debugging
+endif
-$(TARGET_DIR)/usr/sbin/snmpd: $(NETSNMP_DIR)/agent/snmpd
- #$(MAKE) DESTDIR=$(TARGET_DIR) -C $(NETSNMP_DIR) install
- $(MAKE) PREFIX=$(TARGET_DIR)/usr \
- prefix=$(TARGET_DIR)/usr \
- exec_prefix=$(TARGET_DIR)/usr \
- persistentdir=$(TARGET_DIR)/var/lib/snmp \
- infodir=$(TARGET_DIR)/usr/info \
- mandir=$(TARGET_DIR)/usr/man \
- includedir=$(STAGING_DIR)/include/net-snmp \
- ucdincludedir=$(STAGING_DIR)/include/ucd-snmp \
- -C $(NETSNMP_DIR) install;
- rm -rf $(TARGET_DIR)/share/locale $(TARGET_DIR)/usr/info \
- $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/doc
- # Copy the .conf files.
- mkdir -p $(TARGET_DIR)/etc/snmp
- cp $(NETSNMP_DIR)/EXAMPLE.conf $(TARGET_DIR)/etc/snmp/snmpd.conf
- cp $(NETSNMP_DIR)/EXAMPLE-trap.conf $(TARGET_DIR)/etc/snmp/snmptrapd.conf
- -mv $(TARGET_DIR)/usr/share/snmp/mib2c*.conf $(TARGET_DIR)/etc/snmp
- mkdir -p $(TARGET_DIR)/etc/default
- cp $(NETSNMP_DIR)/debian/snmpd.default $(TARGET_DIR)/etc/default/snmpd
- # Remove the unsupported snmpcheck program
- rm $(TARGET_DIR)/usr/bin/snmpcheck
- # Install the "broken" headers
- cp $(NETSNMP_DIR)/agent/mibgroup/struct.h $(STAGING_DIR)/include/net-snmp/agent
- cp $(NETSNMP_DIR)/agent/mibgroup/util_funcs.h $(STAGING_DIR)/include/net-snmp
- cp $(NETSNMP_DIR)/agent/mibgroup/mibincl.h $(STAGING_DIR)/include/net-snmp/library
- cp $(NETSNMP_DIR)/agent/mibgroup/header_complex.h $(STAGING_DIR)/include/net-snmp/agent
+# Remove IPv6 MIBs if there's no IPv6
+ifneq ($(BR2_INET_IPV6),y)
+define NETSNMP_REMOVE_MIBS_IPV6
+ rm -f $(TARGET_DIR)/usr/share/snmp/mibs/IPV6*
+endef
-netsnmp: openssl $(TARGET_DIR)/usr/sbin/snmpd
+NETSNMP_POST_INSTALL_TARGET_HOOKS += NETSNMP_REMOVE_MIBS_IPV6
+endif
-netsnmp-headers: $(TARGET_DIR)/usr/include/net-snmp/net-snmp-config.h
- cp -a $(STAGING_DIR)/include/net-snmp $(TARGET_DIR)/usr/include/net-snmp
- cp -a $(STAGING_DIR)/include/ucd-snmp $(TARGET_DIR)/usr/include/net-snmp
+define NETSNMP_REMOVE_BLOAT_MIBS
+ for mib in $(NETSNMP_BLOAT_MIBS); do \
+ rm -f $(TARGET_DIR)/usr/share/snmp/mibs/$$mib-MIB.txt; \
+ done
+endef
-netsnmp-source: $(DL_DIR)/$(NETSNMP_SOURCE)
+NETSNMP_POST_INSTALL_TARGET_HOOKS += NETSNMP_REMOVE_BLOAT_MIBS
-netsnmp-clean:
- $(MAKE) -C $(NETSNMP_DIR) clean
+define NETSNMP_INSTALL_INIT_SYSV
+ $(INSTALL) -D -m 0755 package/netsnmp/S59snmpd \
+ $(TARGET_DIR)/etc/init.d/S59snmpd
+endef
-netsnmp-dirclean:
- rm -rf $(NETSNMP_DIR)
+define NETSNMP_STAGING_NETSNMP_CONFIG_FIXUP
+ $(SED) "s,^includedir=.*,includedir=\'$(STAGING_DIR)/usr/include\',g" \
+ -e "s,^libdir=.*,libdir=\'$(STAGING_DIR)/usr/lib\',g" \
+ $(STAGING_DIR)/usr/bin/net-snmp-config
+endef
-#############################################################
-#
-# Toplevel Makefile options
-#
-#############################################################
-ifeq ($(strip $(BR2_PACKAGE_NETSNMP)),y)
-TARGETS+=netsnmp
-endif
+NETSNMP_POST_INSTALL_STAGING_HOOKS += NETSNMP_STAGING_NETSNMP_CONFIG_FIXUP
+
+$(eval $(autotools-package))