Skip to content

Instantly share code, notes, and snippets.

@darix
Last active January 28, 2016 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darix/2725672008083c9111ff to your computer and use it in GitHub Desktop.
Save darix/2725672008083c9111ff to your computer and use it in GitHub Desktop.

configure.ac:

# GnuTLS crypto backend
PKG_CHECK_MODULES([gnutls], [gnutls >= 3.0 nettle], [
    CFLAGS_save=$CFLAGS
    CFLAGS="$CFLAGS $gnutls_CFLAGS"
    AC_CHECK_HEADERS([nettle/version.h])
    CFLAGS=$CFLAGS_save

    LDFLAGS_save=$LDFLAGS
    LDFLAGS="$LDFLAGS $gnutls_LIBS"
    AC_CHECK_FUNC([gnutls_pkcs11_privkey_generate3], [enable_pkcs11=yes], [enable_pkcs11=no])
    AS_IF([test "$enable_pkcs11" = yes],
        [AC_DEFINE([ENABLE_PKCS11], [1], [PKCS 11 support available])])

    LDFLAGS=$LDFLAGS_save
])

This generates:

abuild@tengu:/home/abuild/rpmbuild/BUILD/knot-2.1.0> gcc -o conftest -fmessage-length=0 \
   -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables \     
   -fasynchronous-unwind-tables -g -Wall -Werror=format-security -Werror=implicit   \
   -lgnutls -lnettle t.c 
/tmp/cc7IrdFj.o: In function `main':
/home/abuild/rpmbuild/BUILD/knot-2.1.0/t.c:63: undefined reference to `gnutls_pkcs11_privkey_generate3'
collect2: error: ld returned 1 exit status

While reordering the arguments ...:

abuild@tengu:/home/abuild/rpmbuild/BUILD/knot-2.1.0> gcc -o conftest -fmessage-length=0 \
   -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables \     
   -fasynchronous-unwind-tables -g -Wall -Werror=format-security -Werror=implicit   \
   t.c -lgnutls -lnettle
@oerdnj
Copy link

oerdnj commented Jan 28, 2016

Pushed into the git, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment