1 # $NetBSD: find-prefix.mk,v 1.6 2008/02/10 10:12:13 rillig Exp $
3 # This is a "subroutine" that can be included to find the installation
4 # prefix of an installed package.
9 # A list of <VARNAME>=<pattern> pairs, where
11 # * <pattern> is a package wildcard pattern (see pkg_info(8)),
12 # * <VARNAME> is the variable that will be set to the
13 # installation prefix for the package.
18 # The prefix of the corresponding package, or ${LOCALBASE}
19 # if the package is not installed.
23 # FIND_PREFIX:= M4DIR=gm4
24 # .include "../../mk/find-prefix.mk"
25 # # ${M4DIR} now contains the installation prefix for the "gm4" package.
28 .for i in
${FIND_PREFIX}
29 . for varname in
${i
:C
/=.
*$//}
30 . for pattern in
${i
:C
/^
[^
=]*=//}
31 . if
!defined
(${varname})
33 # XXX: Is this *_DEFAULT variable really necessary? The default value
34 # can be easily embedded in the shell code. What if VARNAME is set to
35 # PKG_APACHE, for example?
37 ${varname}_DEFAULT?
= ${LOCALBASE}
39 ${PKG_INFO} -qp
${pattern
:Q
} 2>/dev
/null | \
42 "") ${ECHO} ${${varname}_DEFAULT
:Q
} ;; \
43 *) ${ECHO} "$$arg" ;; \
45 ${varname}= ${_
${varname}_cmd
:sh
}