Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Makefile always running target

Tags:

makefile

I may miss 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 devel/bar target always gets called. I'd expect it to call convert, check the file devel/bar, and call that target only if that file is not found. If I remove its dependency on init, everything works as I would expect. What am I doing wrong?

like image 674
Adam Schmideg Avatar asked Nov 27 '11 21:11

Adam Schmideg


2 Answers

You're not creating a file called init, so init is always out-of-date. Therefore everything that depends on it is always out-of-date.

like image 178
rob mayoff Avatar answered Oct 23 '22 21:10

rob mayoff


There probably is no file named init? So it tries to update devel/bar (since it depends on init).

Consider using .PHONY

like image 39
Has QUIT--Anony-Mousse Avatar answered Oct 23 '22 22:10

Has QUIT--Anony-Mousse