-SRD_LIB_VERSION_CURRENT=1
-SRD_LIB_VERSION_REVISION=0
-SRD_LIB_VERSION_AGE=0
-SRD_LIB_VERSION="$SRD_LIB_VERSION_CURRENT:$SRD_LIB_VERSION_REVISION:$SRD_LIB_VERSION_AGE"
-SRD_LIB_LDFLAGS="-version-info $SRD_LIB_VERSION"
-AC_SUBST(SRD_LIB_VERSION_CURRENT)
-AC_SUBST(SRD_LIB_VERSION_REVISION)
-AC_SUBST(SRD_LIB_VERSION_AGE)
-AC_SUBST(SRD_LIB_VERSION)
-AC_SUBST(SRD_LIB_LDFLAGS)
-
-# Checks for libraries.
-
-# libglib-2.0 is always needed.
-# Note: glib-2.0 is part of the libsigrokdecode API
-# (hard pkg-config requirement).
-AM_PATH_GLIB_2_0([2.24.0],
- [CFLAGS="$CFLAGS $GLIB_CFLAGS"; LIBS="$LIBS $GLIB_LIBS"])
-
-# Python support. We require at least Python >= 3.0.
-AC_ARG_VAR([PYTHON3_CONFIG], [path to python3-config utility])
-AC_CHECK_PROGS([PYTHON3_CONFIG], [python3-config python3.3-config python-config-3.3 python3.2-config python-config-3.2 python3.1-config python-config-3.1 python3.0-config python-config-3.0])
-CPPFLAGS_PYTHON=""
-LDFLAGS_PYTHON=""
-case "$build" in
-*mingw*)
- # We currently hardcode the paths to the Python 3.2 default install
- # location as there's no 'python-config' script on Windows, it seems.
- # Note: We add both the /c/ and c:/ syntax (needed for cmake).
- AC_MSG_WARN([using hardcoded Python3 configuration on MinGW])
- CPPFLAGS_PYTHON="-I/c/Python32/include -Ic:/Python32/include"
- LDFLAGS_PYTHON="-L/c/Python32/libs -Lc:/Python32/libs -lpython32"
- ;;
-*)
- # We know that Linux has 'python3-config'.
- # On Darwin, Macports has python3.x-config, fink has python3-config.
- # Mac OS X (Snow Leopard) ships with 'python-config' per default, but
- # that's Python 2.x, so not useful for us.
- # Everything else is untested, we just hope some $PYTHON3_CONFIG
- # (i.e., any of the tools we check for above) is available.
- if test -n "$PYTHON3_CONFIG"; then
- CPPFLAGS_PYTHON="$($PYTHON3_CONFIG --includes)"
- LDFLAGS_PYTHON="$($PYTHON3_CONFIG --ldflags)"
- else
- AC_MSG_ERROR([python3-config not found])
- fi
- ;;
-esac
-AC_SUBST(CPPFLAGS_PYTHON)
-AC_SUBST(LDFLAGS_PYTHON)
+SR_LIB_VERSION_SET([SRD_LIB_VERSION], [2:0:0])
+
+AM_CONDITIONAL([WIN32], [test -z "${host_os##mingw*}" || test -z "${host_os##cygwin*}"])
+
+############################
+## Package dependencies ##
+############################
+
+# Initialize pkg-config.
+# We require at least 0.22, as "Requires.private" behaviour changed there.
+PKG_PROG_PKG_CONFIG([0.22])
+
+# Collect the pkg-config module names of all dependencies in SRD_PKGLIBS.
+# These are used to derive the compiler flags and for the "Requires.private"
+# field in the generated libsigrokdecode.pc file.
+SRD_PKGLIBS=
+SRD_PKGLIBS_TESTS=
+
+# Keep track of all checked modules so we can list them at the end.
+SR_PKG_CHECK_SUMMARY([srd_pkglibs_summary])
+
+# Python 3 is always needed.
+SR_PKG_CHECK([python3], [SRD_PKGLIBS],
+ [python3 >= 3.2], [python-3.4 >= 3.4], [python-3.3 >= 3.3], [python-3.2 >= 3.2])
+AS_IF([test "x$sr_have_python3" = xno],
+ [AC_MSG_ERROR([Cannot find Python 3 development headers.])])
+
+# We also need to find the name of the python3 executable (for 'make install').
+# Some OSes call this python3, some call it python3.2, etc. etc.
+AC_ARG_VAR([PYTHON3], [Python 3 interpreter])
+AC_CHECK_PROGS([PYTHON3], [python3.4 python3.3 python3.2 python3])
+AS_IF([test "x$PYTHON3" = x],
+ [AC_MSG_ERROR([Cannot find Python 3 interpreter.])])
+
+######################
+## Feature checks ##
+######################
+
+# Keep track of all checked modules so we can list them at the end.
+SR_PKG_CHECK_SUMMARY([srd_pkglibs_opt_summary])