-echo
-echo "libsigrokdecode configuration summary:"
-echo
-echo " - Package version (major.minor.micro): $SRD_PACKAGE_VERSION"
-echo " - Library version (current:revision:age): $SRD_LIB_VERSION"
-echo " - Prefix: $prefix"
-echo
-echo "Detected libraries:"
-echo
-
-# Note: This only works for libs with pkg-config integration.
-for lib in "glib-2.0"; do
- if `$PKG_CONFIG --exists $lib`; then
- ver=`$PKG_CONFIG --modversion $lib`
- answer="yes ($ver)"
- else
- answer="no"
- fi
- echo " - $lib: $answer"
-done
-
-echo
-echo "Detected Python:"
-echo
-echo " - Python CPPFLAGS: $CPPFLAGS_PYTHON"
-echo " - Python LDFLAGS: $LDFLAGS_PYTHON"
-echo
+# 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.
+# Starting with Python 3.8 we need to check for "python-3.8-embed"
+# first, since usually only that variant will add "-lpython3.8".
+# https://docs.python.org/3/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build
+SR_PKG_CHECK([python3], [SRD_PKGLIBS],
+ [python-3.9-embed], [python-3.8-embed], [python-3.8 >= 3.8], [python-3.7 >= 3.7], [python-3.6 >= 3.6], [python-3.5 >= 3.5], [python-3.4 >= 3.4], [python-3.3 >= 3.3], [python-3.2 >= 3.2], [python3 >= 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.8 python3.7 python3.6 python3.5 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])
+
+# The Check unit testing framework is optional. Disable if not found.
+SR_PKG_CHECK([check], [SRD_PKGLIBS_TESTS], [check >= 0.9.4])
+AM_CONDITIONAL([HAVE_CHECK], [test "x$sr_have_check" = xyes])
+
+# Enable the C99 standard if possible, and enforce the use
+# of SRD_API to explicitly mark all public API functions.
+SRD_EXTRA_CFLAGS=
+SR_CHECK_COMPILE_FLAGS([SRD_EXTRA_CFLAGS], [C99], [-std=c99 -c99 -AC99 -qlanglvl=extc99])
+SR_CHECK_COMPILE_FLAGS([SRD_EXTRA_CFLAGS], [visibility], [-fvisibility=hidden])
+
+# Select suitable compiler warning flags.
+SR_ARG_ENABLE_WARNINGS([SRD_WFLAGS], [-Wall], [-Wall -Wextra -Wmissing-prototypes -Wshadow -Wformat=2 -Wno-format-nonliteral -Wfloat-equal])
+
+# Link against libm, this is required (among other things) by Python.
+SRD_EXTRA_LIBS=
+SR_SEARCH_LIBS([SRD_EXTRA_LIBS], [pow], [m])
+
+AC_SYS_LARGEFILE
+
+AC_C_BIGENDIAN
+
+#########################
+## Optional features. ##
+#########################
+
+# Enable IRMP support by default. Accept user overrides.
+AC_ARG_ENABLE([irmp],
+ [AS_HELP_STRING([--enable-irmp], [enable IRMP shared object [default=yes]])],
+ [], [enable_irmp_so=yes])
+AM_CONDITIONAL([WITH_IRMP], [test "x$enable_irmp_so" = "xyes"])
+test -n "$enable_irmp_so" || enable_irmp_so=no
+
+##############################
+## Finalize configuration ##
+##############################
+
+AC_SUBST([SRD_PKGLIBS])
+
+# Retrieve the compile and link flags for all modules combined.
+# Also, bail out at this point if any module dependency is not met.
+PKG_CHECK_MODULES([LIBSIGROKDECODE], [glib-2.0 >= 2.34 $SRD_PKGLIBS])
+PKG_CHECK_MODULES([TESTS], [$SRD_PKGLIBS_TESTS glib-2.0 $SRD_PKGLIBS])
+
+srd_glib_version=`$PKG_CONFIG --modversion glib-2.0 2>&AS_MESSAGE_LOG_FD`
+
+AC_DEFINE_UNQUOTED([CONF_HOST], ["$host"],
+ [The canonical host libsigrokdecode will run on.])
+
+AC_CONFIG_FILES([Makefile libsigrokdecode.pc])
+
+AC_OUTPUT