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
|
# handle dependency on Kerberos port
#
# Feature: gssapi
# Usage: USES=gssapi or USES=gssapi:ARGS
# Valid ARGS: base (default, implicit), heimdal, mit.
# "bootstrap" is a special prefix only for krb5 or heimdal ports.
# ("bootstrap,mit")
# flags is a special suffix to define CFLAGS, LDFLAGS, and LDADD.
# ("base,flags")
#
# MAINTAINER: hrs@FreeBSD.org
#
# User defined variables:
# HEIMDAL_HOME (default: ${LOCALBASE})
# KRB5_HOME (default: ${LOCALBASE})
#
# Exported variables:
# GSSAPIBASEDIR
# GSSAPICPPFLAGS
# GSSAPIINCDIR
# GSSAPILDFLAGS
# GSSAPILIBDIR
# GSSAPILIBS
# GSSAPI_CONFIGURE_ARGS
# KRB5CONFIG
#
# Affected variables:
# PREFIX (bootstrap)
# CPPFLAGS (flags)
# LDADD (flags)
# LDCFLAGS
#
# Notes:
# - GSSAPILIBDIR is prepended to "-Wl,-rpath," in LDFLAGS.
# - bootstrap sets PREFIX based on KRB5_HOME or HEIMDAL_HOME.
#
# Usage:
#
# A typical example:
#
# OPTIONS_SINGLE= GSSAPI
# OPTIONS_SINGLE_GSSAPI= GSSAPI_BASE GSSAPI_HEIMDAL GSSAPI_MIT GSSAPI_NONE
#
# GSSAPI_BASE_USES= gssapi
# GSSAPI_BASE_CONFIGURE_ON= \
# --with-gssapi=${GSSAPIBASEDIR} ${GSSAPI_CONFIGURE_ARGS}
#
# GSSAPI_HEIMDAL_USES=gssapi:heimdal
# GSSAPI_HEIMDAL_CONFIGURE_ON= \
# --with-gssapi=${GSSAPIBASEDIR} ${GSSAPI_CONFIGURE_ARGS}
#
# GSSAPI_MIT_USES= gssapi:mit
# GSSAPI_MIT_CONFIGURE_ON= \
# --with-gssapi=${GSSAPIBASEDIR} ${GSSAPI_CONFIGURE_ARGS}
#
# GSSAPI_NONE_CONFIGURE_ON= --without-gssapi
#
# If pathname is required for Kerberos implementation, use ${GSSAPIBASEDIR}.
#
# CPPFLAGS, LDFLAGS, and LDADD can automatically be set by using "flags"
# modifier. It is useful if the port does not use a configure script.
#
# How To Debug:
#
# A port maintainer can try "make debug-krb" to confirm if building
# a GSSAPI library works fine. It will perform a library link test and
# show which library and what parameters will be used.
# If it works but your port does not build, some parameters are missing in
# the building phase of the port. If it does not work, the problem is in
# the GSSAPI library, not your port. Please contact MAINTAINER of this file
# in that case.
#
.if !defined(_INCLUDE_USES_GSSAPI_MK)
_INCLUDE_USES_GSSAPI_MK= yes
_HEIMDAL_DEPENDS=${GSSAPILIBDIR}/libgssapi.so:security/heimdal
_MITKRB5_DEPENDS=${GSSAPILIBDIR}/libkrb5support.so:security/krb5
_HEADERS= sys/types.h sys/stat.h stdint.h
.if empty(gssapi_ARGS)
gssapi_ARGS= base
.endif
.for _A in ${gssapi_ARGS}
_local:= ${_A}
.if ${_local} == "base"
. if ${SSL_DEFAULT} != base
IGNORE= You are using OpenSSL from ports and have selected GSSAPI from base, please select another GSSAPI value
. endif
HEIMDAL_HOME= /usr
GSSAPIBASEDIR= ${HEIMDAL_HOME}
GSSAPILIBDIR= ${GSSAPIBASEDIR}/lib
GSSAPIINCDIR= ${GSSAPIBASEDIR}/include
_HEADERS+= gssapi/gssapi.h gssapi/gssapi_krb5.h krb5.h
GSSAPICPPFLAGS= -I"${GSSAPIINCDIR}"
GSSAPILIBS= -lkrb5 -lgssapi -lgssapi_krb5
GSSAPILDFLAGS=
.elif ${_local} == "heimdal"
HEIMDAL_HOME?= ${LOCALBASE}
GSSAPIBASEDIR= ${HEIMDAL_HOME}
GSSAPILIBDIR= ${GSSAPIBASEDIR}/lib/heimdal
GSSAPIINCDIR= ${GSSAPIBASEDIR}/include/heimdal
_HEADERS+= gssapi/gssapi.h gssapi/gssapi_krb5.h krb5.h
.if !defined(_KRB_BOOTSTRAP)
BUILD_DEPENDS+= ${_HEIMDAL_DEPENDS}
RUN_DEPENDS+= ${_HEIMDAL_DEPENDS}
.else
PREFIX= ${HEIMDAL_HOME}
.endif
GSSAPICPPFLAGS= -I"${GSSAPIINCDIR}"
GSSAPILIBS= -lkrb5 -lgssapi
GSSAPILDFLAGS= -L"${GSSAPILIBDIR}"
_RPATH= ${GSSAPILIBDIR}
.elif ${_local} == "mit"
KRB5_HOME?= ${LOCALBASE}
GSSAPIBASEDIR= ${KRB5_HOME}
GSSAPILIBDIR= ${GSSAPIBASEDIR}/lib
GSSAPIINCDIR= ${GSSAPIBASEDIR}/include
_HEADERS+= gssapi/gssapi.h gssapi/gssapi_krb5.h krb5.h
.if !defined(_KRB_BOOTSTRAP)
BUILD_DEPENDS+= ${_MITKRB5_DEPENDS}
RUN_DEPENDS+= ${_MITKRB5_DEPENDS}
.else
PREFIX= ${KRB5_HOME}
.endif
GSSAPILIBS= -lkrb5 -lgssapi_krb5
GSSAPICPPFLAGS= -I"${GSSAPIINCDIR}"
GSSAPILDFLAGS= -L"${GSSAPILIBDIR}"
_RPATH= ${GSSAPILIBDIR}
.elif ${_local} == "bootstrap"
_KRB_BOOTSTRAP= 1
.elif ${_local} == "flags"
_KRB_USEFLAGS= 1
.else
IGNORE= USES=gssapi - invalid args: [${_local}] specified
.endif
.endfor
KRB5CONFIG=${GSSAPIBASEDIR}/bin/krb5-config
# Fix up -Wl,-rpath in LDFLAGS
.if defined(_RPATH) && !empty(_RPATH)
.if !empty(LDFLAGS:M-Wl,-rpath,*)
.for F in ${LDFLAGS:M-Wl,-rpath,*}
LDFLAGS:= -Wl,-rpath,${_RPATH}:${F:S/-Wl,-rpath,//} \
${LDFLAGS:N-Wl,-rpath,*}
.endfor
.else
LDFLAGS+= -Wl,-rpath,${_RPATH}:/usr/lib
.endif
_DEBUG_KRB_RPATH= -Wl,-rpath,${_RPATH}
.endif
.if defined(_KRB_USEFLAGS) && !empty(_KRB_USEFLAGS)
CPPFLAGS+= ${GSSAPICPPFLAGS}
LDFLAGS+= ${GSSAPILDFLAGS}
LDADD+= ${GSSAPILIBS}
.endif
GSSAPI_CONFIGURE_ARGS= \
CFLAGS="${GSSAPICPPFLAGS} ${CFLAGS}" \
LDFLAGS="${GSSAPILDFLAGS} ${LDFLAGS}" \
LIBS="${GSSAPILIBS} ${LIBS}" \
KRB5CONFIG="${KRB5CONFIG}"
debug-krb:
@(for I in ${_HEADERS}; do echo "#include <$$I>"; done; \
echo "int main() { gss_acquire_cred(0, 0, 0, 0, 0, 0, 0, 0);" \
"krb5_init_context(0);" \
"gsskrb5_register_acceptor_identity(0); return 0;}" \
) > /tmp/${.TARGET}.c
${CC} ${CFLAGS} -o /tmp/${.TARGET}.x ${GSSAPICPPFLAGS} \
${GSSAPILIBS} ${GSSAPILDFLAGS} ${_DEBUG_KRB_RPATH} \
/tmp/${.TARGET}.c && \
ldd /tmp/${.TARGET}.x; \
${RM} /tmp/${.TARGET}.x
@echo "PREFIX: ${PREFIX}"
@echo "GSSAPIBASEDIR: ${GSSAPIBASEDIR}"
@echo "GSSAPIINCDIR: ${GSSAPIINCDIR}"
@echo "GSSAPILIBDIR: ${GSSAPILIBDIR}"
@echo "GSSAPILIBS: ${GSSAPILIBS}"
@echo "GSSAPICPPFLAGS: ${GSSAPICPPFLAGS}"
@echo "GSSAPILDFLAGS: ${GSSAPILDFLAGS}"
@echo "GSSAPI_CONFIGURE_ARGS: ${GSSAPI_CONFIGURE_ARGS}"
@echo "KRB5CONFIG: ${KRB5CONFIG}"
@echo "CFLAGS: ${CFLAGS}"
@echo "LDFLAGS: ${LDFLAGS}"
@echo "LDADD: ${LDADD}"
.endif
|