28

I have a Makefile with the following structure (working example).

.PHONY: image flashcard put-files

put-files:
    @echo "=== put-files"

image:
    @echo "=== image"

flashcard:
    @echo "=== flashcard"

all: put-files image flashcard
    @echo "Done"

I expect that a simple make would build all three targets, but this is not so:

% make
=== put-files

But if I explicitly specify the target, the dependencies are built as well:

% make all
=== put-files
=== image
=== flashcard
Done

What am I doing wrong?

Dave Vogt
  • 18,600
  • 7
  • 42
  • 54

1 Answers1

40

A simple make will build the first target in the list, which is put-files.

make all will build the target all. If you want all to be the default, then move it to the top of the list.

To understand what the .PHONY does, see http://www.gnu.org/s/hello/manual/make/Phony-Targets.html

koan
  • 3,596
  • 2
  • 25
  • 35
  • 1
    You're right, my problem was that I somehow figured that the default target is chosen by name ("all"), instead of by position. Thanks a lot! – Dave Vogt Jul 28 '11 at 09:04