Mihai Draghicioiu wrote:
##
## Program template
##
define program_template
$(1)_OBJS = $$($(1)_SRCS:.cpp=.o)
Add a line here like this one.
SPECIFIC_CXXFLAGS=$$($(1)_CXXFLAGS)
## Library template
##
define library_template
$(2)_OBJS = $$($(2)_SRCS:.cpp=.o)
And another one here like this.
SPECIFIC_CXXFLAGS=$$($(2)_CXXFLAGS)
Then, move the .cpp.o target outside of the defines and just use one
like this one.
Note: The only thing I changed is the reference to $(SPECIFIC_CXXFLAGS)
and I reduced all of the double dollar signs to single dollar signs
since I was moving it out of the define.
.cpp.o:
@echo "$(COMPILERC)$(CXX) $(CXXFLAGS) $(SPECIFIC_CXXFLAGS) -MMD -c
$< -o $...@$(RESETC)";
@if $(CXX) $(CXXFLAGS) $($SPECIFIC_CXXFLAGS) -MMD -c $< -o $@; then \
cp $*.d $*.P; \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' -e '/^$$/ d'
-e 's/$$/ :/' < $*.d >> $*.P; \
rm -f $*.d; \
else \
echo "$(ERRORC)Compilation failed for $@ $(RESETC)"; \
rm -f $*.d; \
exit 1; \
fi
Oh yeah, thanks for the hints. I've been working on something similar
recently but from a different angle. My common makefile was designed for
a single compile and to have everything be as automatic as possible. I
think I should be able to eventually combine mine with your templates to
make mine more robust.
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make