aboutsummaryrefslogtreecommitdiffstats
path: root/net-mgmt/net-snmp/Makefile
blob: 58239d0ed7a06f173cb32059f13d0ffe83f6ff23 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# Created by: gpalmer
# $FreeBSD$

PORTNAME=   snmp
PORTVERSION=    5.7.2
PORTREVISION=   16
CATEGORIES= net-mgmt ipv6
MASTER_SITES=   SF/net-${PORTNAME}/net-${PORTNAME}/${PORTVERSION}
PKGNAMEPREFIX=  net-
DISTNAME=   ${PKGNAMEPREFIX}${PORTNAME}-${PORTVERSION}

MAINTAINER= zi@FreeBSD.org
COMMENT=    Extendable SNMP implementation

LICENSE=    BSD3CLAUSE
LICENSE_FILE=   ${WRKSRC}/COPYING

OPTIONS_DEFINE= IPV6 MFD_REWRITES PERL PERL_EMBEDDED PYTHON DUMMY TKMIB \
        DMALLOC MYSQL AX_SOCKONLY UNPRIVILEGED SMUX DOCS
OPTIONS_DEFAULT=IPV6 PERL PERL_EMBEDDED DUMMY SMUX

MFD_REWRITES_DESC=  Build with 64-bit Interface Counters
PERL_EMBEDDED_DESC= Build embedded perl
DUMMY_DESC=     Enable dummy values as placeholders
TKMIB_DESC=     Install graphical MIB browser
DMALLOC_DESC=       Enable dmalloc debug memory allocator
AX_SOCKONLY_DESC=   Disable UDP/TCP transports for agentx
UNPRIVILEGED_DESC=  Allow unprivileged users to execute net-snmp
SMUX_DESC=      Build with SNMP multiplexing (SMUX) support

MAKE_JOBS_UNSAFE=   yes

PORTSCOUT=  skipv:5.7.2.1

GNU_CONFIGURE=  yes
USE_RC_SUBR=    snmpd snmptrapd
USE_OPENSSL=    yes
USE_LDCONFIG=   yes
USES=       perl5 libtool
USE_PERL5=  build run fixpacklist

CFLAGS+=    -I${LOCALBASE}/include -I${PKG_PREFIX}/include
LDFLAGS+=   -L${LOCALBASE}/lib
CONFIGURE_ENV+= PERLPROG="${PERL}" PSPROG="${PS_CMD}" SED="${SED}"
CONFIGURE_ARGS+=--enable-shared --enable-internal-md5 \
        --with-default-snmp-version="${DEFAULT_SNMP_VERSION}" \
        --with-sys-contact="${NET_SNMP_SYS_CONTACT}" \
        --with-sys-location="${NET_SNMP_SYS_LOCATION}" \
        --with-logfile="${NET_SNMP_LOGFILE}" \
        --with-persistent-directory="${NET_SNMP_PERSISTENTDIR}" \
        --with-gnu-ld --with-libwrap \
        --with-ldflags="-lm -lkvm -ldevstat -lpkg -L${LOCALBASE}/lib -L${PKG_PREFIX}/lib ${LCRYPTO}"
SUB_FILES=  pkg-message

.if defined(BATCH)
CONFIGURE_ARGS+=--with-defaults
.endif

.include <bsd.port.options.mk>

.if ${PORT_OPTIONS:MPYTHON}
PYDISTUTILS_PKGNAME?=       netsnmp-python
PYDISTUTILS_PKGVERSION?=    1.0a1
USES+=      python
RUN_DEPENDS+=   ${PYTHON_PKGNAMEPREFIX}setuptools${PYTHON_SUFFIX}>0:${PORTSDIR}/devel/py-setuptools${PYTHON_SUFFIX}
BUILD_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}setuptools${PYTHON_SUFFIX}>0:${PORTSDIR}/devel/py-setuptools${PYTHON_SUFFIX}
CONFIGURE_ARGS+=--with-python-modules
CONFIGURE_ENV+= PYTHONPROG="${PYTHON_CMD}"
MAKE_ENV+=  PYDISTUTILS_INSTALLARGS="${PYDISTUTILS_INSTALLARGS}" STAGEDIR="${STAGEDIR}"
PLIST_SUB+= WITH_PYTHON="" PYTHON_VER=${PYTHON_VER}
PLIST_SUB+= PYDISTUTILS_PKGVERSION=${PYDISTUTILS_PKGVERSION}
.else
PLIST_SUB+= WITH_PYTHON="@comment "
.endif

CONFIGURE_ARGS+=--with-openssl="${OPENSSLBASE}"

.if ${PORT_OPTIONS:MDUMMY}
CONFIGURE_ARGS+=--with-dummy-values
.endif

.if ! ${PORT_OPTIONS:MTKMIB}
EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-local:Makefile.in
PLIST_SUB+= WITH_TKMIB="@comment "
.else
RUN_DEPENDS+=   p5-Tk>=0:${PORTSDIR}/x11-toolkits/p5-Tk
PLIST_SUB+= WITH_TKMIB=""
.endif

.if ${PORT_OPTIONS:MPERL}
CONFIGURE_ARGS+=--with-perl-modules
.if ! ${PORT_OPTIONS:MPERL_EMBEDDED}
CONFIGURE_ARGS+=--disable-embedded-perl
PLIST_SUB+= WITH_PERL_EMBEDDED="@comment "
.else
CONFIGURE_ARGS+=--enable-embedded-perl
PLIST_SUB+= WITH_PERL_EMBEDDED=""
.endif
PLIST_SUB+= WITH_PERL=""
.else
USE_PERL5=  build
CONFIGURE_ARGS+=--disable-embedded-perl --without-perl-modules
PLIST_SUB+= WITH_PERL_EMBEDDED="@comment "
PLIST_SUB+= WITH_PERL="@comment "
.endif

.if ${PORT_OPTIONS:MDMALLOC}
LIB_DEPENDS+=   libdmalloc.so:${PORTSDIR}/devel/dmalloc
CONFIGURE_ARGS+=--with-dmalloc=${LOCALBASE}
.endif

.if ${PORT_OPTIONS:MMYSQL}
USE_MYSQL=  yes
CONFIGURE_ARGS+=--with-mysql
CONFIGURE_ENV+= MYSQLCONFIG=${LOCALBASE}/bin/mysql_config
.endif

.if ${PORT_OPTIONS:MAX_SOCKONLY}
CONFIGURE_ARGS+=--enable-agentx-dom-sock-only
.endif

.if ${PORT_OPTIONS:MIPV6}
CONFIGURE_ARGS+=--enable-ipv6
# --with-transport="UDPIPv6 TCPIPv6" --with-modules=mibII/ipv6"
PLIST_SUB+= WITH_IPV6=""
.else
PLIST_SUB+= WITH_IPV6="@comment "
.endif

.if ${PORT_OPTIONS:MUNPRIVILEGED}
CONFIGURE_ARGS+=--without-root-access
.endif

SHLIB_VERSION=  30
SHLIB_VERSION2= .0.2
PLIST_SUB+= SHLIB_VERSION=${SHLIB_VERSION} SHLIB_VERSION2=${SHLIB_VERSION2}
SCRIPTS_SUB=    PREFIX=${PREFIX} PERL=${PERL}

DEFAULT_SNMP_VERSION?=  3
NET_SNMP_SYS_CONTACT?=  nobody@nowhere.invalid
NET_SNMP_SYS_LOCATION?= somewhere
NET_SNMP_LOGFILE?=  /var/log/snmpd.log
NET_SNMP_PERSISTENTDIR?=/var/net-snmp
NET_SNMP_WITH_MIB_MODULE_LIST+= host disman/event-mib mibII/mta_sendmail mibII/tcpTable ucd-snmp/diskio

.if ${OSVERSION} >= 700028
NET_SNMP_WITH_MIB_MODULE_LIST+= sctp-mib
.endif

.if ${OSVERSION} >= 800000
CONFIGURE_ARGS+=    --with-libs="-lssp_nonshared"
.endif

.if ${OSVERSION} >= 1000000
CFLAGS+=    -D_WANT_IFADDR
.endif

.if ${PORT_OPTIONS:MMFD_REWRITES}
CONFIGURE_ARGS+=--enable-mfd-rewrites
NET_SNMP_WITH_MIB_MODULE_LIST+= if-mib
.endif

.if ${PORT_OPTIONS:MSMUX}
NET_SNMP_WITH_MIB_MODULE_LIST+=     smux
.else
NET_SNMP_WITHOUT_MIB_MODULE_LIST+=  smux
.endif

.if defined(NET_SNMP_WITH_MIB_MODULE_LIST) && \
    !empty(NET_SNMP_WITH_MIB_MODULE_LIST)
CONFIGURE_ARGS+=--with-mib-modules="${NET_SNMP_WITH_MIB_MODULE_LIST}"
.endif

.if defined(NET_SNMP_WITHOUT_MIB_MODULE_LIST) && \
    !empty(NET_SNMP_WITHOUT_MIB_MODULE_LIST)
CONFIGURE_ARGS+=--with-out-mib-modules="${NET_SNMP_WITHOUT_MIB_MODULE_LIST}"
.endif

BIN_FILES=  snmpbulkwalk snmpget snmpgetnext snmpset \
        snmpstatus snmptest snmptranslate snmptrap snmpwalk \
        snmptable snmpbulkget snmpdelta snmpdf agentxtrap \
        snmpvacm snmpusm encode_keychange snmpnetstat
LIB_FILES=  libnetsnmp.so.${SHLIB_VERSION}${SHLIB_VERSION2} \
        libnetsnmpagent.so.${SHLIB_VERSION}${SHLIB_VERSION2} \
        libnetsnmpmibs.so.${SHLIB_VERSION}${SHLIB_VERSION2} \
        libnetsnmphelpers.so.${SHLIB_VERSION}${SHLIB_VERSION2} \
        libnetsnmptrapd.so.${SHLIB_VERSION}${SHLIB_VERSION2}
SBIN_FILES= snmpd snmptrapd
STARTUP_DIR=    ${PREFIX}/etc/rc.d
SCRIPT_FILES=   snmpcheck.def mib2c fixproc ipf-mod.pl snmpconf \
        traptoemail
.if ${PORT_OPTIONS:MTKMIB}
SCRIPT_FILES+=  tkmib
.endif
DOC_FILES=  AGENT.txt COPYING FAQ NEWS README \
        README.agentx README.krb5 README.snmpv3 README.thread \
        agent/mibgroup/README.smux

CONFLICTS=  ucd-snmp-4.* net-snmp-5.3.*

.include <bsd.port.pre.mk>

.if defined(WITH_OPENSSL_PORT) || defined(OPENSSL_PORT)
LCRYPTO=    -lcrypto
.else
LCRYPTO=
.endif

pre-everything::
    @${ECHO_MSG}
    @${ECHO_MSG} "You may use the following build options:"
    @${ECHO_MSG}
    @${ECHO_MSG} "DEFAULT_SNMP_VERSION=\"3\"    Default version of SNMP to use."
    @${ECHO_MSG} "NET_SNMP_SYS_CONTACT=\"${NET_SNMP_SYS_CONTACT}\""
    @${ECHO_MSG} "              Default system contact."
    @${ECHO_MSG} "NET_SNMP_SYS_LOCATION=\"${NET_SNMP_SYS_LOCATION}\""
    @${ECHO_MSG} "              Default system location."
    @${ECHO_MSG} "NET_SNMP_LOGFILE=\"${NET_SNMP_LOGFILE}\""
    @${ECHO_MSG} "              Default log file location for snmpd."
    @${ECHO_MSG} "NET_SNMP_PERSISTENTDIR=\"${NET_SNMP_PERSISTENTDIR}\""
    @${ECHO_MSG} "              Default directory for persistent data storage."
    @${ECHO_MSG} "NET_SNMP_WITH_MIB_MODULE_LIST=\"${NET_SNMP_WITH_MIB_MODULE_LIST}\""
    @${ECHO_MSG} "                             MIBs to add to the build."
    @${ECHO_MSG} "NET_SNMP_WITHOUT_MIB_MODULE_LIST=\"${NET_SNMP_WITHOUT_MIB_MODULE_LIST}\""
    @${ECHO_MSG} "                             MIBs to omit from the build."
    @${ECHO_MSG}

post-patch:
.for filename in ${SCRIPT_FILES}
    @${REINPLACE_CMD} -e 's|/usr/local|${PREFIX}|' ${WRKSRC}/local/${filename}
.endfor
.if ${OSVERSION} >= 900007
    @${REINPLACE_CMD} -e 's!utmp_p->ut_name!utmp_p->ut_user!' \
        ${WRKSRC}/agent/mibgroup/host/hr_system.c
.endif

post-configure:
    @${FIND} ${WRKSRC} -name Makefile | \
        ${XARGS} ${REINPLACE_CMD} -E -e '/^INSTALL[     ]+=/s|$$| -m 755|'
.for hdr in sys/mbuf.h netinet/in_pcb.h netinet/in_var.h netinet/ip6.h
    @${REINPLACE_CMD} -E -e '\
        s!^.*#undef.*(HAVE_${hdr:tu:S/./_/g:S/\//_/g}).*$$!#define \1 1!g' \
            ${WRKSRC}/include/net-snmp/net-snmp-config.h
.endfor
.if ${PORT_OPTIONS:MPYTHON}
    @(cd ${WRKSRC}/python; \
    ${SETENV} ${MAKE_ENV} ${PYTHON_CMD} ${PYSETUP} setopt -c bdist_egg \
        -o plat-name -s "" --basedir=${WRKSRC}; \
    ${SETENV} ${MAKE_ENV} ${PYTHON_CMD} ${PYSETUP} setopt -c bdist \
        -o plat-name -s "" --basedir=${WRKSRC})
.endif

post-build:
.if ${PORT_OPTIONS:MPERL}
    ${FIND} ${WRKSRC}/perl -name Makefile | \
    ${XARGS} ${REINPLACE_CMD} -E -e '\
        s!^(PREFIX) = .*!\1 = ${PREFIX}!; \
        s!^(INSTALLMAN3DIR|INSTALLSITEMAN3DIR) = .*!\1 = ${PREFIX}/man/man3!; \
        s!^(INSTALLSITELIB|INSTALLSITEARCH) = /usr/local/(.*)!\1 = ${PREFIX}/\2!; \
        s! doc_(perl|site|\$$\(INSTALLDIRS\))_install$$!!; \
        '
.else
    ${REINPLACE_CMD} -e 's| perlinstall||' ${WRKSRC}/Makefile
.endif

post-install: strip-files install-config-files install-doc-files display-message
    @${MKDIR} ${STAGEDIR}/var/agentx
    @(cd ${STAGEDIR}${PREFIX}/lib && ${LN} -sf libnetsnmp.so.${SHLIB_VERSION} libnetsnmp.so)
    @(cd ${STAGEDIR}${PREFIX}/lib && ${LN} -sf libnetsnmpagent.so.${SHLIB_VERSION} libnetsnmpagent.so)
    @(cd ${STAGEDIR}${PREFIX}/lib && ${LN} -sf libnetsnmphelpers.so.${SHLIB_VERSION} libnetsnmphelpers.so)
    @(cd ${STAGEDIR}${PREFIX}/lib && ${LN} -sf libnetsnmpmibs.so.${SHLIB_VERSION} libnetsnmpmibs.so)
    @(cd ${STAGEDIR}${PREFIX}/lib && ${LN} -sf libnetsnmptrapd.so.${SHLIB_VERSION} libnetsnmptrapd.so)

strip-files:
    (cd ${STAGEDIR}${PREFIX}/bin; ${STRIP_CMD} ${BIN_FILES})
    (cd ${STAGEDIR}${PREFIX}/lib; ${STRIP_CMD} ${LIB_FILES})
    (cd ${STAGEDIR}${PREFIX}/sbin; ${STRIP_CMD} ${SBIN_FILES})

install-config-files:
    ${INSTALL_DATA} ${WRKSRC}/EXAMPLE.conf ${STAGEDIR}${DATADIR}/snmpd.conf.example

install-doc-files:
.if ${PORT_OPTIONS:MDOCS}
    @${MKDIR} ${STAGEDIR}${DOCSDIR}
. for filename in ${DOC_FILES}
    @${INSTALL_DATA} ${WRKSRC}/${filename} ${STAGEDIR}${DOCSDIR}
. endfor
.endif

display-message:
    ${ECHO_MSG}
    ${CAT} ${PKGMESSAGE}

# Maintainer's note:
#   Don't forget to bump library version in these ports.
#   french/plgrenouille,graphics/hpoj,lang/php4,lang/php5,mail/cyrus-imapd22,mail/cyrus-imapd23,misc/kdeutils3,net-mgmt/braa,net-mgmt/docsis,net-mgmt/mbrowse,net-mgmt/nagios-snmp-plugins,net-mgmt/p5-SNMP-Info,net-mgmt/py-yapsnmp,net-mgmt/sdig,net-mgmt/zabbix,net/cactid,net/wireshark,net/ifstat,net/quagga,net/rtg,print/hplip,security/libfwbuilder,sysutils/apcupsd,sysutils/jailadmin,sysutils/nut

.include <bsd.port.post.mk>