the current generated .pc files dump all libraries into the Libs: section.
this is incorrect: only the "main" library should be listed there while all
others should be listed under "Libs.private". in other words, if people want
to use libcrypto, they should just link with -lcrypto by default. if they
want to link statically, then they'd have to link all the other libs. this is
what the split between Libs and Libs.private does for you.
also, rather than hardcoding the sublibs in the higher pkg-config files (i.e.
inlining the contents of libcrypto into libssl), use the Requires fields.
attached patch against openssl-1.0.0e (and seems to apply cleanly to current
CVS) should fix all these issues.
now we get the output we want:
$ pkg-config --libs libcrypto
-lcrypto
$ pkg-config --libs libssl
-lssl
$ pkg-config --libs openssl
-lssl -lcrypto
then when linking in statically, we get the extra stuff:
$ pkg-config --libs --static libcrypto
-lcrypto -lgmp -ldl -lz
$ pkg-config --libs --static libssl
-lssl -lcrypto -lgmp -ldl -lz
$ pkg-config --libs --static openssl
-lssl -lcrypto -lgmp -ldl -lz
as compared to the current pkg-config files which has the "--libs" output look
exactly the same as "--libs --static"
-mike
move internal libraries to ".private" fields so that the default
--libs output matches only what we need
--- a/Makefile.org
+++ b/Makefile.org
@@ -325,7 +325,8 @@ libcrypto.pc: Makefile
echo 'Description: OpenSSL cryptography library'; \
echo 'Version: '$(VERSION); \
echo 'Requires: '; \
- echo 'Libs: -L$${libdir} -lcrypto $(EX_LIBS)'; \
+ echo 'Libs: -L$${libdir} -lcrypto'; \
+ echo 'Libs.private: $(EX_LIBS)'; \
echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > libcrypto.pc
libssl.pc: Makefile
@@ -334,11 +335,12 @@ libssl.pc: Makefile
echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
echo 'includedir=$${prefix}/include'; \
echo ''; \
- echo 'Name: OpenSSL'; \
+ echo 'Name: OpenSSL-libssl'; \
echo 'Description: Secure Sockets Layer and cryptography libraries'; \
echo 'Version: '$(VERSION); \
- echo 'Requires: '; \
- echo 'Libs: -L$${libdir} -lssl -lcrypto $(EX_LIBS)'; \
+ echo 'Requires.private: libcrypto'; \
+ echo 'Libs: -L$${libdir} -lssl'; \
+ echo 'Libs.private: $(EX_LIBS)'; \
echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > libssl.pc
openssl.pc: Makefile
@@ -350,9 +352,7 @@ openssl.pc: Makefile
echo 'Name: OpenSSL'; \
echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
echo 'Version: '$(VERSION); \
- echo 'Requires: '; \
- echo 'Libs: -L$${libdir} -lssl -lcrypto $(EX_LIBS)'; \
- echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > openssl.pc
+ echo 'Requires: libssl libcrypto' ) > openssl.pc
Makefile: Makefile.org Configure config
@echo "Makefile is older than Makefile.org, Configure or config."