-
Notifications
You must be signed in to change notification settings - Fork 589
Don't put @LIBS@
in pc file
#1114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hope that this helps with review: |
Looks good to me! With the note that we also use this Can't comment on |
Found this commit from 2020 that fixes the referenced curl commit above from 2012: It seems to be something that will hit libssh2 too for static-only builds, after merging the first patch. @haampie What do you think? Untested attempt to adapt that patch for libssh2: diff --git a/configure.ac b/configure.ac
index b5a5791e..be7dd717 100644
--- a/configure.ac
+++ b/configure.ac
@@ -392,6 +392,14 @@ fi
LIBS="${LIBS} ${LTLIBZ}"
+dnl merge the pkg-config Libs.private field into Libs when static-only
+if test "x$enable_shared" = "xno"; then
+ LIBS_NO_SHARED=$LIBS
+else
+ LIBS_NO_SHARED=
+fi
+AC_SUBST(LIBS_NO_SHARED)
+
AC_CONFIG_FILES([Makefile
src/Makefile
tests/Makefile
diff --git a/libssh2.pc.in b/libssh2.pc.in
index 9cbebb7f..61b93efe 100644
--- a/libssh2.pc.in
+++ b/libssh2.pc.in
@@ -15,6 +15,6 @@ URL: https://www.libssh2.org/
Description: Library for SSH-based communication
Version: @LIBSSH2VER@
Requires.private: @LIBSREQUIRED@
-Libs: -L${libdir} -lssh2
+Libs: -L${libdir} -lssh2 @LIBS_NO_SHARED@
Libs.private: @LIBS@
Cflags: -I${includedir}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8638ac41..11caa5de 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -189,6 +189,12 @@ endif()
set(LIBSSH2VER ${LIBSSH2_VERSION})
set(LIBSREQUIRED ${PC_REQUIRES_PRIVATE})
set(LIBS ${PC_LIBS})
+# merge the pkg-config Libs.private field into Libs when static-only
+if(BUILD_SHARED_LIBS)
+ set(LIBS_NO_SHARED "")
+else()
+ set(LIBS_NO_SHARED "${PC_LIBS}")
+endif()
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix "\${prefix}")
set(libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}") |
Follow-up to 1209c16 libssh2#1114 Ref: curl/curl@98e5904 Closes #xxxx
Follow-up to 1209c16 libssh2#1114 Ref: curl/curl@98e5904 Ref: curl/curl#5373 Closes #xxxx
Quoting the curl commit message (adapted for libssh2): "A project being built entirely statically will call pkg-config with `--static`, which utilises the `Libs.private` field. Conversely it will not use `--static` when not being built entirely statically, even if there is only a static build of libssh2 available. This will most likely cause the build to fail due to underlinking unless we merge the `Libs` fields. Consider that this is what the Meson build system does when it generates pkg-config files." Follow-up to 1209c16 libssh2#1114 Ref: curl/curl@98e5904 Ref: curl/curl#5373 Closes libssh2#1119
Quoting the curl commit message (adapted for libssh2): "A project being built entirely statically will call pkg-config with `--static`, which utilises the `Libs.private` field. Conversely it will not use `--static` when not being built entirely statically, even if there is only a static build of libssh2 available. This will most likely cause the build to fail due to underlinking unless we merge the `Libs` fields. Consider that this is what the Meson build system does when it generates pkg-config files." Follow-up to 1209c16 libssh2#1114 Ref: curl/curl@98e5904 Ref: curl/curl#5373 Closes libssh2#1119
Quoting the curl commit message (adapted for libssh2): "A project being built entirely statically will call pkg-config with `--static`, which utilises the `Libs.private` field. Conversely it will not use `--static` when not being built entirely statically, even if there is only a static build of libssh2 available. This will most likely cause the build to fail due to underlinking unless we merge the `Libs` fields. Consider that this is what the Meson build system does when it generates pkg-config files." Follow-up to 1209c16 libssh2#1114 Ref: curl/curl@98e5904 Ref: curl/curl#5373 Closes libssh2#1119
Adapted for libssh2 from the curl commit message by James Le Cuirot: "A project built entirely statically will call `pkg-config` with `--static`, which utilises the `Libs.private:` field. Conversely it will not use `--static` when not being built entirely statically, even if there is only a static build of libssh2 available. This will most likely cause the build to fail due to underlinking unless we merge the `Libs:` fields. Consider that this is what the Meson build system does when it generates `pkg-config` files." This patch extends the above to `Requires:`, to mirror `Libs:` with `pkg-config` package names. Follow-up to 1209c16 #1114 Ref: #1114 (comment) Ref: curl/curl@98e5904 Ref: curl/curl#5373 Closes #1119
Adapted for libssh2 from the curl commit message by James Le Cuirot: "A project built entirely statically will call `pkg-config` with `--static`, which utilises the `Libs.private:` field. Conversely it will not use `--static` when not being built entirely statically, even if there is only a static build of libssh2 available. This will most likely cause the build to fail due to underlinking unless we merge the `Libs:` fields. Consider that this is what the Meson build system does when it generates `pkg-config` files." This patch extends the above to `Requires:`, to mirror `Libs:` with `pkg-config` package names. Follow-up to 1209c16 libssh2#1114 Ref: libssh2#1114 (comment) Ref: curl/curl@98e5904 Ref: curl/curl#5373 Closes libssh2#1119
Adapted for libssh2 from the curl commit message by James Le Cuirot: "A project built entirely statically will call `pkg-config` with `--static`, which utilises the `Libs.private:` field. Conversely it will not use `--static` when not being built entirely statically, even if there is only a static build of libssh2 available. This will most likely cause the build to fail due to underlinking unless we merge the `Libs:` fields. Consider that this is what the Meson build system does when it generates `pkg-config` files." This patch extends the above to `Requires:`, to mirror `Libs:` with `pkg-config` package names. Follow-up to 1209c16 libssh2#1114 Ref: libssh2#1114 (comment) Ref: curl/curl@98e5904 Ref: curl/curl#5373 Closes libssh2#1119
Not an autotools expert, but
LIBS
containslibssh2
's own dependencies, so when doing shared linking, it makes no sense to put them underLibs: ...
in the pkg-config file.Libs.private
is what you want to use for that, since during static linking you do have to provide transitive deps.What's not fixed in this PR: adding the
-L
search dirs when doing static linking. Apparently when openssl has its libraries in<prefix>/lib64
, no-L<prefix>/lib64
is added. But when it's in<prefix>/lib
, it is? I guess this is a matter of custom logic in libssh2's autotools stuff, whereLIBS = -L... -lssl
is used for thelib
check (custom?), whileLDFLAGS = -L...
andLIBS = -lssl
is used for thelib64
check (autotools internals?)