Search code examples
cygwingnubisonautomake

I cannot build bison on cygwin using bootstrap


I believe that I have all the necessary tools and sources, including the latest sources of bison from its git repository.

When I run ./bootstrap I get the following error:

lib/local.mk:19: error: lib_libbison_a_SOURCES must be set with '=' before using '+='
Makefile.am:60:   'lib/local.mk' included from here
lib/local.mk:19: warning: variable 'lib_libbison_a_SOURCES' is defined but no program or
lib/local.mk:19: library has 'lib_libbison_a' as canonical name (possible typo)
Makefile.am:60:   'lib/local.mk' included from here
autoreconf-2.69: automake failed with exit status: 1
./bootstrap: autoreconf failed

Looking at the sources reveals that lib/local.mk includes lib/gnulib.mk before line 19 (the first line in the error message above). lib/gnulib.mk is a generated file. It has, for example:

libbison_a_SOURCES =
libbison_a_LIBADD = $(gl_LIBOBJS)
libbison_a_DEPENDENCIES = $(gl_LIBOBJS)
EXTRA_libbison_a_SOURCES =

while lib/local.mk has:

lib_libbison_a_SOURCES +=                       \

so, there is an missing "lib_" in the generated file (or an extra "lib_" in the fixed source).

Any idea how to overcome this problem?t


Solution

  • After some diggings I found the problem, actually problems:

    The "bootstrap" script, after calling gnulib/gnulib-tool, issues the following command:

    build-aux/prefix-gnulib-mk --lib-name=libbison lib/gnulib.mk
    

    This fails and results with the following message:

    Unrecognized character \xFF in column 11 at build-aux/prefix-gnulib-mk line 1
    

    It doesn't say "error" and the execution of the bootstrap script doesn't terminate, so it's easy to miss in the vast amount of messages the script spits out.

    The file build-aux/prefix-gnulib-mk is a symbolic link to gnulib/build-aux/prefix-gnulib-mk generated by the bootstrap script. Apparently, executing this symbolic link fails, perhaps because gnulib/build-aux/prefix-gnulib-mk is missing "#! /bin/perl", I don't know. What I do know is that if the symlink is replaced with a copy it works fine.

    The bootstrap script has an option that tells the script to use copies instead of symlinks, one would think that this would work around the problem, but it doesn't. Apparently, the symlink build-aux/prefix-gnulib-mk is generated by gnulib/gnulib-tool. While gnulib/gnulib-tool has a similar command-line option to use copies instead of symlinks, it is not exploited. Instead, "--symlink" is hard coded in the file bootstrap.conf:

    gnulib_tool_option_extras='--symlink --makefile-name=gnulib.mk'
    

    I ended up creating a hard copy of prefix-gnulib-mk before running the bootsrap script. (I think that editing bootstrap.conf and omitting "--symlink" may also work.) and I also used the option of the bootstrap script to use hard copies, namely "--copy", to be on the safe side... from that point on everything went smooth and I got my bison executable on Windows.