help-make
[Top][All Lists]
Advanced

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

Re: how to force make to do a secondary search for source files?


From: George Brink
Subject: Re: how to force make to do a secondary search for source files?
Date: Tue, 29 May 2007 15:21:50 -0700 (PDT)

--- Kristof Provost <address@hidden>
wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> 
> >> The source of your problem is quite simple. Your
> >> rules don't create
> >> what they claim to create:
> >>
> >> %.cpp: %.xrc
> >>    wxrc -c -oobj\$@ $<
> >>
> >>
> >> The rule claims that a.xrc will be turned into
> >> a.cpp, but it actually
> >> produces obj/a.cpp
> >>
> >>
> >> Fix that and your problem will be gone.
> >
> > Ok, but how can I fix it?
> > My last almost successful attempt looks like this:
> > -------------
> > OBJS=$(objdir)/main.o $(objdir)/icons.o
> > SDIR=obj
> >
> > .INTERMEDIATE: $(objdir)/icons.cpp
> >
> > vpath %.xrc src
> > vpath %.cpp src obj
> >
> > all: subdirs test
> >
> > subdirs: $(SDIR)
> >
> > $(SDIR):
> >      mkdir $@
> >
> > test: $(OBJS)
> >     g++ -o$@ $(OBJS)
> >
> > $(objdir)/%.cpp: %.xrc
> >    wxrc -c -o$@ $<
> >
> > $(objdir)/%.cpp: %.xrc
> >    wxrc -c -o$@ $<
> >
> > -------------
> > That do sucessful compilation all the way, exactly
> > like I want it to be...
> > But there is a lot of "$(objdir)/" in makefile...
> How
> > to get rid of them?
> >
> >
> > George Brink
> Do you still have problems with this Makefile? It
> looks ok.
> 
> You can probably clean up a few things like this:
> 
> OBJS=main.o icons.o
> SDIR=obj
> 
> vpath %.xrc src
> vpath %.cpp src obj
> 
> all: test
> 
> test: $(addprefix $(SDIR), $(OBJS))
>     g++ -o$@ $^
> 
> $(objdir)/%.cpp: %.xrc
>    @mkdir -p $(@D)
>    wxrc -c -o $@ $<
> 
> $(objdir)/%.o: %.cpp
>    @mkdir -p $(@D)
>    gcc -c -o $@ $<
>  
> 
> It saves you a few references to objdir,
Thank you, using function $(addprefix a,b) is a big
help here. Actualy I've never used make functions,
since other makes do not have them :)

But I just found a catch with intermediate file
'icons.cpp'. When I mention it explicitly as
".INTERMEDIATE: $(objdir)/icons.cpp" it goes just as
planned to the rule "$(objdir)/%.o: %.cpp" but without
it will go into implicit rule "%.o: %.cpp"...
It would be fine in simple test program, but in real
life intermediate .cpp files should be compiled by the
same command as normal files. So right now, I have
this:
-------
OBJS=main.o $(XRC_OBJS)
XRC_OBJS=icons.o
.INTERMEDIATE: $(addprefix $(objdir)/, $(patsubst %.o,
%.cpp, $(XRC_OBJS))

$(objdir)/%.o: %.cpp
   ... etc
-------
Comments?

> Have a look at
> http://www.cmcrossroads.com/content/view/6936/268/
> for hints on how to handle this.
Thank you again, this is a very intersting set of
articles, I'll read them.


George Brink


       
____________________________________________________________________________________Ready
 for the edge of your seat? 
Check out tonight's top picks on Yahoo! TV. 
http://tv.yahoo.com/




reply via email to

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