mkimage-profiles/lib/clean.mk
Michael Shigorin 30b1aa9be6 toplevel build report now timestamped
Thanks torabora@ for yet again seemingly obvious feature request
which strangely managed to evade implementation before.

On an afterthought, mass builds would suggest too much coffee
instead of a progress indicator -- so implemented the latter.

NB: the actual downstream-make-calling rule would expand the "naive"
$(shell date) too early: the rule is evaluated before starting its
execution, and as it's the time consuming one the shell evaluation
was in need, not make's.  The result is less generally available
(needs to be double quoted and won't work inside e.g. awk programs)
but way more precise.
2011-11-07 00:01:36 +02:00

36 lines
1.0 KiB
Makefile

# this makefile can be used standalone
# drop stock predefined rules
.DEFAULT:
# tmpfs-sparing extra rule: cleanup workdir after completing each stage
# (as packed results are saved this only lowers RAM pressure)
ifdef CLEAN
export GLOBAL_CLEAN_WORKDIR = clean-current
ifdef DEBUG
WARNING = (NB: DEBUG scope is limited when CLEAN is enabled)
endif
endif
# ordinary clean: destroys workdirs but not the corresponding results
clean:
@echo "$(TIME) cleaning up $(WARNING)"
@find -name '*~' -delete >&/dev/null ||:
@if [ -L build -a -d build/ ]; then \
$(MAKE) -C build $@ \
GLOBAL_BUILDDIR=$(shell readlink build) $(LOG) ||:; \
fi
# there can be some sense in writing log here even if normally
# $(BUILDDIR)/ gets purged: make might have failed,
# and BUILDLOG can be specified by hand either
distclean: clean
@if [ -L build -a -d build/ ]; then \
rm -rf build/.git; \
$(MAKE) -C build $@ \
GLOBAL_BUILDDIR=$(shell readlink build) $(LOG) || \
rm -rf build/; \
rm -rf $(shell readlink build); \
fi
@rm -f build ||: