Re: Per-target make rules.
- From: "jason.cipriani@xxxxxxxxx" <jason.cipriani@xxxxxxxxx>
- Date: Thu, 29 May 2008 09:45:18 -0700 (PDT)
On May 29, 11:02 am, Thomas Maier-Komor <tho...@xxxxxxxxxxxxxx> wrote:
You could write the object files to different directories, each
directory containing object files with a common set of CFLAGS. Then
rules as below:
$(DDIR)/%.o: %.c
$(CC) $(D_CFLAGS) -c $< -o $@
$(CDIR)/%.o: %.c
$(CC) $(C_CFLAGS) -c $< -o $@
Thanks! So I took your suggestion and did it that way, but then I was
having other issues related to having a bunch of subdirectories for
different .o files. I found something called "static rules" in
Makefiles that accomplish something similar, and while they do prevent
me from using the same source file in both lib and test program
(unlike yours, which allows for that no problems), I'm OK with that.
So I am now doing something like this:
$(LIB_OBJS): %.o: %.cpp
$(CC) $(LIB_CFLAGS) -c $<
$(TEST_OBJS): %.o: %.cpp
$(CC) $(TEST_CFLAGS) -c $<
And that almost works perfect, except now I am having a different
problem. I didn't mention this, but some of the libraries have special
cases per source file; for example, in addition to the above generic
rules, an individual library's Makefile needs to be able to specify
extra options per-file, which I did like this when I was using .cpp.o
before:
special.o: special.cpp
$(CC) $(LIB_CFLAGS) -funroll-loops -Wno-long-long $<
And that would appear in the individual Makefiles that included the
common one. Also, I generate dependency information (using g++ -M) so
I have a separate dependency file with lines in it like:
special.o: special.h include.h something.h
That all used to work fine, but now when I'm using the static rules,
Make complains about overriding existing rules (whereas with implicit
rules, rules for the same target were all combined, with static rules,
they aren't combined). Is there some way I can do this?
I could go back to using the solution of placing .o files in separate
directories... in fact, this is all becoming kind of a nightmare and I
think I may take your suggestion one step further and just put the
tester program source in separate directories altogether.
What a pain. I've spent an unacceptable amount of time today working
on Makefiles and organizing directory structures. I can't come up with
a good solution that I'm happy with.
Thanks,
Jason
.
- Follow-Ups:
- Re: Per-target make rules.
- From: Thomas Maier-Komor
- Re: Per-target make rules.
- References:
- Per-target make rules.
- From: jason.cipriani@xxxxxxxxx
- Re: Per-target make rules.
- From: Thomas Maier-Komor
- Per-target make rules.
- Prev by Date: Re: fastest transition from bitmask to the position of it's lowest SET bit
- Next by Date: Re: how does retu() switch new process's ppda?
- Previous by thread: Re: Per-target make rules.
- Next by thread: Re: Per-target make rules.
- Index(es):
Relevant Pages
|