95e44d91ed7da5c2f304c28c003ccdec812eea55
[packages.git] / net / net-snmp / Makefile
1 #
2 # Copyright (C) 2006-2009 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=net-snmp
11 PKG_VERSION:=5.4.2.1
12 PKG_RELEASE:=2
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15 PKG_SOURCE_URL:=@SF/net-snmp
16 PKG_MD5SUM:=984932520143f0c8bf7b7ce1fc9e1da1
17
18 include $(INCLUDE_DIR)/package.mk
19
20 define Package/net-snmp/Default
21   SECTION:=net
22   CATEGORY:=Network
23   URL:=http://www.net-snmp.org/
24 endef
25
26 define Package/net-snmp/Default/description
27  Simple Network Management Protocol (SNMP) is a widely used protocol for 
28  monitoring the health and welfare of network equipment (eg. routers), 
29  computer equipment and even devices like UPSs. Net-SNMP is a suite of 
30  applications used to implement SNMP v1, SNMP v2c and SNMP v3 using both 
31  IPv4 and IPv6.
32 endef
33
34
35 define Package/libnetsnmp
36 $(call Package/net-snmp/Default)
37   SECTION:=libs
38   CATEGORY:=Libraries
39   DEPENDS:=+libelf
40   TITLE:=Open source SNMP implementation (libraries)
41 endef
42
43 define Package/libnetsnmp/description
44 $(call Package/net-snmp/Default/description)
45  .
46  This package contains shared libraries, needed by other programs.
47 endef
48
49
50 define Package/snmp-utils
51 $(call Package/net-snmp/Default)
52   DEPENDS:=+libnetsnmp
53   TITLE:=Open source SNMP implementation (utilities)
54 endef
55
56 define Package/snmp-utils/description
57 $(call Package/net-snmp/Default/description)
58  .
59  This package contains SNMP client utilities.
60 endef
61
62
63 define Package/snmpd
64 $(call Package/net-snmp/Default)
65   DEPENDS:=+libnetsnmp
66   TITLE:=Open source SNMP implementation (daemon)
67 endef
68
69 define Package/snmpd/description
70 $(call Package/net-snmp/Default/description)
71  .
72  This package contains the SNMP agent, dynamically linked.
73 endef
74
75
76 define Package/snmpd-static
77 $(call Package/net-snmp/Default)
78   TITLE:=Open source SNMP implementation (daemon)
79   DEPENDS:=+libelf
80 endef
81
82 define Package/snmpd-static/description
83 $(call Package/net-snmp/Default/description)
84  .
85  This package contains the SNMP agent, statically linked.
86 endef
87
88
89 SNMP_MIB_MODULES_INCLUDED = \
90         host/hr_device \
91         host/hr_disk \
92         host/hr_filesys \
93         host/hr_network \
94         host/hr_partition \
95         host/hr_proc \
96         host/hr_storage \
97         host/hr_system \
98         ieee802dot11 \
99         mibII/at \
100         mibII/icmp \
101         mibII/ifTable \
102         mibII/ip \
103         mibII/snmp_mib \
104         mibII/sysORTable \
105         mibII/system_mib \
106         mibII/tcp \
107         mibII/udp \
108         mibII/vacm_context \
109         mibII/vacm_vars \
110         snmpv3/snmpEngine \
111         snmpv3/snmpMPDStats \
112         snmpv3/usmStats \
113         snmpv3/usmUser \
114         tunnel \
115         ucd-snmp/disk \
116         ucd-snmp/dlmod \
117         ucd-snmp/extensible \
118         ucd-snmp/loadave \
119         ucd-snmp/memory \
120         ucd-snmp/pass \
121         ucd-snmp/proc \
122         ucd-snmp/vmstat \
123         util_funcs \
124         utilities/execute \
125
126 SNMP_MIB_MODULES_EXCLUDED = \
127         agent_mibs \
128         agentx \
129         disman/event \
130         disman/schedule \
131         hardware \
132         host \
133         if-mib \
134         mibII \
135         notification \
136         notification-log-mib \
137         snmpv3mibs \
138         target \
139         tcp-mib \
140         ucd_snmp \
141         udp-mib \
142         utilities \
143
144 SNMP_TRANSPORTS_INCLUDED = Callback UDP 
145
146 SNMP_TRANSPORTS_EXCLUDED = TCP TCPIPv6 Unix
147
148 TARGET_CFLAGS += $(FPIC)
149
150 CONFIGURE_ARGS += \
151         --enable-shared \
152         --enable-static \
153         --with-endianness=little \
154         --with-logfile=/var/log/snmpd.log \
155         --with-persistent-directory=/usr/lib/snmp/ \
156         --with-default-snmp-version=1 \
157         --with-sys-contact=root@localhost \
158         --with-sys-location=Unknown \
159         --enable-applications \
160         --disable-debugging \
161         --disable-manuals \
162         --disable-mibs \
163         --disable-scripts \
164         --with-out-mib-modules="$(SNMP_MIB_MODULES_EXCLUDED)" \
165         --with-mib-modules="$(SNMP_MIB_MODULES_INCLUDED)" \
166         --with-out-transports="$(SNMP_TRANSPORTS_EXCLUDED)" \
167         --with-transports="$(SNMP_TRANSPORTS_INCLUDED)" \
168         --without-openssl \
169         --without-libwrap \
170         --without-rpm \
171         --without-zlib \
172
173 ifeq ($(CONFIG_IPV6),y)
174 SNMP_TRANSPORTS_INCLUDED+= UDPIPv6
175 CONFIGURE_ARGS+= --enable-ipv6
176 endif
177
178 TARGET_LDFLAGS += -L$(TOOLCHAIN_DIR)/usr/lib
179
180 ifdef CONFIG_PACKAGE_snmpd-static
181   define Build/Compile/static
182         $(MAKE) -C $(PKG_BUILD_DIR)/agent \
183                 LDFLAGS="$(TARGET_LDFLAGS) -lm -static" \
184                 EXEEXT="-static" \
185                 snmpd-static
186   endef
187 endif
188
189 define Build/Compile
190         $(MAKE) -C $(PKG_BUILD_DIR) \
191                 INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
192                 LDFLAGS="$(TARGET_LDFLAGS) -lm -lc" \
193                 all install     
194         $(Build/Compile/static)
195 endef
196
197 define Build/InstallDev
198         $(INSTALL_DIR) $(2)/bin
199         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/net-snmp-config $(2)/bin/
200         $(SED) 's,=/usr,=$(STAGING_DIR)/usr,g' $(2)/bin/net-snmp-config
201
202         $(INSTALL_DIR) $(1)/usr/include
203         $(CP) $(PKG_INSTALL_DIR)/usr/include/net-snmp $(1)/usr/include/
204         $(INSTALL_DIR) $(1)/usr/lib
205         $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnetsnmp{,agent,helpers,mibs}.{a,so*} $(1)/usr/lib/
206 endef
207
208 define Package/libnetsnmp/install
209         $(INSTALL_DIR) $(1)/usr/lib
210         $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnetsnmp{,agent,helpers,mibs}.so.* $(1)/usr/lib/
211 endef
212
213 define Package/snmpd/conffiles
214 /etc/default/snmpd
215 /etc/config/snmpd
216 endef
217
218 define Package/snmpd/install
219         $(INSTALL_DIR) $(1)/etc/config
220         $(INSTALL_DATA) ./files/snmpd.conf $(1)/etc/config/snmpd
221         $(INSTALL_DIR) $(1)/etc/snmp
222         ln -sf /var/run/snmpd.conf $(1)/etc/snmp/
223         $(INSTALL_DIR) $(1)/etc/default
224         $(INSTALL_DATA) ./files/snmpd.default $(1)/etc/default/snmpd
225         $(INSTALL_DIR) $(1)/etc/init.d
226         $(INSTALL_BIN) ./files/snmpd.init $(1)/etc/init.d/snmpd
227         $(INSTALL_DIR) $(1)/usr/sbin
228         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/snmpd $(1)/usr/sbin/snmpd
229 endef
230
231 define Package/snmpd-static/conffiles
232 /etc/default/snmpd
233 /etc/config/snmpd
234 endef
235
236 define Package/snmpd-static/install
237         $(INSTALL_DIR) $(1)/etc/config
238         $(INSTALL_DATA) ./files/snmpd.conf $(1)/etc/config/snmpd
239         $(INSTALL_DIR) $(1)/etc/snmp
240         ln -sf /var/run/snmpd.conf $(1)/etc/snmp/
241         $(INSTALL_DIR) $(1)/etc/default
242         $(INSTALL_DATA) ./files/snmpd.default $(1)/etc/default/snmpd
243         $(INSTALL_DIR) $(1)/etc/init.d
244         $(INSTALL_BIN) ./files/snmpd.init $(1)/etc/init.d/snmpd
245         $(INSTALL_DIR) $(1)/usr/sbin
246         $(INSTALL_BIN) $(PKG_BUILD_DIR)/agent/snmpd-static $(1)/usr/sbin/snmpd
247 endef
248
249 define Package/snmp-utils/install
250         $(INSTALL_DIR) $(1)/usr/bin
251         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/snmp{get,set,status,test,trap,walk} $(1)/usr/bin/
252 endef
253
254 $(eval $(call BuildPackage,libnetsnmp))
255 $(eval $(call BuildPackage,snmp-utils))
256 $(eval $(call BuildPackage,snmpd))
257 $(eval $(call BuildPackage,snmpd-static))