Commit c8b1d2fa authored by Martin Storsjö's avatar Martin Storsjö Committed by Niels Möller

Include private dependencies automatically in pkg-config for non-shared builds

When a user invokes pkg-config to get the necessary linker flags
for linking to libhogweed, the user can add --static to get the
private dependencies included, which are necessary for static
linking. If the hogweed build contains both static and shared
libraries, this works as intended - if the user explicitly passes
-static to the linker to have it favor static libs over shared
ones, the same user also needs to tell pkg-config about this intention.

If the hogweed build happens to be static-only, the user of the
library might not be aware of this, and might not realize needing
to pass --static to pkg-config. (This is even more an issue in
setups with a large number of libraries, where only a few of them
are built static-only.)

For these cases, where a library is built as only a static library,
one fairly common convention (not used everywhere, but at least in
some libraries I regularly use) is to include the private dependencies
in the non-private section. This makes sure a user of the library
doesn't need to be concerned about which way this library was built
(unless the user intentionally overrides defaults by passing
flags such as -static to the linker).
parent 0e5b4910
...@@ -757,8 +757,10 @@ fi ...@@ -757,8 +757,10 @@ fi
if test "x$enable_shared" = xyes ; then if test "x$enable_shared" = xyes ; then
IF_SHARED='' IF_SHARED=''
IF_NOT_SHARED='#'
else else
IF_SHARED='#' IF_SHARED='#'
IF_NOT_SHARED=''
fi fi
# Documentation tools # Documentation tools
...@@ -792,6 +794,7 @@ fi ...@@ -792,6 +794,7 @@ fi
AC_SUBST(IF_HOGWEED) AC_SUBST(IF_HOGWEED)
AC_SUBST(IF_STATIC) AC_SUBST(IF_STATIC)
AC_SUBST(IF_SHARED) AC_SUBST(IF_SHARED)
AC_SUBST(IF_NOT_SHARED)
AC_SUBST(IF_DOCUMENTATION) AC_SUBST(IF_DOCUMENTATION)
AC_SUBST(IF_DLL) AC_SUBST(IF_DLL)
AC_SUBST(IF_MINI_GMP) AC_SUBST(IF_MINI_GMP)
......
...@@ -11,8 +11,9 @@ Name: Hogweed ...@@ -11,8 +11,9 @@ Name: Hogweed
Description: Nettle low-level cryptographic library (public-key algorithms) Description: Nettle low-level cryptographic library (public-key algorithms)
URL: http://www.lysator.liu.se/~nisse/nettle URL: http://www.lysator.liu.se/~nisse/nettle
Version: @PACKAGE_VERSION@ Version: @PACKAGE_VERSION@
Requires.private: nettle Requires: @IF_NOT_SHARED@ nettle
Libs: -L${libdir} -lhogweed Requires.private: @IF_SHARED@ nettle
Libs.private: @LIBS@ Libs: -L${libdir} -lhogweed @IF_NOT_SHARED@ @LIBS@
Libs.private: @IF_SHARED@ @LIBS@
Cflags: -I${includedir} Cflags: -I${includedir}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment