Annotation of pkgsrc/mk/plist/plist.mk, Revision 1.50
1.50 ! prlw1 1: # $NetBSD: plist.mk,v 1.49 2015/07/04 16:18:38 joerg Exp $
1.1 jlam 2: #
3: # This Makefile fragment handles the creation of PLISTs for use by
4: # pkg_create(8).
5: #
1.6 jlam 6: # The following variables affect the PLIST generation:
1.1 jlam 7: #
8: # PLIST_TYPE specifies whether the generated PLIST is derived
9: # automatically from the installed files, or if the PLIST entries
10: # are listed in files. Valid values are "dynamic" and "static",
11: # and the default value is "static".
12: #
1.37 jlam 13: # PLIST_VARS is the list of names corresponding to automatic variables
14: # generated by plist.mk to simplify having conditionally-present
15: # entries in the PLIST. If "var" is listed in PLIST_VARS, then the
16: # automatic variable is named PLIST.var. If PLIST.var is defined,
17: # then in the PLIST generation, the ${PLIST.var} symbol is replaced
18: # with the empty string, or "@comment " otherwise.
19: #
1.42 obache 20: # PLIST_AWK_ENV holds the shell environment passed to PLIST_AWK.
21: #
22: # PLIST_AWK is the awk script that does post-processing of the PLIST.
23: #
1.25 rillig 24: # PLIST_SRC is the list of source files from which the PLIST file of
25: # the binary package will be generated. By default, its value is
26: # constructed from the PLIST.* files within the package directory,
27: # in the following order (if the files are present):
28: #
29: # PLIST.common
30: # PLIST.${OPSYS} (e.g., PLIST.NetBSD)
31: # PLIST.${MACHINE_ARCH} (e.g,, PLIST.macppc)
32: # PLIST.${OPSYS}-${MACHINE_ARCH} (e.g., PLIST.NetBSD-macppc)
33: # PLIST
34: # PLIST.common_end
1.1 jlam 35: #
36: # GENERATE_PLIST is a sequence of commands, terminating in a semicolon,
37: # that outputs contents for a PLIST to stdout and is appended to
38: # the contents of ${PLIST_SRC}.
39: #
1.6 jlam 40: # IGNORE_INFO_DIRS is a list of ${PREFIX}-relative paths that do
41: # *not* contain info files.
42: #
1.1 jlam 43:
1.32 rillig 44: _VARGROUPS+= plist
45: _USER_VARS.plist= # none
1.37 jlam 46: _PKG_VARS.plist= PLIST_SUBST PLIST_VARS PLIST_SRC GENERATE_PLIST
1.32 rillig 47: _SYS_VARS.plist= PLIST_TYPE PLIST
48:
1.37 jlam 49: PLIST_VARS?= # empty
1.42 obache 50: PLIST_AWK?= # empty
51: PLIST_AWK_ENV?= # empty
1.37 jlam 52:
1.1 jlam 53: PLIST_TYPE?= static
54:
55: ######################################################################
56:
1.26 jlam 57: .if exists(${PKGDIR}/PLIST.common)
58: PLIST_SRC_DFLT+= ${PKGDIR}/PLIST.common
59: .endif
60: .if exists(${PKGDIR}/PLIST.${OPSYS})
61: PLIST_SRC_DFLT+= ${PKGDIR}/PLIST.${OPSYS}
62: .endif
63: .if exists(${PKGDIR}/PLIST.${MACHINE_ARCH:C/i[3-6]86/i386/g})
64: PLIST_SRC_DFLT+= ${PKGDIR}/PLIST.${MACHINE_ARCH:C/i[3-6]86/i386/g}
65: .endif
66: .if exists(${PKGDIR}/PLIST.${OPSYS}-${MACHINE_ARCH:C/i[3-6]86/i386/g})
67: PLIST_SRC_DFLT+= ${PKGDIR}/PLIST.${OPSYS}-${MACHINE_ARCH:C/i[3-6]86/i386/g}
68: .endif
1.30 jlam 69: .if defined(EMUL_PLATFORM) && exists(${PKGDIR}/PLIST.${EMUL_PLATFORM})
70: PLIST_SRC_DFLT+= ${PKGDIR}/PLIST.${EMUL_PLATFORM}
71: .endif
1.26 jlam 72: .if exists(${PKGDIR}/PLIST)
73: PLIST_SRC_DFLT+= ${PKGDIR}/PLIST
74: .endif
75: .if exists(${PKGDIR}/PLIST.common_end)
76: PLIST_SRC_DFLT+= ${PKGDIR}/PLIST.common_end
77: .endif
1.35 jlam 78:
79: #
80: # If the following 3 conditions hold, then fail the package build:
81: #
82: # (1) The package doesn't set PLIST_SRC.
83: # (2) The package doesn't set GENERATE_PLIST.
84: # (3) There are no PLIST files.
85: #
86: .if !defined(PLIST_SRC) && !defined(GENERATE_PLIST)
87: . if !defined(PLIST_SRC_DFLT) || empty(PLIST_SRC_DFLT)
88: PKG_FAIL_REASON+= "Missing PLIST file or PLIST/GENERATE_PLIST definition."
89: . endif
90: .endif
91:
1.26 jlam 92: PLIST_SRC?= ${PLIST_SRC_DFLT}
1.1 jlam 93:
94: # This is the path to the generated PLIST file.
95: PLIST= ${WRKDIR}/.PLIST
1.24 heinz 96: _PLIST_NOKEYWORDS=${PLIST}_nokeywords
1.1 jlam 97:
98: ######################################################################
99:
100: .if (defined(USE_IMAKE) || !empty(USE_TOOLS:Mimake))
1.13 jlam 101: _IMAKE_MANINSTALL= ${IMAKE_MANINSTALL}
1.41 tron 102: _PLIST_MANINSTALL= ${IMAKE_MANINSTALL}
1.13 jlam 103: .else
1.1 jlam 104: _IMAKE_MANINSTALL= # empty
1.41 tron 105: _PLIST_MANINSTALL= ${MANINSTALL}
1.1 jlam 106: .endif
107:
108: _LIBTOOL_EXPAND= \
1.40 abs 109: ${PKGSRC_SETENV} ECHO=${TOOLS_ECHO:Q} GREP=${TOOLS_GREP:Q} \
1.1 jlam 110: SORT=${TOOLS_SORT:Q} TEST=${TOOLS_TEST:Q} \
1.45 obache 111: BASENAME=${BASENAME:Q} DIRNAME=${DIRNAME:Q} \
112: PWD_CMD=${PWD_CMD:Q} \
113: SHLIB_TYPE=${SHLIB_TYPE:Q} \
1.1 jlam 114: ${SH} ${.CURDIR}/../../mk/plist/libtool-expand
115:
1.6 jlam 116: .if !defined(_IGNORE_INFO_PATH)
117: . for _dir_ in ${IGNORE_INFO_DIRS}
118: _IGNORE_INFO_PATH:= ${_IGNORE_INFO_PATH}:${_dir_}
119: . endfor
120: _IGNORE_INFO_PATH:= ${_IGNORE_INFO_PATH:S/^://}
121: .endif
122: MAKEVARS+= _IGNORE_INFO_PATH
123:
1.1 jlam 124: # _PLIST_AWK_ENV holds the shell environment passed to the awk script
125: # that does post-processing of the PLIST. See the individual *.awk
126: # scripts for information on each of the variable set in the environment.
127: #
1.10 jlam 128: _PLIST_AWK_ENV+= PKGLOCALEDIR=${PKGLOCALEDIR:Q}
1.11 jlam 129: _PLIST_AWK_ENV+= USE_PKGLOCALEDIR=${USE_PKGLOCALEDIR:Dyes:Uno}
1.46 jperkin 130: _PLIST_AWK_ENV+= CATMAN_SECTION_SUFFIX=${CATMAN_SECTION_SUFFIX:Q}
1.1 jlam 131: _PLIST_AWK_ENV+= IMAKE_MANINSTALL=${_IMAKE_MANINSTALL:Q}
1.6 jlam 132: _PLIST_AWK_ENV+= IGNORE_INFO_PATH=${_IGNORE_INFO_PATH:Q}
1.7 jlam 133: _PLIST_AWK_ENV+= PKGINFODIR=${PKGINFODIR:Q}
1.8 jlam 134: _PLIST_AWK_ENV+= IGNORE_LIBTOOLIZE=${IGNORE_LIBTOOLIZE:Q}
1.1 jlam 135: _PLIST_AWK_ENV+= LIBTOOLIZE_PLIST=${LIBTOOLIZE_PLIST:Q}
1.5 jlam 136: _PLIST_AWK_ENV+= LIBTOOL_EXPAND=${_LIBTOOL_EXPAND:Q}
1.1 jlam 137: _PLIST_AWK_ENV+= LS=${TOOLS_LS:Q}
1.41 tron 138: _PLIST_AWK_ENV+= MANINSTALL=${_PLIST_MANINSTALL:Q}
1.1 jlam 139: _PLIST_AWK_ENV+= MANZ=${_MANZ:Q}
1.44 jperkin 140: _PLIST_AWK_ENV+= PKGGNUDIR=${PKGGNUDIR:Q}
1.1 jlam 141: _PLIST_AWK_ENV+= PKGMANDIR=${PKGMANDIR:Q}
1.16 joerg 142: _PLIST_AWK_ENV+= PREFIX=${DESTDIR:Q}${PREFIX:Q}
1.1 jlam 143: _PLIST_AWK_ENV+= TEST=${TOOLS_TEST:Q}
1.42 obache 144: _PLIST_AWK_ENV+= ${PLIST_AWK_ENV}
1.1 jlam 145:
146: # PLIST_SUBST contains package-settable "${variable}" to "value"
147: # substitutions for PLISTs
148: #
149: PLIST_SUBST+= OPSYS=${OPSYS:Q} \
150: OS_VERSION=${OS_VERSION:Q} \
151: MACHINE_ARCH=${MACHINE_ARCH:Q} \
152: MACHINE_GNU_ARCH=${MACHINE_GNU_ARCH:Q} \
153: MACHINE_GNU_PLATFORM=${MACHINE_GNU_PLATFORM:Q} \
154: LN=${LN:Q} \
155: LOWER_VENDOR=${LOWER_VENDOR:Q} \
156: LOWER_OPSYS=${LOWER_OPSYS:Q} \
157: LOWER_OS_VERSION=${LOWER_OS_VERSION:Q} \
158: PKGBASE=${PKGBASE:Q} \
159: PKGNAME=${PKGNAME_NOREV:Q} \
160: PKGLOCALEDIR=${PKGLOCALEDIR:Q} \
1.19 uebayasi 161: PKGVERSION=${PKGVERSION:C/nb[0-9]*$//:Q} \
1.1 jlam 162: LOCALBASE=${LOCALBASE:Q} \
163: VIEWBASE=${VIEWBASE:Q} \
164: X11BASE=${X11BASE:Q} \
165: CHGRP=${CHGRP:Q} \
166: CHMOD=${CHMOD:Q} \
167: CHOWN=${CHOWN:Q} \
168: MKDIR=${MKDIR:Q} \
169: RMDIR=${RMDIR:Q} \
170: RM=${RM:Q} \
171: TRUE=${TRUE:Q} \
1.44 jperkin 172: PKGGNUDIR=${PKGGNUDIR:Q} \
1.1 jlam 173: PKGMANDIR=${PKGMANDIR:Q}
174:
1.37 jlam 175: .for _var_ in ${PLIST_VARS}
176: PLIST_SUBST+= ${PLIST.${_var_}:DPLIST.${_var_}=:UPLIST.${_var_}="@comment "}
177: .endfor
178:
1.1 jlam 179: # Pass the PLIST_SUBST substitutions to the subst.awk script by prepending
180: # PLIST_" to all of the variable names and adding them into the environment.
181: #
182: _PLIST_AWK_ENV+= ${PLIST_SUBST:S/^/PLIST_/}
183: _PLIST_AWK_ENV+= PLIST_SUBST_VARS=${PLIST_SUBST:S/^/PLIST_/:C/=.*//:M*:Q}
184:
1.36 rillig 185: _PLIST_1_AWK+= -f ${PKGSRCDIR}/mk/plist/plist-functions.awk
186: _PLIST_1_AWK+= -f ${PKGSRCDIR}/mk/plist/plist-subst.awk
187: _PLIST_1_AWK+= -f ${PKGSRCDIR}/mk/plist/plist-macros.awk
188:
1.1 jlam 189: _PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-functions.awk
1.10 jlam 190: _PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-locale.awk
1.44 jperkin 191: _PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-gnu.awk
1.1 jlam 192: _PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-info.awk
193: _PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-man.awk
194: _PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-libtool.awk
1.45 obache 195: .if ${OPSYS} == "Cygwin"
196: _PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-cygwin.awk
197: .endif
1.42 obache 198: _PLIST_AWK+= ${PLIST_AWK}
1.1 jlam 199: _PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-default.awk
200:
1.7 jlam 201: _PLIST_INFO_AWK+= -f ${.CURDIR}/../../mk/plist/plist-functions.awk
202: _PLIST_INFO_AWK+= -f ${.CURDIR}/../../mk/plist/plist-info.awk
203:
1.1 jlam 204: _PLIST_SHLIB_AWK= -f ${_SHLIB_AWKFILE.${SHLIB_TYPE}}
1.21 tnn 205: _SHLIB_AWKFILE.ECOFF= ${.CURDIR}/../../mk/plist/shlib-elf.awk
1.1 jlam 206: _SHLIB_AWKFILE.ELF= ${.CURDIR}/../../mk/plist/shlib-elf.awk
1.22 tnn 207: _SHLIB_AWKFILE.SOM= ${.CURDIR}/../../mk/plist/shlib-som.awk
1.38 joerg 208: _SHLIB_AWKFILE.aixlib= ${.CURDIR}/../../mk/plist/shlib-elf.awk
1.1 jlam 209: _SHLIB_AWKFILE.a.out= ${.CURDIR}/../../mk/plist/shlib-aout.awk
1.45 obache 210: _SHLIB_AWKFILE.PEwin= ${.CURDIR}/../../mk/plist/shlib-pe.awk
1.1 jlam 211: _SHLIB_AWKFILE.dylib= ${.CURDIR}/../../mk/plist/shlib-dylib.awk
212: _SHLIB_AWKFILE.none= ${.CURDIR}/../../mk/plist/shlib-none.awk
213:
214: ######################################################################
215:
216: # GENERATE_PLIST is a sequence of commands, terminating in a semicolon,
217: # that outputs contents for a PLIST to stdout and is appended to
218: # the contents of ${PLIST_SRC}.
219: #
1.35 jlam 220: .if empty(PLIST_SRC)
221: GENERATE_PLIST?= ${ECHO} "@comment "${PKGNAME:Q}" has no files.";
222: .else
223: GENERATE_PLIST?= ${TRUE};
1.34 jlam 224: .endif
225:
1.14 rillig 226: _BUILD_DEFS+= _PLIST_IGNORE_FILES
1.1 jlam 227:
228: .if ${PLIST_TYPE} == "dynamic"
229: _PLIST_IGNORE_CMD= \
230: ( while read i; do \
231: ignore=no; \
232: for p in ${_PLIST_IGNORE_FILES}; do \
233: case "$$i" in \
234: $$p) ignore=yes; break ;; \
235: esac; \
236: done; \
237: [ "$$ignore" = "yes" ] || ${ECHO} "$$i"; \
238: done )
239: _GENERATE_PLIST= \
1.16 joerg 240: ${FIND} ${DESTDIR}${PREFIX} \! -type d -print | ${SORT} | \
241: ${SED} -e "s|^${DESTDIR}${PREFIX}/||" | \
1.1 jlam 242: ${_PLIST_IGNORE_CMD}; \
1.16 joerg 243: ${FIND} ${DESTDIR}${PREFIX} -type d -print | ${SORT} -r | \
1.1 jlam 244: ${GREP} -v "^${PREFIX}$$" | \
245: ${_PLIST_IGNORE_CMD} | \
1.16 joerg 246: ${SED} -e "s|^${DESTDIR}${PREFIX}/|@unexec ${RMDIR} -p %D/|" \
1.1 jlam 247: -e "s,$$, 2>/dev/null || ${TRUE},";
248: .else
1.34 jlam 249: _GENERATE_PLIST= ${CAT} /dev/null ${PLIST_SRC}; ${GENERATE_PLIST}
1.1 jlam 250: .endif
251:
252: .PHONY: plist
1.23 heinz 253: plist: ${PLIST} ${_PLIST_NOKEYWORDS}
1.1 jlam 254:
1.33 jlam 255: .if (${PLIST_TYPE} == "static") && !empty(PLIST_SRC)
1.1 jlam 256: ${PLIST}: ${PLIST_SRC}
257: .endif
258: ${PLIST}:
1.36 rillig 259: ${RUN} ${MKDIR} ${.TARGET:H}
260: ${RUN} { ${_GENERATE_PLIST} } > ${.TARGET}-1src
1.40 abs 261: ${RUN} ${PKGSRC_SETENV} ${_PLIST_AWK_ENV} ${AWK} ${_PLIST_1_AWK} < ${.TARGET}-1src > ${.TARGET}-2mac
262: ${RUN} ${PKGSRC_SETENV} ${_PLIST_AWK_ENV} ${AWK} ${_PLIST_AWK} < ${.TARGET}-2mac > ${.TARGET}-3mag
263: ${RUN} ${PKGSRC_SETENV} ${_PLIST_AWK_ENV} ${AWK} ${_PLIST_SHLIB_AWK} < ${.TARGET}-3mag > ${.TARGET}
1.7 jlam 264:
1.23 heinz 265: # for list of keywords see pkg_create(1)
266: ${_PLIST_NOKEYWORDS}: ${PLIST}
1.39 rillig 267: ${RUN} ${AWK} < ${PLIST} > ${.TARGET} ' \
1.23 heinz 268: BEGIN { \
269: FILTER="@("; \
270: FILTER=FILTER"cd|cwd|src|exec|unexec|mode|option";\
271: FILTER=FILTER"|owner|group|comment|ignore"; \
272: FILTER=FILTER"|ignore_inst|name|dirrm|mtree"; \
273: FILTER=FILTER"|display|pkgdep|blddep|pkgcfl"; \
274: FILTER=FILTER")[[:space:]]"; \
275: }; \
276: $$0 ~ FILTER { next }; \
277: { print }'
278:
1.7 jlam 279: .if defined(INFO_FILES)
280: INFO_FILES_cmd= \
281: ${CAT} ${PLIST} | \
1.40 abs 282: ${PKGSRC_SETENV} ${_PLIST_AWK_ENV} ${AWK} ${_PLIST_INFO_AWK} | \
1.20 rillig 283: ${AWK} '($$0 !~ "-[0-9]*(\\.gz)?$$") { print }'
1.7 jlam 284: .endif
1.43 cheusov 285:
1.50 ! prlw1 286: ICON_THEMES_cmd= \
! 287: ${CAT} ${PLIST} | \
! 288: ${PKGSRC_SETENV} ${_PLIST_AWK_ENV} ${AWK} -F / \
! 289: '$$0 ~ "^share/icons/[^/]+/.*$$" { print $$3 }' | \
! 290: ${SORT} -u
! 291:
1.43 cheusov 292: ######################################################################
293: ### plist-clean (PRIVATE)
294: ######################################################################
295: ### plist-clean removes the files for the "plist"
296: ### so that the "plist" target may be re-invoked.
297: ###
298: .PHONY: plist-clean
299: plist-clean:
300: ${RUN} ${RM} -f ${PLIST} ${_PLIST_NOKEYWORDS} ${_DEPENDS_PLIST}
CVSweb <webmaster@jp.NetBSD.org>