summaryrefslogtreecommitdiff
path: root/mk/plist/print-plist.mk
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2006-01-12 23:43:56 +0000
committerjlam <jlam@pkgsrc.org>2006-01-12 23:43:56 +0000
commitdd1e85068eea1eec252d89741095566e06b4c8b7 (patch)
tree549e889f813ac3835ae3b1d7708def459c235461 /mk/plist/print-plist.mk
parentcb3bdb2826ccb0db0e79327a5972b5e044b00b6f (diff)
downloadpkgsrc-dd1e85068eea1eec252d89741095566e06b4c8b7.tar.gz
Initial commit of a new module that encapsulates all of the code
for manipulating PLISTs. This module is not used by default pending more widespread testing -- currently the variable _USE_PLIST_MODULE must be defined in /etc/mk.conf to enable its use. The main features of the new PLIST module are: (1) Splits out the PLIST-handling code from bsd.pkg.mk into a separate "plist" module. (2) Splits out giant, multi-line awk scripts stored in make variables into separate awk scripts that may be joined together to post-process PLISTs. Each of these awk scripts consolidates the processing for one set of files, e.g., man pages, info pages, etc., and is more easily commented than a make variable. (3) Splits out the print-PLIST code from the regular PLIST code since they have no common pieces (print-plist.mk vs. plist.mk). (4) Completely re-implements the shared-library handling to be more efficient. Along the way, this also fixes a problem for Mac OS X users where the PLISTs incorrectly contained absolute paths. (5) Completely re-implements the info-file handling so that we can migrate from INFO_FILES definitions to just adding info/foo.info entries in the static PLISTs. (6) Adds commented-out support for automatically compressed or decompressed info page entries based on the value of MANZ. These changes will be activated after texinfo.mk has been replaced by something that is built using the more modern primitives now available in pkgsrc. (7) Move the file compression logic into a separate script "doc-compress" that compresses or decompresses files while minding symlinks. This script is now called by bsd.pkg.mk to do the "autmoatic man page handling". In the future, it will also handle the "automatic info page handling" and possible others. In general, the idea is to move stuff out of the Makefiles and into separate files where we don't need to worry about quoting rules and where each file can have a separate history of commits. This simplifies the makefile logic (especially in terms of readability) and also simplifies maintenance of the code.
Diffstat (limited to 'mk/plist/print-plist.mk')
-rw-r--r--mk/plist/print-plist.mk172
1 files changed, 172 insertions, 0 deletions
diff --git a/mk/plist/print-plist.mk b/mk/plist/print-plist.mk
new file mode 100644
index 00000000000..f3c6dcf5ab8
--- /dev/null
+++ b/mk/plist/print-plist.mk
@@ -0,0 +1,172 @@
+# $$etBSD$
+
+###
+### Automatic PLIST generation
+### - files & symlinks first
+### - @dirrm statements last
+### - empty directories are handled properly
+### - dirs from mtree files are excluded
+### - substitute for platform or package specifics substrings
+###
+### Usage:
+### - make install
+### - make print-PLIST | brain >PLIST
+###
+
+_PRINT_PLIST_AWK_SUBST={ \
+ gsub(/${OPSYS}/, "$${OPSYS}"); \
+ gsub(/${OS_VERSION:S/./\./g}/, "$${OS_VERSION}"); \
+ gsub(/${MACHINE_GNU_PLATFORM}/, "$${MACHINE_GNU_PLATFORM}"); \
+ gsub(/${MACHINE_ARCH}/, "$${MACHINE_ARCH}"); \
+ gsub(/${MACHINE_GNU_ARCH}/, "$${MACHINE_GNU_ARCH}");
+.if !empty(LOWER_VENDOR)
+_PRINT_PLIST_AWK_SUBST+= gsub(/${LOWER_VENDOR}/, "$${LOWER_VENDOR}");
+.endif
+_PRINT_PLIST_AWK_SUBST+= \
+ gsub(/${LOWER_OS_VERSION:S/./\./g}/, "$${LOWER_OS_VERSION}"); \
+ gsub(/${LOWER_OPSYS}/, "$${LOWER_OPSYS}"); \
+ gsub(/${PKGNAME_NOREV}/, "$${PKGNAME}"); \
+ gsub(/${PKGVERSION:S/./\./g:C/nb[0-9]*$$//}/, "$${PKGVERSION}");\
+ gsub(/${PKGLOCALEDIR}\/locale/, "$${PKGLOCALEDIR}/locale"); \
+ gsub("^${PKGMANDIR}\/", "man/"); \
+}
+
+_PRINT_PLIST_AWK_IGNORE= ($$0 ~ /emul\/linux\/proc/)
+_PRINT_PLIST_AWK_IGNORE+= || ($$0 ~ /^info\/dir$$/)
+.if defined(INFO_DIR) && empty(INFO_DIR:Minfo)
+_PRINT_PLIST_AWK_IGNORE+= || ($$0 ~ /^${INFO_DIR:S|/|\\/|g}\/dir$$/)
+.endif
+.if !empty(INFO_FILES)
+. for _f_ in ${INFO_FILES}
+_PRINT_PLIST_AWK_IGNORE+= || ($$0 ~ /^${INFO_DIR:S|/|\\/|g}\/${_f_:S|+|\+|g}(-[0-9]+)?(\.gz)?$$/)
+. endfor
+.endif
+
+# Common (system) directories not to generate @dirrm statements for
+# Reads MTREE_FILE and generate awk statements that will
+# sort out which directories NOT to include into the PLIST @dirrm list
+.if make(print-PLIST)
+_PRINT_PLIST_COMMON_DIRS!= ${AWK} 'BEGIN { \
+ i=0; \
+ stack[i]="${PREFIX}" ; \
+ cwd=""; \
+ } \
+ ! ( /^\// || /^\#/ || /^$$/ ) { \
+ if ( $$1 == ".." ){ \
+ i=i-1; \
+ cwd = stack[i]; \
+ } else if ( $$1 == "." ){ \
+ } else { \
+ stack[i] = cwd ; \
+ if ( i == 0 ){ \
+ cwd = $$1 ; \
+ } else { \
+ cwd = cwd "\\/" $$1 ; \
+ } \
+ print "/^" cwd "$$$$/ { next; }"; \
+ i=i+1 ; \
+ } \
+ } \
+ END { print "{ print $$$$0; }"; } \
+ ' <${MTREE_FILE}
+.endif
+
+# scan $PREFIX for any files/dirs modified since the package was extracted
+# will emit "@exec mkdir"-statements for empty directories
+# XXX will fail for data files that were copied using tar (e.g. emacs)!
+# XXX should check $LOCALBASE and $X11BASE, and add @cwd statements
+
+_PRINT_PLIST_FILES_CMD= \
+ ${FIND} ${PREFIX}/. -xdev -newer ${_EXTRACT_COOKIE} \! -type d -print
+_PRINT_PLIST_DIRS_CMD= \
+ ${FIND} ${PREFIX}/. -xdev -newer ${_EXTRACT_COOKIE} -type d -print
+
+.if !empty(LIBTOOLIZE_PLIST:M[yY][eE][sS])
+_PRINT_PLIST_LIBTOOLIZE_FILTER?= \
+ ( \
+ if ${TEST} -d ${WRKDIR}; then \
+ tmpdir="${WRKDIR}"; \
+ else \
+ tmpdir="$${TMPDIR-/tmp}"; \
+ fi; \
+ fileslist="$$tmpdir/print.plist.files.$$$$"; \
+ libslist="$$tmpdir/print.plist.libs.$$$$"; \
+ while read file; do \
+ case $$file in \
+ *.la) \
+ ${_LIBTOOL_EXPAND} $$file >> $$libslist; \
+ ;; \
+ esac; \
+ ${ECHO} "$$file"; \
+ done > $$fileslist; \
+ if ${TEST} -f "$$libslist"; then \
+ ${GREP} -hvxF "`${SORT} -u $$libslist`" "$$fileslist"; \
+ else \
+ ${CAT} "$$fileslist"; \
+ fi; \
+ ${RM} -f "$$fileslist" "$$libslist"; \
+ )
+.else
+_PRINT_PLIST_LIBTOOLIZE_FILTER?= ${CAT}
+.endif
+
+.PHONY: print-PLIST
+.if !target(print-PLIST)
+print-PLIST:
+ ${_PKG_SILENT}${_PKG_DEBUG}\
+ ${ECHO} '@comment $$'NetBSD'$$'
+ ${_PKG_SILENT}${_PKG_DEBUG}\
+ shlib_type=`${MAKE} ${MAKEFLAGS} show-shlib-type`; \
+ case $$shlib_type in \
+ "a.out") genlinks=1 ;; \
+ *) genlinks=0 ;; \
+ esac; \
+ ${_PRINT_PLIST_FILES_CMD} \
+ | ${_PRINT_PLIST_LIBTOOLIZE_FILTER} \
+ | ${SORT} \
+ | ${AWK} ' \
+ { sub("${PREFIX}/\\./", ""); } \
+ ${_PRINT_PLIST_AWK_IGNORE} { next; } \
+ ${_PRINT_PLIST_AWK_SUBST} \
+ /^@/ { print $$0; next } \
+ /.*\/lib[^\/]+\.so\.[0-9]+\.[0-9]+\.[0-9]+$$/ { \
+ print $$0; \
+ sub("\\.[0-9]+$$", ""); \
+ if ('$$genlinks') print $$0; \
+ sub("\\.[0-9]+$$", ""); \
+ if ('$$genlinks') print $$0; \
+ sub("\\.[0-9]+$$", ""); \
+ if ('$$genlinks') print $$0; \
+ next; \
+ } \
+ /.*\/lib[^\/]+\.so\.[0-9]+\.[0-9]+$$/ { \
+ print $$0; \
+ sub("\\.[0-9]+$$", ""); \
+ if ('$$genlinks') print $$0; \
+ sub("\\.[0-9]+$$", ""); \
+ if ('$$genlinks') print $$0; \
+ next; \
+ } \
+ ${PRINT_PLIST_AWK} \
+ { print $$0; }'
+ ${_PKG_SILENT}${_PKG_DEBUG}\
+ for i in `${_PRINT_PLIST_DIRS_CMD} \
+ | ${SORT} -r \
+ | ${AWK} ' \
+ /emul\/linux\/proc/ { next; } \
+ /${PREFIX:S|/|\\/|g}\/\.$$/ { next; } \
+ { sub("${PREFIX}/\\\\./", ""); } \
+ { sub("^${PKGMANDIR}/", "man/"); } \
+ ${_PRINT_PLIST_COMMON_DIRS}'` ; \
+ do \
+ if [ `${LS} -la ${PREFIX}/$$i | ${WC} -l` = 3 ]; then \
+ ${ECHO} @exec \$${MKDIR} %D/$$i | ${AWK} ' \
+ ${PRINT_PLIST_AWK} \
+ { print $$0; }' ; \
+ fi ; \
+ ${ECHO} @dirrm $$i | ${AWK} ' \
+ ${PRINT_PLIST_AWK} \
+ { print $$0; }' ; \
+ done \
+ | ${AWK} '${_PRINT_PLIST_AWK_SUBST} { print $$0; }'
+.endif # target(print-PLIST)