Makefile.am: Use BUILT_SOURCES for GENERATED headers (#4068)

The previous fix when using _DEPENDENCIES was wrong because that
dependency is only created for the final executable. However, the build
fails when building the object file. The manual explicitly mentions that
using _DEPENDENCIES is wrong for source files:
> In rare cases you may need to add other kinds of files such as linker
> scripts, but listing a source file in _DEPENDENCIES is wrong. If some
> source file needs to be built before all the components of a program
> are built, consider using the BUILT_SOURCES variable instead (see
> Sources).
https://www.gnu.org/software/automake/manual/automake.html#Linking

Instead, using BUILT_SOURCES works, as mentioned in the manual.
https://www.gnu.org/software/automake/manual/automake.html#Sources

I have also removed the dependencies from i3_SOURCES since AFAIK
dependencies to header files don't do anything. I have verified that
modifying the header correctly re-triggers the build for i3 &
i3-config-wizard.
> Header files listed in a _SOURCES definition will be included in the
> distribution but otherwise ignored. In case it isn’t obvious, you
> should not include the header file generated by configure in a
> _SOURCES variable; this file should not be distributed. Lex (.l) and
> Yacc (.y) files can also be listed; see Yacc and Lex.
https://www.gnu.org/software/automake/manual/automake.html#Program-Sources

An alternative instead of BUILT_SOURCES that should also work in our
case is found in this section:
https://www.gnu.org/software/automake/manual/automake.html#Built-Sources-Example
see "Recording Dependencies manually". The syntax would be:
    foo.$(OBJEXT): $(config_parser_SOURCES) $(command_parser_SOURCES)
The benefit of this over BUILT_SOURCES is that it will work for targets
other than 'all', 'check' and 'install'. However, since we don't really
have such targets we don't need to do this right now.

Tested extensively using this script:
    #!/bin/bash
    set -x

    autoreconf -fi
    while mkdir build && cd build && ../configure && make -j; do
        cd ..
        rm -rf build
    done

Fixes #3670
This commit is contained in:
Orestis Floros 2020-05-05 18:13:19 +02:00 committed by GitHub
parent 666906b517
commit 6a37114af1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -442,7 +442,6 @@ i3_config_wizard_i3_config_wizard_SOURCES = \
i3-config-wizard/xcb.h
i3_config_wizard_i3_config_wizard_DEPENDENCIES = \
$(config_parser_SOURCES) \
$(top_builddir)/libi3.a
test_inject_randr15_CPPFLAGS = \
@ -496,9 +495,9 @@ config_parser_SOURCES = \
parser/GENERATED_config_tokens.h \
parser/GENERATED_config_call.h
BUILT_SOURCES = $(command_parser_SOURCES) $(config_parser_SOURCES)
i3_SOURCES = \
$(command_parser_SOURCES) \
$(config_parser_SOURCES) \
include/all.h \
include/assignments.h \
include/atoms_NET_SUPPORTED.xmacro \

View File

@ -32,3 +32,4 @@ strongly encouraged to upgrade.
• do not focus floating windows changing workspace with ConfigureNotify
• i3-dmenu-desktop: Support symlinks in search path
• build: correctly provide auxiliary functions when needed
• build: fix issues with parallel build