Target specific variables

199 views
Skip to first unread message

Ciaran McCreesh

unread,
Jul 22, 2008, 3:25:57 PM7/22/08
to quagmire...@googlegroups.com
I'm encountering a bit of an oddity with target specific variables. The
README says:

> One general rule in Quagmire is that if there is a simple, generic GNU
> make way to do something, then we don't need special support for it.
> This leads to many differences from the way that Automake does things.
> For instance, in Automake there is a separate quux_CFLAGS variable for
> an aggregate. In Quagmire, you would instead use a target-specific
> CFLAGS assignment.

The make documentation [1] says:

> There is one more special feature of target-specific variables: when
> you define a target-specific variable that variable value is also in
> effect for all prerequisites of this target, and all their
> prerequisites, etc.

This is a nuisance. Consider the following:

noinst_SHARED_LIBRARIES = libone.so libtwo.so libthree.so

libone.so_SOURCES = one.c
libone.so : LDFLAGS = -Wl,-soname,libone.so
libone.so_LIBS = libthree.so

libtwo.so_SOURCES = two.c
libtwo.so : LDFLAGS = -Wl,-soname,libtwo.so
libtwo.so_LIBS = libthree.so

libthree.so_SOURCES = three.c

Then we get:

$ make clean all &>/dev/null ; scanelf -S libthree.so
TYPE SONAME FILE
ET_DYN libone.so libthree.so

$ make clean libone.so &>/dev/null ; scanelf -S libthree.so
TYPE SONAME FILE
ET_DYN libone.so libthree.so

$ make clean libtwo.so &>/dev/null ; scanelf -S libthree.so
TYPE SONAME FILE
ET_DYN libtwo.so libthree.so

$ make clean libthree.so &>/dev/null ; scanelf -S libthree.so
TYPE SONAME FILE
ET_DYN libthree.so

So to set soname, I see two options. Either we use LINK instead:

libone.so_LINK = $(LINK.c) -Wl,-soname,libone.so

Or we explicitly unset target-specific variables for everything that
could accidentally pick one up, which quickly becomes an awful lot of
unsetting. Is there a better way?

1: http://www.gnu.org/software/make/manual/make.html#Target_002dspecific

--
Ciaran McCreesh

signature.asc

Tom Tromey

unread,
Jul 27, 2008, 5:24:31 PM7/27/08
to Ciaran McCreesh, quagmire...@googlegroups.com
Ciaran> So to set soname, I see two options. Either we use LINK instead:
Ciaran> libone.so_LINK = $(LINK.c) -Wl,-soname,libone.so

Ciaran> Or we explicitly unset target-specific variables for everything that
Ciaran> could accidentally pick one up, which quickly becomes an awful lot of
Ciaran> unsetting. Is there a better way?

Yeah, I think we have to go with the _LINK approach, and limit our use
of target-specific variables.

Care to write a patch? :-)

Tom

Matt Rice

unread,
Aug 22, 2009, 5:10:48 AM8/22/09
to tro...@peakpeak.com, Ciaran McCreesh, quagmire...@googlegroups.com


i ran into this with CFLAGS... and tried to come up with a patch which
allows you to define foo.o_CFLAGS

you can see in the fuzz there is an else there for older gcc's i
wasn't exactly sure what to do there and don't have an old enough gcc
around to test it out.

defining foo.o_CFLAGS
for all 2 of my .o files was rather tedious so i stuck something like
this in my Quagmire.mk

foo.so_CFLAGS=.....

$(foreach obj,$(foo.so_OBJECTS),$(eval $(obj)_CFLAGS+= $(foo.so_CFLAGS) ))

is this something which maybe also {c,sh}ould make its way into quagmire?

foo.diff
Reply all
Reply to author
Forward
0 new messages