bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Gnulib-related problems building Bison from git


From: Bruno Haible
Subject: Re: Gnulib-related problems building Bison from git
Date: Mon, 04 Jul 2022 23:31:46 +0200

Hi Akim,

> Since Bison was moved to use gnulib's support for --automake-subdir, the 
> configuration fails for people who don't have libtextstyle installed.  Or 
> distcheck fails when libtextstyle is not installed in a default include path.
> 
> This is because --automake-subdir is built (apparently) for projects that use 
> a single Makefile for the sources, but another for the tests.  This is not 
> the case of Bison, where we have a single Makefile for the whole project.
> 
> In <https://lists.gnu.org/r/bug-gnulib/2022-01/msg00156.html> I had asked 
> what was the preferred fix.  Below, I chose to add another option, 
> --automake-subdir-test to signal cases such as Bison's.

I'm glad that you got to the root cause and found this fix (because I
never found the time to dig deeply enough into this problem).

>     gnulib-tool: add support for --automake-subdir-test

We call it the "tests" directory (plural), not the "test" directory.
Therefore it would be only consistent to adjust the name of the option
and of the shell variable:
  s/automake-subdir-test/automake-subdir-tests/g
  s/automake_subdir_test/automake_subdir_tests/g

> @@ -311,6 +311,8 @@ Options for --import, --add/remove-import:
>        --automake-subdir     Specify that the makefile in the source-base
>                              directory be generated in such a way that it can
>                              be 'include'd from the toplevel Makefile.am.
> +      --automake-subdir-test
> +                            Likewise, but for the test directory.

s/test/tests/

> @@ -4518,7 +4526,9 @@ func_emit_initmacro_end ()
>    echo "      sed_dirname4='s,\\(.\\)/[^/]*\$,\\1,'"
>    echo "      sed_basename1='s,.*/,,'"
>    echo "changequote([, ])dnl"
> -  if $automake_subdir && ! "$2" && test -n "$sourcebase" && test 
> "$sourcebase" != '.'; then
> +  if (($2 && $automake_subdir_test) || (! $2 && $automake_subdir)) \
> +     && test -n "$sourcebase" \
> +     && test "$sourcebase" != '.'; then
>      subdir="$sourcebase/"
>    else
>      subdir=

Three things are wrong here:
  - If $2, subdir should be set to "$testsbase/", not "$sourcebase/".
  - Parentheses introduce a subshell, which is more expensive to execute
    than a compound shell command. IOW,
      { command1 && command2; } || { command3 && command4; }
    is more efficient than
      (command1 && command2) || (command3 && command4)
  - Some bash versions interpret '((' as the start of an evaluation
    command. To please these shells, you would have to add a space,
    i.e. write   ( (   instead of   ((

So, I think these lines should be changed to

  if $automake_subdir && ! "$2"; then
    if test -n "$sourcebase" && test "$sourcebase" != '.'; then
      subdir="$sourcebase/"
    else
      subdir=
  elif $automake_subdir_tests && "$2"; then
    if test -n "$testsbase" && test "$testsbase" != '.'; then
      subdir="$testsbase/"
    else
      subdir=
  else
    subdir=
  fi

> @@ -4584,12 +4594,15 @@ func_emit_initmacro_done ()
>  #                            false otherwise
>  # - base             base directory, relative to the top-level directory
>  # - automake_subdir  true if --automake-subdir was given, false otherwise
> +# - automake_subdir_test  true if --automake-subdir-test was given, false 
> otherwise
>  func_emit_shellvars_init ()
>  {
>    # Define the base directory, relative to the top-level directory.
>    echo "  gl_source_base='$2'"
>    # Define the prefix for the file name of generated files.
> -  if $automake_subdir && ! $1; then
> +  if $1 && $automake_subdir_test; then
> +    echo "  gl_source_base_prefix='\$(top_build_prefix)$sourcebase/'"

I don't believe that the unconditional reference to $sourcebase is
correct here. Look at the various invocations of func_emit_shellvars_init;
you need to accommodate all different cases.

Bruno






reply via email to

[Prev in Thread] Current Thread [Next in Thread]