Skip to content
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

configure.ac: use MbedTLS pkg-config if available #1455

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

pulsastrix
Copy link
Contributor

Newer MbedTLS versions provide pkg-config files for easier dependency management/linking, see the release notes of versions 3.6.0 and 2.28.8.

This PR allows the autoconf build script to utilize the mbedtls pkg-config file if it exists, falling back to the previous method of finding MbedTLS if no pkg-config file was found.

Additionally, this change allows overriding MbedTLS_CFLAGS and MbedTLS_LIBS, which was previously not possible (unlike all the other DTLS libraries).

@pulsastrix pulsastrix marked this pull request as draft July 1, 2024 13:56
@pulsastrix pulsastrix force-pushed the use_mbedtls_pkgconfig branch 2 times, most recently from 863e6bd to c013ab4 Compare July 1, 2024 15:08
@pulsastrix pulsastrix marked this pull request as ready for review July 1, 2024 15:09
@mrdeep1
Copy link
Collaborator

mrdeep1 commented Jul 2, 2024

Thanks for doing this.

Great that MBed TLS have eventually added .pc files. Shame that they do not have it for their make system, only for cmake.

However, for libcoap

./configure --with-mbedtls --disable-doxygen --disable-manpages --enable-tests --disable-shared
make

fails with

make[2]: Entering directory '/home/jon/libcoap/tests'
  CCLD     testdriver
/usr/bin/ld: ../.libs/libcoap-3-mbedtls.a(libcoap_3-mbedtls_la-coap_mbedtls.o): undefined reference to symbol 'mbedtls_x509_crt_parse_file'
/usr/bin/ld: /usr/local/lib/libmbedx509.so.7: error adding symbols: DSO missing from command line

or

./configure --with-mbedtls --disable-doxygen --disable-manpages --disable-tests --disable-shared
make

gives

  CCLD     coap-client-mbedtls
/usr/bin/ld: ../.libs/libcoap-3-mbedtls.a(libcoap_3-mbedtls_la-coap_mbedtls.o): undefined reference to symbol 'mbedtls_x509_crt_parse_file'
/usr/bin/ld: /usr/local/lib/libmbedx509.so.7: error adding symbols: DSO missing from command line

The issue here is the non-shared file ../.libs/libcoap-3-mbedtls.a does not indicate that the libraries mbedcrypto mbedx509 are not indicated as being needed.

./configure --with-mbedtls --disable-doxygen --disable-manpages --disable-tests --enabled-shared
make

does work as expected (note: tests/testdriver has to use the static file, hence why that is always failing).

I suspect that you may need to use PKG_CHECK_MODULES_STATIC if --disable-shared is set.

@pulsastrix
Copy link
Contributor Author

Hi, thanks for the review.

I have now replaced PKG_CHECK_MODULES with PKG_CHECK_MODULES_STATIC if --enable-static is set, which should fix the issue you mentioned (at least it did on my system).

Copy link
Collaborator

@mrdeep1 mrdeep1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pulsastrix It is looking good. Just a couple of things.

configure.ac Outdated Show resolved Hide resolved
configure.ac Show resolved Hide resolved
Additionally, this change allows overriding the MbedTLS compiler and
linker flags (just like with the other DTLS libraries).
@mrdeep1 mrdeep1 merged commit 2ae46c9 into obgm:develop Jul 10, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants