tcpdump mailing list archives

Re: [PATCH][RFC] Allow linking from custom staticlib.a instead of list of object files


From: Guy Harris <guy () alum mit edu>
Date: Fri, 8 Jan 2010 12:56:09 -0800


On Jan 7, 2010, at 12:22 PM, Christian Bell wrote:

libpcap.a: $(OBJ)
      @rm -f $@
-     ar rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
+     if test -n "$(ADDLARCHIVES)"; then \
+         EXTRA_OBJS=`ar t $(ADDLARCHIVES) | tr '\n' ' '`; \
+         ar x $(ADDLARCHIVES); \
+     fi; \
+     ar rc $@ $(OBJ) $$EXTRA_OBJS $(ADDLARCHIVEOBJS)
      $(RANLIB) $@

That looks reasonable, although I don't think the "tr" command is needed - in the output of a command run inside 
backquotes, newlines are treated like any other white space:

        $ cat /tmp/catlist
        #! /bin/sh
        echo this
        echo is
        echo a
        echo test
        $ xx=`/tmp/catlist`
        $ echo $xx
        this is a test

(tested with both bash and ksh - it'll probably work even with the Boring Old Bourne Shell).

You might want to call it ARCHIVELIBS, by analogy to LIBS.

shared: libpcap.$(DYEXT)
@@ -331,8 +337,12 @@ libpcap.so: $(OBJ)
      @rm -f $@
      VER=`cat $(srcdir)/VERSION`; \
      MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
+     if test -n "$(ADDLPICARCHIVES)"; then \
+         EXTRA_OBJS=`ar t $(ADDLPICARCHIVES) | tr '\n' ' '`; \
+         ar x $(ADDLPICARCHIVES); \
+     fi; \
      @V_SHLIB_CMD@ @V_SHLIB_OPT@ @V_SONAME_OPT@$@.$$MAJOR_VER $(LDFLAGS) \
-         -o $@.$$VER $(OBJ) $(ADDLOBJS) $(LIBS)
+         -o $@.$$VER $(OBJ) $$EXTRA_OBJS $(ADDLOBJS) $(LIBS)

So is the expectation here that there is an archive library containing PIC object files, but no shared library built 
from those object files?  If there's a shared library built from those object files, presumably you'd just want to link 
the shared libpcap with that library, at least on platforms where you can link shared libraries with other shared 
libraries - and both Linux and FreeBSD are platforms where you can do that (I think most UN*Xes are; AIX might be one 
of the exceptions).

-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.


Current thread: