tech-toolchain archive

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

Re: Changing "make clean" and "make cleandir"



On Thu, 29 Sep 2011, Simon Gerraty wrote:
Would you suggest a variable or a target for that, and do you have
name suggestions?

make clean-src
make clean-srcdir

or MKOBJDIRS=no make clean

Hmm. I wanted a target that would simultaneously clean both the src tree and the obj tree. "make MKOBJDIRS=no clean" might use existing obj dirs if they already exist, though it won't make new ones.

How about this variable:

   MKCLEANSRC
                   If set to "yes" then the "clean" and "cleandir"
                   targets will repeat their work in the source
                   directory ${.CURDIR}, in addition to the usual
                   work in ${.OBJDIR}.  If set to "no" then only
                   ${.OBJDIR} is cleaned, which is the traditional
                   behaviour.  The default is "???".

I'd like the default to be "yes", to help people who run "make" in a subdirectory of the source tree without obj dirs, then later run a build with obj dirs. In this situation, I'd like a "make cleandir" at the start of the build to remove stray files in the src tree. The default can be switched to "no" by auto-obj.mk.
However, I would accept the default being "no", with build.sh
setting it to "yes".

Do you also want a knob to switch whether or not to use "ls" to verify that "rm" worked? If so, I'd really like the default to be "yes".

I added two knobs in a test tree, and here are some timing results from

    /usr/bin/time -c \
    /bin/sh ./build.sh -U -O ../obj \
        -V MKCLEANSRC=XXX -V MKCLEANVERIFY=XXX \
        cleandir >/dev/null

in a NetBSD-current source tree with obj dirs. I discarded the first two timing results for each case, to warm the cache.

    MKCLEANSRC=no  MKCLEANVERIFY=no
                32.9u 16.7s 0:49.58 100.2% 0+0k 0+3io 0pf+0w
                33.7u 16.6s 0:50.25 100.1% 0+0k 0+3io 0pf+0w
                33.1u 16.9s 0:50.07 100.0% 0+0k 0+3io 0pf+0w

    MKCLEANSRC=no  MKCLEANVERIFY=yes
                41.9u 27.2s 1:09.02 100.3% 0+0k 0+3io 0pf+0w
                42.3u 26.8s 1:09.08 100.1% 0+0k 0+3io 0pf+0w
                41.8u 27.3s 1:08.78 100.5% 0+0k 0+3io 0pf+0w

    MKCLEANSRC=yes MKCLEANVERIFY=no
                39.9u 23.3s 1:03.14 100.2% 0+0k 0+3io 0pf+0w
                39.7u 23.5s 1:03.15 100.2% 0+0k 0+3io 0pf+0w
                39.9u 23.3s 1:03.12 100.2% 0+0k 0+3io 0pf+0w

    MKCLEANSRC=yes MKCLEANVERIFY=yes
                57.4u 43.5s 1:40.57 100.3% 0+0k 0+3io 0pf+0w
                56.7u 42.7s 1:39.84 99.6% 0+0k 0+3io 0pf+0w
                57.7u 43.4s 1:40.72 100.4% 0+0k 0+3io 0pf+0w

How would you suggest implementing a policy of never building
without objdirs?

By creating them automatically.
Using .error might be a bit harsh.

FWIW I also favor 'make destroy' (which rm -rf's the objdir)
over 'make clean*'.  Destroy is much faster, and more
reliable/thorough, and since if using auto.obj.mk the objdir
will be auto created when next you run make - no hassle.

Can you share an implementation of auto.obj.mk?

Sure.  It is inlcuded in my mk files collection:

http://www.crufty.net/ftp/pub/sjg/mk.tar.gz

Thanks.

--apb (Alan Barrett)


Home | Main Index | Thread Index | Old Index