aboutsummaryrefslogtreecommitdiff
path: root/sysutils/nut/Makefile
blob: bb9e7967190e58906e7559aa5474dde796ebb19b (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
# Created by: Boris Popov <bp@FreeBSD.org>

PORTNAME=	nut
PORTVERSION=	2.7.4
PORTREVISION=	18
CATEGORIES=	sysutils
MASTER_SITES=	http://www.networkupstools.org/source/${PORTVERSION:R}/
DISTFILES=	${DISTNAME}${EXTRACT_SUFX}
EXTRACT_ONLY=	${DISTNAME}${EXTRACT_SUFX}

MAINTAINER=	cy@FreeBSD.org
COMMENT=	Network UPS Tools

GNU_CONFIGURE=	yes
USE_LDCONFIG=	yes
USES=		autoreconf gmake pkgconfig libtool

NUT_USER?=	uucp
NUT_GROUP?=	uucp
STATEDIR?=	/var/db/nut
PLIST_SUB+=	NUT_USER=${NUT_USER}
PLIST_SUB+=	NUT_GROUP=${NUT_GROUP}

OPTIONS_DEFAULT=SERIAL USB SNMP NEON IPMI_OFF SSL_OFF
OPTIONS_DEFINE=	SERIAL USB SNMP NEON PDU CGI BASH AVAHI DOCS
OPTIONS_SINGLE=	IPMI SSL
OPTIONS_SINGLE_IPMI=	IPMI_OFF IPMIPSU FREEIPMI
OPTIONS_SINGLE_SSL=	SSL_OFF OPENSSL NSS

SERIAL_DESC=	SERIAL support
USB_DESC=	USB support
SNMP_DESC=	SNMP support
NEON_DESC=	NEON XML/HTTP support
PDU_DESC=	Powerman PDU support
CGI_DESC=	Web CGI interface
BASH_DESC=	Bash Completion support
AVAHI_DESC=	Avahi support
IPMI_OFF_DESC=	No IPMI support
FREEIPMI_DESC=	freeipmi support
IPMIPSU_DESC=	Use nut-ipmipsu support (experimental)
SSL_OFF_DESC=	No SSL support

USE_RC_SUBR=	nut nut_upsmon nut_upslog
SUB_LIST+=	STATEDIR=${STATEDIR}
PLIST_SUB+=	STATEDIR=${STATEDIR}

PORTDOCS=	*

.include <bsd.port.options.mk>

CONFIGURE_ARGS=	--sysconfdir=${PREFIX}/etc/nut \
		--program-transform-name="" \
		--localstatedir=${STATEDIR} \
		--datadir=${PREFIX}/etc/nut \
		--with-devd-dir=${PREFIX}/etc/devd \
		--with-drvpath=${PREFIX}/libexec/nut \
		--with-statepath=${STATEDIR} \
		--with-altpidpath=${STATEDIR} \
		--with-pidpath=${STATEDIR} \
		--with-pkgconfig-dir=${PREFIX}/libdata/pkgconfig \
		--with-user=${NUT_USER} \
		--with-group=${NUT_GROUP} \
		--with-dev

.if ${PORT_OPTIONS:MCGI}
LIB_DEPENDS+=	libgd.so:graphics/gd
CGIDIR?=	${PREFIX}/www/cgi-bin/${PORTNAME}
CGIDIR_REL?=	${CGIDIR:S,^${PREFIX}/,,}
CONFIGURE_ARGS+=	--with-cgi --with-cgipath=${CGIDIR} \
			--with-htmlpath=${WWWDIR} \
			--with-gd-includes=-I${LOCALBASE}/include \
			--with-gd-libs="-L${LOCALBASE}/lib -lgd"
PLIST_SUB+=	NUT_CGI=""
PLIST_SUB+=	CGIDIR="${CGIDIR_REL}"
PLIST_SUB+=	CGIETCDIR="etc/nut/"
.else
CONFIGURE_ARGS+=	--without-cgi
PLIST_SUB+=	NUT_CGI="@comment "
.endif

.if ${PORT_OPTIONS:MSERIAL}
CONFIGURE_ARGS+=	--with-serial
PLIST_SUB+=	NUT_SERIAL=""
.else
CONFIGURE_ARGS+=	--without-serial
PLIST_SUB+=	NUT_SERIAL="@comment "
.endif

.if ${PORT_OPTIONS:MUSB}
#EXTRA_PATCHES=	${FILESDIR}/extra-patch-m4_nut_check_libusb.m4
CONFIGURE_ARGS+=	--with-usb=auto
PLIST_SUB+=	NUT_USB=""
.else
CONFIGURE_ARGS+=	--without-usb
PLIST_SUB+=	NUT_USB="@comment "
.endif

.if ${PORT_OPTIONS:MSNMP}
LIB_DEPENDS+=	libnetsnmp.so:net-mgmt/net-snmp
CONFIGURE_ARGS+=	--with-snmp
PLIST_SUB+=	NUT_SNMP=""
.else
CONFIGURE_ARGS+=	--without-snmp
PLIST_SUB+=	NUT_SNMP="@comment "
.endif

.if ${PORT_OPTIONS:MNEON}
LIB_DEPENDS+=	libneon.so:www/neon
CONFIGURE_ARGS+=	--with-neon
PLIST_SUB+=	NUT_NEON=""
.else
CONFIGURE_ARGS+=	--without-neon
CONFIGURE_ARGS+=	--disable-neon
PLIST_SUB+=	NUT_NEON="@comment "
.endif

.if ${PORT_OPTIONS:MPDU}
LIB_DEPENDS+=	libpowerman.so:sysutils/powerman
CONFIGURE_ARGS+=	--with-powerman
PLIST_SUB+=	NUT_PDU=""
.else
CONFIGURE_ARGS+=	--without-powerman
PLIST_SUB+=	NUT_PDU="@comment "
.endif

.if ${PORT_OPTIONS:MBASH}
BUILD_DEPENDS+=	${LOCALBASE}/share/bash-completion/bash_completion.sh:shells/bash-completion
RUN_DEPENDS+=	${LOCALBASE}/share/bash-completion/bash_completion.sh:shells/bash-completion
PLIST_SUB+=	BASH=""
.else
PLIST_SUB+=	BASH="@comment "
.endif

.if ${PORT_OPTIONS:MAVAHI}
BUILD_DEPENDS+=	${LOCALBASE}/include/avahi-ui/avahi-ui.h:net/avahi-header
BUILD_DEPENDS+=	avahi-daemon:net/avahi-app
RUN_DEPENDS+=	avahi-daemon:net/avahi-app
CONFIGURE_ARGS+=	--with-avahi
.else
CONFIGURE_ARGS+=	--without-avahi
.endif

.if ${PORT_OPTIONS:MFREEIPMI}
LIB_DEPENDS+=	libfreeipmi.so:sysutils/freeipmi
CONFIGURE_ARGS+=	--with-freeipmi
PLIST_SUB+=	NUT_FREEIPMI=""
.else
CONFIGURE_ARGS+=	--without-freeipmi
PLIST_SUB+=	NUT_FREEIPMI="@comment "
.endif

.if ${PORT_OPTIONS:MIPMIPSU}
LIB_DEPENDS+=	libfreeipmi.so:sysutils/freeipmi
CONFIGURE_ARGS+=	--with-ipmi
PLIST_SUB+=	NUT_IPMIPSU=""
.else
CONFIGURE_ARGS+=	--without-ipmi
PLIST_SUB+=	NUT_IPMIPSU="@comment "
.endif

.if ${PORT_OPTIONS:MOPENSSL}
USES+=	ssl
CONFIGURE_ARGS+=	--with-openssl
.elif ${PORT_OPTIONS:MNSS}
LIB_DEPENDS=		libnss3.so:security/nss
CONFIGURE_ARGS+=	--with-nss
.else
CONFIGURE_ARGS+=	--without-openssl --without-ssl
.endif

pre-install:
	@${MKDIR} ${STAGEDIR}${PREFIX}/libexec/nut
	@${REINPLACE_CMD} -e 's/device-name\*/cdev/g' ${WRKSRC}/scripts/devd/nut-usb.conf

post-install:
	@${MKDIR} ${STAGEDIR}${STATEDIR}
	@${MKDIR} ${STAGEDIR}${PREFIX}/etc/syslog.d
.if ${PORT_OPTIONS:MBASH}
	@${MKDIR} ${STAGEDIR}${PREFIX}/etc/bash_completion.d/
	${INSTALL_DATA} ${WRKSRC}/scripts/misc/nut.bash_completion ${STAGEDIR}${PREFIX}/etc/bash_completion.d/
.endif
.if ${PORT_OPTIONS:MDOCS}
	@${MKDIR} ${STAGEDIR}${DOCSDIR}/cables
	${INSTALL_DATA} ${WRKSRC}/docs/cables/*.txt ${STAGEDIR}${DOCSDIR}/cables
	${INSTALL_DATA} ${WRKSRC}/docs/*.txt ${STAGEDIR}${DOCSDIR}
	${INSTALL_DATA} ${WRKSRC}/docs/FAQ.txt ${STAGEDIR}${DOCSDIR}
.for file in AUTHORS COPYING ChangeLog INSTALL MAINTAINERS NEWS README UPGRADING
	${INSTALL_DATA} ${WRKSRC}/${file} ${STAGEDIR}${DOCSDIR}
.endfor
.endif
	@${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
	${INSTALL_DATA} ${PATCHDIR}/nut.syslog ${STAGEDIR}${EXAMPLESDIR}/syslog.sample
	${INSTALL_DATA} ${PATCHDIR}/nut.newsyslog ${STAGEDIR}${EXAMPLESDIR}/newsyslog.sample
	${MKDIR} ${STAGEDIR}/var/log/nut

.include <bsd.port.mk>