Makefile always launches a target

I can skip something very obvious with this Makefile:

convert: devel/bar touch convert init: devel/foo echo 'init' devel/foo: mkdir -p devel touch devel/foo devel/bar: init touch devel/bar 

When I run it, the target devel/bar always called. I expect it to call convert , check the devel/bar file and call this target only if this file is not found. If I remove its dependency on init , everything will work as I expected. What am I doing wrong?

+4
source share
2 answers

You are not creating a file called init , so init always deprecated. Therefore, everything that depends on him is always out of date.

+6
source

Probably no file named init ? Therefore, it tries to update devel/bar (since it depends on init ).

Consider using .PHONY

+2
source

Source: https://habr.com/ru/post/1383341/


All Articles