fsmgr := $(shell which fsmgr) ifeq ($(fsmgr),) $(error "no fsmgr") endif sudo := $(shell [ "$$(id -u)" = 0 ] || echo sudo) rootfs ?= samizdat.seed.btrfs patchfs ?= samizdat.patch.btrfs .DEFAULT_GOAL = all .PHONY: all rootfs patchfs clean pristine all: $(rootfs) $(patchfs) clean = $(patchfs) $(rootfs) $(patsubst %.seed.btrfs, %.btrfs, $(rootfs)) clean := $(clean) $(patsubst %, %.tmp, $(clean)) clean: rm -f $(clean) pristine: clean @# TODO: implement rm --recursive --auto-umount @# TODO: consider even rm --root-command=sudo for auto-sudo. Why not for all coreutils? $(sudo) rm -i -rf _build rootfs: $(rootfs) patchfs: $(patchfs) %.patch.btrfs: %.seed.btrfs $(sudo) $(fsmgr) build $@ %.seed.btrfs: %.btrfs $(sudo) $(fsmgr) build $@ %.btrfs: $(sudo) $(fsmgr) build $@ $(patchfs): $(rootfs) $(patchfs) $(rootfs): $(sudo) REWRITE_SOURCES_LIST=y $(fsmgr) build $@