URI: 
       tAutoframework (Jeff Sickel) - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit fc165dcb3eb3f6d5994903ae7f9cb91c9f598cef
   DIR parent f810f8a5b03247430f1d7b219f83bfe31eaeee02
  HTML Author: rsc <devnull@localhost>
       Date:   Wed, 19 Oct 2005 03:15:30 +0000
       
       Autoframework (Jeff Sickel)
       
       Diffstat:
         M bin/9l                              |      53 +++++++++++++++++++++++++++++--
         M bin/ps                              |      18 +++++++++++++++++-
         M bin/psu                             |      21 ++++++++++++++++++++-
       
       3 files changed, 87 insertions(+), 5 deletions(-)
       ---
   DIR diff --git a/bin/9l b/bin/9l
       t@@ -2,14 +2,16 @@
        
        test -f $PLAN9/config && . $PLAN9/config
        libsl=""
       -
       +frameworks=""
        doautolib=true
       +doautoframework=true
        verbose=false
        
        if [ "x$1" = "x-l" ]
        then
                shift
                doautolib=false
       +        doautoframework=false
        elif [ "x$1" = "x-v" ]
        then
                shift
       t@@ -162,6 +164,51 @@ then
                        libsl="$libsl -L$X11/lib -lX11"
                fi
        fi
       +if $doautoframework
       +then
       +        ofiles=""
       +        for i
       +        do
       +                case "$i" in
       +                *.[ao])
       +                        ofiles="$ofiles $i"
       +                        ;;
       +                esac
       +        done
       +
       +        # echo "ofiles $ofiles"
       +        autoframeworks=""
       +        if [ "x$ofiles" != "x" ]
       +        then
       +                a=`
       +                        nm $ofiles |
       +                        grep '__p9l_autoframework_[a-zA-Z0-9+-]*$' |
       +                        sed 's/.*__p9l_autoframework_//' |
       +                        sort -u
       +                `
       +                for i in $a
       +                do
       +                        autoframeworks="$autoframeworks $i"
       +                        eval "need$i=true"
       +                done
       +        fi
       +
       +        if $verbose
       +        then
       +                echo "autoframeworks $autoframeworks"
       +        fi
       +
       +        for i in $autoframeworks
       +        do
       +                eval "have$i() { false; }"
       +        done
       +
       +        frameworks=""
       +        for i in $autoframeworks
       +        do        
       +                frameworks="-framework $i $frameworks"
       +        done
       +fi
        
        extralibs="-lm"
        tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}"
       t@@ -245,7 +292,7 @@ esac
        
        if $verbose
        then
       -        echo $ld -L$PLAN9/lib "$@" $libsl $extralibs
       +        echo $ld -L$PLAN9/lib "$@" $libsl $extralibs $frameworks
        fi
        
        xtmp=/tmp/9l.$$.$USER.out
       t@@ -254,7 +301,7 @@ xxout() {
                rm -f $xtmp
        }
        
       -if $ld -L$PLAN9/lib "$@" $libsl $extralibs >$xtmp 2>&1
       +if $ld -L$PLAN9/lib "$@" $libsl $extralibs $frameworks >$xtmp 2>&1
        then
                xxout
                exit 0
   DIR diff --git a/bin/ps b/bin/ps
       t@@ -64,9 +64,25 @@ function statestr(s, wchan)
                if(start ~ /..:..:../){        # drop :ss
                        sub(/:..$/, "", start);
                }
       -        printf("%-8s  %11d %8s %8s %8dK %-8s %s\n",
       +        sub(/[         ]+$/, "", cmd);
       +        line[0+nline++] = sprintf("%s\001%d\001%s\001%s\001%dK\001%s\001%s",
                        user, pid, start, cputime, mem, statestr(stat, wchan), cmd);
        }
       +
       +END{
       +        for(i=0; i<nline; i++){
       +                split(line[i], a, "\001");
       +                for(j=1; j<=7; j++)
       +                        if(length(a[j]) > max[j])
       +                                max[j] = length(a[j]);
       +        }
       +        for(i=0; i<nline; i++){
       +                split(line[i], a, "\001");
       +                printf("%-*s %*s %*s %*s %*s %-*s %s\n",
       +                        max[1], a[1], max[2], a[2], max[3], a[3], max[4], a[4],
       +                        max[5], a[5], max[6], a[6], a[7]);
       +        }
       +}
        !
        
        case "${SYSNAME:-`uname`}" in 
   DIR diff --git a/bin/psu b/bin/psu
       t@@ -19,4 +19,23 @@ case $# in
                exit 1
        esac
        
       -9 ps $flag | grep "^$user "
       +9 ps $flag | grep "^$user " | awk '
       +        BEGIN { min = 1000000 };
       +        { 
       +                line[0+nline++] = $0;
       +                n = length;
       +                sub(/ +/, "", $0);
       +                n -= length;
       +                if(n < min)
       +                        min = n;
       +        }
       +        END{
       +                s = "";
       +                for(i=0; i<min-1; i++)
       +                        s = s " ";
       +                for(i=0; i<nline; i++){
       +                        sub(s, "", line[i])
       +                        print line[i]
       +                }
       +        }
       +'