[Top][All Lists]

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

Re: Naming object files according to target

From: Sam Ravnborg
Subject: Re: Naming object files according to target
Date: Sun, 3 May 2009 21:54:34 +0200
User-agent: Mutt/

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 $@


reply via email to

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