2005-11-28 06:54:17 +01:00
|
|
|
# $NetBSD: find-prefix.mk,v 1.4 2005/11/28 05:54:17 jlam Exp $
|
2005-05-12 22:41:10 +02:00
|
|
|
#
|
|
|
|
# This is a "subroutine" that can be included to find the installation
|
|
|
|
# prefix of a package.
|
|
|
|
#
|
2005-11-28 06:54:17 +01:00
|
|
|
# The input variable is FIND_PREFIX, which is a list of VARNAME=<pattern>
|
2005-05-12 22:41:10 +02:00
|
|
|
# pairs, where "VARNAME" is the variable that will be set to the
|
2005-11-28 06:54:17 +01:00
|
|
|
# installation prefix for the package, and <pattern> is a package
|
|
|
|
# wildcard pattern used to match the installed package (see pkg_info(8)).
|
2005-05-12 22:41:10 +02:00
|
|
|
#
|
|
|
|
# An example use is:
|
|
|
|
#
|
|
|
|
# FIND_PREFIX:= M4DIR=gm4
|
|
|
|
# .include "../../mk/find-prefix.mk"
|
|
|
|
# # ${M4DIR} now contains the installation prefix for the "gm4" package
|
|
|
|
#
|
|
|
|
|
|
|
|
.for _def_ in ${FIND_PREFIX}
|
2005-05-12 23:56:11 +02:00
|
|
|
. if !defined(${_def_:C/=.*$//})
|
2005-05-12 22:41:10 +02:00
|
|
|
${_def_:C/=.*$//}_DEFAULT?= ${LOCALBASE}
|
|
|
|
_${_def_:C/=.*$//}_cmd= \
|
2005-11-28 06:54:17 +01:00
|
|
|
${PKG_INFO} -qp ${_def_:C/^[^=]*=//:Q} 2>/dev/null | \
|
2005-05-14 01:37:54 +02:00
|
|
|
{ read cmd arg; \
|
|
|
|
case "$$arg" in \
|
|
|
|
"") ${ECHO} ${${_def_:C/=.*$//}_DEFAULT:Q} ;; \
|
|
|
|
*) ${ECHO} "$$arg" ;; \
|
|
|
|
esac; }
|
2005-05-12 22:41:10 +02:00
|
|
|
${_def_:C/=.*$//}= ${_${_def_:C/=.*$//}_cmd:sh}
|
|
|
|
. endif
|
|
|
|
MAKEVARS+= ${_def_:C/=.*$//}
|
|
|
|
.endfor
|
|
|
|
.undef _def_
|