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