Skip to content

Commit 0298571

Browse files
committed
configure: Use pkg-config to find libs whenever possible
Use pkg-config to find cppunit, libxml2 and expat. All those libraries provide pkg-config files, and in all of those cases the pkg-config macro is superior to the custom macros used currently. The advantages of pkg-config files include: - Explicit static linking support via --static. Currently, e.g. 'xml2-config --libs' prints all libraries needed for static linking when doing dynamic linking unnecessary, resulting in unnecessary direct deps. - Better cross-build support. You don't have to build the additional *-config tools for target. - Better multilib support. Per-ABI pkgconfig directories are commonly supported while packages usually fail to look for per-CHOST *-config variants. - Better override support. The current macros allow little to no result overrides, the pkg-config macros let you pass FOO_CFLAGS and FOO_LIBS manually. - Cleaner version checks. The code used in libxml.m4 is really creepy.
1 parent d289dc1 commit 0298571

File tree

4 files changed

+14
-45
lines changed

4 files changed

+14
-45
lines changed

configure.ac

+10-22
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ AC_SUBST(LT_REVISION, 0)
2121
AC_SUBST(LT_AGE, 0)
2222

2323
AC_CONFIG_MACRO_DIR([m4])
24-
m4_ifdef([AM_PATH_CPPUNIT], [AM_PATH_CPPUNIT(1.10.2)])
2524
AC_CONFIG_SRCDIR([src/a2io.h])
2625
AC_CONFIG_HEADERS([config.h])
2726

@@ -202,6 +201,9 @@ fi
202201

203202
# Checks for libraries.
204203

204+
# Check availability of cppunit
205+
PKG_CHECK_MODULES([CPPUNIT], [cppunit >= 1.10.2], [], [])
206+
205207
# Check availability of libz
206208
if test "x$with_libz" = "xyes"; then
207209
PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.3], [have_zlib=yes], [have_zlib=no])
@@ -318,13 +320,7 @@ AM_CONDITIONAL([HAVE_LIBUV], [test "x$have_libuv" = "xyes"])
318320

319321
have_libxml2=no
320322
if test "x$with_libxml2" = "xyes"; then
321-
m4_ifdef([AM_PATH_XML2], [AM_PATH_XML2([2.6.24], [have_libxml2=yes])], [
322-
AC_MSG_WARN([configure was generated without libxml2 detection. libxml2 detection is disabled])
323-
XML_CPPFLAGS=
324-
XML_LIBS=
325-
AC_SUBST([XML_CPPFLAGS])
326-
AC_SUBST([XML_LIBS])
327-
])
323+
PKG_CHECK_MODULES([LIBXML2],[libxml-2.0 >= 2.6.24],[have_libxml2=yes],[have_libxml2=no])
328324
if test "x$have_libxml2" = "xyes"; then
329325
AC_DEFINE([HAVE_LIBXML2], [1], [Define to 1 if you have libxml2.])
330326
elif test "x$with_libxml2_requested" = "xyes"; then
@@ -334,13 +330,7 @@ fi
334330

335331
have_libexpat=no
336332
if test "x$with_libexpat" = "xyes" && test "x$have_libxml2" != "xyes"; then
337-
m4_ifdef([AM_PATH_LIBEXPAT], [AM_PATH_LIBEXPAT], [
338-
AC_MSG_WARN([configure was generated without libexpat detection. libexpat detection is disabled])
339-
EXPAT_CFLAGS=
340-
EXPAT_LIBS=
341-
AC_SUBST([EXPAT_CFLAGS])
342-
AC_SUBST([EXPAT_LIBS])
343-
])
333+
PKG_CHECK_MODULES([EXPAT],[expat],[have_libexpat=yes],[have_libexpat=no])
344334
if test "x$have_libexpat" != "xyes" &&
345335
test "x$with_libexpat_requested" = "xyes"; then
346336
ARIA2_DEP_NOT_MET([libexpat])
@@ -511,14 +501,12 @@ have_libgcrypt=no
511501
if test "x$have_openssl" != "xyes"; then
512502
if test "x$with_libnettle" = "xyes" &&
513503
test "x$have_nativetls" != "xyes"; then
514-
AC_CHECK_LIB([nettle], [nettle_sha1_init],
515-
[have_libnettle=yes], [have_libnettle=no])
504+
PKG_CHECK_MODULES([LIBNETTLE], [nettle],
505+
[have_libnettle=yes], [have_libnettle=no])
516506
if test "x$have_libnettle" = "xyes"; then
517-
LIBNETTLE_CFLAGS=
518-
LIBNETTLE_LIBS="-lnettle"
519-
AC_SUBST([LIBNETTLE_CFLAGS])
520-
AC_SUBST([LIBNETTLE_LIBS])
521507
AC_DEFINE([HAVE_LIBNETTLE], [1], [Define to 1 if you have libnettle.])
508+
elif test "x$with_libnettle_requested" = "xyes"; then
509+
ARIA2_DEP_NOT_MET([nettle])
522510
fi
523511
fi
524512
if test "x$with_libgmp" = "xyes" &&
@@ -1229,7 +1217,7 @@ CA Bundle: $ca_bundle
12291217
LibNettle: $have_libnettle (CFLAGS='$LIBNETTLE_CFLAGS' LIBS='$LIBNETTLE_LIBS')
12301218
LibGmp: $have_libgmp (CFLAGS='$LIBGMP_CFLAGS' LIBS='$LIBGMP_LIBS')
12311219
LibGcrypt: $have_libgcrypt (CFLAGS='$LIBGCRYPT_CFLAGS' LIBS='$LIBGCRYPT_LIBS')
1232-
LibXML2: $have_libxml2 (CFLAGS='$XML_CPPFLAGS' LIBS='$XML_LIBS')
1220+
LibXML2: $have_libxml2 (CFLAGS='$LIBXML2_CFLAGS' LIBS='$LIBXML2_LIBS')
12331221
LibExpat: $have_libexpat (CFLAGS='$EXPAT_CFLAGS' LIBS='$EXPAT_LIBS')
12341222
LibCares: $have_libcares (CFLAGS='$LIBCARES_CFLAGS' LIBS='$LIBCARES_LIBS')
12351223
Zlib: $have_zlib (CFLAGS='$ZLIB_CFLAGS' LIBS='$ZLIB_LIBS')

m4/libexpat.m4

-19
This file was deleted.

src/Makefile.am

+2-2
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ AM_CPPFLAGS = \
711711
@EXTRACPPFLAGS@ \
712712
@ZLIB_CFLAGS@ \
713713
@LIBUV_CFLAGS@ \
714-
@XML_CPPFLAGS@ \
714+
@LIBXML2_CFLAGS@ \
715715
@EXPAT_CFLAGS@ \
716716
@SQLITE3_CFLAGS@ \
717717
@LIBGNUTLS_CFLAGS@ \
@@ -733,7 +733,7 @@ EXTLDADD = @ALLOCA@ \
733733
@EXTRALIBS@ \
734734
@ZLIB_LIBS@ \
735735
@LIBUV_LIBS@ \
736-
@XML_LIBS@ \
736+
@LIBXML2_LIBS@ \
737737
@EXPAT_LIBS@ \
738738
@SQLITE3_LIBS@ \
739739
@WINTLS_LIBS@ \

test/Makefile.am

+2-2
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ aria2c_LDADD = \
246246
@EXTRALIBS@ \
247247
@ZLIB_LIBS@ \
248248
@LIBUV_LIBS@ \
249-
@XML_LIBS@ \
249+
@LIBXML2_LIBS@ \
250250
@EXPAT_LIBS@ \
251251
@SQLITE3_LIBS@ \
252252
@WINTLS_LIBS@ \
@@ -274,7 +274,7 @@ AM_CPPFLAGS = \
274274
@EXTRACPPFLAGS@ \
275275
@ZLIB_CFLAGS@ \
276276
@LIBUV_CFLAGS@ \
277-
@XML_CPPFLAGS@ \
277+
@LIBXML2_CFLAGS@ \
278278
@EXPAT_CFLAGS@ \
279279
@SQLITE3_CFLAGS@ \
280280
@LIBGNUTLS_CFLAGS@ \

0 commit comments

Comments
 (0)