help-make
[Top][All Lists]
Advanced

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

Re: Naming object files according to target


From: t-timmy
Subject: Re: Naming object files according to target
Date: Sun, 3 May 2009 13:21:36 -0700 (PDT)

Do you mind explaining how to extend your example so that I can compile
different targets using the same source file, like in my first question?

Let's say, how do I compile foo-debug.o, bar-debug.o, foo-release.o and
bar-release.o if I have different C flags for targets "debug" and "release"?

What makes this whole thing complicated is that make compares the C file
timestamp with the O file timestamp and according to that decides whether to
compile or not. So how can I make it listen to differently named object
files?

Thanks


Sam Ravnborg wrote:
> 
> On Sun, May 03, 2009 at 11:25:10AM -0700, t-timmy wrote:
>> 
>> Hello,
>> 
>> I know this may sound newbie-ish, but I really need some help.
>> 
>> I want to name each of my object files prefixed with the current target
>> name.
>> That way when I change targets, I won't have to recompile everything to
>> make
>> sure there is no residue from the previous compilation (which may have
>> been
>> for a different target).
>> 
>> For example:
>> 
>> target1: c_flags = -DSOMETHING
>> target1: main.o
>> 
>> target2: c_flags = -DSOMETHING_ELSE
>> target2: main.o
>> 
>> main.o:
>> gcc $(c_flags) etc...
>> 
>> The only way I can avoid recompiling every time is by manually making a
>> rule
>> for, let's say, target1-main.o and target2-main.o, but I have a lot of
>> source files and it's a real hassle.
> 
> May I suggest you to read up on static patters.
> It looks like this is what is needed here if I understood you correct.
> 
> Snip from the documentation:
>    Here is an example, which compiles each of `foo.o' and `bar.o' from
> the corresponding `.c' file:
> 
>      objects = foo.o bar.o
> 
>      all: $(objects)
> 
>      $(objects): %.o: %.c
>              $(CC) -c $(CFLAGS) $< -o $@
> 
> 
>       Sam
> 
> 
> _______________________________________________
> Help-make mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-make
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Naming-object-files-according-to-target-tp23358342p23359394.html
Sent from the Gnu - Make - Help mailing list archive at Nabble.com.





reply via email to

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