aboutsummaryrefslogtreecommitdiff
path: root/sysutils/apcupsd/Makefile
blob: f4f4d770ddf5b6beed36ebabab5a28721efad3fc (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
# New ports collection makefile for:	apcupsd
# Date created:		1.12.2001
# Whom:			Lars Köller <Lars.Koeller@Uni-Bielefeld.DE>
#
# $FreeBSD$
#

PORTNAME=	apcupsd
PORTVERSION=	3.10.18
PORTREVISION=	1
CATEGORIES=	sysutils
MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR=	${PORTNAME}

MAINTAINER=	ports@FreeBSD.org
COMMENT=	A daemon for controlling APC UPS

USE_GETTEXT=	yes
USE_REINPLACE=	yes

STARTUP_SCRIPT=	apcupsd.sh.sample
PLIST_SUB=	STARTUP_SCRIPT=${STARTUP_SCRIPT}

HAS_CONFIGURE=	yes
CONFIGURE_ARGS=	--prefix=${PREFIX} --sbindir=${PREFIX}/sbin \
		--with-nologin=/var/run \
		--disable-install-distdir \
		--sysconfdir=${PREFIX}/etc/apcupsd \
		--with-serial-dev=/dev/usv

OPTIONS=	CLIENT_ONLY "Build apcupsd client only (no network server)" off
OPTIONS+=	CGI "Compile with CGI programms to show status" off
OPTIONS+=	USB "Compile with USB Support (READ MANUAL!!!)" off
OPTIONS+=	SNMP "Compile with SNMP Support (READ MANUAL!!!)" off
OPTIONS+=	NOPTHREADS "Compile without pthreads support (READ MANUAL!!!)" off

.include <bsd.port.pre.mk>

.if defined(WITH_NOPTHREADS)
CONFIGURE_ARGS+=--disable-pthreads
.endif

.if defined(WITH_USB)
CONFIGURE_ARGS+=--enable-usb
.endif

.if defined(WITH_CGI)
CONFIGURE_ARGS+=--enable-cgi --with-cgi-bin=${PREFIX}/etc/apcupsd/cgi
LIB_DEPENDS+=	gd.4:${PORTSDIR}/graphics/gd
PLIST_SUB+=	CGI=""
.else
PLIST_SUB+=	CGI="@comment "
.endif

.if defined(WITH_CLIENT_ONLY)
CONFIGURE_ARGS+=--enable-net
.else
CONFIGURE_ARGS+=--enable-master-slave
.endif

.if defined(WITH_SNMP)
LIB_DEPENDS+=	netsnmp.9:${PORTSDIR}/net-mgmt/net-snmp
CONFIGURE_ARGS+=--enable-snmp
.endif

CONFIGURE_ENV=	CPPFLAGS="-I${LOCALBASE}/include -L${LOCALBASE}/lib" \
		CFLAGS="-I${LOCALBASE}/include -L${LOCALBASE}/lib"   \
		LDFLAGS="-L${LOCALBASE}/lib"

# Cause FreeBSD 3.X misses libmenu, libforms and libpanel (curses)
.if ${OSVERSION} > 400000
CONFIGURE_ARGS+=--enable-powerflute --with-libwrap=yes
PLIST_SUB+=	POWERFL=""
.else
PLIST_SUB+=	POWERFL="@comment "
.endif

MAN8=		"apcupsd.8"

PORTDOCS=	manual.pdf

pre-everything::
	@${ECHO_MSG} ""
	@${ECHO_MSG} "You may use the following build options:"
	@${ECHO_MSG} ""
	@${ECHO_MSG} "  WITH_CGI=yes		if you want to build CGI support."
	@${ECHO_MSG} "  WITH_CLIENT_ONLY=yes	if you only want a network client."
	@${ECHO_MSG} "  WITH_USB=yes		to compile with USB support (READ MANUAL!!!)"
	@${ECHO_MSG} "  WITH_SNMP=yes		to compile with SNMP support (READ MANUAL!!!)"
	@${ECHO_MSG} "  WITH_NOPTHREADS=yes	to compile without pthreads support (READ MANUAL!!!)"
	@${ECHO_MSG} ""
.if defined(WITH_CGI)
	@${ECHO_MSG} "===> Building with CGI support."
.endif
.if defined(WITH_CLIENT_ONLY)
	@${ECHO_MSG} "===> Building network client."
.endif

post-configure:
	${REINPLACE_CMD} -e "s|%PREFIX%|${PREFIX}|g" ${WRKSRC}/doc/apcupsd.man

post-install:
# 	If the files presaved are identical with the new one, include then in
# 	the package list. So the port could be removed without problems
	for na in apccontrol commfailure mainsback mastertimeout \
		  changeme commok masterconnect onbattery; do \
		if [ -f ${PREFIX}/etc/apcupsd/$$na.orig ]; then \
			if cmp -s ${PREFIX}/etc/apcupsd/$$na ${PREFIX}/etc/apcupsd/$$na.orig; then \
				${ECHO_CMD} "etc/apcupsd/$$na.orig" >> ${TMPPLIST}; \
			fi \
		fi; \
	done
	${ECHO_CMD} "@unexec if [ -d %D/etc/apcupsd ]; then ${ECHO_CMD} \"If you are permanently removing this port, you should do a ``rm -rf ${PREFIX}/etc/apcupsd`` to remove config files left.\" | ${FMT} ; fi" >> ${TMPPLIST}
# 	Install sample startup script
	${INSTALL_SCRIPT} ${FILESDIR}/${STARTUP_SCRIPT} ${PREFIX}/etc/rc.d/${STARTUP_SCRIPT}
	${INSTALL_DATA} ${FILESDIR}/apcupsd.conf.net-master.sample ${PREFIX}/etc/apcupsd/
	${INSTALL_DATA} ${FILESDIR}/apcupsd.conf.net-slave.sample ${PREFIX}/etc/apcupsd/
# 	If there is already a config file it is installed as ...new
	for na in apcupsd.conf apcupsd.css hosts.conf multimon.conf; do \
		if [ -f ${PREFIX}/etc/apcupsd/$$na ]; then \
			if [ -f ${PREFIX}/etc/apcupsd/$$na.new ]; then \
				${MV} ${PREFIX}/etc/apcupsd/$$na.new ${PREFIX}/etc/apcupsd/$$na.sample; \
			else \
				${CP} ${PREFIX}/etc/apcupsd/$$na ${PREFIX}/etc/apcupsd/$$na.sample; \
			fi; \
		fi; \
	done

.if !defined(NOPORTDOCS)
	@${MKDIR} ${DOCSDIR}
.for filen in ${PORTDOCS}
	${INSTALL_DATA} ${WRKSRC}/doc/texi/${filen} ${DOCSDIR}
.endfor
.endif

.include <bsd.port.post.mk>