Robert Nesius writes:
> Multiple Makefiles not strictly needed though that can work.  I think
> multiple targets in the makefile would maybe be more handy.
>
> all: static shared
>
> static:
>    Compile source files with static flags - object files as .o
>    link with static flags (generate the .a or whatever)
>
> shared:
>    Compile source files with shared flags - object files as .so?
>    Link with shared flags - generate the .so
>
> I was going to do an experiment to see if you could compile with source
> files with -fPIC and then link statically. While addresses have to be
> position independent in a shared object and statically linked code does
not
> need to be position independent, I'm not sure that implies addresses in a
> static lib CAN'T be position independent.

Sorry, I should have added that I have it building both libraries
using files that were compiled using fpic.  It seems to work fine,
but I noticed that one of my executables is 1.5% bigger and
another is 3.3% bigger when they are linked with the static library
built from files that were compiled with fpic.  I've put a lot of work
into making the executables lean and want to preserve that here.
(I'm not sure I need a shared library, but it seems to make some
sense in my "data center" where I have multiple instances of
the back tier running.  The other two programs I mentioned are
the middle and front tiers.  I expect to continue to build those
using  the static library.)

>
> It's been awhile since I've built something from source. I think I'm
> remembering for most libraries I built, asking for shared and static libs
> resulted in all object files being compiled with flags appropriate for
> shared libs and then two separate links at the end to create the .a and
> .so.
>
> I'd recommend downloading zlib or some other small library and configure
it
> to compile both shared and static.  Log the build and then see how they
> handled it. I'm guessing there's some useful stuff in their autoconf setup
> you could swipe?  If you're not using autoconf you could look at their
> generated Makefiles for ideas...

I haven't been using autoconf.  I have a hand written makefile.   Someone
suggested looking into libtool.


-- 
Brian Wood
Ebenezer Enterprises - go Twins.
http://webEbenezer.net          (651) 251-9384
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.mn-linux.org/pipermail/tclug-list/attachments/20130401/6b5f1137/attachment.html>