Different CFLAGS for shared and static libraries

Dag-Erling Smørgrav des at des.no
Thu Nov 17 16:42:05 UTC 2011


The attached patch adds support for using different CFLAGS for shared
and static libraries.  Specifically, it adds SHARED_{C,CXX}FLAGS
variables which are added to the cc / cxx command line when building
shared libraries, and STATIC_{C,CXX}FLAGS which are used when building
static libraries.

The rationale is that certain libraries (libpam, possibly also libnss)
contain code which is specific to either shared or static libraries.  It
is possible (with some effort) to detect this by inspecting certain
preprocessor macros, but not in a reliable or portable manner, whether
across platforms or compilers.  For instance, IIRC, MIPS code is always
compiled with -DPIC.

The downside is that the .c.o rule is no longer implicit.

Using this patch, I was able to greatly simplify the libpam build.  It
is no longer a prebuild lib and no longer needs to be built twice.  This
also means that certain other libraries - libssh, for one - can move out
of _prebuild_libs.

DES
-- 
Dag-Erling Smørgrav - des at des.no

-------------- next part --------------
A non-text attachment was scrubbed...
Name: static_cflags.diff
Type: text/x-patch
Size: 1371 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20111117/5606499c/static_cflags.bin


More information about the freebsd-arch mailing list