aboutsummaryrefslogtreecommitdiff
path: root/net/quagga/Makefile
blob: cb6dcbb7dfdcf707ec9b891793ed2a0c25f2a752 (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
# New ports collection makefile for:    quagga
# Date created:         3 September 2003
# Whom:                 Bruce M Simpson <bms@FreeBSD.org>
#
# $FreeBSD$
#

PORTNAME=	quagga
PORTVERSION=	0.96.5
PORTREVISION=	0
CATEGORIES=	net ipv6
MASTER_SITES=	http://quagga.net/download/

PATCH_SITES=	http://quagga.net/

MAINTAINER=	boris@tagnet.ru
COMMENT=	Free RIPv1, RIPv2, OSPFv2, BGP4, IS-IS route software (server/reflector)

CONFLICTS=	zebra-devel-* zebra-0*

GNU_CONFIGURE=	yes
USE_GMAKE=	yes
USE_SUBMAKE=	yes
WANT_AUTOCONF_VER=	259
WANT_AUTOMAKE_VER=	18
AUTOMAKE_ARGS=	-a -i

MAN1=		vtysh.1
MAN8=		bgpd.8 ospf6d.8 ospfd.8 ripd.8 ripngd.8 zebra.8

CONFIGURE_ARGS+=--includedir=${PREFIX}/include --enable-exampledir=${PREFIX}/share/examples/quagga
SCRIPTS_ENV=	WRKDIRPREFIX=${WRKDIRPREFIX} WITH_SNMP_4=${WITH_SNMP_4} \
		SYSCONF_DIR=${SYSCONF_DIR} SYSSTATE_DIR=${SYSSTATE_DIR} \
		ENABLE_USER=${ENABLE_USER} ENABLE_GROUP=${ENABLE_GROUP}

pre-fetch:
	@${SETENV} ${SCRIPTS_ENV} ${SH} ${SCRIPTDIR}/configure.quagga

.if exists(${WRKDIRPREFIX}${.CURDIR}/Makefile.inc)
.include "${WRKDIRPREFIX}${.CURDIR}/Makefile.inc"
.endif

.if ${CONFIGURE_ARGS:M--enable-opaque-lsa} != ""
PLIST_SUB+=	OSPFAPI_HEADER="include/quagga/ospfapi/ospf_apiclient.h"
PLIST_SUB+=	OSPFAPI_PATH="@dirrm include/quagga/ospfapi"
PLIST_SUB+=	OSPFAPI_LIB="lib/libospfapiclient.a"
PLIST_SUB+=	OSPFAPI_SBIN="sbin/ospfclient"
.else
PLIST_SUB+=	OSPFAPI_HEADER=
PLIST_SUB+=	OSPFAPI_PATH=
PLIST_SUB+=	OSPFAPI_LIB=
PLIST_SUB+=	OSPFAPI_SBIN=
.endif

.if !defined(ENABLE_USER)
ENABLE_USER=quagga
.endif
.if !defined(ENABLE_GROUP)
ENABLE_GROUP=quagga
.endif

CONFIGURE_ARGS+=--enable-user=${ENABLE_USER}
CONFIGURE_ARGS+=--enable-group=${ENABLE_GROUP}

.if !defined(SYSCONF_DIR)
SYSCONF_DIR=${PREFIX}/etc/quagga
.endif
.if !defined(LOCALSTATE_DIR)
LOCALSTATE_DIR=/var/run/quagga
.endif

CONFIGURE_ARGS+=--sysconfdir=${SYSCONF_DIR}
CONFIGURE_ARGS+=--localstatedir=${LOCALSTATE_DIR}

.if defined(ENABLE_VTY_GROUP)
CONFIGURE_ARGS+=--enable-vty-group=${ENABLE_VTY_GROUP}
.endif

CONFIGURE_ARGS+=--enable-vtysh

.include <bsd.port.pre.mk>

.if ${OSVERSION} >= 500038
RC_SUBR?=	${DESTDIR}/etc/rc.subr
RC_DIR=		${DESTDIR}/etc/rc.d
RC_SUFX=
.else
USE_RC_SUBR=	yes
RC_DIR=		${PREFIX}/etc/rc.d
RC_SUFX=	.sh
.endif

QUAGGA_SCRIPTS=	zebra ripd ripngd ospfd ospf6d bgpd

SED_SCRIPT=	-e 's,%%PREFIX%%,${PREFIX},g' \
		-e 's,%%SYSCONF_DIR%%,${SYSCONF_DIR},g' \
		-e 's,%%LOCALSTATE_DIR%%,${LOCALSTATE_DIR},g' \
		-e 's,%%RC_SUBR%%,${RC_SUBR},g' \
		-e 's,%%RC_DIR%%,${RC_DIR},g' \
		-e 's,%%RC_SUFX%%,${RC_SUFX},g'

PLIST_SUB+=	RC_DIR=${RC_DIR} \
		RC_SUFX=${RC_SUFX} \
		LOCALSTATE_DIR=${LOCALSTATE_DIR} \
		ENABLE_USER=${ENABLE_USER} \
		ENABLE_GROUP=${ENABLE_GROUP}

pre-everything::
	@${ECHO} "============================================================="
	@${ECHO}
	@${ECHO} "You can build ${PORTNAME} with the following options:"
	@${ECHO}
	@${ECHO} "WITH_SNMP_4       Force net-snmp 4.x to be used"
	@${ECHO} "ENABLE_USER       Specify user to run Quagga suite as"
	@${ECHO} "ENABLE_GROUP      Specify group to run Quagga suite as"
	@${ECHO} "ENABLE_VTY_GROUP  Specify group for vty socket ownership"
	@${ECHO} "SYSCONF_DIR       Specify directory for Quagga configuration files"
	@${ECHO} "LOCALSTATE_DIR    Specify directory for Quagga runtime files"
	@${ECHO}
	@${ECHO} "The following options may be configured interactively:"
	@${ECHO} "QUAGGA_OPTIONS    Specify additional switches, including:"
	@${ECHO} "   LIBPAM           PAM authentication for vtysh"
	@${ECHO} "   OSPF_NSSA        NSSA support (RFC1587)"
	@${ECHO} "   OSPF_OPAQUE_LSA  OSPF Opaque-LSA with OSPFAPI support (RFC2370)"
	@${ECHO} "   RTADV            IPv6 Router Advertisements"
	@${ECHO} "   SNMP             SNMP support"
	@${ECHO} "   TCPSOCKETS       Use TCP/IP sockets for protocol daemons"
	@${ECHO} "   TCPMD5           TCP-MD5 support for BGP sessions"

pre-configure:
	@(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOMAKE_ENV} ${ACLOCAL} )
	@(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOHEADER_ENV} ${AUTOHEADER} \
		${AUTOHEADER_ARGS})
	-@(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOMAKE_ENV} ${AUTOMAKE} \
		${AUTOMAKE_ARGS})
	@(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOCONF_ENV} ${AUTOCONF} \
		${AUTOCONF_ARGS})

post-build:
	@${SED} ${SED_SCRIPT} ${FILESDIR}/quagga.sh > ${WRKDIR}/quagga.sh

post-install:
	@${SETENV} ${SCRIPTS_ENV} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
	@${ECHO} "===>     installing ${PORTNAME} startup file..."
	@${ECHO} "Add the folliwing lines to /etc/rc.conf to enable quagga:"
	@${ECHO} ""
	@${ECHO} "defaultrouter=\"NO\""
	@${ECHO} "quagga_enable=\"YES\""
	@${ECHO} ""
	@${ECHO} "Also, you may wish to set the following options:"
	@${ECHO} "quagga_daemons=\"zebra bgpd etc...\""
	@${ECHO} "quagga_flags=\"....\""
	@${ECHO} "quagga_extralibs_path=\"/path1 /path2\""
	@${ECHO} "router_enable=\"NO\""
	@${ECHO} ""
	@${ECHO} "Note!!! Since 0.96.4_5 port uses new id for quagga user and group."
	@${ECHO} "        So, You need to manually chown files:"
	@${ECHO} "        in ${SYSCONF_DIR}"
	@${ECHO} "        and ${LOCALSTATE_DIR}"
	@${ECHO} "        if You had never do this before. Or run"
	@${ECHO} "        make changeuser"
	@${ECHO} ""
	@${INSTALL_SCRIPT} ${WRKDIR}/quagga.sh ${RC_DIR}/quagga${RC_SUFX}

.if !defined(BATCH)
post-clean:
	@${RM} -f ${WRKDIRPREFIX}${.CURDIR}/Makefile.inc
.endif

changeuser:
# Recover from the problem that earlier versions of this port created the
# quagga pseudo-user with an id of 90 which is used by FireBird database
# engine. The port now uses id 101:101.
# NOTE:
# This target assumes that ENABLE_GROUP is the primary group of ENABLE_USER. If you
# have a different setup, do not run this target!
	@if [ `${ID} -u` -ne 0 ]; \
	then ${ECHO_CMD} "Sorry, you must be root to use this target."; exit 1; fi; \
	current_uid=`id -u ${ENABLE_USER}`; \
	current_gid=`pw groupshow ${ENABLE_GROUP}|cut -f 3 -d :`; \
	${ECHO_CMD} "I will remove this user:"; \
	${ID} -P $${current_uid}; \
	${ECHO_CMD} "and this group:"; \
	pw groupshow ${ENABLE_GROUP}; \
	${ECHO_CMD} "I will then re-create them with a user and group id of 101."; \
	${ECHO_CMD} "Then all files and directories under ${PREFIX} and /var that"; \
	${ECHO_CMD} "are owned by uid $${current_uid} will be chown(1)'ed."; \
	${ECHO_CMD} "After that, all files and directories that were accessible"; \
	${ECHO_CMD} "by group $${current_gid} will chgrp(1)'ed respectively."; \
	${ECHO_CMD} "Note that this assumes group '${ENABLE_GROUP}' to be the primary"; \
	${ECHO_CMD} "group of user '${ENABLE_USER}'. If you have a different setup"; \
	${ECHO_CMD} "please abort this target now. Also don't forget to write your"; \
	${ECHO_CMD} "Quagga configs right now!"; \
	read -p "Press RETURN to continue or CTRL-C to abort:" dummy ; \
	${ECHO_CMD} "OK, here we go:"; \
	${ECHO_CMD} "deleting user $${current_uid} and his primary group..."; \
	pw userdel -u $${current_uid}; \
	${ECHO_CMD} "adding user ${ENABLE_USER} with id 101..."; \
	pw groupadd -n ${ENABLE_USER} -g 101; \
	pw useradd -n ${ENABLE_GROUP} -u 101 -c "quagga route daemon pseudo-user" \
	    -d ${SYSCONF_DIR} -s /sbin/nologin -h - ; \
	${ECHO_CMD} "chown(1)'ing everything under ${PREFIX} from $${current_uid} to 101..."; \
	${FIND} -H ${PREFIX} -user $${current_uid} -exec ${CHOWN} 101 {} \; ; \
	${ECHO_CMD} "chgrp(1)'ing everything under ${PREFIX} from $${current_gid} to 100..."; \
	${FIND} -H ${PREFIX} -group $${current_gid} -exec ${CHOWN} :101 {} \; ; \
	${ECHO_CMD} "chown(1)'ing everything under /var from $${current_uid} to 101..."; \
	${FIND} -H /var -user $${current_uid} -exec ${CHOWN} 101 {} \; ; \
	${ECHO_CMD} "chgrp(1)'ing everything under /var from $${current_gid} to 101..."; \
	${FIND} -H /var -group $${current_gid} -exec ${CHOWN} :101 {} \; ; \
	${ECHO_CMD} "Finished. You must stop and then start Quagga now."

.include <bsd.port.post.mk>