help-make
[Top][All Lists]
Advanced

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

Re: Pattern match, multiple targets


From: Paul D. Smith
Subject: Re: Pattern match, multiple targets
Date: Fri, 3 Nov 2000 14:00:35 -0500

%% Regarding Pattern match, multiple targets; you wrote:

  gs>      Perhaps a silly question, but here goes (are the list archives 
  gs>      searchable? - is there a FAQ?)

See the URL at the bottom of the message.

  gs>      I have a makefile that wants to make several (shared library)
  gs>      targets.
     
  gs>      Can I write something like
     
  gs>      LIB1 := one.o
  gs>      LIB2 := two.o
     
  gs>      all: libLIB1.so libLIB2.so
     
  gs>      lib%.so: $(%)
     
No.

Variables in the target and prerequisite lists are expanded when the
makefile is read, so make will try to expand the variable named with the
literal string "%", because that % isn't transformed into a real value
until later, when make is actually trying to build stuff.

See the section "How `make' Reads a Makefile" in the GNU make manual for
more information on when expansion happens in different parts of the
makefile.

You can write this:

  lib%.so:
        ...rule to build address@hidden

  libLIB1.so: $(LIB1)
  libLIB2.so: $(LIB2)

This allows you to write the actual command only once, but you still
need to write the prerequisites each time.

The only way to get around doing that by hand is by using the "included
makefile auto-re-exec" trick.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.paulandlesley.org/gmake/
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist



reply via email to

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