aboutsummaryrefslogtreecommitdiffstats
path: root/net-mgmt/zabbix/Makefile
blob: 2e5fada87d94a8de730e51bee4b38982a5f1d26b (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
# Ports collection makefile for:  zabbix
# Date created:           Jun 18 2003
# Whom:               Sergey Akifyev <asa@gascom.ru>
#
# $FreeBSD$
#

PORTNAME=   zabbix
PORTVERSION=    1.0
PORTEPOCH=  1
CATEGORIES?=    net-mgmt
MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= ${PORTNAME}

MAINTAINER= asa@gascom.ru
COMMENT=    Very advanced network monitoring system

.ifndef(ZABBIX_AGENT_ONLY)
OPTIONS=    PGSQL "Use a PostgreSQL backend" off \
        MYSQL "Use a MySQL backend" on \
        FPING "Use fping for pinging hosts" on
.endif

.include <bsd.port.pre.mk>

.ifdef(ZABBIX_AGENT_ONLY)
PKGNAMESUFFIX=  -agent
PLIST=      ${MASTERDIR}/pkg-plist.agent
PKGMESSAGE= nonexistent
.else # ZABBIX_AGENT_ONLY
LIB_DEPENDS=    netsnmp.6:${PORTSDIR}/net-mgmt/net-snmp
RUN_DEPENDS=    php:${PORTSDIR}/lang/php4-nms
.endif # ZABBIX_AGENT_ONLY

.ifndef(WITHOUT_FPING)
RUN_DEPENDS+=   ${LOCALBASE}/sbin/fping:${PORTSDIR}/net/fping
.endif

.ifndef(ZABBIX_AGENT_ONLY)
.ifndef(WITH_PGSQL)
.ifdef(WITHOUT_MYSQL)
IGNORE=     You should configure to use either a MySQL or PostgreSQL backend
.endif
.endif

.ifdef(WITH_PGSQL)
CONFIGURE_ARGS+=--with-pgsql
LIB_DEPENDS+=   pq.3:${PORTSDIR}/databases/postgresql7
.endif
.ifndef(WITHOUT_MYSQL)
USE_MYSQL=  yes
CONFIGURE_ARGS= --with-mysql
.endif
CONFIGURE_ARGS+=--with-net-snmp
.endif # ZABBIX_AGENT_ONLY

PKGMESSAGE= ${WRKDIR}/pkg-message

USE_REINPLACE=  yes
USE_RC_SUBR=    yes
GNU_CONFIGURE=  yes
CONFIGURE_ENV=  CPPFLAGS=-I${LOCALBASE}/include

ZABBIX_BINARIES=    zabbix_agent zabbix_agentd zabbix_sender
ZABBIX_CONFIGS=     zabbix_agent.conf zabbix_agentd.conf
.ifndef(ZABBIX_AGENT_ONLY)
ZABBIX_BINARIES+=   zabbix_suckerd zabbix_trapper zabbix_trapperd
ZABBIX_CONFIGS+=    zabbix_suckerd.conf zabbix_trapper.conf zabbix_trapperd.conf
.endif

SCRIPT_REGEX=   -e 's|%PREFIX%|${PREFIX}|g' -e 's|%LOCALBASE%|${LOCALBASE}|g'

pre-patch:
.if !defined(ZABBIX_AGENT_ONLY)
    @${SED} ${SCRIPT_REGEX} ${PKGDIR}/pkg-message > ${PKGMESSAGE}
    @${SED} ${SCRIPT_REGEX} ${PKGDIR}/scripts/zabbix.sh.sample > \
        ${WRKDIR}/zabbix.sh.sample
.endif
    @${SED} ${SCRIPT_REGEX} ${PKGDIR}/scripts/zabbix-agent.sh.sample > \
        ${WRKDIR}/zabbix-agent.sh.sample

.ifndef(ZABBIX_AGENT_ONLY)
post-patch:
    @${REINPLACE_CMD} 's|%LOCALBASE%|${LOCALBASE}|' ${WRKSRC}/src/zabbix_sucker/zabbix_sucker.c
.ifdef WITHOUT_FPING
    @${ECHO} 'DisablePinger=yes' >> ${WRKSRC}/misc/conf/zabbix_suckerd.conf
.endif
.endif # ZABBIX_AGENT_ONLY

.if ${ARCH} == "amd64"
post-configure:
    ${ECHO_CMD} "#define HAVE_VA_COPY 1" >> ${WRKSRC}/include/config.h
.endif

do-install:
.for FILE in ${ZABBIX_BINARIES}
    ${INSTALL_PROGRAM} ${WRKSRC}/bin/${FILE} ${PREFIX}/bin
.endfor
    ${MKDIR} ${PREFIX}/etc/zabbix
    ${LN} -sf ${PREFIX}/etc/zabbix /etc/zabbix
.for FILE in ${ZABBIX_CONFIGS}
    ${INSTALL_DATA} ${WRKSRC}/misc/conf/${FILE} \
            ${PREFIX}/etc/zabbix/${FILE}.sample
.endfor
.ifndef(ZABBIX_AGENT_ONLY)
    ${MKDIR} ${PREFIX}/share/zabbix
    ${MKDIR} ${PREFIX}/share/zabbix/create
    ${INSTALL_DATA} ${MASTERDIR}/scripts/dbsetup.sh \
            ${PREFIX}/share/zabbix/create
    ${CP} -Rf ${WRKSRC}/frontends/* ${PREFIX}/share/zabbix
    ${CP} -Rf ${WRKSRC}/create/* ${PREFIX}/share/zabbix/create
    ${CP} -Rf ${WRKSRC}/upgrades/dbpatches ${PREFIX}/share/zabbix
    ${INSTALL_SCRIPT} ${MASTERDIR}/scripts/dbsetup.sh \
            ${PREFIX}/share/zabbix/create
    ${INSTALL_SCRIPT} ${MASTERDIR}/scripts/zabbix.sh.sample \
            ${PREFIX}/etc/rc.d
.endif
    ${INSTALL_SCRIPT} ${MASTERDIR}/scripts/zabbix-agent.sh.sample \
            ${PREFIX}/etc/rc.d
    ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL
.ifndef(ZABBIX_AGENT_ONLY)
    @${CAT} ${PKGMESSAGE}
.endif

.include <bsd.port.post.mk>