Re: Make and Archives.

From: Larry Lindstrom (larryl@aracnet.com)
Date: 04/15/03


From: Larry Lindstrom <larryl@aracnet.com>
Date: Tue, 15 Apr 2003 20:56:11 GMT


"Michael B. Allen" wrote:
>
> On Mon, 14 Apr 2003 20:10:16 -0400, Larry Lindstrom wrote:
>
> > Hi Experts;
> >
> > I've decided to stop leaving piles of object
> > files around and use make to compile from source to library.
> >
> > My problem is that this always compiles my
> > source and inserts the object in the archive. Even when the archive is
> > up to date.
> >
> > Here is my makefile:
> >
> > $ cat makefile
> >
> > libtest(test.o): test.cpp
> > echo
> > ar -tv libtest.a
> > echo
> > ls -l test.cpp
> > echo
> >
> > g++ -c test.cpp -o test.o
> >
> > ar -r libtest.a test.o
> >
> > rm -f test.o
>
> Make will only skip a procedure if the right hand side of the production
> is "up to date". So I think you want something like:

Thanks Mike:

   I believe he procedure skipped if the left side of
the ":" is newer than the right.

> libtest.a: test.o
> ar rv libtest.a test.o
> test.o: test.c
> cc ...

   I don't think so.

   What happens if another object was added to libtest.a
that makes libtest.a newer than test.o? If many object
files are built in a project, can't libtest.a could be
newer than a fresh test.o that hasn't yet been archived.

   I'm trying to test against the date on the object's
image inside the library, not the library's date.

> Here's a fairly complete Makefile that creates a .so, .a, and may be
> used with RPM:
>
> http://www.ioplex.com/~miallen/libmba/dl/Makefile
>
> Maybe you can gleen some useful information from it.

   I see the following dependency line in your
example:

   $(SONAME): $(ARNAME)($(OBJS)) $(OBJS)

   Which I believe is saying, "If $SOMNAME is older
than the image of $OBJS in the library $ARNAME, or
the file $OBJS, perform the task"

   Isn't this the same as the "libtest(test.o)"
syntax I'm using in my dependency line? My use has
that syntax on the left side of the ":". The
samples in O'Reilly's "Managing Projects with make",
pages 35-37, show the syntax on both sides of the
":"
in the dependency line.

   I appreciate your advice, but I don't understand
why the statements following

    libtest(test.o): test.cpp

are being executed if

     ar -tv libtest.a

shows that test.o in libtest.a is newer than
test.cpp.

   I've noticed in my example, the make will fail
if the library doesn't exist. If you want to test
what I'm doing, comment out the offending "ar -tv"
statement until the archive is created.

                                          Thanks
                                          Larry



Relevant Pages

  • Re: Inserting variables into a Makefile using Autotools.
    ... However, when I try to compile from the lower directories, I ... That way when I'm in a lower level of the development tree, ... default dependency output file. ... "This option instructs CPP to add a phony target for each dependency ...
    (comp.os.linux.development.apps)
  • Re: Segfault City
    ... it will at least compile if you just use gcc -o foo foo.c, ... "Use the following syntax: %s"), ... have anybody doing quality assurance of the code -- which, ...
    (comp.lang.c)
  • Re: compiling
    ... >> referred to download sites, but when I download the indicated ... > headerfiles are needed to be able to compile programs to use the libraries. ... as this ways I wouldn't get dependency problems). ...
    (alt.linux)
  • Re: "pointers" in /clr
    ... Although C++/CLI has stack syntax, the framework only supports pointer syntax for ref classes, and value classes are severely limited. ... Virtual functions must be explicitly declared "override" if they override an existing one. ... When you could really write it once and compile standard native C++ code into pure managed assemblies. ... Automatically substituting default arguments with function overriding for .NET. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: System-wide timer
    ... the run directory because it would conflict with dependency 'mscorlib, ... Not the entire OpenNETCF just the multi-media portion. ... Some kind of compile error message comes up when I am compiling ...
    (microsoft.public.dotnet.framework.compactframework)