gnu make - Makefile rule always been processed -


my recipe $(hdaimg) been processed, when there $(hdaimg) file in folder. what doing wrong?

hdaimg      := $(testdir)/$(project)-hda.img 

hdaimg value, actually, 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 used print color or execute choosed verbose; there in makeconfig.mk 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))' 

$(hdaimg) has check-env prerequisite, , make thinks check-env must rebuilt, because check-env not file exists. therefore make decides $(hdaimg) must rebuilt.

it make more sense perform check first command in rule, rather prerequisite.


Comments

Popular posts from this blog

Change the color of an oval at click in Java AWT -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -