bug-automake
[Top][All Lists]
Advanced

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

preventing variable expansion


From: Marcus Brinkmann
Subject: preventing variable expansion
Date: Sat, 13 Sep 2003 01:54:05 +0200
User-agent: Mutt/1.5.4i

Hi,

I have this issue here, and a work around.  But as automake work arounds
often break with new versions, I wanted to let you know about my need for a
work around, and maybe there is a better (existing or future) solution.

I want to build a convenience library out of objects taken from an
installed static library (glibc, to be precise).  Portability is not so much
an issue.  So I take my list of functions, filter for the modules containing
them with "nm --print-armap".  Here is the Makefile.am snippet:

======================
routines := memcpy memmove memset htonl ntohl  # And more of course.

# We have to find all modules in the archive which contain the above
# functions.
routines_subexp := 's/^\($(shell echo $(routines) \
        | $(SED) -e 's/ \+/\\|/g')\) in \(.*\)$$/\2/p'
routines_objects := $(shell $(NM) --print-armap @STATIC_GLIBC@ 2>/dev/null \
        | $(SED) -n -e $(routines_subexp) | $(SORT) -u)
======================

Now, the obvious thing to do would be:

libc_parts_a_LIBADD = $(routines_objects)

But surprise!  It doesn't work.  automake expands the variable in
Makefile.in, which then contains garbage like

libc_parts_a_LIBADD = $(shell $(NM) --print-armap 2>/dev/null | ...

and so on.  $(routines_subexp) is also expanded.  Note that @STATIC_GLIBC@
went away, too.  automake doesn't like the "linker option" --print-armap
either.

So I am working around it like this:

routines_varname := routines_objects
libc_parts_a_LIBADD = $($(routines_varname))

Automake is not smart enough to expand this at all, and I get what I want. 
Here is the rules, in case you wonder:

$(routines_objects): %.$(OBJEXT): @STATIC_GLIBC@
        $(AR) -x $< $@

That's all.  I couldn't find a better solution.  If you think the above is
ugly, I agree.  If you have any better idea, that is more in line with what
automake is about, please let me know.  Maybe I shouldn't use a convenience
library for this at all, but it is... convenient ;)

Thanks,
Marcus

-- 
`Rhubarb is no Egyptian god.' GNU      http://www.gnu.org    address@hidden
Marcus Brinkmann              The Hurd http://www.gnu.org/software/hurd/
address@hidden
http://www.marcus-brinkmann.de/




reply via email to

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