[PATCH] build: use pkg-config to find nss and avahi

Dave Brolley brolley@redhat.com
Thu Sep 1 20:25:00 GMT 2011


Thanks! This patch has been comitted.

Dave

On 09/01/2011 09:41 AM, Diego Elio Pettenò wrote:
> Checking for directories directly on the /usr disallows building against a
> locally-installed NSS or Avahi, and makes cross-compilation difficult.
>
> By using pkg-config, it's easy to override the results, which allow
> building against non-system libraries as well as properly identifying
> cross-compiled libraries.
>
> Signed-off-by: Diego Elio Pettenò<flameeyes@flameeyes.eu>
> ---
>   Makefile.am  |   38 ++++++++++++++++--------------
>   configure.ac |   72 ++++++++++++++-------------------------------------------
>   2 files changed, 38 insertions(+), 72 deletions(-)
>
> diff --git a/Makefile.am b/Makefile.am
> index 43fd480..6f88b52 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -107,15 +107,15 @@ stap_LDFLAGS = $(AM_LDFLAGS) @PIELDFLAGS@
>   if HAVE_AVAHI
>   stap_CXXFLAGS += $(avahi_CFLAGS)
>   stap_CPPFLAGS += $(avahi_CFLAGS)
> -stap_LDADD += -lavahi-client -lavahi-common
> +stap_LDADD += $(avahi_LIBS)
>   endif
>
>   if HAVE_NSS
>   stap_SOURCES += nsscommon.cxx
> -stap_CFLAGS += $(nss_CFLAGS) $(nspr_CFLAGS) -DSTAP
> -stap_CXXFLAGS += $(nss_CFLAGS) $(nspr_CFLAGS)
> -stap_CPPFLAGS += $(nss_CFLAGS) $(nspr_CFLAGS)
> -stap_LDADD += -lssl3 -lnss3 -lnspr4 -lplc4 -lsmime3
> +stap_CFLAGS += $(nss_CFLAGS) -DSTAP
> +stap_CXXFLAGS += $(nss_CFLAGS)
> +stap_CPPFLAGS += $(nss_CFLAGS)
> +stap_LDADD += $(nss_LIBS)
>
>   install-exec-local: install-scripts
>
> @@ -164,33 +164,35 @@ if BUILD_TRANSLATOR
>   if HAVE_NSS
>   stap_sign_module_SOURCES = stap-sign-module.cxx nsscommon.cxx util.cxx
>   stap_sign_module_CPPFLAGS = $(AM_CPPFLAGS)
> -stap_sign_module_CXXFLAGS = $(AM_CXXFLAGS) @PIECXXFLAGS@ $(nss_CFLAGS) $(nspr_CFLAGS)
> -stap_sign_module_CFLAGS = $(AM_CFLAGS) @PIECFLAGS@ $(nss_CFLAGS) $(nspr_CFLAGS)
> +stap_sign_module_CXXFLAGS = $(AM_CXXFLAGS) @PIECXXFLAGS@ $(nss_CFLAGS)
> +stap_sign_module_CFLAGS = $(AM_CFLAGS) @PIECFLAGS@ $(nss_CFLAGS)
>   stap_sign_module_LDFLAGS = $(AM_LDFLAGS) @PIELDFLAGS@
> -stap_sign_module_LDADD = -lssl3 -lnss3 -lnspr4 -lsmime3
> +stap_sign_module_LDADD = $(nss_LIBS)
>
>   stap_authorize_cert_SOURCES = stap-authorize-cert.cxx nsscommon.cxx util.cxx
>   stap_authorize_cert_CPPFLAGS = $(AM_CPPFLAGS)
> -stap_authorize_cert_CXXFLAGS = $(AM_CXXFLAGS) @PIECXXFLAGS@ $(nss_CFLAGS) $(nspr_CFLAGS)
> -stap_authorize_cert_CFLAGS = $(AM_CFLAGS) @PIECFLAGS@ $(nss_CFLAGS) $(nspr_CFLAGS)
> +stap_authorize_cert_CXXFLAGS = $(AM_CXXFLAGS) @PIECXXFLAGS@ $(nss_CFLAGS)
> +stap_authorize_cert_CFLAGS = $(AM_CFLAGS) @PIECFLAGS@ $(nss_CFLAGS)
>   stap_authorize_cert_LDFLAGS = $(AM_LDFLAGS) @PIELDFLAGS@
> -stap_authorize_cert_LDADD = -lssl3 -lnss3 -lnspr4 -lsmime3
> +stap_authorize_cert_LDADD = $(nss_LIBS)
>
>   if BUILD_SERVER
>   stap_serverd_SOURCES = stap-serverd.cxx cscommon.cxx util.cxx nsscommon.cxx
> -stap_serverd_CXXFLAGS = $(AM_CXXFLAGS) @PIECXXFLAGS@ $(nss_CFLAGS) $(nspr_CFLAGS)
> -stap_serverd_CFLAGS = $(AM_CFLAGS) @PIECFLAGS@ $(nss_CFLAGS) $(nspr_CFLAGS)
> +stap_serverd_CXXFLAGS = $(AM_CXXFLAGS) @PIECXXFLAGS@ $(nss_CFLAGS)
> +stap_serverd_CFLAGS = $(AM_CFLAGS) @PIECFLAGS@ $(nss_CFLAGS)
>   stap_serverd_LDFLAGS = $(AM_LDFLAGS) @PIELDFLAGS@
> -stap_serverd_LDADD = -lssl3 -lnss3 -lnspr4 -lplc4 -lsmime3 -lpthread
> +stap_serverd_LDADD = $(nss_LIBS)
>   if HAVE_AVAHI
> -stap_serverd_LDADD += -lavahi-client -lavahi-common
> +stap_serverd_CFLAGS += $(avahi_CFLAGS)
> +stap_serverd_CXXFLAGS += $(avahi_CFLAGS)
> +stap_serverd_LDADD += $(avahi_LIBS)
>   endif
>
>   stap_gen_cert_SOURCES = stap-gen-cert.cxx util.cxx nsscommon.cxx
> -stap_gen_cert_CXXFLAGS = $(AM_CXXFLAGS) @PIECXXFLAGS@ $(nss_CFLAGS) $(nspr_CFLAGS)
> -stap_gen_cert_CFLAGS = $(AM_CFLAGS) @PIECFLAGS@ $(nss_CFLAGS) $(nspr_CFLAGS)
> +stap_gen_cert_CXXFLAGS = $(AM_CXXFLAGS) @PIECXXFLAGS@ $(nss_CFLAGS)
> +stap_gen_cert_CFLAGS = $(AM_CFLAGS) @PIECFLAGS@ $(nss_CFLAGS)
>   stap_gen_cert_LDFLAGS = $(AM_LDFLAGS) @PIELDFLAGS@
> -stap_gen_cert_LDADD = -lssl3 -lnss3 -lnspr4 -lsmime3
> +stap_gen_cert_LDADD = $(nss_LIBS)
>   endif
>   endif
>
> diff --git a/configure.ac b/configure.ac
> index 8e88c2c..44fe0b0 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -309,31 +309,11 @@ AM_CONDITIONAL([BUILD_PDFREFDOCS], [test "$have_xmlto_pdf" == "yes"])
>   rm -f conftest.xml
>
>   dnl See if we have the nss/nspr headers and libraries
> -AC_CHECK_FILE([/usr/include/nss3], nssdir=nss3, [
> -  AC_CHECK_FILE([/usr/include/nss], nssdir=nss)
> -])
> -AC_CHECK_FILE([/usr/include/nspr4], nsprdir=nspr4, [
> -  AC_CHECK_FILE([/usr/include/nspr], nsprdir=nspr)
> -])
> -if test "x$nssdir" != "x" -a "x$nsprdir" != "x"; then
> -  nss_CFLAGS="-I/usr/include/$nssdir"
> -  nspr_CFLAGS="-I/usr/include/$nsprdir"
> -  AC_SUBST(nss_CFLAGS)
> -  AC_SUBST(nspr_CFLAGS)
> -  save_CPPFLAGS="$CPPFLAGS"
> -  CPPFLAGS="$CFLAGS $nss_CFLAGS $nspr_CFLAGS"
> -  have_nss_includes=yes
> -  AC_CHECK_HEADERS(["$nsprdir/nspr.h" "$nsprdir/plgetopt.h" "$nsprdir/prerror.h" "$nssdir/ssl.h" "$nssdir/nss.h" "$nssdir/pk11func.h" "$nssdir/secerr.h"], [], have_nss_includes=no)
> -  CPPFLAGS="$save_CPPFLAGS"
> -  have_nss_libs=no
> -fi
> -AC_CHECK_LIB(nspr4, PR_Connect, [
> -  AC_CHECK_LIB(ssl3, SSL_ReHandshake, have_nss_libs=yes)
> -])
> -if test "x${have_nss_includes}${have_nss_libs}" = "xyesyes"; then
> -  AC_DEFINE([HAVE_NSS], [1], [Define to 1 if you have the nss libraries.])
> -fi
> -AM_CONDITIONAL([HAVE_NSS], [test "x${have_nss_includes}${have_nss_libs}" == "xyesyes"])
> +PKG_CHECK_MODULES([nss], [nss>= 3],
> +  [have_nss=yes
> +   AC_DEFINE([HAVE_NSS], [1], [Define to 1 if you have the nss libraries.])
> +  ], [have_nss=no])
> +AM_CONDITIONAL([HAVE_NSS], [test "${have_nss}" = "yes"])
>
>   dnl Handle the option to build the compile server.
>   AC_ARG_ENABLE([server],
> @@ -344,42 +324,26 @@ AC_ARG_ENABLE([server],
>
>   if test "$enable_server" != "no"; then
>   dnl See if we have enough libraries and tools to build the compile server
> -  if test "x${have_nss_includes}" != "xyes"; then
> -    AC_MSG_WARN([will not build systemtap compile server, cannot find nss/nspr headers])
> +  if test "x${have_nss}" != "xyes"; then
> +    AC_MSG_WARN([will not build systemtap compile server, cannot find nss headers])
>     fi		
> -  if test "x${have_nss_libs}" != "xyes"; then
> -    AC_MSG_WARN([will not build systemtap compile server, cannot find nss/nspr libraries])
> -  fi
>   fi
> -AM_CONDITIONAL([BUILD_SERVER], [test "x${have_nss_includes}${have_nss_libs}" == "xyesyes" -a "$enable_server" != "no"])
> +AM_CONDITIONAL([BUILD_SERVER], [test "${have_nss}" == "yes" -a "$enable_server" != "no"])
>
> -if test "x${have_nss_includes}" != "xyes"; then
> -  AC_MSG_WARN([some compile server client functionality will be restricted, cannot find nss/nspr headers])
> +if test "${have_nss}" != "yes"; then
> +  AC_MSG_WARN([some compile server client functionality will be restricted, cannot find nss development files])
>   fi		
> -if test "x${have_nss_libs}" != "xyes"; then
> -  AC_MSG_WARN([some compile server client functionality will be restricted, cannot find nss/nspr libraries])
> -fi
>
>   dnl See if we have the avahi libraries and headers
> -AC_CHECK_FILE([/usr/include/avahi-client], avahi_clientdir=avahi-client)
> -AC_CHECK_FILE([/usr/include/avahi-common], avahi_commondir=avahi-common)
> -if test "x$avahi_clientdir" != "x" -a "x$avahi_commondir" != "x"; then
> -  have_avahi_includes=yes
> -  AC_CHECK_HEADERS(["$avahi_clientdir/client.h" "$avahi_clientdir/lookup.h" "$avahi_commondir/simple-watch.h" "$avahi_commondir/malloc.h" "$avahi_commondir/error.h"], [], have_avahi_includes=no)
> -  have_avahi_libs=no
> -fi
> -AC_CHECK_LIB(avahi-client, avahi_client_new,
> -  AC_CHECK_LIB(avahi-common, avahi_strerror, have_avahi_libs=yes))
> -if test "x${have_avahi_includes}" != "xyes"; then
> -  AC_MSG_WARN([some compile-server functionality will be restricted, cannot find avahi headers])
> -fi
> -if test "x${have_avahi_libs}" != "xyes"; then
> -  AC_MSG_WARN([some compile-server functionality will be restricted, cannot find avahi libraries])
> -fi
> -if test "x${have_avahi_includes}${have_avahi_libs}" = "xyesyes"; then
> -  AC_DEFINE([HAVE_AVAHI], [1], [Define to 1 if you have the avahi libraries.])
> +PKG_CHECK_MODULES([avahi], [avahi-client],
> +  [have_avahi=yes
> +   AC_DEFINE([HAVE_AVAHI], [1], [Define to 1 if you have the avahi libraries.])
> +  ], [have_avahi=no])
> +AM_CONDITIONAL([HAVE_AVAHI], [test "${have_avahi}" = "yes"])
> +
> +if test "${have_avahi}" != "yes"; then
> +  AC_MSG_WARN([some compile-server functionality will be restricted, cannot find avahi development files])
>   fi
> -AM_CONDITIONAL([HAVE_AVAHI], [test "x${have_avahi_includes}${have_avahi_libs}" == "xyesyes"])
>
>   dnl Handle the optional grapher
>   AC_ARG_ENABLE([grapher],



More information about the Systemtap mailing list