Skip to content

Commit fc9b622

Browse files
tiranErlend Egeberg Aasland
and
Erlend Egeberg Aasland
authored
bpo-45723: Add --with-pkg-config to configure (GH-29517)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
1 parent 0a9f695 commit fc9b622

File tree

4 files changed

+210
-135
lines changed

4 files changed

+210
-135
lines changed

Doc/using/configure.rst

+11
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,17 @@ General Options
116116

117117
.. versionadded:: 3.10
118118

119+
.. cmdoption:: --with-pkg-config=[check|yes|no]
120+
121+
Whether configure should use :program:`pkg-config` to detect build
122+
dependencies.
123+
124+
* ``check`` (default): :program:`pkg-config` is optional
125+
* ``yes``: :program:`pkg-config` is mandatory
126+
* ``no``: configure does not use :program:`pkg-config` even when present
127+
128+
.. versionadded:: 3.11
129+
119130

120131
Install Options
121132
---------------
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:program:`configure` has a new option ``--with-pkg-config`` to disable or
2+
require pkg-config.

configure

+167-133
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,6 @@ DTRACE
661661
TCLTK_LIBS
662662
TCLTK_INCLUDES
663663
LIBFFI_INCLUDEDIR
664-
PKG_CONFIG_LIBDIR
665-
PKG_CONFIG_PATH
666-
PKG_CONFIG
667664
TZPATH
668665
SHLIBS
669666
CFLAGSFORSHARED
@@ -756,6 +753,9 @@ LIPO_INTEL64_FLAGS
756753
LIPO_32BIT_FLAGS
757754
ARCH_RUN_32BIT
758755
UNIVERSALSDK
756+
PKG_CONFIG_LIBDIR
757+
PKG_CONFIG_PATH
758+
PKG_CONFIG
759759
CONFIG_ARGS
760760
SOVERSION
761761
VERSION
@@ -816,6 +816,7 @@ SHELL'
816816
ac_subst_files=''
817817
ac_user_opts='
818818
enable_option_checking
819+
with_pkg_config
819820
enable_universalsdk
820821
with_universal_archs
821822
with_framework_name
@@ -869,17 +870,17 @@ enable_test_modules
869870
ac_precious_vars='build_alias
870871
host_alias
871872
target_alias
873+
PKG_CONFIG
874+
PKG_CONFIG_PATH
875+
PKG_CONFIG_LIBDIR
872876
MACHDEP
873877
CC
874878
CFLAGS
875879
LDFLAGS
876880
LIBS
877881
CPPFLAGS
878882
CPP
879-
PROFILE_TASK
880-
PKG_CONFIG
881-
PKG_CONFIG_PATH
882-
PKG_CONFIG_LIBDIR'
883+
PROFILE_TASK'
883884

884885

885886
# Initialize some variables set by options.
@@ -1532,6 +1533,8 @@ Optional Features:
15321533
Optional Packages:
15331534
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
15341535
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
1536+
--with-pkg-config use pkg-config to detect build options (default is
1537+
check)
15351538
--with-universal-archs=ARCH
15361539
specify the kind of macOS universal binary that
15371540
should be created. This option is only valid when
@@ -1634,6 +1637,11 @@ Optional Packages:
16341637
install python.o (default is yes)
16351638

16361639
Some influential environment variables:
1640+
PKG_CONFIG path to pkg-config utility
1641+
PKG_CONFIG_PATH
1642+
directories to add to pkg-config's search path
1643+
PKG_CONFIG_LIBDIR
1644+
path overriding pkg-config's built-in search path
16371645
MACHDEP name for machine-dependent library files
16381646
CC C compiler command
16391647
CFLAGS C compiler flags
@@ -1645,11 +1653,6 @@ Some influential environment variables:
16451653
CPP C preprocessor
16461654
PROFILE_TASK
16471655
Python args for PGO generation task
1648-
PKG_CONFIG path to pkg-config utility
1649-
PKG_CONFIG_PATH
1650-
directories to add to pkg-config's search path
1651-
PKG_CONFIG_LIBDIR
1652-
path overriding pkg-config's built-in search path
16531656

16541657
Use these variables to override the choices made by `configure' or to help
16551658
it to find libraries and programs with nonstandard names/locations.
@@ -3079,6 +3082,158 @@ define_xopen_source=yes
30793082

30803083
CONFIG_ARGS="$ac_configure_args"
30813084

3085+
3086+
# Check whether --with-pkg-config was given.
3087+
if test "${with_pkg_config+set}" = set; then :
3088+
withval=$with_pkg_config;
3089+
else
3090+
with_pkg_config=check
3091+
3092+
fi
3093+
3094+
case $with_pkg_config in #(
3095+
yes|check) :
3096+
3097+
if test -z "$PKG_CONFIG"; then
3098+
{ PKG_CONFIG=; unset PKG_CONFIG;}
3099+
{ ac_cv_path_ac_pt_PKG_CONFIG=; unset ac_cv_path_ac_pt_PKG_CONFIG;}
3100+
{ ac_cv_prog_ac_ct_PKG_CONFIG=; unset ac_cv_prog_ac_ct_PKG_CONFIG;}
3101+
fi
3102+
3103+
3104+
3105+
3106+
3107+
3108+
3109+
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
3110+
if test -n "$ac_tool_prefix"; then
3111+
# Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
3112+
set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
3113+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
3114+
$as_echo_n "checking for $ac_word... " >&6; }
3115+
if ${ac_cv_path_PKG_CONFIG+:} false; then :
3116+
$as_echo_n "(cached) " >&6
3117+
else
3118+
case $PKG_CONFIG in
3119+
[\\/]* | ?:[\\/]*)
3120+
ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
3121+
;;
3122+
*)
3123+
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3124+
for as_dir in $PATH
3125+
do
3126+
IFS=$as_save_IFS
3127+
test -z "$as_dir" && as_dir=.
3128+
for ac_exec_ext in '' $ac_executable_extensions; do
3129+
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
3130+
ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
3131+
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
3132+
break 2
3133+
fi
3134+
done
3135+
done
3136+
IFS=$as_save_IFS
3137+
3138+
;;
3139+
esac
3140+
fi
3141+
PKG_CONFIG=$ac_cv_path_PKG_CONFIG
3142+
if test -n "$PKG_CONFIG"; then
3143+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
3144+
$as_echo "$PKG_CONFIG" >&6; }
3145+
else
3146+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
3147+
$as_echo "no" >&6; }
3148+
fi
3149+
3150+
3151+
fi
3152+
if test -z "$ac_cv_path_PKG_CONFIG"; then
3153+
ac_pt_PKG_CONFIG=$PKG_CONFIG
3154+
# Extract the first word of "pkg-config", so it can be a program name with args.
3155+
set dummy pkg-config; ac_word=$2
3156+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
3157+
$as_echo_n "checking for $ac_word... " >&6; }
3158+
if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
3159+
$as_echo_n "(cached) " >&6
3160+
else
3161+
case $ac_pt_PKG_CONFIG in
3162+
[\\/]* | ?:[\\/]*)
3163+
ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
3164+
;;
3165+
*)
3166+
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3167+
for as_dir in $PATH
3168+
do
3169+
IFS=$as_save_IFS
3170+
test -z "$as_dir" && as_dir=.
3171+
for ac_exec_ext in '' $ac_executable_extensions; do
3172+
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
3173+
ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
3174+
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
3175+
break 2
3176+
fi
3177+
done
3178+
done
3179+
IFS=$as_save_IFS
3180+
3181+
;;
3182+
esac
3183+
fi
3184+
ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
3185+
if test -n "$ac_pt_PKG_CONFIG"; then
3186+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
3187+
$as_echo "$ac_pt_PKG_CONFIG" >&6; }
3188+
else
3189+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
3190+
$as_echo "no" >&6; }
3191+
fi
3192+
3193+
if test "x$ac_pt_PKG_CONFIG" = x; then
3194+
PKG_CONFIG=""
3195+
else
3196+
case $cross_compiling:$ac_tool_warned in
3197+
yes:)
3198+
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
3199+
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
3200+
ac_tool_warned=yes ;;
3201+
esac
3202+
PKG_CONFIG=$ac_pt_PKG_CONFIG
3203+
fi
3204+
else
3205+
PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
3206+
fi
3207+
3208+
fi
3209+
if test -n "$PKG_CONFIG"; then
3210+
_pkg_min_version=0.9.0
3211+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
3212+
$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
3213+
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
3214+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
3215+
$as_echo "yes" >&6; }
3216+
else
3217+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
3218+
$as_echo "no" >&6; }
3219+
PKG_CONFIG=""
3220+
fi
3221+
fi
3222+
;; #(
3223+
no) :
3224+
3225+
PKG_CONFIG=''
3226+
ac_cv_path_ac_pt_PKG_CONFIG=''
3227+
ac_cv_prog_ac_ct_PKG_CONFIG=''
3228+
;; #(
3229+
*) :
3230+
as_fn_error $? "invalid argument --with-pkg-config=$with_pkg_config" "$LINENO" 5
3231+
;;
3232+
esac
3233+
if test "$with_pkg_config" = yes -a -z "$PKG_CONFIG"; then
3234+
as_fn_error $? "pkg-config is required" "$LINENO" 5]
3235+
fi
3236+
30823237
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --enable-universalsdk" >&5
30833238
$as_echo_n "checking for --enable-universalsdk... " >&6; }
30843239
# Check whether --enable-universalsdk was given.
@@ -10541,127 +10696,6 @@ $as_echo "no" >&6; }
1054110696
fi
1054210697

1054310698

10544-
10545-
10546-
10547-
10548-
10549-
10550-
10551-
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
10552-
if test -n "$ac_tool_prefix"; then
10553-
# Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
10554-
set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
10555-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
10556-
$as_echo_n "checking for $ac_word... " >&6; }
10557-
if ${ac_cv_path_PKG_CONFIG+:} false; then :
10558-
$as_echo_n "(cached) " >&6
10559-
else
10560-
case $PKG_CONFIG in
10561-
[\\/]* | ?:[\\/]*)
10562-
ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
10563-
;;
10564-
*)
10565-
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
10566-
for as_dir in $PATH
10567-
do
10568-
IFS=$as_save_IFS
10569-
test -z "$as_dir" && as_dir=.
10570-
for ac_exec_ext in '' $ac_executable_extensions; do
10571-
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
10572-
ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
10573-
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
10574-
break 2
10575-
fi
10576-
done
10577-
done
10578-
IFS=$as_save_IFS
10579-
10580-
;;
10581-
esac
10582-
fi
10583-
PKG_CONFIG=$ac_cv_path_PKG_CONFIG
10584-
if test -n "$PKG_CONFIG"; then
10585-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
10586-
$as_echo "$PKG_CONFIG" >&6; }
10587-
else
10588-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10589-
$as_echo "no" >&6; }
10590-
fi
10591-
10592-
10593-
fi
10594-
if test -z "$ac_cv_path_PKG_CONFIG"; then
10595-
ac_pt_PKG_CONFIG=$PKG_CONFIG
10596-
# Extract the first word of "pkg-config", so it can be a program name with args.
10597-
set dummy pkg-config; ac_word=$2
10598-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
10599-
$as_echo_n "checking for $ac_word... " >&6; }
10600-
if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
10601-
$as_echo_n "(cached) " >&6
10602-
else
10603-
case $ac_pt_PKG_CONFIG in
10604-
[\\/]* | ?:[\\/]*)
10605-
ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
10606-
;;
10607-
*)
10608-
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
10609-
for as_dir in $PATH
10610-
do
10611-
IFS=$as_save_IFS
10612-
test -z "$as_dir" && as_dir=.
10613-
for ac_exec_ext in '' $ac_executable_extensions; do
10614-
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
10615-
ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
10616-
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
10617-
break 2
10618-
fi
10619-
done
10620-
done
10621-
IFS=$as_save_IFS
10622-
10623-
;;
10624-
esac
10625-
fi
10626-
ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
10627-
if test -n "$ac_pt_PKG_CONFIG"; then
10628-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
10629-
$as_echo "$ac_pt_PKG_CONFIG" >&6; }
10630-
else
10631-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10632-
$as_echo "no" >&6; }
10633-
fi
10634-
10635-
if test "x$ac_pt_PKG_CONFIG" = x; then
10636-
PKG_CONFIG=""
10637-
else
10638-
case $cross_compiling:$ac_tool_warned in
10639-
yes:)
10640-
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
10641-
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
10642-
ac_tool_warned=yes ;;
10643-
esac
10644-
PKG_CONFIG=$ac_pt_PKG_CONFIG
10645-
fi
10646-
else
10647-
PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
10648-
fi
10649-
10650-
fi
10651-
if test -n "$PKG_CONFIG"; then
10652-
_pkg_min_version=0.9.0
10653-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
10654-
$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
10655-
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
10656-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
10657-
$as_echo "yes" >&6; }
10658-
else
10659-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10660-
$as_echo "no" >&6; }
10661-
PKG_CONFIG=""
10662-
fi
10663-
fi
10664-
1066510699
# Check for use of the system expat library
1066610700
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-system-expat" >&5
1066710701
$as_echo_n "checking for --with-system-expat... " >&6; }

0 commit comments

Comments
 (0)