Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Make Utility Question

$
0
0
Hello,

I'm a recent convert to UNIX and I'm attempting to understand exactly how the make utility is working under the hood.

Now, I understand that each rule has a target, dependencies, and update command, but the thing I'm confused about is exactly how the utility is determining when to build a target. From the man page, I thought I deduced that the only times that a target is updated is when the target does not exist in the file system or one of the dependencies is newer than the target file.

However, what I'm confused about is whether the utility does something different for the primary target being built (i.e. the target specified by the user at the command line or if no target specified, the first one in the makefile)

For example, if I have a makefile with the following:
-------------------------------------------------
Code:

test: dep1.o dep2.o
[tab]commands to update test here

dep1.o: dep1.c
[tab]commands to update dep1.o here

dep2.o: dep2.c
[tab]commands to update dep2.o here

-------------------------------------------------

If I create dummy files using cat to produce test, dep1.o, and dep2.o, making sure to create test after dep1.o and dep2.o, make still appears to go through and build each dependency. Does it just unconditionally build the primary target every time (ignoring timestamp comparison for it), and then for all dependency rules that were in test, it goes through and does the timestamp comparisons for those?

Any clarifications on this would be super helpful, thanks!

Viewing all articles
Browse latest Browse all 16232

Trending Articles