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: Kristof Provost
Subject: Re: how to force make to do a secondary search for source files?
Date: Wed, 30 May 2007 12:31:34 +0200
User-agent: Thunderbird 1.5.0.10 (X11/20070403)

-----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
I'm not that familiar with other make programs. The only one I know
(other than GNU Make) is ClearMake (included with ClearCase) and it
does support functions. It lacks a couple of the more advanced
features (like $(call ...)) though.

I'm not quite sure why the xrc-generated .cpp file gets handled by the
standard rule though. I think it's because the .cpp file is generated
in the objdir and not in the source directory. That means the
$(objdir)/%.o: %.cpp rule doesn't match (because %.cpp is also in objdir).

It should be fixed if you generate the .cpp file in the src directory,
altough I can understand why you prefer it in the objdir.

Kristof

Kristof


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGXVKGUEZ9DhGwDugRAgjeAJ96b/NlxdhWbx0twwhGheciMCvEMwCgiv1l
Ji8yDaLD4lZPUAwE99vACG0=
=+h50
-----END PGP SIGNATURE-----





reply via email to

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