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:
-------------------------------------------------
-------------------------------------------------
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!
In this makefile, test has dependencies on dep1.o and dep2.o, dep1.o has a dependency on dep1.c, and dep2.o has a dependency on dep2.c. If your commands to update dep1.o and dep2.o don't create dep1.c and dep2.c, respectively, before updating dep1.o and dep2.o then dep1.o and dep2.o will never be considered up-to-date and will have to be rebuilt every time you check to see if test is up-to-date.
Normally, for something like this you would start out with dep1.c and dep2.c and make would use something like cc -c dep1.c to create dep1.o, cc -c dep2.c to create dep2.o, and the commands to update test would then link dep1.o, dep2.o, and whatever startup code is needed to produce test. Then subsequent invocations of make wouldn't need to do anything until you updated one of your C source files.
xmake is a make-like build utility based on lua. (Link to project site: xmake)
The project focuses on making development and building easier and provides many features (.e.g package, install, plugin, macro, action, option, task ...), so that any developer can quickly pick it up and enjoy the... (1 Reply)
Hi,
Could someone tell me why make utility is mostly preferred for compilation and generating executable in UNIX rather than any user created scripts which contains commands for compilation? (2 Replies)
Hi,
I'm trying to create a C program that functions like the make utility in UNIX for personal use. My program would read in from a generic makefile and execute whatever is in that makefile but I'm not sure as to where I should start coding.
I would appreciate any help.
Thanks. (1 Reply)
Hi want to know the syntax of printing something (value or variable) in GNU make utility. I give this in the Makefile:
echo "Hi"
OR
@echo "Hi"
But I only get error this when I run make (at the line where I have echo):
Makefile:9: *** missing separator. Stop.
Whats the problem? How can... (2 Replies)
(Sorry for previous not on enlish! I did not realized it is english forum. )
I am looking for help with Make utility. I could not get help from the 'man' pages.
1. About Macro (as a variable): It is clear about defining any macro in beginning or in command line, but isn't it no way to redefine... (0 Replies)
Hello all
im looking for some kind of utility that convert make files to dsp files
is there any kind of tool/script that does this job?
thanks (1 Reply)
Hi Guys,
I m very confused about the make/makefile utility in all unix.
1) My questions is why we need make.
2) Why some source code needs to complile.
3) I download the Bind 9 from Sunfreeware.com. I use pkgadd -d to install the bind. I 'm struck here becasue I can't find /etc/named.conf... (2 Replies)
I wrote a makefile, every thing is working fine,
But One of the C header files which is created by me is kept in a different folder other than the current directory,
I have given this PATH to VPATH Variable
Example :- VPATH = /home/user1/projects/victor.h
It gives an error as : file... (4 Replies)
When we run the make utility , make compiles only those files which are undergone changes(other files which have not undergone any changes are not recompiled)
The Following quotes says
When you run the make utility, it examines the modification times of files and determines what needs to be... (4 Replies)
The following is my makefile. When I run "make", it gives me a bunch of error. I've compiled each file separately and there are no compilation errors.
The target is "monprc". Have a look below:
monprc: monprc.o monrep.o dsz.o
cc -o monprc monprc.o monrep.o dsz.o
monprc.o: monprc.c... (1 Reply)