Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between "make" and "make all"?

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?

like image 856
Dave Vogt Avatar asked Jul 28 '11 08:07

Dave Vogt


People also ask

What is all in make?

This means that when you do a "make all", make always thinks that it needs to build it, and so executes all the commands for that target. Those commands will typically be ones that build all the end-products that the makefile knows about, but it could do anything.

What the difference between make and install?

make follows the instructions of the Makefile and converts source code into binary for the computer to read. make install installs the program by copying the binaries into the correct places as defined by ./configure and the Makefile.

What is the default make target?

By default, the goal is the first target in the makefile (not counting targets that start with a period). Therefore, makefiles are usually written so that the first target is for compiling the entire program or programs they describe.

What is a makefile target?

A simple makefile consists of “rules” with the following shape: target … : prerequisites … recipe … … A target is usually the name of a file that is generated by a program; examples of targets are executable or object files. A target can also be the name of an action to carry out, such as ' clean ' (see Phony Targets).


1 Answers

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

like image 184
koan Avatar answered Sep 20 '22 07:09

koan