Hello to all.
We suppose that a program consists of three source files main.c f1.c and f2.c plus two header files, f1.h and f2.h. All three source files include f1.h, but only f1.c and f2.c include f2.h.
I wrote a makefile for this program and I want your opinion if is it correct :
I read that the order of rules is arbitrary ... so we can start with demo.o as a first rule? of f1.o ?Code:demo : demo.o f1.o f2.o gcc -o demo demo.o f1.o f2.o demo.o : main.c f1.h gcc -c main.c f1.o: f1.c f1.h f2.h gcc -c f1.c f2.o: f2.c f1.h f2.h gcc -c f2.c
The file is to be named demo of course and I know about the tab space before the command of each rule.
Another issue that I need some opinion is the following :
If a change affects a header file we will recompile all files that include this header file since they could potentially be affected by the change. (Some of them might not be , but it pays to be conservative)
How can "some of them might not be?" Do you have an example?
Thank you in advance.