Kent Boortz <[EMAIL PROTECTED]> writes: > I want the "*.a" files to contain PIC objects, so that they can be > used to create other shared objects. What I really want is to create > the "*.a" files from the objects in ".libs/*.o", i.e. what is used for > creating shared objects. But there is no option for that that I know > of. So the only other option is to try compile all objects with PIC.
Just to clarify, short term I just want all objects to be "suitable for inclusion into another shared object", i.e. PIC compiled into a "*.a". Long term I might change all library targets to be LT-libraries, and the situation could be like this - There is one library "a" that is "internal" to the build. - There is one library "b" that is both used internally in the build, and to be installed as static library, but the static library is to be PIC. - There is one library "c" that is both used internally in the build, and is to be installed, both as shared and static, but the static library is to be PIC. - There is one executable "d" that depends on both "a", "b" and "c", and will link with static versions of them all. For effeciency both "a" and "b" should be non PIC. Hmm.... maybe I can do this, by using multiple targets for the same library, "internal" and "external" with different names, and give the "-prefer-pic" to libtool in the cases where I want it, without using --with-pic to configure? I.e. can I use something like this, assuming we have source files "a.c" "b.c", "c.c" and "d.c"? bin_PROGRAMS = d pkglib_LTLIBRARIES = b c noinst_LTLIBRARIES = b_int c_int noinst_LIBRARIES = a d_LDADD = a.a b_int.la c_int.la libb_int_la_SOURCES = $(libb_la_SOURCES) libc_int_la_SOURCES = $(libc_la_SOURCES) libb_la_LDFLAGS = -prefer-pic -static libc_la_LDFLAGS = -prefer-pic If "-prefer-pic" affects the creation of static libraries at all? Drawback is of course that each C source file is compiled more times than actually needed. The "-prefer-pic" flag seems undocumented, but so is "--with-pic", kent -- Kent Boortz, Senior Production Engineer MySQL AB, www.mysql.com Office: +46 18 174400 ext. 4450 (VoIP) Office: +46 19 182931 Mobile: +46 70 2791171