pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/mk Use an awk script to avoid using possibly non-porta...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/c8e8f7aa2986
branches:  trunk
changeset: 479216:c8e8f7aa2986
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Sat Aug 07 18:02:05 2004 +0000

description:
Use an awk script to avoid using possibly non-portable shell constructs.

diffstat:

 mk/bsd.options.mk |  34 ++++++++++++++++------------------
 1 files changed, 16 insertions(+), 18 deletions(-)

diffs (48 lines):

diff -r 410bcb662a6a -r c8e8f7aa2986 mk/bsd.options.mk
--- a/mk/bsd.options.mk Sat Aug 07 17:10:04 2004 +0000
+++ b/mk/bsd.options.mk Sat Aug 07 18:02:05 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.options.mk,v 1.4 2004/08/05 02:10:20 jlam Exp $
+# $NetBSD: bsd.options.mk,v 1.5 2004/08/07 18:02:05 jlam Exp $
 #
 # This Makefile fragment provides boilerplate code for standard naming
 # conventions for handling per-package build options.
@@ -169,23 +169,21 @@
        @${ECHO} "=========================================================================="
        @${ECHO} "The supported build options for this package are:"
        @${ECHO} ""
-       @set -- ${PKG_SUPPORTED_OPTIONS};                               \
-       printwidth=40;                                                  \
-       while ${TEST} $$# -gt 0; do                                     \
-               if ${TEST} -z "$$line"; then                            \
-                       line=$$1;                                       \
-               else                                                    \
-                       line="$$line $$1";                              \
-               fi;                                                     \
-               if ${TEST} $${#line} -gt $$printwidth; then             \
-                       ${ECHO} "       $$line";                        \
-                       line=;                                          \
-               fi;                                                     \
-               shift;                                                  \
-       done;                                                           \
-       if ${TEST} $${#line} -le $$printwidth; then                     \
-               ${ECHO} "       $$line";                                \
-       fi
+       @${ECHO} "${PKG_SUPPORTED_OPTIONS}" | ${XARGS} -n 1 | ${SORT} | \
+       ${AWK} '                                                        \
+               BEGIN { printwidth = 40; line = "" }                    \
+               {                                                       \
+                       if (length(line) > 0)                           \
+                               line = line" "$$0;                      \
+                       else                                            \
+                               line = $$0;                             \
+                       if (length(line) > 40) {                        \
+                               print " "line;                          \
+                               line = "";                              \
+                       }                                               \
+               }                                                       \
+               END { if (length(line) > 0) print "     "line }         \
+       '
        @${ECHO} ""
        @${ECHO} "You can select which build options to use by setting the following"
        @${ECHO} "variables.  Their curent value is shown:"



Home | Main Index | Thread Index | Old Index