help-make
[Top][All Lists]
Advanced

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

Re: How to generalize a lib make rules.


From: Todd Showalter
Subject: Re: How to generalize a lib make rules.
Date: Mon, 21 Jun 2010 09:43:08 -0400

On Sun, Jun 20, 2010 at 3:08 PM, Palani Chinnakannan (pals)
<address@hidden> wrote:

>     I need to write a set of rules etc to make a library that can be used
> project wide.  First let me give a specific instance of  how I make library; 
> then I
> need some help on showing me how to generalize this

    You've actually pretty much got it already.  Assuming that each
library lives within its own subdirectory (which is usually proper
project hygene anyways), each library directory contains a file called
"makefile" containing:

LIB_MAJ       := 0
LIB_MIN        := 0
LIB_REV       := 1
LIB_NAME    := libclos_trace.so
LIB_SRCS:=\
                clos_trace.c

include $(PATH_TO_YOUR_MASTER_TEMPLATE)/Library.make

    You may need an environment variable to drive that, unless you
have a hard-coded path that is always valid.  After that, it's just a
matter of writing Library.make, using the stuff you already
specified...

LIB_TARGET=$(ARCH)/lib$(LIB_NAME).$(LIB_MAJ).$(LIB_MIN).so
LIB_SONAME=lib$(LIB_NAME).$(LIB_MAJ).$(LIB_MIN).so.$(LIB_MAJ)

LIB_OBJS:= $(LIB_SRCS:%.c=$(ARCH)/%.o)

$(LIB_TARGET): $(LIB_OBJS) | $(ARCH)
    ld -shared -soname $(LIB_SONAME) -o $@ $(LIB_OBJS)

$(ARCH):
    mkdir - p $@

    Then at the project root, you have another makefile that simply
knows to call make -C to each of the library directories:

LIBS = clos_trace \
           foo            \
           bar

$(LIBS):
    @make -sC $@

                                                            Todd.

-- 
 Todd Showalter, President,
 Electron Jump Games, Inc.



reply via email to

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