help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: common.mk


From: Harvey Chapman
Subject: Re: common.mk
Date: Sun, 22 Mar 2009 23:39:55 -0400
User-agent: Postbox 1.0b9 (Macintosh/2009030821)

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 address@hidden(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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]