help-make
[Top][All Lists]
Advanced

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

RE: Trying to get rid of one redundand rule


From: Alexander.Farber
Subject: RE: Trying to get rid of one redundand rule
Date: Tue, 14 Jun 2005 16:49:40 +0200

Thanks, but I keep rereading that and the manual, and still dont get it.
The generated files $(BLDDIR)/rcompl.cpp and rcomp.cpp are _SOURCE_ files too.

Why doesnt the rule

  VPATH = $(SRCDIR) $(BLDDIR)

  $(BLDDIR)/%.o: %.cpp
        $(CXX) $(CXXFLAGS) -D __LINUX__ -I $(INCDIR) -I $(BLDDIR) -c $< -o $@

find them and an implicit rule for .cpp->.o triggers instead?

Regards
Alex

PS: Here is my Makefile again
 
CXX    = g++296
YACC   = bison
LEX    = flex

BLDDIR = ../build
SRCDIR = ../src
INCDIR = ../inc

SOURCE = main.cpp \
         array.cpp astring.cpp ccodes.cpp ctable.cpp \
         datatype.cpp errorhan.cpp fileacc.cpp fileline.cpp \
         indextab.cpp linklist.cpp mem.cpp \
         nameidma.cpp numval.cpp rcbinstr.cpp \
         rcostrm.cpp \
         rcscan.cpp rcstack.cpp resource.cpp \
         stack.cpp stringar.cpp structst.cpp \
         unicode_compressor.cpp \
         localise.cpp

GENSRC = rcompl.cpp rcomp.cpp
OBJECT = $(addprefix $(BLDDIR)/, $(notdir $(SOURCE:.cpp=.o) \
                                          $(GENSRC:.cpp=.o)))
TARGET = $(addprefix $(BLDDIR)/, rcomp )

vpath %.cpp $(SRCDIR) $(BLDDIR)

all: $(TARGET)

$(TARGET): $(OBJECT)
        $(CXX) $^ -o $@
        strip $@
        
$(OBJECT): $(BLDDIR)/stamp $(BLDDIR)/rcomp.hpp

$(BLDDIR)/stamp:
        mkdir -p $(dir $@)
        touch $@

$(BLDDIR)/%.o: %.cpp
        $(CXX) $(CXXFLAGS) -D __LINUX__ -I $(INCDIR) -I $(BLDDIR) -c $< -o $@

#%.o: %.cpp
#       $(CXX) $(CXXFLAGS) -D __LINUX__ -I $(INCDIR) -I $(BLDDIR) -c $< -o $@

$(BLDDIR)/rcompl.cpp: $(SRCDIR)/rcomp.l
        $(LEX) -t $< > $@

$(BLDDIR)/rcomp.cpp $(BLDDIR)/rcomp.hpp: $(SRCDIR)/rcomp.y
        $(YACC) -d $< -o $(BLDDIR)/rcomp.cpp

clean:
        rm -f $(GENSRC) $(OBJECT) $(TARGET) $(BLDDIR)/stamp
        rm -f $(addprefix $(BLDDIR)/, $(GENSRC)) $(BLDDIR)/rcomp.hpp
        -rmdir $(BLDDIR)

.PHONY: all clean




-----Original Message-----
From: Paul Smith [mailto:address@hidden Behalf Of ext Paul D.
Smith
Sent: Dienstag, 14. Juni 2005 14:52
To: Farber Alexander (Nokia-TP/Bochum)
Cc: address@hidden
Subject: Re: Trying to get rid of one redundand rule


%% Regarding Trying to get rid of one redundand rule; you wrote:

  n> My problem: even though I list both $(SRCDIR) and $(BLDDIR) in the VPATH, 
  n>            I still have to list a separate rule to compile those 2 files:

  n> $(BLDDIR)/%.o: %.cpp
  n>    $(CXX) $(CXXFLAGS) -D __LINUX__ -I $(INCDIR) -I $(BLDDIR) -c $< -o $@

  n> %.o: %.cpp
  n>    $(CXX) $(CXXFLAGS) -D __LINUX__ -I $(INCDIR) -I $(BLDDIR) -c $< -o $@

VPATH is ONLY for finding _SOURCE_ files, never for finding target
files.

See the papers on VPATH on my web site below.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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