make option to recompile only changed files

Andre-Marcel Hellmund mail@andihellmund.com
Fri Oct 22 13:30:00 GMT 2010


Hey Asma,
> thank you for your help, but acctually, I do not change the uml1.c itself, I
> changed in a text file that contains a set of c instructions and I include this
> file in my uml1.c
>    
Why do you do that? Just from a style perspective, you shouldn't include 
C instructions that way into your language hooks. Obviously, that works, 
but you should better work with functions (in separate source files) and 
call these functions then from your language hooks.
> So, if I do not reconfigure and make, the compiler will not compile the uml1.c
> again, it will keep the same uml1.o (with old c instructions took from the old
> text file).
>    
Your makefile (make-lang.in) misses some dependencies. Your uml1.o rule 
should look like this:

uml1.o: uml1.c <GCC stuff> <your_text_file_containing_instructions>
  ...

Then uml1.o will be re-compiled once you modify your text file ...

> any idea ? I can not add to make coomand a list of files to recompile ? or can I
> add the c instructions of text.txt to my uml1.c using another way ?
>    
Yes, by using functions and let the linker finally do the work for you. 
Just as an example: you would create a source file for your language 
hooks (my_hook.c) and a source file for your C instructions doing the 
GENERIC stuff (my_generic.c). You'll then compile them both separately 
and link them together into <your_compiler>, e.g. gcc my_hook.o 
my_generic.o <other_stuff> -o <your_compiler>

For a reference, please look at the sample front-ends you already used 
so far. The gcalc front-end uses the approach described above ...

Hope that helps,
Andi



More information about the Gcc-help mailing list