1.) What is the -g option for gcc?
Generate Debug Information
2.) What is $ * and $@
$* is the basis of the rule. When you make a rule like
%.ext: %.otherext ext2otherext --input $? --output $@ --logfile $*.log
and the rule tries to make file.ext from file.otherext , then in log goes to file.log
$@ is the name of the target file ( file.ext in the case above).
3.) How do I know how to accomplish the last goal?
It's a secret.
$* used for intermediate files: for example, when you try to make %.so from %.c , you need the %.o intermediary, which is neither the target nor the source. You put:
%.so: %.c gcc -fPIC -g -c -o $*.o $? ld -shared -o $@ $*.o
In other words, the rule %.extension $* has everything except .extension .
As a goal, $* does not make sense.
Are you sure this rule is actually being implemented somewhere? When I try to play it using the Makefile, it applies the default rules ( cc -o ) instead of gcc -g -o
The rule you need looks like:
%: %.c gcc -g -o $@ $?
source share