From fc9b62281931da8d20f85d5ed44cfc24f068d3f4 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Thu, 11 Nov 2021 00:02:19 +0200 Subject: [PATCH] bpo-45723: Add --with-pkg-config to configure (GH-29517) Co-authored-by: Erlend Egeberg Aasland --- Doc/using/configure.rst | 11 + .../2021-11-10-16-13-02.bpo-45723.B5gCB1.rst | 2 + configure | 300 ++++++++++-------- configure.ac | 32 +- 4 files changed, 210 insertions(+), 135 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2021-11-10-16-13-02.bpo-45723.B5gCB1.rst diff --git a/Doc/using/configure.rst b/Doc/using/configure.rst index 75f572c61877fe..f00766dfc4f76f 100644 --- a/Doc/using/configure.rst +++ b/Doc/using/configure.rst @@ -116,6 +116,17 @@ General Options .. versionadded:: 3.10 +.. cmdoption:: --with-pkg-config=[check|yes|no] + + Whether configure should use :program:`pkg-config` to detect build + dependencies. + + * ``check`` (default): :program:`pkg-config` is optional + * ``yes``: :program:`pkg-config` is mandatory + * ``no``: configure does not use :program:`pkg-config` even when present + + .. versionadded:: 3.11 + Install Options --------------- diff --git a/Misc/NEWS.d/next/Build/2021-11-10-16-13-02.bpo-45723.B5gCB1.rst b/Misc/NEWS.d/next/Build/2021-11-10-16-13-02.bpo-45723.B5gCB1.rst new file mode 100644 index 00000000000000..49636183c2c68d --- /dev/null +++ b/Misc/NEWS.d/next/Build/2021-11-10-16-13-02.bpo-45723.B5gCB1.rst @@ -0,0 +1,2 @@ +:program:`configure` has a new option ``--with-pkg-config`` to disable or +require pkg-config. diff --git a/configure b/configure index 2a89703d294751..3c5a5dabb07924 100755 --- a/configure +++ b/configure @@ -661,9 +661,6 @@ DTRACE TCLTK_LIBS TCLTK_INCLUDES LIBFFI_INCLUDEDIR -PKG_CONFIG_LIBDIR -PKG_CONFIG_PATH -PKG_CONFIG TZPATH SHLIBS CFLAGSFORSHARED @@ -756,6 +753,9 @@ LIPO_INTEL64_FLAGS LIPO_32BIT_FLAGS ARCH_RUN_32BIT UNIVERSALSDK +PKG_CONFIG_LIBDIR +PKG_CONFIG_PATH +PKG_CONFIG CONFIG_ARGS SOVERSION VERSION @@ -816,6 +816,7 @@ SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking +with_pkg_config enable_universalsdk with_universal_archs with_framework_name @@ -869,6 +870,9 @@ enable_test_modules ac_precious_vars='build_alias host_alias target_alias +PKG_CONFIG +PKG_CONFIG_PATH +PKG_CONFIG_LIBDIR MACHDEP CC CFLAGS @@ -876,10 +880,7 @@ LDFLAGS LIBS CPPFLAGS CPP -PROFILE_TASK -PKG_CONFIG -PKG_CONFIG_PATH -PKG_CONFIG_LIBDIR' +PROFILE_TASK' # Initialize some variables set by options. @@ -1532,6 +1533,8 @@ Optional Features: Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-pkg-config use pkg-config to detect build options (default is + check) --with-universal-archs=ARCH specify the kind of macOS universal binary that should be created. This option is only valid when @@ -1634,6 +1637,11 @@ Optional Packages: install python.o (default is yes) Some influential environment variables: + PKG_CONFIG path to pkg-config utility + PKG_CONFIG_PATH + directories to add to pkg-config's search path + PKG_CONFIG_LIBDIR + path overriding pkg-config's built-in search path MACHDEP name for machine-dependent library files CC C compiler command CFLAGS C compiler flags @@ -1645,11 +1653,6 @@ Some influential environment variables: CPP C preprocessor PROFILE_TASK Python args for PGO generation task - PKG_CONFIG path to pkg-config utility - PKG_CONFIG_PATH - directories to add to pkg-config's search path - PKG_CONFIG_LIBDIR - path overriding pkg-config's built-in search path Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -3079,6 +3082,158 @@ define_xopen_source=yes CONFIG_ARGS="$ac_configure_args" + +# Check whether --with-pkg-config was given. +if test "${with_pkg_config+set}" = set; then : + withval=$with_pkg_config; +else + with_pkg_config=check + +fi + +case $with_pkg_config in #( + yes|check) : + + if test -z "$PKG_CONFIG"; then + { PKG_CONFIG=; unset PKG_CONFIG;} + { ac_cv_path_ac_pt_PKG_CONFIG=; unset ac_cv_path_ac_pt_PKG_CONFIG;} + { ac_cv_prog_ac_ct_PKG_CONFIG=; unset ac_cv_prog_ac_ct_PKG_CONFIG;} + fi + + + + + + + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. +set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +PKG_CONFIG=$ac_cv_path_PKG_CONFIG +if test -n "$PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 +$as_echo "$PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_path_PKG_CONFIG"; then + ac_pt_PKG_CONFIG=$PKG_CONFIG + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $ac_pt_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG +if test -n "$ac_pt_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 +$as_echo "$ac_pt_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_pt_PKG_CONFIG" = x; then + PKG_CONFIG="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + PKG_CONFIG=$ac_pt_PKG_CONFIG + fi +else + PKG_CONFIG="$ac_cv_path_PKG_CONFIG" +fi + +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=0.9.0 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 +$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG="" + fi +fi + ;; #( + no) : + + PKG_CONFIG='' + ac_cv_path_ac_pt_PKG_CONFIG='' + ac_cv_prog_ac_ct_PKG_CONFIG='' + ;; #( + *) : + as_fn_error $? "invalid argument --with-pkg-config=$with_pkg_config" "$LINENO" 5 + ;; +esac +if test "$with_pkg_config" = yes -a -z "$PKG_CONFIG"; then + as_fn_error $? "pkg-config is required" "$LINENO" 5] +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --enable-universalsdk" >&5 $as_echo_n "checking for --enable-universalsdk... " >&6; } # Check whether --enable-universalsdk was given. @@ -10541,127 +10696,6 @@ $as_echo "no" >&6; } fi - - - - - - - -if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. -set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_PKG_CONFIG+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -PKG_CONFIG=$ac_cv_path_PKG_CONFIG -if test -n "$PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 -$as_echo "$PKG_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_path_PKG_CONFIG"; then - ac_pt_PKG_CONFIG=$PKG_CONFIG - # Extract the first word of "pkg-config", so it can be a program name with args. -set dummy pkg-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $ac_pt_PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG -if test -n "$ac_pt_PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 -$as_echo "$ac_pt_PKG_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_pt_PKG_CONFIG" = x; then - PKG_CONFIG="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - PKG_CONFIG=$ac_pt_PKG_CONFIG - fi -else - PKG_CONFIG="$ac_cv_path_PKG_CONFIG" -fi - -fi -if test -n "$PKG_CONFIG"; then - _pkg_min_version=0.9.0 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 -$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } - if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - PKG_CONFIG="" - fi -fi - # Check for use of the system expat library { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-system-expat" >&5 $as_echo_n "checking for --with-system-expat... " >&6; } diff --git a/configure.ac b/configure.ac index 4817422178df75..898c2ba632015b 100644 --- a/configure.ac +++ b/configure.ac @@ -155,6 +155,36 @@ define_xopen_source=yes AC_SUBST(CONFIG_ARGS) CONFIG_ARGS="$ac_configure_args" +dnl Allow users to disable pkg-config or require pkg-config +AC_ARG_WITH( + [pkg-config], + [AS_HELP_STRING([[--with-pkg-config=[yes|no|check]]], + [use pkg-config to detect build options (default is check)])], + [], + [with_pkg_config=check] +) +AS_CASE([$with_pkg_config], + [yes|check], [ + if test -z "$PKG_CONFIG"; then + dnl invalidate stale config.cache values + AS_UNSET([PKG_CONFIG]) + AS_UNSET([ac_cv_path_ac_pt_PKG_CONFIG]) + AS_UNSET([ac_cv_prog_ac_ct_PKG_CONFIG]) + fi + PKG_PROG_PKG_CONFIG + ], + [no], [ + PKG_CONFIG='' + dnl force AX_CHECK_OPENSSL to ignore pkg-config + ac_cv_path_ac_pt_PKG_CONFIG='' + ac_cv_prog_ac_ct_PKG_CONFIG='' + ], + [AC_MSG_ERROR([invalid argument --with-pkg-config=$with_pkg_config])] +) +if test "$with_pkg_config" = yes -a -z "$PKG_CONFIG"; then + AC_MSG_ERROR([pkg-config is required])] +fi + AC_MSG_CHECKING([for --enable-universalsdk]) AC_ARG_ENABLE(universalsdk, AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], @@ -2978,8 +3008,6 @@ LIBS="$withval $LIBS" ], [AC_MSG_RESULT(no)]) -PKG_PROG_PKG_CONFIG - # Check for use of the system expat library AC_MSG_CHECKING(for --with-system-expat) AC_ARG_WITH(system_expat,