diff options
author | Mathieu Arnold <mat@FreeBSD.org> | 2014-06-17 15:00:21 +0000 |
---|---|---|
committer | Mathieu Arnold <mat@FreeBSD.org> | 2014-06-17 15:00:21 +0000 |
commit | 427e48f5debfab5d5b17c82fac38980c441dbb9f (patch) | |
tree | 2fa5b529cbad7bc53bd61e6b88518c392e920bf4 /Mk | |
parent | science/afni: bring back into shape. (diff) |
Introduce Uses/gssapi.mk to help handle dependencies on Kerberos in a
consistent way.
Submitted by: hrs
With hat: portmgr
Sponsored by: Absolight
Notes
Notes:
svn path=/head/; revision=358126
Diffstat (limited to 'Mk')
-rw-r--r-- | Mk/Uses/gssapi.mk | 174 |
1 files changed, 174 insertions, 0 deletions
diff --git a/Mk/Uses/gssapi.mk b/Mk/Uses/gssapi.mk new file mode 100644 index 000000000000..b7a2b8c58f27 --- /dev/null +++ b/Mk/Uses/gssapi.mk @@ -0,0 +1,174 @@ +# $FreeBSD$ +# +# 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 +# +# Affected variables: +# PREFIX (bootstrap) +# CFLAGS (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}. +# +# CFLAGS, 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 + +GSSAPILIBDIR= ${GSSAPIBASEDIR}/lib +GSSAPIINCDIR= ${GSSAPIBASEDIR}/include + +_HEIMDAL_DEPENDS=${GSSAPILIBDIR}/libgssapi.so:${PORTSDIR}/security/heimdal +_MITKRB5_DEPENDS=${GSSAPILIBDIR}/libkrb5support.so:${PORTSDIR}/security/krb5 +_HEADERS= sys/types.h sys/stat.h stdint.h + +gssapi_ARGS?= base +.for _A in ${gssapi_ARGS:S/,/ /g} +.if ${_A} == "base" +HEIMDAL_HOME= /usr +GSSAPIBASEDIR= ${HEIMDAL_HOME} +_HEADERS+= gssapi/gssapi.h gssapi/gssapi_krb5.h krb5.h +GSSAPICPPFLAGS= -I${GSSAPIINCDIR} +GSSAPILIBS= -lkrb5 -lgssapi -lgssapi_krb5 +GSSAPILDFLAGS= -L"${GSSAPILIBDIR}" +.elif ${_A} == "heimdal" +HEIMDAL_HOME?= ${LOCALBASE} +GSSAPIBASEDIR= ${HEIMDAL_HOME} +.if !defined(_KRB_BOOTSTRAP) +BUILD_DEPENDS+= ${_HEIMDAL_DEPENDS} +RUN_DEPENDS+= ${_HEIMDAL_DEPENDS} +_HEADERS+= gssapi/gssapi.h gssapi/gssapi_krb5.h krb5.h +.else +PREFIX= ${HEIMDAL_HOME} +.endif +GSSAPICPPFLAGS= -I${GSSAPIINCDIR} +GSSAPILIBS= -lkrb5 -lgssapi +GSSAPILDFLAGS= -L"${GSSAPILIBDIR}" +_RPATH= ${GSSAPILIBDIR} +.elif ${_A} == "mit" +KRB5_HOME?= ${LOCALBASE} +GSSAPIBASEDIR= ${KRB5_HOME} +.if !defined(_KRB_BOOTSTRAP) +BUILD_DEPENDS+= ${_MITKRB5_DEPENDS} +RUN_DEPENDS+= ${_MITKRB5_DEPENDS} +_HEADERS+= gssapi/gssapi.h gssapi/gssapi_krb5.h krb5.h +.else +PREFIX= ${KRB5_HOME} +.endif +GSSAPILIBS= -lkrb5 -lgssapi_krb5 +GSSAPICPPFLAGS= -I"${GSSAPIINCDIR}" +GSSAPILDFLAGS= -L"${GSSAPILIBDIR}" +_RPATH= ${GSSAPILIBDIR} +.elif ${_A} == "bootstrap" +_KRB_BOOTSTRAP= 1 +.elif ${_A} == "flags" +_KRB_USEFLAGS= 1 +.else +IGNORE= USES=gssapi - invalid args: [${_A}] specified +.endif +.endfor + +# 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) +CFLAGS+= ${GSSAPICPPFLAGS} +LDFLAGS+= ${GSSAPILDFLAGS} +LDADD+= ${GSSAPILIBS} +.endif +GSSAPI_CONFIGURE_ARGS= \ + CFLAGS="${GSSAPICPPFLAGS} ${CFLAGS}" \ + LDFLAGS="${GSSAPILDFLAGS} ${LDFLAGS}" \ + LIBS="${GSSAPILIBS} ${LIBS}" + +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 -f /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 "CFLAGS: ${CFLAGS}" + @echo "LDFLAGS: ${LDFLAGS}" + @echo "LDADD: ${LDADD}" +.endif |