Re: [PATCH] sim/bfin: include config/pkg.m4 in configure.ac (was: Patch "Run `autoreconf -vf` throughout" broke the rtems-bfin build on FreeBSD)

Andrew Burgess <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
* Simon Marchi <[email protected]> [2020-08-20 10:04:33 -0400]:

> On 2020-08-20 9:45 a.m., Simon Marchi wrote:
> > On 2020-08-20 9:43 a.m., Andreas Schwab wrote:
> >> That's because aclocal cannot find a definition of PKG_CHECK_MODULES.
> >> You need to run autoreconf with -I ../../config.
> > 
> > Indeed, that's what I found in the end.  Though I'll propose a patch that
> > adds the required include to configure.ac.
> 
> Here's the patch:
> 
> From 45dce782e0a999efb892588885fc4c7f7e2e0868 Mon Sep 17 00:00:00 2001
> From: Simon Marchi <[email protected]>
> Date: Thu, 20 Aug 2020 09:31:49 -0400
> Subject: [PATCH] sim/bfin: include config/pkg.m4 in configure.ac
> 
> When trying to re-generate configure in sim/bfin, I get:
> 
>     $ autoreconf -vf
>     autoreconf: Entering directory `.'
>     autoreconf: configure.ac: not using Gettext
>     autoreconf: running: aclocal --force
>     autoreconf: configure.ac: tracing
>     autoreconf: configure.ac: not running libtoolize: --install not given
>     autoreconf: running: /opt/autostuff/bin/autoconf --force
>     configure.ac:57: error: possibly undefined macro: AC_CHECK_LIB
>           If this token and others are legitimate, please use m4_pattern_allow.
>           See the Autoconf documentation.
>     autoreconf: /opt/autostuff/bin/autoconf failed with exit status: 1
> 
> This happens since commit f693213d126a ("Run `autoreconf -vf` throughout").
> 
> The problem (not clear from the error message) is that the
> PKG_CHECK_MODULES macro used in configure.ac is undefined.  In the past, I
> suppose that it relied on the person running autoconf having pkg.m4 (from
> pkg-config) in their include path.  That's not my case.
> 
> Since we recently added a local version of PKG_CHECK_MODULES to our tree,
> we can just make sim/bfin/configure.ac use it.  This patch makes
> configure.ac include config/pkg.m4, and re-generates configure.  With this,
> the configure script appears to be generated correctly, I am able to
> configure and build the bfin simulator.
> 
> Note: using sinclude to include the required m4 files makes no sense to
> me.  These files contain macros we need, if they are not defined then
> the resulting file is unusable.  And sinclude fails silently if the file
> is not found.  So, better use include/m4_include.
> 
> sim/bfin/ChangeLog:
> 
> 	* configure.ac: Include config/pkg.m4.
> 
> Change-Id: I7d8012e5ed510cd7746b94e918f0feb1c701cd83
> ---
>  sim/bfin/configure    | 305 ++++++++++++++++++++++++++++++++++++++++--
>  sim/bfin/configure.ac |   1 +
>  2 files changed, 298 insertions(+), 8 deletions(-)

I'm no autoconf expert, but it looks reasonable to me.

Thanks,
Andrew


> 
> diff --git a/sim/bfin/configure b/sim/bfin/configure
> index d3aed28eaca2..9f0b46e11110 100755
> --- a/sim/bfin/configure
> +++ b/sim/bfin/configure
> @@ -634,6 +634,9 @@ LIBOBJS
>  cgen_breaks
>  SDL_LIBS
>  SDL_CFLAGS
> +PKG_CONFIG_LIBDIR
> +PKG_CONFIG_PATH
> +PKG_CONFIG
>  REPORT_BUGS_TEXI
>  REPORT_BUGS_TO
>  PKGVERSION
> @@ -797,7 +800,12 @@ CFLAGS
>  LDFLAGS
>  LIBS
>  CPPFLAGS
> -CPP'
> +CPP
> +PKG_CONFIG
> +PKG_CONFIG_PATH
> +PKG_CONFIG_LIBDIR
> +SDL_CFLAGS
> +SDL_LIBS'
> 
> 
>  # Initialize some variables set by options.
> @@ -1471,6 +1479,13 @@ Some influential environment variables:
>    CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
>                you have headers in a nonstandard directory <include dir>
>    CPP         C preprocessor
> +  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
> +  SDL_CFLAGS  C compiler flags for SDL, overriding pkg-config
> +  SDL_LIBS    linker flags for SDL, overriding pkg-config
> 
>  Use these variables to override the choices made by `configure' or to help
>  it to find libraries and programs with nonstandard names/locations.
> @@ -4171,6 +4186,26 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
> 
> 
> 
> +
> +
> +
> +
> +# pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
> +# serial 12 (pkg-config-0.29.2)
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> 
> 
> 
> @@ -12887,7 +12922,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 12890 "configure"
> +#line 12925 "configure"
>  #include "confdefs.h"
> 
>  #if HAVE_DLFCN_H
> @@ -12993,7 +13028,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 12996 "configure"
> +#line 13031 "configure"
>  #include "confdefs.h"
> 
>  #if HAVE_DLFCN_H
> @@ -13926,13 +13961,267 @@ fi
>  done
> 
> 
> -PKG_PROG_PKG_CONFIG
> -PKG_CHECK_MODULES(SDL, sdl,
> -	AC_CHECK_LIB(dl, dlopen, [
> +
> +
> +
> +
> +
> +
> +
> +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
> +
> +pkg_failed=no
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sdl" >&5
> +$as_echo_n "checking for sdl... " >&6; }
> +
> +if test -n "$SDL_CFLAGS"; then
> +    pkg_cv_SDL_CFLAGS="$SDL_CFLAGS"
> + elif test -n "$PKG_CONFIG"; then
> +    if test -n "$PKG_CONFIG" && \
> +    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl\""; } >&5
> +  ($PKG_CONFIG --exists --print-errors "sdl") 2>&5
> +  ac_status=$?
> +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
> +  test $ac_status = 0; }; then
> +  pkg_cv_SDL_CFLAGS=`$PKG_CONFIG --cflags "sdl" 2>/dev/null`
> +		      test "x$?" != "x0" && pkg_failed=yes
> +else
> +  pkg_failed=yes
> +fi
> + else
> +    pkg_failed=untried
> +fi
> +if test -n "$SDL_LIBS"; then
> +    pkg_cv_SDL_LIBS="$SDL_LIBS"
> + elif test -n "$PKG_CONFIG"; then
> +    if test -n "$PKG_CONFIG" && \
> +    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl\""; } >&5
> +  ($PKG_CONFIG --exists --print-errors "sdl") 2>&5
> +  ac_status=$?
> +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
> +  test $ac_status = 0; }; then
> +  pkg_cv_SDL_LIBS=`$PKG_CONFIG --libs "sdl" 2>/dev/null`
> +		      test "x$?" != "x0" && pkg_failed=yes
> +else
> +  pkg_failed=yes
> +fi
> + else
> +    pkg_failed=untried
> +fi
> +
> +if test $pkg_failed = no; then
> +  pkg_save_LDFLAGS="$LDFLAGS"
> +  LDFLAGS="$LDFLAGS $pkg_cv_SDL_LIBS"
> +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +
> +int
> +main ()
> +{
> +
> +  ;
> +  return 0;
> +}
> +_ACEOF
> +if ac_fn_c_try_link "$LINENO"; then :
> +
> +else
> +  pkg_failed=yes
> +fi
> +rm -f core conftest.err conftest.$ac_objext \
> +    conftest$ac_exeext conftest.$ac_ext
> +  LDFLAGS=$pkg_save_LDFLAGS
> +fi
> +
> +
> +
> +if test $pkg_failed = yes; then
> +        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +
> +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
> +        _pkg_short_errors_supported=yes
> +else
> +        _pkg_short_errors_supported=no
> +fi
> +        if test $_pkg_short_errors_supported = yes; then
> +	        SDL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "sdl" 2>&1`
> +        else
> +	        SDL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "sdl" 2>&1`
> +        fi
> +	# Put the nasty error message in config.log where it belongs
> +	echo "$SDL_PKG_ERRORS" >&5
> +
> +	:
> +elif test $pkg_failed = untried; then
> +        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +	:
> +else
> +	SDL_CFLAGS=$pkg_cv_SDL_CFLAGS
> +	SDL_LIBS=$pkg_cv_SDL_LIBS
> +        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
> +$as_echo "yes" >&6; }
> +
> +	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
> +$as_echo_n "checking for dlopen in -ldl... " >&6; }
> +if ${ac_cv_lib_dl_dlopen+:} false; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  ac_check_lib_save_LIBS=$LIBS
> +LIBS="-ldl  $LIBS"
> +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +
> +/* Override any GCC internal prototype to avoid an error.
> +   Use char because int might match the return type of a GCC
> +   builtin and then its argument prototype would still apply.  */
> +#ifdef __cplusplus
> +extern "C"
> +#endif
> +char dlopen ();
> +int
> +main ()
> +{
> +return dlopen ();
> +  ;
> +  return 0;
> +}
> +_ACEOF
> +if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_lib_dl_dlopen=yes
> +else
> +  ac_cv_lib_dl_dlopen=no
> +fi
> +rm -f core conftest.err conftest.$ac_objext \
> +    conftest$ac_exeext conftest.$ac_ext
> +LIBS=$ac_check_lib_save_LIBS
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
> +$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
> +if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
> +
>  		SDL_CFLAGS="${SDL_CFLAGS} -DHAVE_SDL"
>  		SDL_LIBS="-ldl"
> -		], [SDL_CFLAGS= SDL_LIBS=])
> -	, :)
> +
> +else
> +  SDL_CFLAGS= SDL_LIBS=
> +fi
> +
> +
> +fi
> 
> 
> 
> diff --git a/sim/bfin/configure.ac b/sim/bfin/configure.ac
> index 44b9952c75b8..47bacb1c0d2e 100644
> --- a/sim/bfin/configure.ac
> +++ b/sim/bfin/configure.ac
> @@ -1,6 +1,7 @@
>  dnl Process this file with autoconf to produce a configure script.
>  AC_INIT(Makefile.in)
>  sinclude(../common/acinclude.m4)
> +m4_include([../../config/pkg.m4])
> 
>  SIM_AC_COMMON
> 
> -- 
> 2.28.0
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.