quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] [patch 4/4] makefile cleanup


From: John Vandenberg
Subject: [Quilt-dev] [patch 4/4] makefile cleanup
Date: Wed, 28 Sep 2005 11:54:44 +1000
User-agent: quilt/0.42-1

Add quilt --reference to print all command help
Output --reference to a file and parse for quilt.1 and README

 bin/quilt.in   |   55 ++++++++++++++++++++++++++++++++++++++++++++-----------
 Makefile.in    |   41 ++++++++++++-----------------------------
 doc/.cvsignore |    2 +-
 3 files changed, 57 insertions(+), 41 deletions(-)

--- quilt-local.orig/bin/quilt.in
+++ quilt-local/bin/quilt.in
@@ -32,8 +32,8 @@ fi
 
 usage()
 {
-
        echo $"Usage: quilt [--trace[=verbose]] [--quiltrc=XX] command [-h] ..."
+       echo $"       quilt --reference"
        echo $"       quilt --version"
 
        echo $"Commands are:"
@@ -41,7 +41,7 @@ usage()
        | sort \
        | column | column -t \
        | sed -e $'s/^/\t/'
-       echo $"
+       printf $"
 Global options:
 
 --trace
@@ -53,10 +53,37 @@ Global options:
        documentation for details about its possible contents.
 
 --version
-       Print the version number and exit immediately."
+       Print the version number and exit immediately.
+
+--reference
+       Print the command referernce.
+"
        exit 1
 }
 
+quilt_command ()
+{
+       local command=$1
+       shift
+
+       QUILT_COMMAND="" bash $BASH_OPTS -c ". $QUILT_COMMAND_DIR/$command" 
"quilt $command" "$@"
+}
+
+quilt_reference()
+{
+       local command
+
+
+       for command in $(quilt_commands)
+       do
+               quilt_command $command -h
+               echo
+       done | \
+       sed -e 's/\$EDITOR ([^)]*)/$EDITOR/' \
+           -e '/^$/!s/^/  /' \
+           -e 's/^  Usage: quilt *//'
+}
+
 quilt_commands()
 {
        local command
@@ -75,6 +102,20 @@ then
        exit
 fi
 
+# Support compatibility layer
+if [ -d "$QUILT_DIR"/compat ]
+then
+       export PATH="$QUILT_DIR/compat:$PATH"
+fi
+
+export QUILT_DIR QUILT_SCRIPTS QUILT_LIB QUILT_COMMAND_DIR
+
+if [ $# -eq 1 -a "$1" == "--reference" ]
+then
+       quilt_reference
+       exit
+fi
+
 BASH_OPTS=
 while [ $# -ne 0 ]
 do
@@ -112,12 +153,6 @@ do
        shift
 done
 
-# Support compatibility layer
-if [ -d "$QUILT_DIR"/compat ]
-then
-       export PATH="$QUILT_DIR/compat:$PATH"
-fi
-
 if ! [ -f "$QUILT_COMMAND_DIR/$command" -a -x "$QUILT_COMMAND_DIR/$command" ]
 then
        if [ -n "$command" ]
@@ -151,6 +186,4 @@ unset args
 
 export QUILT_COMMAND="${command##*/}"
 
-export QUILT_DIR QUILT_SCRIPTS QUILT_LIB QUILT_COMMAND_DIR
-
 bash $BASH_OPTS -c ". $QUILT_COMMAND_DIR/$command" "quilt ${command##*/}" "$@"
--- quilt-local.orig/Makefile.in
+++ quilt-local/Makefile.in
@@ -157,12 +157,12 @@ po/quilt.pot: $(filter-out debian/contro
        |msguniq \
        |msgcat --force-po -F - $@ -o $@
 
-doc/README : doc/README.in $(QUILT:%=quilt/%)
+doc/README : doc/README.in $(QUILT:%=quilt/%) doc/reference
        @echo "README.in -> README"
        @while read line; do \
                case "$$line" in \
                @REFERENCE@) \
-                       $(MAKE) -s reference | grep -v '^make' \
+                       sed -e $$'s/^\([^ ]\)/\\nquilt \\1/g' doc/reference; \
                        ;; \
                *) \
                        echo $$line \
@@ -170,26 +170,18 @@ doc/README : doc/README.in $(QUILT:%=qui
                esac ; \
        done 2>&1 < $< > $@
 
-doc/quilt.1: doc/quilt.1.in $(QUILT:%=quilt/%)
+doc/quilt.1: doc/quilt.1.in $(QUILT:%=quilt/%) doc/reference
        @echo "quilt.1.in -> quilt.1"
        @while read line; do                             \
          case "$$line" in                               \
            '@REFERENCE''@')                             \
-              for cmd in $(sort $(QUILT)) ; do \
-               ($(BASH) -c "LC_ALL=C ./bin/quilt $$cmd -h")| \
-                  sed -e 's/Usage: quilt //'            \
-                      -e 's/^\([^ ]*\)/\\fB\1\\fP/'     \
-                      -e 's/^/.IP "/' -e 's/$$/ " 4/' | \
-                  head -n 1;                            \
-                echo ;                                  \
-               ($(BASH) -c "LC_ALL=C ./bin/quilt $$cmd -h")| \
-                grep -v 'Usage: quilt' |                \
-                  sed -e $$'s/^\t//'                    \
-                      -e $$'s/\t/\\\n/' |               \
-                  sed -e 's/^\(-.*\)$$/.IP "    \1" 8/' \
-                      -e 's/\$$EDITOR ([^)]*)/$$EDITOR/'; \
-                echo;                                   \
-              done                                      \
+                sed -e '/^[a-z]/{s/^\([^ ]*\)/\\fB\1\\fP/; \
+                                 s/^/.IP "/;            \
+                                 s/$$/ " 4/;}'          \
+                    -e $$'s/^\(.IP.*4\)/\\1\\n/'           \
+                    -e $$'s/^[\t ]*//'                  \
+                    -e $$'s/\t/\\\n/' doc/reference |   \
+                sed -e 's/^ *\(-.*\)$$/.IP "    \1" 8/'; \
             ;;                                          \
             *)                                          \
               echo "$$line"                             \
@@ -197,17 +189,8 @@ doc/quilt.1: doc/quilt.1.in $(QUILT:%=qu
           esac ;                                        \
        done 2>&1 < $< > $@
 
-.PHONY : reference
-reference : $(QUILT:%=quilt/%) scripts/patchfns
-       @for cmd in $(sort $(QUILT)); \
-       do \
-               echo; \
-               ($(BASH) -c "LC_ALL=C ./bin/quilt $$cmd -h"); \
-               echo; \
-       done | \
-       sed -e 's/\$$EDITOR ([^)]*)/$$EDITOR/' \
-           -e '/^$$/!s/^/  /' \
-           -e 's/^  Usage: *//'
+doc/reference : bin/quilt $(QUILT:%=quilt/%) scripts/patchfns
+       LC_ALL=C ./bin/quilt --reference > $@
 
 bin/guards.1 : bin/guards
        mkdir -p `dirname address@hidden
--- quilt-local.orig/doc/.cvsignore
+++ quilt-local/doc/.cvsignore
@@ -1 +1 @@
-quilt.1 quilt.dvi quilt.ps README quilt.aux quilt.log
+quilt.1 quilt.dvi quilt.ps README quilt.aux quilt.log reference

--
John




reply via email to

[Prev in Thread] Current Thread [Next in Thread]