aboutsummaryrefslogtreecommitdiffstats
path: root/net/isc-dhcp41-server/Makefile
blob: 25eb4fcee4f864c411c9e8067419e28b99f2c645 (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
# Ports collection makefile for:    isc-dhcp41-server
# Date created:         28 March 2010
# Whom:                 Wesley Shields <wxs@FreeBSD.org>
#
# $FreeBSD$
#

PORTNAME=   dhcp
DISTVERSION=    4.1-ESV
PORTREVISION=   ${DHCP_PORTREVISION}
PORTEPOCH=  2
CATEGORIES= net
MASTER_SITES=   ${MASTER_SITE_ISC}
MASTER_SITE_SUBDIR= dhcp
PKGNAMEPREFIX=  isc-
PKGNAMESUFFIX=  41-${SUBSYS}
DISTFILES=  ${PORTNAME}-${DISTVERSION}-${PATCHLEVEL}${EXTRACT_SUFX}

MAINTAINER= douglas@douglasthrift.net
COMMENT?=   The ISC Dynamic Host Configuration Protocol server

LICENSE=    ISCL

PATCHLEVEL= R2
PORTREVISION_SERVER=    0
PORTREVISION_CLIENT=    0
PORTREVISION_RELAY= 0

SUBSYS?=    server
WRKSRC=     ${WRKDIR}/${PORTNAME}-${DISTVERSION}-${PATCHLEVEL}

UNIQUENAME= ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}

.if ${SUBSYS} == server
OPTIONS=    DHCP_PARANOIA "Enable support for chroot" on \
        DHCP_LDAP "Experimental LDAP backend support" off \
        DHCP_LDAP_SSL "Support LDAP connection over SSL/TLS" on
.endif

# PORTREVISION and CONFLICTS handling
.if ${SUBSYS} == client
CONFLICTS=  isc-dhcp3?-client*
DHCP_PORTREVISION=  ${PORTREVISION_CLIENT}
.elif ${SUBSYS} == relay
CONFLICTS=  isc-dhcp3?-relay*
DHCP_PORTREVISION=  ${PORTREVISION_RELAY}
.else
CONFLICTS=  isc-dhcp3?-server*
DHCP_PORTREVISION=  ${PORTREVISION_SERVER}
.endif

.if ${SUBSYS} == server
USERS=  dhcpd
GROUPS= dhcpd
.endif

.include <bsd.port.pre.mk>

MAN_COMPRESSED= no
GNU_CONFIGURE=  yes
CONFIGURE_ENV=  CPPFLAGS="-D_PATH_DHCLIENT_SCRIPT='\"${PREFIX}/sbin/dhclient-script\"' -D_PATH_DHCLIENT_CONF='\"${PREFIX}/etc/dhclient.conf\"' -D_PATH_DHCPD_CONF='\"${PREFIX}/etc/dhcpd.conf\"'"
SCRIPTS_ENV+=   PKG_PREFIX=${PREFIX}

.if ${SUBSYS} == client
MAN5+=      dhclient.conf.5 dhclient.leases.5
MAN8+=      dhclient.8 dhclient-script.8
CONF_FILE=  dhclient.conf
.elif ${SUBSYS} == server
CONFIGURE_ARGS+=    --localstatedir=/var
MAN5+=      dhcpd.conf.5 dhcpd.leases.5 dhcp-eval.5 dhcp-options.5
MAN8+=      dhcpd.8
MAN1=       omshell.1
MAN3=       dhcpctl.3 omapi.3
CFLAGS+=    -fPIC
CONF_FILE=  dhcpd.conf dhcpd6.conf
.else
MAN8+=      dhcrelay.8
.endif

DESCR=      ${.CURDIR}/pkg-descr
PLIST=      ${.CURDIR}/pkg-plist

.if ${SUBSYS} == server
USE_RC_SUBR=    isc-dhcpd
.elif ${SUBSYS} == relay
USE_RC_SUBR=    isc-dhcrelay
.endif

SCHEMA_DIR= ${PREFIX}/share/${PKGBASE}
DOCSDIR=    ${PREFIX}/share/doc/${PKGBASE}
DATADIR=    /var/db

MSG_FILE=   ${.CURDIR}/pkg-message
PKGMESSAGE= ${WRKDIR}/pkg-message

REINPLACE_SUB=  PREFIX="${PREFIX}"
PKGMESSAGE_SUB= PREFIX="${PREFIX}" MAN1PREFIX="${MAN1PREFIX}" \
        DOCSDIR="${DOCSDIR}"

# XXX: Have to hardcode 4.1.1 here as there is no release for 4.1.2 or later.
.if defined(WITH_DHCP_LDAP)
MASTER_SITES+=      http://cloud.github.com/downloads/dcantrell/ldap-for-dhcp/:ldap
LDAPPATCHRELEASE=   2
LDAPPATCHDIST=      ldap-for-dhcp-4.1.1-${LDAPPATCHRELEASE}
LDAPPATCHFILE=      dhcp-4.1.1-ldap.patch
DISTFILES+=     ${LDAPPATCHDIST}.tar.gz:ldap
PLIST_SUB+=     SCHEMA_DIR="${SCHEMA_DIR:S,^${PREFIX}/,,}" LDAP=""
PORTDOCS+=      README.ldap LICENSE.ldap
LDAP_SCRIPT=        ${WRKDIR}/${LDAPPATCHDIST}/dhcpd-conf-to-ldap
LDAP_SCHEMA=        ${WRKDIR}/${LDAPPATCHDIST}/dhcp.schema
USE_PERL5_RUN=      yes
USE_OPENLDAP=       yes
USE_AUTOTOOLS=      aclocal libtoolize autoconf autoheader automake
LIBTOOLIZE_ARG=     --copy --force
AUTOMAKE_ARGS=      --foreign --add-missing --copy
CFLAGS+=        -I${PREFIX}/include -L${PREFIX}/lib
CONFIGURE_ARGS+=    --with-ldap
.else
PLIST_SUB+= LDAP="@comment "
.endif

# WITH_DHCP_LDAP_SSL without WITH_DHCP_LDAP is silly.
.if defined(WITH_DHCP_LDAP_SSL) && defined (WITH_DHCP_LDAP)
USE_OPENSSL=    yes
CONFIGURE_ARGS+=    --with-ldapcrypto
CONFIGURE_ENV+= LIBS="-lssl"
# hack to get bsd.openssl.mk included at this late state
.include "${PORTSDIR}/Mk/bsd.openssl.mk"
.endif

.if defined(WITH_DHCP_PARANOIA)
CONFIGURE_ARGS+=    --enable-paranoia --enable-early-chroot
SUB_LIST+=  PARANOIA=yes
.else
SUB_LIST+=  PARANOIA=no
.endif

pre-patch:
.if ${SUBSYS} == server && defined(WITH_DHCP_LDAP)
    @cd ${WRKSRC} && ${PATCH} -p1 < ${WRKDIR}/${LDAPPATCHDIST}/${LDAPPATCHFILE}
.endif

post-patch:
    @${SED} ${PKGMESSAGE_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \
        ${MSG_FILE} > ${PKGMESSAGE}
    @${REINPLACE_CMD} ${REINPLACE_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \
        ${WRKSRC}/client/dhclient.conf

do-install:
    ${MAKE} -C ${WRKSRC}/${SUBSYS} install
.if ${SUBSYS} == server
    ${MAKE} -C ${WRKSRC}/dhcpctl install
    ${MAKE} -C ${WRKSRC}/dst install
    ${MAKE} -C ${WRKSRC}/omapip install
    ${MAKE} -C ${WRKSRC}/includes install
    ${MAKE} -C ${WRKSRC}/common install
    ${INSTALL_DATA} ${WRKSRC}/dhcpctl/dhcpctl.h ${PREFIX}/include
    ${INSTALL_DATA} ${WRKSRC}/doc/examples/dhcpd-dhcpv6.conf \
        ${PREFIX}/etc/dhcpd6.conf.sample
.endif
.if defined(WITH_DHCP_LDAP)
    @${MKDIR} ${SCHEMA_DIR}
    ${INSTALL_DATA} ${LDAP_SCHEMA} ${SCHEMA_DIR}
    ${INSTALL_SCRIPT} ${LDAP_SCRIPT} ${PREFIX}/bin
.endif
.if defined(WITH_DHCP_LDAP) && !defined(NOPORTDOCS)
    ${MKDIR} ${DOCSDIR}
    ${INSTALL_MAN} ${WRKDIR}/${LDAPPATCHDIST}/README.ldap   ${DOCSDIR}
    ${INSTALL_MAN} ${WRKDIR}/${LDAPPATCHDIST}/LICENSE.ldap  ${DOCSDIR}
.endif

post-install:
.if defined(CONF_FILE)
.for FILE in ${CONF_FILE}
    if [ ! -f ${PREFIX}/etc/${FILE} ]; then \
        ${CP} -p ${PREFIX}/etc/${FILE}.sample ${PREFIX}/etc/${FILE} ; \
    fi
.endfor
.endif
.if ${SUBSYS} == client
    ${INSTALL_SCRIPT} ${WRKSRC}/client/scripts/freebsd ${PREFIX}/sbin/dhclient-script
.elif ${SUBSYS} == server
    @${LN} -sf isc-dhcpd ${PREFIX}/etc/rc.d/isc-dhcpd6
.endif
    @${SED} ${PKGMESSAGE_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \
        ${MSG_FILE} > ${PKGMESSAGE}
.if defined(WITH_DHCP_LDAP)
    @${REINPLACE_CMD} -e 's|^%%LDAP%%||g' ${PKGMESSAGE}
.else
    @${REINPLACE_CMD} -e '/^%%LDAP%%/d' ${PKGMESSAGE}
.endif
    @${ECHO_MSG}
    @${CAT} ${PKGMESSAGE}
    @${ECHO_MSG}

.include <bsd.port.post.mk>