Refactored configure.ac, added pkg-config support

This commit is contained in:
Fabian Freyer
2014-09-26 01:41:00 +02:00
parent dcbf3fb4d5
commit 55efc601cb
4 changed files with 62 additions and 16 deletions

1
.gitignore vendored
View File

@@ -25,6 +25,7 @@ examples/*.o
tests/*.o
tests/check_parser
*.a
*.pc
*.tar.gz
*.zip
docs/html

View File

@@ -36,6 +36,9 @@ endif
include_HEADERS = strophe.h
noinst_HEADERS = strophepp.h
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libstrophe.pc
EXTRA_DIST = docs
## Examples

View File

@@ -12,8 +12,14 @@ AS_CASE([$host_os],
[freebsd*], [PLATFORM="freebsd"],
[PLATFORM="nix"])
PKG_CHECK_MODULES([openssl], [openssl], [],
[AC_CHECK_HEADER(openssl/ssl.h, [openssl_LIBS="-lssl -lcrypto"], [AC_MSG_ERROR([openssl not found; openssl required])])])
PKG_CHECK_MODULES([openssl], [openssl], [PC_REQUIRES+=(openssl)],
[AC_CHECK_HEADER([openssl/ssl.h],
[
openssl_LIBS="-lssl -lcrypto"
PC_LIBS+=($openssl_LIBS)
],
[AC_MSG_ERROR([openssl not found; openssl required])]
)])
PKG_CHECK_MODULES([check], [check >= 0.9.4], [], [AC_MSG_WARN([libcheck not found; unit tests will not be compilable])])
@@ -24,18 +30,35 @@ AC_ARG_WITH([libxml2],
if test "x$with_libxml2" != xno; then
PKG_CHECK_MODULES([libxml2], [libxml-2.0 >= 2.7],
[with_libxml2=yes], [dummy=1])
if test "x$with_libxml2" != xyes; then
old_CFLAGS=$CFLAGS
CFLAGS="-I${includedir}/libxml2"
AC_CHECK_HEADER([libxml/parser.h],
[with_libxml2=yes; libxml2_CFLAGS="-I${includedir}/libxml2"; libxml2_LIBS="-lxml2"],
[AC_MSG_ERROR([libxml2 not found.])])
CFLAGS=$old_CFLAGS
fi
[
with_libxml2=yes
PC_REQUIRES+=(libxml-2.0)
],
[
old_CFLAGS=$CFLAGS
CFLAGS="-I${includedir}/libxml2"
AC_CHECK_HEADER([libxml/parser.h],
[
with_libxml2=yes
libxml2_CFLAGS="-I${includedir}/libxml2"
libxml2_LIBS="-lxml2"
PC_LIBS+=($libxml2_LIBS)
PC_CFLAGS+=($libxml2_CFLAGS)
],
[AC_MSG_ERROR([libxml2 not found.])])
CFLAGS=$old_CFLAGS
])
else
PKG_CHECK_MODULES([expat], [expat >= 2.0.0], [],
[AC_CHECK_HEADER(expat.h, [expat_LIBS="-lexpat"], [AC_MSG_ERROR([expat not found; expat required.])])])
PKG_CHECK_MODULES([expat], [expat >= 2.0.0],
[PC_REQUIRES+=(expat)],
[AC_CHECK_HEADER([expat.h],
[
expat_LIBS="-lexpat"
PC_LIBS+=($expat_LIBS)
],
[AC_MSG_ERROR([expat not found; expat required.])]
)
])
fi
if test "x$with_libxml2" = xyes; then
@@ -54,8 +77,8 @@ AC_MSG_NOTICE([libstrophe will use the $with_parser XML parser])
AC_SEARCH_LIBS([socket], [socket])
if test "x$PLATFORM" != xfreebsd; then
AC_CHECK_LIB([resolv], [res_query], [],
[AC_CHECK_LIB([resolv], [__res_query], [],
AC_CHECK_LIB([resolv], [res_query], [LIBS="-lresolv $LIBS"; PC_LIBS+=(-lresolv)],
[AC_CHECK_LIB([resolv], [__res_query], [LIBS="-lresolv $LIBS"; PC_LIBS+=(-lresolv)],
[AC_MSG_ERROR([libresolv not found; libresolv required. ])])])
else
AC_MSG_NOTICE([skipping libresolv checks for freebsd])
@@ -64,8 +87,13 @@ fi
AC_CHECK_HEADERS([arpa/nameser_compat.h])
AM_CONDITIONAL([PARSER_EXPAT], [test x$with_parser != xlibxml2])
AC_SUBST([PC_REQUIRES], [${PC_REQUIRES[[@]]}])
AC_SUBST([PC_CFLAGS], [${PC_CFLAGS[[@]]}])
AC_SUBST([PC_LIBS], [${PC_LIBS[[@]]}])
AC_SUBST(PARSER_NAME)
AC_SUBST(PARSER_CFLAGS)
AC_SUBST(PARSER_LIBS)
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([Makefile libstrophe.pc])
AC_OUTPUT

14
libstrophe.pc.in Normal file
View File

@@ -0,0 +1,14 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libstrophe
Description: A simple, lightweight C library for writing XMPP clients
URL: http://strophe.im/libstrophe/
Version: @VERSION@
Requires:
Requires.private: @PC_REQUIRES@
Libs: -L${libdir} -lstrophe
Libs.private: @PC_LIBS@
Cflags: -I${includedir} @PC_CFLAGS@