Mon Mar 30 22:54:24 2020 UTC ()
mk/plist/plist.mk: use less verbose code for picking up PLIST files

While here, add more verbose documentation on PLIST_SUBST since the way
from the package's PLIST file to the +PLIST file can easily be confused
with the other way round, which is handled by print-PLIST.


(rillig)
diff -r1.53 -r1.54 pkgsrc/mk/plist/plist.mk

cvs diff -r1.53 -r1.54 pkgsrc/mk/plist/plist.mk (expand / switch to unified diff)

--- pkgsrc/mk/plist/plist.mk 2020/01/05 21:38:54 1.53
+++ pkgsrc/mk/plist/plist.mk 2020/03/30 22:54:24 1.54
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: plist.mk,v 1.53 2020/01/05 21:38:54 rillig Exp $ 1# $NetBSD: plist.mk,v 1.54 2020/03/30 22:54:24 rillig Exp $
2# 2#
3# This Makefile fragment handles the creation of PLISTs for use by 3# This Makefile fragment handles the creation of PLISTs for use by
4# pkg_create(8). 4# pkg_create(8).
5# 5#
6# The following variables affect the PLIST generation: 6# The following variables affect the PLIST generation:
7# 7#
8# PLIST_TYPE specifies whether the generated PLIST is derived 8# PLIST_TYPE specifies whether the generated PLIST is derived
9# automatically from the installed files, or if the PLIST entries 9# automatically from the installed files, or if the PLIST entries
10# are listed in files. Valid values are "dynamic" and "static", 10# are listed in files. Valid values are "dynamic" and "static",
11# and the default value is "static". 11# and the default value is "static".
12# 12#
13# PLIST_VARS is the list of names corresponding to automatic variables 13# PLIST_VARS is the list of names corresponding to automatic variables
14# generated by plist.mk to simplify having conditionally-present 14# generated by plist.mk to simplify having conditionally-present
@@ -46,47 +46,38 @@ _USER_VARS.plist= # none @@ -46,47 +46,38 @@ _USER_VARS.plist= # none
46_PKG_VARS.plist= PLIST_SUBST PLIST_VARS PLIST_SRC GENERATE_PLIST 46_PKG_VARS.plist= PLIST_SUBST PLIST_VARS PLIST_SRC GENERATE_PLIST
47_SYS_VARS.plist= PLIST_TYPE PLIST 47_SYS_VARS.plist= PLIST_TYPE PLIST
48_SORTED_VARS.plist= *_SUBST *_VARS 48_SORTED_VARS.plist= *_SUBST *_VARS
49_LISTED_VARS.plist= *_SRC GENERATE_PLIST 49_LISTED_VARS.plist= *_SRC GENERATE_PLIST
50 50
51PLIST_VARS?= # empty 51PLIST_VARS?= # empty
52PLIST_AWK?= # empty 52PLIST_AWK?= # empty
53PLIST_AWK_ENV?= # empty 53PLIST_AWK_ENV?= # empty
54 54
55PLIST_TYPE?= static 55PLIST_TYPE?= static
56 56
57###################################################################### 57######################################################################
58 58
59.if exists(${PKGDIR}/PLIST.common) 59.for f in \
60PLIST_SRC_DFLT+= ${PKGDIR}/PLIST.common 60 PLIST.common \
61.endif 61 PLIST.${OPSYS} \
62.if exists(${PKGDIR}/PLIST.${OPSYS}) 62 PLIST.${MACHINE_ARCH:C/i[3-6]86/i386/g} \
63PLIST_SRC_DFLT+= ${PKGDIR}/PLIST.${OPSYS} 63 PLIST.${OPSYS}-${MACHINE_ARCH:C/i[3-6]86/i386/g} \
64.endif 64 ${defined(EMUL_PLATFORM):?PLIST.${EMUL_PLATFORM}:} \
65.if exists(${PKGDIR}/PLIST.${MACHINE_ARCH:C/i[3-6]86/i386/g}) 65 PLIST \
66PLIST_SRC_DFLT+= ${PKGDIR}/PLIST.${MACHINE_ARCH:C/i[3-6]86/i386/g} 66 PLIST.common_end
67.endif 67. if exists(${PKGDIR}/${f})
68.if exists(${PKGDIR}/PLIST.${OPSYS}-${MACHINE_ARCH:C/i[3-6]86/i386/g}) 68PLIST_SRC_DFLT+= ${PKGDIR}/${f}
69PLIST_SRC_DFLT+= ${PKGDIR}/PLIST.${OPSYS}-${MACHINE_ARCH:C/i[3-6]86/i386/g} 69. endif
70.endif 70.endfor
71.if defined(EMUL_PLATFORM) && exists(${PKGDIR}/PLIST.${EMUL_PLATFORM}) 
72PLIST_SRC_DFLT+= ${PKGDIR}/PLIST.${EMUL_PLATFORM} 
73.endif 
74.if exists(${PKGDIR}/PLIST) 
75PLIST_SRC_DFLT+= ${PKGDIR}/PLIST 
76.endif 
77.if exists(${PKGDIR}/PLIST.common_end) 
78PLIST_SRC_DFLT+= ${PKGDIR}/PLIST.common_end 
79.endif 
80 71
81# 72#
82# If the following 3 conditions hold, then fail the package build: 73# If the following 3 conditions hold, then fail the package build:
83# 74#
84# (1) The package doesn't set PLIST_SRC. 75# (1) The package doesn't set PLIST_SRC.
85# (2) The package doesn't set GENERATE_PLIST. 76# (2) The package doesn't set GENERATE_PLIST.
86# (3) There are no PLIST files. 77# (3) There are no PLIST files.
87# 78#
88.if !defined(PLIST_SRC) && !defined(GENERATE_PLIST) 79.if !defined(PLIST_SRC) && !defined(GENERATE_PLIST)
89. if !defined(PLIST_SRC_DFLT) || empty(PLIST_SRC_DFLT) 80. if !defined(PLIST_SRC_DFLT) || empty(PLIST_SRC_DFLT)
90PKG_FAIL_REASON+= "Missing PLIST file or PLIST/GENERATE_PLIST definition." 81PKG_FAIL_REASON+= "Missing PLIST file or PLIST/GENERATE_PLIST definition."
91. endif 82. endif
92.endif 83.endif
@@ -135,28 +126,39 @@ _PLIST_AWK_ENV+= IGNORE_INFO_PATH=${_IGN @@ -135,28 +126,39 @@ _PLIST_AWK_ENV+= IGNORE_INFO_PATH=${_IGN
135_PLIST_AWK_ENV+= PKGINFODIR=${PKGINFODIR:Q} 126_PLIST_AWK_ENV+= PKGINFODIR=${PKGINFODIR:Q}
136_PLIST_AWK_ENV+= IGNORE_LIBTOOLIZE=${IGNORE_LIBTOOLIZE:Q} 127_PLIST_AWK_ENV+= IGNORE_LIBTOOLIZE=${IGNORE_LIBTOOLIZE:Q}
137_PLIST_AWK_ENV+= LIBTOOLIZE_PLIST=${LIBTOOLIZE_PLIST:Q} 128_PLIST_AWK_ENV+= LIBTOOLIZE_PLIST=${LIBTOOLIZE_PLIST:Q}
138_PLIST_AWK_ENV+= LIBTOOL_EXPAND=${_LIBTOOL_EXPAND:Q} 129_PLIST_AWK_ENV+= LIBTOOL_EXPAND=${_LIBTOOL_EXPAND:Q}
139_PLIST_AWK_ENV+= LS=${TOOLS_LS:Q} 130_PLIST_AWK_ENV+= LS=${TOOLS_LS:Q}
140_PLIST_AWK_ENV+= MANINSTALL=${_PLIST_MANINSTALL:Q} 131_PLIST_AWK_ENV+= MANINSTALL=${_PLIST_MANINSTALL:Q}
141_PLIST_AWK_ENV+= MANZ=${_MANZ:Q} 132_PLIST_AWK_ENV+= MANZ=${_MANZ:Q}
142_PLIST_AWK_ENV+= PKGGNUDIR=${PKGGNUDIR:Q} 133_PLIST_AWK_ENV+= PKGGNUDIR=${PKGGNUDIR:Q}
143_PLIST_AWK_ENV+= PKGMANDIR=${PKGMANDIR:Q} 134_PLIST_AWK_ENV+= PKGMANDIR=${PKGMANDIR:Q}
144_PLIST_AWK_ENV+= PREFIX=${DESTDIR:Q}${PREFIX:Q} 135_PLIST_AWK_ENV+= PREFIX=${DESTDIR:Q}${PREFIX:Q}
145_PLIST_AWK_ENV+= TEST=${TOOLS_TEST:Q} 136_PLIST_AWK_ENV+= TEST=${TOOLS_TEST:Q}
146_PLIST_AWK_ENV+= ${PLIST_AWK_ENV} 137_PLIST_AWK_ENV+= ${PLIST_AWK_ENV}
147 138
148# PLIST_SUBST contains package-settable "${variable}" to "value" 139# PLIST_SUBST contains package-settable VAR=value substitutions that are
149# substitutions for PLISTs 140# used when generating the actual file list for the package from the
 141# package's PLIST files, as listed in PLIST_SRC. These files may contain
 142# placeholders of the form ${VAR}, which are then substituted by their
 143# corresponding value from PLIST_SUBST.
 144#
 145# Example: PLIST_SUBST+= PKGNAME=${PKGNAME_NOREV} means that the package's
 146# PLIST file may contain the placeholder ${PKGNAME}, which will be replaced
 147# with the package version excluding the "nb13" extension.
 148#
 149# The other direction of generating the package's PLIST file from the list
 150# of actually installed files is covered by PRINT_PLIST_AWK. This is only
 151# needed when developing the package itself, for example after an update.
150# 152#
151PLIST_SUBST+= OPSYS=${OPSYS:Q} \ 153PLIST_SUBST+= OPSYS=${OPSYS:Q} \
152 OS_VERSION=${OS_VERSION:Q} \ 154 OS_VERSION=${OS_VERSION:Q} \
153 MACHINE_ARCH=${MACHINE_ARCH:Q} \ 155 MACHINE_ARCH=${MACHINE_ARCH:Q} \
154 MACHINE_GNU_ARCH=${MACHINE_GNU_ARCH:Q} \ 156 MACHINE_GNU_ARCH=${MACHINE_GNU_ARCH:Q} \
155 MACHINE_GNU_PLATFORM=${MACHINE_GNU_PLATFORM:Q} \ 157 MACHINE_GNU_PLATFORM=${MACHINE_GNU_PLATFORM:Q} \
156 LN=${LN:Q} \ 158 LN=${LN:Q} \
157 LOWER_VENDOR=${LOWER_VENDOR:Q} \ 159 LOWER_VENDOR=${LOWER_VENDOR:Q} \
158 LOWER_OPSYS=${LOWER_OPSYS:Q} \ 160 LOWER_OPSYS=${LOWER_OPSYS:Q} \
159 LOWER_OS_VERSION=${LOWER_OS_VERSION:Q} \ 161 LOWER_OS_VERSION=${LOWER_OS_VERSION:Q} \
160 PKGBASE=${PKGBASE:Q} \ 162 PKGBASE=${PKGBASE:Q} \
161 PKGNAME=${PKGNAME_NOREV:Q} \ 163 PKGNAME=${PKGNAME_NOREV:Q} \
162 PKGLOCALEDIR=${PKGLOCALEDIR:Q} \ 164 PKGLOCALEDIR=${PKGLOCALEDIR:Q} \