Help on Makefiles and using/maintaining user libraries

Help on Makefiles and using/maintaining user libraries

Post by Chris Adam Thom » Fri, 22 Apr 1994 06:54:17

I've tried to understand enough about Makefile(s).  Read everything I can
find.  But now I'm dazed and confused.  What Im trying to do is generate
a makefile that makes the necessary files / librarys as follows:

        ../dir1/libcommon.a    is used by and is created from files in

        ../dir1/dir_d   etc

In each of these directories is a program file that needs ../dir1/libcommon.a
and is a source file (C or Fortran) that is complied and include in the
libcommon.a    Also included in libcommon.a is ../dir1/xy.c

So.  A Makefile in ../dir1/dir_b to make the executable bx depends on the
file ../dir1/dir_b/bsx.c and on the librarys ../dir1/libcommon.a and on
additional user libraries that don't change, say, /usr/local/lib/libabcd.a

        ../dir1/libcommon.a   depends on;


What Makefile would properly make bx when in ../dir1/dir_b?

I hope that clearly defined the problem.  Any help would be appreciated.


1. Maintaining a function library: sample Makefile wanted

Since this is more programmer oriented I'm guessing it is better to post this
question here than in c.u.q:

I'm interested in maintaining a library of functions.  The functions will
probably all be in C.  What I am looking for is a sample generic Makefile
that will do the job of keeping the actual library itself up to date by
just running make.

I would prefer:

1.  That excessive compiles be avoided if possible.  In other words, if the
    member in the library is up to date, do not recompile.  However this is
    not critical.

2.  Do not leave loose object files lying around.  This can be a part of
    "make clean" as is usual practice.

3.  Easy to add new functions.  The minimal amount of editing of the Makefile
    is highly desired when adding new function names.  Particularly to be
    avoided are large complex statements that exist for each function.  The
    best would be a Makefile that does not have to be edited at all to add
    new functions.

4.  Very portable across UNIX platforms.  Ease of porting to other systems
    like messy-DOS is attractive, but of course major editing for the commands
    that are available (or lacking) is expected.

I've never tried keeping a library of functions on UNIX with make, so this is
new to me.  All I have come up with so far is utterly complex and cumbersome.

The last system I worked on would search for functions to be linked by looking
through the object files themselves, in addition to libraries, so it really
was not necessary to go through the library maintenance process.  A way to get
the linker to do this would be an attractive alternative.

Also, for anyone who has done this (keeping a private library of their own
functions) and in turn distributed code that used these functions, I'd like
to know if you had an way of automatically extracting the sources of the
function library that are needed, and building a Makefile to be distributed
for that package.

\ depending on government is that you cannot depend on it" - Tony Brown /

2. Default Raid Setup

3. Maintaining archives with makefiles

4. Need help setting up SoundBlaster Live

5. Maintaining archives with makefile (MORE INFO)

6. IPmasquerade and Ethernet 100mb problem

7. Makefile help (libraries maintenance)

8. pppd with kernel 2.4.5

9. Maintaining Shared Libraries

10. Maintaining a library with make

11. Matrox Mystique ands X.

12. User PPP - can't maintain connected

13. Printing from NT to Linux maintained printer using NFS