Make...tips and tricks

Priority for searching
Many makefiles provide list of objects to be compiled. And along with a variable VPATH is set, which gives directories to be searched.
Consider a case, where main.o is one of the files to objects to be created and there is main.asm and main.c in two different folders.
The object list contains entry main.o and the rules for C compilation and assembly compilation are one after other.
So, what happens is follows:
- As C rule is before assembly routine, make searches for main.c in the VPATH, and if found it would create main.o out of main.c
- So, if intention of to convert main.asm to main.o, then put assembly rule before C rule.
Of-course some one would have exactly opposite need, in such cases, use vpath %.s and vpath %.c . (note VPATH and vpath are different for Gnu Make).

Comments