poke-devel
[Top][All Lists]
Advanced

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

Re: build from tarball uses bison


From: Jose E. Marchesi
Subject: Re: build from tarball uses bison
Date: Sat, 20 Feb 2021 12:13:51 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi Bruno.

> A build of poke-0.90 uses bison:
>
> bison -d -t --report=state --output pk-map-tab.c \
>           ../../poke/pk-map-tab.y
>
> While the GCS allow this (see
> <https://www.gnu.org/prep/standards/html_node/Utilities-in-Makefiles.html>),
> it is a best practice to avoid bison as a build prerequisite, by packaging
> the generated files in the tarball. See
> <https://www.gnu.org/prep/standards/html_node/Makefile-Basics.html>
>
> The attached patch to poke/Makefile.am fixes this.
>
> The libpoke/ subdirectory has a related problem: It distributes the
> pkl-tab.h and pkl-tab.c files (good!), but erases them during "make clean".
> After "make clean", "make" then needs bison here as well:
>
> bison -d -t --report=state --output pkl-tab.c \
>           ./pkl-tab.y
>
> Also fixed in the patch.

OK for master.
Thanks!

>
>>From 3a3be1a93156bb527b949a41f1fd1f83b00ac38e Mon Sep 17 00:00:00 2001
> From: Bruno Haible <bruno@clisp.org>
> Date: Sat, 20 Feb 2021 00:26:14 +0100
> Subject: [PATCH] Make it possible to build the tarballs without bison.
>
> * poke/Makefile.am (pk-map-tab.c, pk-map-tab.h): Use a rule that writes the
> generated files into the source directory, that works with parallel make, and
> that does not produce broken #line statements.
> * libpoke/Makefile.am (pkl-tab.c, pkl-tab.h): Likewise. Don't erase these 
> files
> during 'make clean'.
> ---
>  libpoke/Makefile.am | 54 ++++++++++++++++++++++++++++++++++++++++-------
>  poke/Makefile.am    | 60 
> +++++++++++++++++++++++++++++++++++++++++++----------
>  2 files changed, 95 insertions(+), 19 deletions(-)
>
> diff --git a/libpoke/Makefile.am b/libpoke/Makefile.am
> index fecf46d..50d1834 100644
> --- a/libpoke/Makefile.am
> +++ b/libpoke/Makefile.am
> @@ -76,17 +76,55 @@ pkl-gen.pkc pkl-asm.pkc: $(srcdir)/ras 
> $(srcdir)/pkl-insn.def
>  MOSTLYCLEANFILES += pkl-gen.pkc.tmp pkl-asm.pkc.tmp
>  
>  # XXX Adding pkl-lex.h shouldn't be necessary?
> -EXTRA_DIST = pkl-tab.y pkl-lex.h ras
> +EXTRA_DIST = pkl-lex.h ras
>  
> -BUILT_SOURCES = pkl-tab.h pkl-tab.c pkl-lex.c \
> +BUILT_SOURCES = pkl-lex.c \
>                  pkl-gen.pkc pkl-asm.pkc
>  
> -pkl-tab.h pkl-tab.c: pkl-tab.y
> -     $(POKE_BISON) -d -t --report=state --output pkl-tab.c \
> -          $(srcdir)/pkl-tab.y
> -
> -AM_YFLAGS =
> -MOSTLYCLEANFILES += pkl-tab.output pkl-tab.h pkl-tab.c
> +AM_YFLAGS = -t --report=state
> +# The Automake generated .y.c rule is broken: When executed in a VPATH build,
> +#   - The .c file gets generated in the build directory. But since it 
> requires
> +#     special tools to rebuild it, we need to distribute it in the tarballs,
> +#     and by the GNU Coding Standards
> +#     <https://www.gnu.org/prep/standards/html_node/Makefile-Basics.html>
> +#     the file should be generated in the source directory.
> +#   - The #line numbers in the .c file refer to a nonexistent file once it
> +#     has been moved from the build directory to the source directory. This
> +#     leads to error if 'lcov' is used later.
> +# Additionally, here we assume GNU Bison and therefore don't need the ylwrap
> +# script.
> +# Therefore we override this rule.
> +# Since this is a rule that produces multiple files, we apply the idiom from
> +# <https://lists.gnu.org/archive/html/bug-make/2020-09/msg00008.html>, so 
> that
> +# it works also in parallel 'make'.
> +generate-pkl-tab:
> +     $(AM_V_YACC)$(POKE_BISON) -d $(YFLAGS) $(AM_YFLAGS) $(srcdir)/pkl-tab.y 
> \
> +     && test ':' = '$(POKE_BISON)' || { \
> +       sed -e 's|".*/pkl-tab\.y"|"pkl-tab.y"|' \
> +           -e 's|"pkl-tab\.tab\.c"|"pkl-tab.c"|' \
> +           -e 's|"pkl-tab\.tab\.h"|"pkl-tab.h"|' \
> +           < pkl-tab.tab.c > pkl-tab.c-tmp \
> +       && sed -e 's|".*/pkl-tab\.y"|"pkl-tab.y"|' \
> +              -e 's|"pkl-tab\.tab\.h"|"pkl-tab.h"|' \
> +              < pkl-tab.tab.h > pkl-tab.h-tmp \
> +       && rm -f pkl-tab.tab.c pkl-tab.tab.h \
> +       && mv pkl-tab.c-tmp $(srcdir)/pkl-tab.c \
> +       && mv pkl-tab.h-tmp $(srcdir)/pkl-tab.h; \
> +     }
> +.PHONY: generate-pkl-tab
> +# The above rule will generate files with time stamp order
> +# pkl-tab.y <= pkl-tab.c <= pkl-tab.h.
> +pkl-tab.c: pkl-tab.y
> +     @{ test -f $(srcdir)/pkl-tab.c && test ! $(srcdir)/pkl-tab.c -ot 
> $(srcdir)/pkl-tab.y; } || $(MAKE) generate-pkl-tab
> +pkl-tab.h: pkl-tab.c
> +     @{ test -f $(srcdir)/pkl-tab.h && test ! $(srcdir)/pkl-tab.h -ot 
> $(srcdir)/pkl-tab.c; } || $(MAKE) generate-pkl-tab
> +BUILT_SOURCES += pkl-tab.c pkl-tab.h
> +MOSTLYCLEANFILES += \
> +  pkl-tab.tab.c pkl-tab.tab.h \
> +  pkl-tab.c-tmp pkl-tab.h-tmp \
> +  pkl-tab.output
> +MAINTAINERCLEANFILES += pkl-tab.c pkl-tab.h
> +EXTRA_DIST += pkl-tab.y pkl-tab.c pkl-tab.h
>  
>  AM_LFLAGS = -d
>  
> diff --git a/poke/Makefile.am b/poke/Makefile.am
> index 6059e88..e7883cb 100644
> --- a/poke/Makefile.am
> +++ b/poke/Makefile.am
> @@ -40,10 +40,6 @@ poke_SOURCES = poke.c poke.h \
>  
>  poke_SOURCES += ../common/pk-utils.c ../common/pk-utils.h
>  
> -pk-map-tab.h pk-map-tab.c: pk-map-tab.y
> -     $(POKE_BISON) -d -t --report=state --output pk-map-tab.c \
> -          $(srcdir)/pk-map-tab.y
> -
>  poke_CPPFLAGS = -I$(top_builddir)/gl -I$(top_srcdir)/gl \
>                  -I$(top_srcdir)/common \
>                  -I$(top_srcdir)/libpoke -I$(top_builddir)/libpoke \
> @@ -58,12 +54,54 @@ poke_LDADD = $(top_builddir)/gl/libgnu.la \
>               $(LTLIBTEXTSTYLE)
>  poke_LDFLAGS =
>  
> -AM_YFLAGS = -d -t --report=state
>  AM_LFLAGS = -d
> -
> -EXTRA_DIST = pk-map-lex.h pk-map-tab.y
> -
> -BUILT_SOURCES = pk-map-tab.h pk-map-tab.c pk-map-lex.c
> +BUILT_SOURCES = pk-map-lex.c
> +EXTRA_DIST = pk-map-lex.h
> +
> +AM_YFLAGS = -t --report=state
> +# The Automake generated .y.c rule is broken: When executed in a VPATH build,
> +#   - The .c file gets generated in the build directory. But since it 
> requires
> +#     special tools to rebuild it, we need to distribute it in the tarballs,
> +#     and by the GNU Coding Standards
> +#     <https://www.gnu.org/prep/standards/html_node/Makefile-Basics.html>
> +#     the file should be generated in the source directory.
> +#   - The #line numbers in the .c file refer to a nonexistent file once it
> +#     has been moved from the build directory to the source directory. This
> +#     leads to error if 'lcov' is used later.
> +# Additionally, here we assume GNU Bison and therefore don't need the ylwrap
> +# script.
> +# Therefore we override this rule.
> +# Since this is a rule that produces multiple files, we apply the idiom from
> +# <https://lists.gnu.org/archive/html/bug-make/2020-09/msg00008.html>, so 
> that
> +# it works also in parallel 'make'.
> +generate-pk-map-tab:
> +     $(AM_V_YACC)$(POKE_BISON) -d $(YFLAGS) $(AM_YFLAGS) 
> $(srcdir)/pk-map-tab.y \
> +     && test ':' = '$(POKE_BISON)' || { \
> +       sed -e 's|".*/pk-map-tab\.y"|"pk-map-tab.y"|' \
> +           -e 's|"pk-map-tab\.tab\.c"|"pk-map-tab.c"|' \
> +           -e 's|"pk-map-tab\.tab\.h"|"pk-map-tab.h"|' \
> +           < pk-map-tab.tab.c > pk-map-tab.c-tmp \
> +       && sed -e 's|".*/pk-map-tab\.y"|"pk-map-tab.y"|' \
> +              -e 's|"pk-map-tab\.tab\.h"|"pk-map-tab.h"|' \
> +              < pk-map-tab.tab.h > pk-map-tab.h-tmp \
> +       && rm -f pk-map-tab.tab.c pk-map-tab.tab.h \
> +       && mv pk-map-tab.c-tmp $(srcdir)/pk-map-tab.c \
> +       && mv pk-map-tab.h-tmp $(srcdir)/pk-map-tab.h; \
> +     }
> +.PHONY: generate-pk-map-tab
> +# The above rule will generate files with time stamp order
> +# pk-map-tab.y <= pk-map-tab.c <= pk-map-tab.h.
> +pk-map-tab.c: pk-map-tab.y
> +     @{ test -f $(srcdir)/pk-map-tab.c && test ! $(srcdir)/pk-map-tab.c -ot 
> $(srcdir)/pk-map-tab.y; } || $(MAKE) generate-pk-map-tab
> +pk-map-tab.h: pk-map-tab.c
> +     @{ test -f $(srcdir)/pk-map-tab.h && test ! $(srcdir)/pk-map-tab.h -ot 
> $(srcdir)/pk-map-tab.c; } || $(MAKE) generate-pk-map-tab
> +BUILT_SOURCES += pk-map-tab.c pk-map-tab.h
> +MOSTLYCLEANFILES += \
> +  pk-map-tab.tab.c pk-map-tab.tab.h \
> +  pk-map-tab.c-tmp pk-map-tab.h-tmp \
> +  pk-map-tab.output
> +MAINTAINERCLEANFILES += pk-map-tab.c pk-map-tab.h
> +EXTRA_DIST += pk-map-tab.y pk-map-tab.c pk-map-tab.h
>  
>  # Machine interface
>  if POKE_MI
> @@ -80,7 +118,7 @@ if HSERVER
>    dist_pkgdata_DATA += pk-hserver.pk
>  endif
>  
> -# nodelist is reated by doc/Makefile.am.
> -MOSTLYCLEANFILES += nodelist pk-map-tab.h pk-map-tab.c pk-map-tab.output
> +# nodelist is now treated by doc/Makefile.am.
> +MOSTLYCLEANFILES += nodelist
>  
>  # End of Makefile.am



reply via email to

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