help-make
[Top][All Lists]
Advanced

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

Re: Building libraries 101


From: John Graham-Cumming
Subject: Re: Building libraries 101
Date: Thu, 26 May 2005 17:03:38 -0400

On Thu, 2005-05-26 at 21:50 +0100, Brendan Heading wrote:
> libfoo.a: $(FOO_OBJS)
>       $(AR) ...
> 
> libbar.a: $(BAR_OBJS)
>       $(AR) ...

I assume that the command being run as specified in the rule is
identical?

> libfoo.a:$(FOO_OBJS)
> libbar.a:$(BAR_OBJS)
> libbaz.a:$(BAZ_OBJS)
> 
> and then in another part of the makefile have a generic rule that 
> determines what must be done to satisfy a build, ie
> 
> lib*.a:
>       $(AR_COMMAND) ...

I assume that the what you are doing is building a library (.a) from a
bunch of .o files.  You could do something like this:

    lib%.a:
        $(AR) r '$@' $^
        ranlib '$@'

then (as you have above), just specify the list of objects like this:

    libfoo.a: $(FOO_OBJS)
    libbar.a: $(BAR_OBJS)
    libbaz.a: $(BAZ_OBJS)

John.
-- 
John Graham-Cumming

Home: http://www.jgc.org/
Work: http://www.electric-cloud.com/
POPFile: http://getpopfile.org/
GNU Make Standard Library: http://gmsl.sf.net/






reply via email to

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