Reputation: 1122
My recipe $(HDAIMG) is always been processed, even when already there is a $(HDAIMG) file in the folder. What am I doing wrong?
HDAIMG := $(TESTDIR)/$(PROJECT)-hda.img
HDAIMG value, actually, is test/project-hda.img
PHONY: $(PROJECT)
all: $(PROJECT) $(HDAIMG)
$(PROJECT): check-env
$(call v_exec, 1, $(MAKE) -C $(SRCDIR) $@)
$(HDAIMG): $(PROJECT) check-env
$(call print_white_init, HDAIMG)
$(call print, Creating $@)
$(call v_exec, 2, dd if=/dev/zero of=$@ count=0 bs=1 seek=$(HDAIMGSIZE) &> /dev/null)
$(call print, Partitioning $@)
$(call v_exec, 2, parted --script $@ mklabel msdos mkpart primary ext4 1 100%)
$(call print, Creating $@ device maps)
$(call v_exec, 2, sudo kpartx -a $@ -s)
$(call v_exec, 2, sudo mkfs.ext4 /dev/mapper/loop0p1 -q)
$(call v_exec, 2, sudo mount /dev/mapper/loop0p1 $(TESTDIR)/mnt)
$(call v_exec, 2, sudo umount $(TESTDIR)/mnt)
$(call v_exec, 2, sudo kpartx -d $@)
$(call print_white_done, HDAIMG)
check-env:
ifneq ($(ERROR),)
$(call print_error, $(ERROR))
exit 1
endif
That called functions are used to print with color or to execute with choosed verbose; there are in my Makeconfig.mk already included. Some:
v_exec = $(V$(strip $(1)))$(strip $(2))
print = @echo -e '$(LEAD_SUB_STR) $(strip $(1))'
print_white_init= @echo -e '$(subst PATTERN,$(strip $(1)),$(WHITE_INIT)) $(strip $(2))'
print_white_done= @echo -e '$(subst PATTERN,$(strip $(1)),$(WHITE_DONE)) $(strip $(2))'
Upvotes: 0
Views: 71
Reputation: 99172
$(HDAIMG)
has check-env
as a prerequisite, and Make always thinks that check-env
must be rebuilt, because check-env
is not actually a file that exists. Therefore Make decides that $(HDAIMG)
must be rebuilt.
It would make more sense to perform the check as the first command in the rule, rather than as a prerequisite.
Upvotes: 3