aboutsummaryrefslogtreecommitdiffstats
path: root/net/freeradius/Makefile
blob: d65f2ea035b5b2db73570ec1eb6b5acf498b61f2 (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
# New ports collection makefile for:    freeradius
# Date created:         May 9 2002
# Whom:                 Brian Somers <brian@FreeBSD.org>
#
# $FreeBSD$
#

PORTNAME=   freeradius
PORTVERSION?=   1.1.8
PORTREVISION?=  5
CATEGORIES= net
MASTER_SITES=   ftp://ftp.freeradius.org/pub/freeradius/%SUBDIR%/ \
        ftp://ftp.ntua.gr/pub/net/radius/freeradius/%SUBDIR%/ \
        ftp://ftp.uk.freeradius.org/pub/radius/%SUBDIR%/ \
        http://ftp.cc.uoc.gr/mirrors/ftp.freeradius.org/%SUBDIR%/ \
        http://freeradius.portal-to-web.de/%SUBDIR%/ \
        http://mirrors.rit.edu/zi/
MASTER_SITE_SUBDIR= . old
# If FREERADIUS_SLAVE_MYSQL is defined, we want to build the
# freeradius-mysql slave port
.ifdef(FREERADIUS_SLAVE_MYSQL)
PKGNAMESUFFIX=  -mysql
.endif

MAINTAINER?=    zi@FreeBSD.org
COMMENT?=   A free RADIUS server implementation

LICENSE=    GPLv2
LICENSE_FILE=   ${WRKSRC}/LICENSE

LIB_DEPENDS=    gdbm.4:${PORTSDIR}/databases/gdbm

CONFLICTS=  gnu-radius-[0-9].* openradius-[0-9].* radiusd-cistron-[0-9].*
# If FREERADIUS_SLAVE_MYSQL is defined, we want to build the
# freeradius-mysql slave port
.ifdef(FREERADIUS_SLAVE_MYSQL)
CONFLICTS+= freeradius-[0-9].* freeradius-mysql-[02-9].*
.else
CONFLICTS+= freeradius-mysql-[0-9].* freeradius-[02-9].*
.endif

MAN1=       radclient.1 radeapclient.1 radlast.1 radtest.1 radwho.1 \
        radzap.1
MAN5=       acct_users.5 clients.5 clients.conf.5 dictionary.5 naslist.5 \
        radiusd.conf.5 rlm_acct_unique.5 rlm_always.5 \
        rlm_attr_filter.5 rlm_attr_rewrite.5 rlm_chap.5 rlm_counter.5 \
        rlm_detail.5 rlm_expr.5 rlm_files.5 rlm_mschap.5 rlm_pap.5 \
        rlm_passwd.5 rlm_realm.5 rlm_sql.5 rlm_sql_log.5 rlm_unix.5 \
        users.5
MAN8=       radiusd.8 radrelay.8 radsqlrelay.8 radwatch.8 rlm_ippool_tool.8

USE_BZIP2=  yes
WANT_PERL=  yes

LOGDIR?=    /var/log

NO_LATEST_LINK= yes

USE_RC_SUBR=    radiusd
USE_AUTOTOOLS=  libltdl libtool autoconf
USE_GMAKE=  yes
USE_OPENSSL=    yes
USE_LDCONFIG=   yes
CONFIGURE_ARGS= --quiet \
        --prefix=${PREFIX} \
        --localstatedir=/var \
        --with-system-libtool \
        --with-logdir=${LOGDIR} \
        --with-large-files \
        --with-openssl-includes=${OPENSSLINC} \
        --without-rlm_sql_db2 \
        --without-rlm_sql_freetds \
        --without-rlm_sql_iodbc \
        --without-rlm_sql_oracle \
        --without-rlm_sql_sybase
MAKE_ARGS+= LDFLAGS="-L${LOCALBASE}/lib ${PTHREAD_LIBS}"
CFLAGS+=    -I${LOCALBASE}/include -L${LOCALBASE}/lib
MAKE_JOBS_UNSAFE=   yes

PLIST_SUB=  PORTVERSION=${PORTVERSION}
USERS=      freeradius
GROUPS= freeradius

OPTIONS=    KERBEROS    "With Kerberos support" off \
        HEIMDAL     "With Heimdal Kerberos support" off \
        LDAP        "With LDAP database support" off
.ifndef(FREERADIUS_SLAVE_MYSQL)
OPTIONS+=   MYSQL       "With MySQL database support" off
.endif
OPTIONS+=   PGSQL       "With PostgreSQL database support" off \
        UNIXODBC    "With unixODBC database support" off \
        FIREBIRD    "With Firebird database support (EXPERIMENTAL)" off \
        SNMP        "With SNMP support" off \
        EDIR        "With Novell eDirectory support" off \
        NOPERL      "Do not require perl (use only if necessary)" off \
        EXPERIMENTAL    "Build experimental modules" off

# Default requirements for rc script
_REQUIRE=   NETWORKING SERVERS

.include <bsd.port.options.mk>

.ifdef(FREERADIUS_SLAVE_MYSQL)
WITH_MYSQL= yes
.endif

.ifdef(NOPORTDOCS)
CONFIGURE_ARGS+=--without-docdir
PLIST_SUB+= PORTDOCS="@comment "
.else
CONFIGURE_ARGS+=--with-docdir=${DOCSDIR}
PLIST_SUB+= PORTDOCS=""
.endif

.if defined(WITH_HEIMDAL) && !defined(WITH_KERBEROS)
WITH_KERBEROS=  yes
.endif

.ifdef(WITH_KERBEROS)
.ifdef(WITH_HEIMDAL)
LIB_DEPENDS+=   krb5.26:${PORTSDIR}/security/heimdal
CONFIGURE_ARGS+=--enable-heimdal-krb5
.else
LIB_DEPENDS+=   krb5.3:${PORTSDIR}/security/krb5
.endif
CONFIGURE_ARGS+=--with-rlm-krb5-lib-dir=${LOCALBASE}/lib
CONFIGURE_ARGS+=--with-rlm-krb5-include-dir=${LOCALBASE}/include
PLIST_SUB+= KRB5=""
.else
CONFIGURE_ARGS+=--without-rlm_krb5
PLIST_SUB+= KRB5="@comment "
.endif

.if defined(WITH_EDIR) && !defined(WITH_LDAP)
WITH_LDAP=  yes
.endif

.ifdef(WITH_LDAP)
USE_OPENLDAP=   YES
PLIST_SUB+= LDAP=""
_REQUIRE+=  slapd
.else
CONFIGURE_ARGS+=--without-rlm_ldap
PLIST_SUB+= LDAP="@comment "
.endif

.ifdef(WITH_EDIR)
CONFIGURE_ARGS+=--with-edir
.endif

.ifdef(WITH_MYSQL)
USE_MYSQL=  YES
CONFIGURE_ARGS+=--with-rlm_sql_mysql
PLIST_SUB+= MYSQL=""
_REQUIRE+=  mysql
.else
CONFIGURE_ARGS+=--without-rlm_sql_mysql
PLIST_SUB+= MYSQL="@comment "
.endif

.ifdef(WITH_PGSQL)
USE_PGSQL=  YES
CONFIGURE_ARGS+=--with-rlm_sql_postgresql
PLIST_SUB+= PGSQL=""
_REQUIRE+=  postgresql
.else
CONFIGURE_ARGS+=--without-rlm_sql_postgresql
PLIST_SUB+= PGSQL="@comment "
.endif

.ifdef(WITH_UNIXODBC)
CONFIGURE_ARGS+=--with-rlm_sql_unixodbc
PLIST_SUB+= UNIXODBC=""
LIB_DEPENDS+=   odbc.2:${PORTSDIR}/databases/unixODBC
.else
CONFIGURE_ARGS+=--without-rlm_sql_unixodbc
PLIST_SUB+= UNIXODBC="@comment "
.endif

.ifdef(WITH_FIREBIRD)
USE_FIREBIRD=   YES
CONFIGURE_ARGS+=--with-rlm_sql_firebird
PLIST_SUB+= FIREBIRD=""
.else
CONFIGURE_ARGS+=--without-rlm_sql_firebird
PLIST_SUB+= FIREBIRD="@comment "
.endif

# Firebird module is still experimental
.if defined(WITH_FIREBIRD) && !defined(WITH_EXPERIMENTAL)
WITH_EXPERIMENTAL=  yes
.endif

.ifdef(WITH_SNMP)
LIB_DEPENDS+=   netsnmp.30:${PORTSDIR}/net-mgmt/net-snmp
.else
CONFIGURE_ARGS+=--without-snmp
.endif

.ifdef(WITH_EXPERIMENTAL)
USE_PYTHON= yes
CONFIGURE_ARGS+=--with-experimental-modules
PLIST_SUB+= EXPM=""
.else
PLIST_SUB+= EXPM="@comment "
.endif

.ifdef(WITH_DEVELOPER)
CONFIGURE_ARGS+=--enable-developer
.endif

.ifdef(WITH_NOPERL)
CONFIGURE_ARGS+=--without-rlm_perl
PLIST_SUB+= RLMPERL="@comment "
.else
USE_PERL5=  yes
CONFIGURE_ARGS+=--with-rlm_perl
PLIST_SUB+= RLMPERL=""
.endif

SUB_LIST+=  REQUIRE="${_REQUIRE}"

.include <bsd.port.pre.mk>

# This conditionality avoids -L/usr/lib in the radiusd build step when
# building with base system OpenSSL
.if ${OPENSSLLIB} != "/usr/lib"
CONFIGURE_ARGS+=--with-openssl-libraries=${OPENSSLLIB}
.endif

.if ${ARCH} == amd64
CONFIGURE_ARGS+=    --with-pic
.endif

post-patch:
    @${REINPLACE_CMD} -e 's|timestamp(14)|timestamp|g' \
        ${WRKSRC}/doc/examples/mysql.sql
    @${RM} ${WRKSRC}/doc/examples/mysql.sql.bak
# Patch Makefile / Makefile.in throughout the source tree to install raddb
# contents in ${EXAMPLESDIR}/raddb rather than the raddbdir from configure
    @${FIND} -E ${WRKSRC} -regex '.*/Makefile(\.in)?$$' -exec \
        ${REINPLACE_CMD} -e "s:\$$(R)\$$(raddbdir):${EXAMPLESDIR}/raddb:g" {} \;
# Clean up after the last operation (so as not to get unwanted files when installing doc/)
    @${FIND} -E ${WRKSRC} -regex '.*/Makefile(\.in)?\.(orig|bak)$$' -delete

pre-configure:
# Replace -pthread with ${PTHREAD_LIBS} in configure(.in) files
    @${FIND} -E ${WRKSRC} -regex '.*/configure(\.in)?$$' -exec \
        ${REINPLACE_CMD} -e "s:-pthread:${PTHREAD_LIBS}:g" {} \;
# Force the rebuild of some configures from configure.in, as we're patching
# the configure.in
# NOTE: ${WRKSRC}/configure is rebuilt automatically once autoconf is
# added to USE_AUTOTOOLS
    @cd ${WRKSRC}/src/modules/rlm_ldap && ${AUTOCONF} -I ${WRKSRC}
    @cd ${WRKSRC}/src/modules/rlm_sql/drivers/rlm_sql_mysql \
        && ${AUTOCONF} -I ${WRKSRC}
    @cd ${WRKSRC}/src/modules/rlm_python && ${AUTOCONF} -I ${WRKSRC}

post-install:
# Create (if necessary) ${PREFIX}/etc/raddb and subdirectories using
# ${EXAMPLESDIR}/raddb as the model layout
    @for i in `${FIND} ${EXAMPLESDIR}/raddb/ -type d -print \
    | ${SED} -e 's:^${EXAMPLESDIR}/raddb::g'`; do \
        if [ ! -d ${PREFIX}/etc/raddb$${i} ]; then \
            ${MKDIR} ${PREFIX}/etc/raddb$${i}; \
        fi; \
    done
# Copy all files from ${EXAMPLESDIR}/raddb to ${PREFIX}/etc/raddb if they
# don't already exist in the destination location
    @for i in `${FIND} ${EXAMPLESDIR}/raddb/ -type f -print \
    | ${SED} -e 's:^${EXAMPLESDIR}/raddb/::g'`; do \
        if [ ! -f ${PREFIX}/etc/raddb/$${i} ]; then \
            ${CP} ${EXAMPLESDIR}/raddb/$${i} ${PREFIX}/etc/raddb/$${i}; \
        fi; \
    done
# Set ${PREFIX}/etc/raddb and all the files and folders in it to g-w,o-rwx
# (FreeRADIUS will probably complain if this is not done)
    @${CHMOD} -R g-w,o-rwx ${PREFIX}/etc/raddb
    @${CHOWN} -R ${USERS}:${GROUPS} ${PREFIX}/etc/raddb

    @${TOUCH} ${LOGDIR}/radius.log
    @${CHOWN} ${USERS}:${GROUPS} ${LOGDIR}/radius.log
    @${CHOWN} ${USERS}:${GROUPS} ${LOGDIR}/radacct
    @${CHOWN} ${USERS}:${GROUPS} /var/run/radiusd

.include <bsd.port.post.mk>