pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk Allow a new variable SUBST_FILTER_CMD.<class> that ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/e27f87f538ba
branches:  trunk
changeset: 462644:e27f87f538ba
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Tue Oct 07 10:19:09 2003 +0000

description:
Allow a new variable SUBST_FILTER_CMD.<class> that is a command filter or
pipeline that takes stdin, performs the substitions and writes the result
to stdout.  It defaults to ${SED} ${SUBST_SED.<class>}.  Use this variable
to replace the sed command with something else, like an awk process.

diffstat:

 mk/subst.mk |  23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diffs (66 lines):

diff -r 9b644662146d -r e27f87f538ba mk/subst.mk
--- a/mk/subst.mk       Tue Oct 07 09:43:30 2003 +0000
+++ b/mk/subst.mk       Tue Oct 07 10:19:09 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: subst.mk,v 1.2 2003/09/02 06:59:47 jlam Exp $
+# $NetBSD: subst.mk,v 1.3 2003/10/07 10:19:09 jlam Exp $
 #
 # This Makefile fragment implements a general text replacement facility
 # for different classes of files in ${WRKSRC}.  For each class of files,
@@ -19,6 +19,10 @@
 #
 # SUBST_SED.<class>
 #      sed(1) substitution expression to run on the specified files
+#
+# SUBST_FILTER_CMD.<class>
+#      filter used to perform the actual substitution on the specified
+#      files.  Defaults to ${SED} ${SUBST_SED.<class>}.
 
 ECHO_SUBST_MSG?=       ${ECHO}
 
@@ -29,6 +33,12 @@
 .for _class_ in ${SUBST_CLASSES}
 _SUBST_COOKIE.${_class_}=      ${WRKDIR}/.subst_${_class_}_done
 
+.if defined(SUBST_SED.${_class_}) && !empty(SUBST_SED.${_class_})
+SUBST_FILTER_CMD.${_class_}?=  ${SED} ${SUBST_SED.${_class_}}
+.else
+SUBST_FILTER_CMD.${_class_}?=  # empty
+.endif
+
 SUBST_TARGETS+=                        subst-${_class_}
 _SUBST_TARGETS.${_class_}=     subst-${_class_}-message
 _SUBST_TARGETS.${_class_}+=    ${_SUBST_COOKIE.${_class_}}
@@ -36,9 +46,9 @@
 
 .ORDER: ${_SUBST_TARGETS.${_class_}}
 
-.if defined(SUBST_STAGE.${_class_})
+.  if defined(SUBST_STAGE.${_class_})
 ${SUBST_STAGE.${_class_}}: subst-${_class_}
-.endif
+.  endif
 
 .PHONY: subst-${_class_}
 subst-${_class_}: ${_SUBST_TARGETS.${_class_}}
@@ -54,7 +64,7 @@
        ${TOUCH} ${TOUCH_FLAGS} ${_SUBST_COOKIE.${_class_}}
 
 ${_SUBST_COOKIE.${_class_}}:
-.  if !empty(SUBST_SED.${_class_})
+.  if !empty(SUBST_FILTER_CMD.${_class_})
        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
        cd ${WRKSRC};                                                   \
        files="${SUBST_FILES.${_class_}}";                              \
@@ -63,8 +73,9 @@
        *)      for file in $${files}; do                               \
                        if ${_SUBST_IS_TEXT_FILE}; then                 \
                                ${MV} -f $$file $$file.subst.sav;       \
-                               ${SED}  ${SUBST_SED.${_class_}}         \
-                                       $$file.subst.sav > $$file;      \
+                               ${CAT} $$file.subst.sav                 \
+                                       | ${SUBST_FILTER_CMD.${_class_}} \
+                                       > $$file;                       \
                                if [ -x $$file.subst.sav ]; then        \
                                        ${CHMOD} +x $$file;             \
                                fi;                                     \



Home | Main Index | Thread Index | Old Index