[Top][All Lists]

[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


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

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


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 \

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

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

all: $(TARGET)

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

        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

        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.
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

See the papers on VPATH on my web site below.

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "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]