pkgsrc/mk/resolv.buildlink3.mk
joerg 2d1ba244e9 Simply and speed up buildlink3.mk files and processing.
This changes the buildlink3.mk files to use an include guard for the
recursive include. The use of BUILDLINK_DEPTH, BUILDLINK_DEPENDS,
BUILDLINK_PACKAGES and BUILDLINK_ORDER is handled by a single new
variable BUILDLINK_TREE. Each buildlink3.mk file adds a pair of
enter/exit marker, which can be used to reconstruct the tree and
to determine first level includes. Avoiding := for large variables
(BUILDLINK_ORDER) speeds up parse time as += has linear complexity.
The include guard reduces system time by avoiding reading files over and
over again. For complex packages this reduces both %user and %sys time to
half of the former time.
2009-03-20 19:23:50 +00:00

64 lines
1.8 KiB
Makefile

# $NetBSD: resolv.buildlink3.mk,v 1.3 2009/03/20 19:25:01 joerg Exp $
#
# This Makefile fragment is included by package Makefiles and
# buildlink3.mk files for the packages that need a thread-safe
# DNS resolver.
#
# It defines the variables RESOLV_LDFLAGS and RESOLV_LIBS,
# which are also exported into the CONFIGURE_ENV and MAKE_ENV environments.
#
# Package-settable variables:
#
# RESOLV_AUTO_VARS
# When set to "yes", the necessary flags are added automatically
# to LDFLAGS and friends.
#
# Default: no
#
# Keywords: resolv
#
RESOLV_BUILDLINK3_MK:= ${RESOLV_BUILDLINK3_MK}+
.include "../../mk/bsd.fast.prefs.mk"
RESOLV_AUTO_VARS?= no
CHECK_BUILTIN.resolv= no
.if ${OPSYS} == "DragonFly" || ${OPSYS} == "FreeBSD"
USE_BUILTIN.resolv?= yes
BUILDLINK_LDFLAGS.resolv= # empty, in libc
.elif (${OPSYS} == "NetBSD" && empty(OS_VERSION:M[012].*)) || \
(${OPSYS} == "Darwin" && empty(OS_VERSION:M[0123467].*))
USE_BUILTIN.resolv?= yes
# BIND 9 resolver
BUILDLINK_LDFLAGS.resolv= -lresolv
.else
USE_BUILTIN.resolv?= no
.endif
.if !empty(USE_BUILTIN.resolv:M[yY][eE][sS])
BUILDLINK_TREE+= resolv -resolv
BUILDLINK_AUTO_VARS.resolv= ${RESOLV_AUTO_VARS}
.else
. include "../../net/bind9/buildlink3.mk"
BUILDLINK_AUTO_VARS.bind= ${RESOLV_AUTO_VARS}
BUILDLINK_LDFLAGS.resolv= ${BUILDLINK_LDFLAGS.bind}
BUILDLINK_LIBS.resolv= ${BUILDLINK_LIBS.bind}
.endif
.if !empty(RESOLV_BUILDLINK3_MK:M+)
#
# Define user-visible RESOLV_{LDFLAGS,LIBS} as compiler options used
# to link code that needs a thread-safe DNS resolver.
#
RESOLV_LDFLAGS= ${BUILDLINK_LDFLAGS.resolv}
RESOLV_LIBS= ${BUILDLINK_LIBS.resolv}
CONFIGURE_ENV+= RESOLV_LDFLAGS=${RESOLV_LDFLAGS:Q}
CONFIGURE_ENV+= RESOLV_LIBS=${RESOLV_LIBS:Q}
MAKE_ENV+= RESOLV_LDFLAGS=${RESOLV_LDFLAGS:Q}
MAKE_ENV+= RESOLV_LIBS=${RESOLV_LIBS:Q}
.endif # RESOLV_BUILDLINK3_MK