M
matthias_k
Hello,
I am currently working on a Makefile mechanism which can for most
parts create dependencies automatically and look for sources in
other folders than "." .
As a basis, I have been adopting some mechanisms of the way the CDT
plugin for Eclipse handles this. However, at one point, I really don't
get what it's doing:
<snip>
# Makefile
[...]
-include $(SUBDIRS:%=%/subdir.mk)
[...]
</snip>
<snip>
# code is a subdir containing code
# code/subdir.mk
# Each subdirectory must supply rules for building sources it contributes
code/%.o: code/%.cpp
@echo 'Building file: $<'
$(CC) $(CFLAGS) -o $@ $< && \
echo -n $(@:%.o=%.d) '' > $(@:%.o=%.d) && \
$(CC) -MM -MG -P -w $(CFLAGS) $< >> $(@:%.o=%.d)
@echo 'Finished building: $<'
@echo ' '
</snip>
Okay, I know that in that include directive, all entries in SUBDIRS
are substituted in a way that "/subdir.mk" is attached to the end.
However my question is:
What does that mysterious % Operator do? I have searched the net with no
results. I have searched the bash manpage but it doesn't seem to be a
shell variable either.
Can you tell?
Thanks in advance,
- Matthias
I am currently working on a Makefile mechanism which can for most
parts create dependencies automatically and look for sources in
other folders than "." .
As a basis, I have been adopting some mechanisms of the way the CDT
plugin for Eclipse handles this. However, at one point, I really don't
get what it's doing:
<snip>
# Makefile
[...]
-include $(SUBDIRS:%=%/subdir.mk)
[...]
</snip>
<snip>
# code is a subdir containing code
# code/subdir.mk
# Each subdirectory must supply rules for building sources it contributes
code/%.o: code/%.cpp
@echo 'Building file: $<'
$(CC) $(CFLAGS) -o $@ $< && \
echo -n $(@:%.o=%.d) '' > $(@:%.o=%.d) && \
$(CC) -MM -MG -P -w $(CFLAGS) $< >> $(@:%.o=%.d)
@echo 'Finished building: $<'
@echo ' '
</snip>
Okay, I know that in that include directive, all entries in SUBDIRS
are substituted in a way that "/subdir.mk" is attached to the end.
However my question is:
What does that mysterious % Operator do? I have searched the net with no
results. I have searched the bash manpage but it doesn't seem to be a
shell variable either.
Can you tell?
Thanks in advance,
- Matthias