tRemove some redundancy between operations - mkports - recipes for building multiple softwares with mk(1)
 (HTM) git clone git://z3bra.org/mkports
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit 9cb98637f81926c6de7004f03d121bba0b198f83
 (DIR) parent b3216e162aa64c00b18607bfbde161a87c07d003
 (HTM) Author: z3bra <willyatmailoodotorg>
       Date:   Wed, 27 Jan 2016 13:52:42 +0100
       
       Remove some redundancy between operations
       
       Diffstat:
         M default.mk                          |      24 ++++++++++++++----------
         M mkfile                              |       3 +++
       
       2 files changed, 17 insertions(+), 10 deletions(-)
       ---
 (DIR) diff --git a/default.mk b/default.mk
       t@@ -1,5 +1,5 @@
        destdir = `{printf '%s/%s/.rootfs' "$(pwd)" "$pkg-$ver"}
       -archive = `{basename $url 2>/dev/null}
       +archive = `{basename $url 2>/dev/null || echo /dev/null}
        
        # create a pack from an chroot install (see the "install" target)
        $pkg\#$ver.tar.bz2:Q: fetch patch build install cleanup
       t@@ -23,12 +23,12 @@ install:QV: build
        
        cleanup:QV: install
                cd $destdir
       -        find . -name '*.la'   | xargs rm
       -        find . -name '*.so'   | xargs rm
       -        find . -name '*.so.*' | xargs rm
       -        find . -name 'info'      -type d | xargs rm -r
       -        find . -name 'doc'       -type d | xargs rm -r
       -        find . -name 'pkgconfig' -type d | xargs rm -r
       +        find . -name '*.la'   | xargs -r rm
       +        find . -name '*.so'   | xargs -r rm
       +        find . -name '*.so.*' | xargs -r rm
       +        find . -name 'info'      -type d | xargs -r rm -r
       +        find . -name 'doc'       -type d | xargs -r rm -r
       +        find . -name 'pkgconfig' -type d | xargs -r rm -r
                if [ -d ./share ] && [ -z "$(ls ./share)" ]; then
                        rmdir ./share
                fi
       t@@ -54,9 +54,8 @@ fetch-git:QV:
        
        # if $url is set, download/extract the archive, and move its
        # content to a directory named $pkg-$ver
       -fetch-archive:QV:
       +fetch-archive:QV: $archive
                if [ -n "$url" ]; then
       -                test -f $archive || curl -LO $url > $archive
                        rm -rf $pkg-$ver
                        case $archive in
                        *.tar.bz2)      opt="-xvj" ;;
       t@@ -68,12 +67,17 @@ fetch-archive:QV:
                        if [ "$src" != "$pkg-$ver" ]; then
                                mv "$src" "$pkg-$ver"
                        fi
       -                rm $archive
       +        fi
       +
       +$archive:Q:
       +        if [ -n "$url" ]; then
       +                curl -LO $url > $archive
                fi
        
        # delete everything but the pack
        clean:V:
                rm -rf $pkg-$ver
       +        test -z "$url" || rm -f $archive
        
        # remove the pack
        distclean:V: clean
 (DIR) diff --git a/mkfile b/mkfile
       t@@ -16,11 +16,14 @@ all:QV: ${ALL}
        # trying to build multiple targets from the cli, otherwise
        # the recipe will be executed one more time for the fake
        # target "command line arguments"
       +NPROC = 1
        %:V:
       +        if ! pm -i $stem >/dev/null; then
                for d in $prereq; do pm -af $d/$d#*.tar.bz2; done
                cd $stem
                env -i PATH=$PATH mk
                env -i PATH=$PATH mk clean
       +        fi
        
        clean:QV:
                for p in ${ALL}; do (cd $p; mk clean); done