3d2f69f112
First, let's not do rsync --delete on an unverified target dir again: the lesson was learned during a subway hacking session and I must say that SSDs are frightening fast (even if it was more than a second to realize what happens and terminate the extermination before it got /home, thanks xterm). Second, let's use a variable for common name and make's own realpath function instead of external binary.
46 lines
1.3 KiB
Makefile
46 lines
1.3 KiB
Makefile
# this makefile can be used standalone
|
|
|
|
# drop stock predefined rules
|
|
.DEFAULT:
|
|
|
|
SYMLINK = build
|
|
|
|
# tmpfs-sparing extra rule: cleanup workdir after completing each stage
|
|
# (as packed results are saved this only lowers RAM pressure)
|
|
# NB: it's useful enough to be enabled by default in DEBUG abscence
|
|
ifndef DEBUG
|
|
CLEAN ?= 1
|
|
endif
|
|
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:
|
|
@find -name '*~' -delete >&/dev/null ||:
|
|
@if [ -L "$(SYMLINK)" -a -d "$(SYMLINK)"/ ]; then \
|
|
echo "$(TIME) cleaning up $(WARNING)"; \
|
|
$(MAKE) -C "$(SYMLINK)" $@ \
|
|
GLOBAL_BUILDDIR="$(realpath $(SYMLINK))" $(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 "$(SYMLINK)" -a -d "$(SYMLINK)"/ ]; then \
|
|
build="$(realpath $(SYMLINK)/)"; \
|
|
if [ "$$build" = / ]; then \
|
|
echo "** ERROR: invalid \`"$(SYMLINK)"' symlink" >&2; \
|
|
exit 128; \
|
|
else \
|
|
$(MAKE) -C "$(SYMLINK)" $@ \
|
|
GLOBAL_BUILDDIR="$$build" $(LOG) ||: \
|
|
rm -rf "$$build"; \
|
|
fi; \
|
|
fi
|
|
@rm -f "$(SYMLINK)"
|