tags:

views:

54

answers:

2

Hi folks!

I read the german article about "Make" on Wikipedia and found the following 2 lines:

.c.o:
     $(CC) $(CFLAGS) -c -o $@ $<

Why is the dependency expression left out and why does the target use a double file extension?

+1  A: 

That is what is called a 'Suffix Rule', and is used to make a target with the second suffix from a source with the first suffix, as long as the suffixes are known to make. See Suffix Rules in the make manual for a more detailed description

Oblomov
As said above the other post contained more information. But your answer is proper as well!
Mike Dooley
+2  A: 

This is actually defining a suffix rule... it is defining how to build a file ending in ".o" from a corresponding file ending in ".c", which tells make to infer that "filename.c", if it exists, is a dependency for "filename.o" for any such filename, and that the "filename.o" file may be built from its *.c dependency with the provided rule.

I should point out, though, that this line is completely unnecessary and is, in fact, not something one should put in a Makefile, since Make is already capable of deducing that type of dependency. You may be interested in my Makefile tutorial as it goes on in quite some detail all the things Make is capable of inferring.

Michael Aaron Safyan
Thank you. I accepted that post as "the answer" because it is more precise than the other one. I skimmed over your cmake tutorial too. Actually I have to cope with makefiles atm, but I will read that tutorial over summer ;)
Mike Dooley
@Mike, my tutorial is a Makefile tutorial, not a CMake tutorial. I believe you are confused. My first paragraph was warning that CMake is better to use than Make, but then goes on to teach regular Make. CMake is completely different than Make, and their syntax looks nothing alike.
Michael Aaron Safyan
Oh, I see! I didn't read further than the first paragraph and missed the important parts. A very detailed tutorial, I like it!
Mike Dooley