I have the following makefile which I am trying to upgrade, but there is a certain element which I am not able to understand what means:
$(OBJDIR)/%.o: %.f Makefile @$(F90) $(FFLAGS) $(POPTIONS) -o $@ $< %.o: %.f Makefile @make $(OBJDIR)/$@
I understand that $(OBJDIR)/%.o:
is obtained by executing the f90 compiler with flags etc.
But why do I need the %.o
rule, and what does @make
mean. Am I missing a general understanding of how a Makefile work?
Advertisement
Answer
@make
means invoke make
but do not echo that in the output (@
symbol). The correct way is @${MAKE}
because make
may not refer to the make being executed, whereas ${MAKE}
does.
In makefiles rules must create the target file they promise to (unless the targed is marked as .PHONY
). Here, that %.o
rule promises to build that %.o
, but what it does in fact is it builds $(OBJDIR)/%.o
. This is a broken rule.