]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Fix build failure with bison 3.7. Revisit bison Makefile rules.
authorBruno Haible <bruno@clisp.org>
Sat, 1 Aug 2020 15:25:10 +0000 (17:25 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 11 Sep 2022 10:02:33 +0000 (12:02 +0200)
* gettext-runtime/intl/Makefile.am ($(srcdir)/plural.c): Keep and distribute the
plural.h file. Don't use --output option.
* gettext-tools/src/Makefile.am (YACC): Removed unused variable.
(po-gram-gen.c, po-gram-gen.h): Correct the #line statements in the generated
files.
(po-gram-gen2.h): Likewise.
(cldr-plural.c, cldr-plural.h): Likewise.

.gitignore
gettext-runtime/intl/Makefile.am
gettext-tools/src/Makefile.am

index 1de922cea566b513ac99bfecf27621a4e24b1990..7f7ab417958c5e0ca3cf35e956459f4db540947f 100644 (file)
 /gettext-tools/libgettextpo/iconv_open-zos.h
 # Files generated by "make", using bison.
 /gettext-runtime/intl/plural.c
+/gettext-runtime/intl/plural.h
 /gettext-tools/src/cldr-plural.c
 /gettext-tools/src/cldr-plural.h
 /gettext-tools/src/po-gram-gen.c
index 22de832e9f34455cc99b73061a8bedf50638b413..d3fa63fc63be4ed672b5c86646f734063acd996a 100644 (file)
@@ -70,8 +70,9 @@ AM_CPPFLAGS += \
   -DDEPENDS_ON_LIBICONV=1
 
 BISON = @INTLBISON@
-YACC = $(BISON) -d
 BISONFLAGS = --name-prefix=__gettext
+# Just to shut up Automake "error: Yacc source seen but 'YACC' is undefined".
+YACC = $(BISON) -d
 
 # Tell the ELF linker which symbols to export.
 AM_CFLAGS = @CFLAG_VISIBILITY@
@@ -321,19 +322,29 @@ MOSTLYCLEANFILES += localename-table.h
 # script.
 # Additionally, here we need a rule that works even without a VPATH variable.
 # Therefore we override this rule.
+# Note: There is no point in using Bison's --output option, since we need to
+# postprocess the generated files and we don't want that unpostprocessed files
+# remain in place if the user interrupts the build through Ctrl-C.
 
 $(srcdir)/plural.c: $(srcdir)/plural.y
-       $(AM_V_YACC)$(YACC) $(BISONFLAGS) --output plural.c $(srcdir)/plural.y \
+       $(AM_V_YACC)$(BISON) -d $(BISONFLAGS) $(srcdir)/plural.y \
        && test ':' = '$(BISON)' || { \
-         sed -e 's|".*/plural.y"|"plural.y"|' < plural.c > plural.c-tmp \
-         && rm -f plural.c plural.h \
-         && mv plural.c-tmp $(srcdir)/plural.c; \
+         sed -e 's|".*/plural.y"|"plural.y"|' \
+             -e 's|"plural\.tab\.c"|"plural.c"|' \
+             -e 's|"plural\.tab\.h"|"plural.h"|' \
+             < plural.tab.c > plural.c-tmp \
+         && sed -e 's|".*/plural.y"|"plural.y"|' \
+                -e 's|"plural\.tab\.h"|"plural.h"|' \
+                < plural.tab.h > plural.h-tmp \
+         && rm -f plural.tab.c plural.tab.h \
+         && mv plural.c-tmp $(srcdir)/plural.c \
+         && mv plural.h-tmp $(srcdir)/plural.h; \
        }
 # Don't put plural.c into BUILT_SOURCES. Since plural.c is in the source
 # directory, 'make' does not find it without a VPATH variable.
-MOSTLYCLEANFILES     += plural.c-tmp
-MAINTAINERCLEANFILES += plural.c
-EXTRA_DIST           += plural.c
+MOSTLYCLEANFILES     += plural.tab.c plural.tab.h plural.c-tmp plural.h-tmp
+MAINTAINERCLEANFILES += plural.c plural.h
+EXTRA_DIST           += plural.c plural.h
 
 # Rules for compiling a .c file, that work even without a VPATH variable.
 bindtextdom.lo: $(srcdir)/bindtextdom.c
index 764ffadbd3add5e8ce65a735e890a2bdc260ae56..510ab2a08f8ae5b473b87f8c9a1790c8cfb97684 100644 (file)
@@ -113,7 +113,6 @@ OTHERPROGDEPENDENCIES = ../gnulib-lib/libgettextlib.la $(WOE32_LDADD)
 
 SED = sed
 BISON = @TOOLS_BISON@
-YACC = @YACC@ -d
 JAR = @JAR@
 JAVACOMP = $(SHELL) ../javacomp.sh
 CSHARPCOMP = $(SHELL) ../csharpcomp.sh
@@ -551,24 +550,37 @@ endif
 #     always fires and, since $(srcdir) is read-only, the commands which update
 #     (or at least touch) $(srcdir)/FILE.c and $(srcdir)/FILE.h fail.
 # Therefore we don't use ylwrap.
+#
+# Note: There is no point in using Bison's --output option, since we need to
+# postprocess the generated files and we don't want that unpostprocessed files
+# remain in place if the user interrupts the build through Ctrl-C.
 
 po-gram-gen.c po-gram-gen.h: po-gram-gen.y
        $(AM_V_YACC)$(BISON) -d $(YFLAGS) $(AM_YFLAGS) $(srcdir)/po-gram-gen.y \
        && test ':' = '$(BISON)' || { \
-         sed -e 's|".*/po-gram-gen.y"|"po-gram-gen.y"|' < po-gram-gen.tab.c > po-gram-gen.c-tmp \
-         && rm -f po-gram-gen.tab.c \
+         sed -e 's|".*/po-gram-gen.y"|"po-gram-gen.y"|' \
+             -e 's|"po-gram-gen\.tab\.c"|"po-gram-gen.c"|' \
+             -e 's|"po-gram-gen\.tab\.h"|"po-gram-gen.h"|' \
+             < po-gram-gen.tab.c > po-gram-gen.c-tmp \
+         && sed -e 's|".*/po-gram-gen.y"|"po-gram-gen.y"|' \
+                -e 's|"po-gram-gen\.tab\.h"|"po-gram-gen.h"|' \
+                < po-gram-gen.tab.h > po-gram-gen.h-tmp \
+         && rm -f po-gram-gen.tab.c po-gram-gen.tab.h \
          && mv po-gram-gen.c-tmp $(srcdir)/po-gram-gen.c \
-         && mv po-gram-gen.tab.h $(srcdir)/po-gram-gen.h; \
+         && mv po-gram-gen.h-tmp $(srcdir)/po-gram-gen.h; \
        }
 BUILT_SOURCES += po-gram-gen.c po-gram-gen.h
-MOSTLYCLEANFILES += po-gram-gen.tab.c po-gram-gen.tab.h po-gram-gen.c-tmp
+MOSTLYCLEANFILES += po-gram-gen.tab.c po-gram-gen.tab.h po-gram-gen.c-tmp po-gram-gen.h-tmp
 MAINTAINERCLEANFILES += po-gram-gen.c po-gram-gen.h
 EXTRA_DIST += po-gram-gen.c po-gram-gen.h
 
+
 # po-gram-gen2.h is generated from po-gram-gen.h and is also distributed in the
 # tarballs (just for convenience).
 po-gram-gen2.h: po-gram-gen.h
-       $(SED) -e 's/yy/po_gram_/g' -e 's/extern /extern DLL_VARIABLE /' $(srcdir)/po-gram-gen.h > po-gram-gen2.h-tmp \
+       $(SED) -e 's/yy/po_gram_/g' -e 's/extern /extern DLL_VARIABLE /' \
+              -e 's|"po-gram-gen\.h"|"po-gram-gen2.h"|' \
+              < $(srcdir)/po-gram-gen.h > po-gram-gen2.h-tmp \
        && mv po-gram-gen2.h-tmp $(srcdir)/po-gram-gen2.h
 BUILT_SOURCES += po-gram-gen2.h
 MOSTLYCLEANFILES += po-gram-gen2.h-tmp
@@ -580,13 +592,19 @@ po-lex.o po-lex.lo: po-gram-gen2.h
 cldr-plural.c cldr-plural.h: cldr-plural.y
        $(AM_V_YACC)$(BISON) -d $(YFLAGS) $(AM_YFLAGS) $(srcdir)/cldr-plural.y \
        && test ':' = '$(BISON)' || { \
-         sed -e 's|".*/cldr-plural.y"|"cldr-plural.y"|' < cldr-plural.tab.c > cldr-plural.c-tmp \
-         && rm -f cldr-plural.tab.c \
+         sed -e 's|".*/cldr-plural.y"|"cldr-plural.y"|' \
+             -e 's|"cldr-plural\.tab\.c"|"cldr-plural.c"|' \
+             -e 's|"cldr-plural\.tab\.h"|"cldr-plural.h"|' \
+             < cldr-plural.tab.c > cldr-plural.c-tmp \
+         && sed -e 's|".*/cldr-plural.y"|"cldr-plural.y"|' \
+                -e 's|"cldr-plural\.tab\.h"|"cldr-plural.h"|' \
+                < cldr-plural.tab.h > cldr-plural.h-tmp \
+         && rm -f cldr-plural.tab.c cldr-plural.tab.h \
          && mv cldr-plural.c-tmp $(srcdir)/cldr-plural.c \
-         && mv cldr-plural.tab.h $(srcdir)/cldr-plural.h; \
+         && mv cldr-plural.h-tmp $(srcdir)/cldr-plural.h; \
        }
 BUILT_SOURCES += cldr-plural.c cldr-plural.h
-MOSTLYCLEANFILES += cldr-plural.tab.c cldr-plural.tab.h cldr-plural.c-tmp
+MOSTLYCLEANFILES += cldr-plural.tab.c cldr-plural.tab.h cldr-plural.c-tmp cldr-plural.h-tmp
 MAINTAINERCLEANFILES += cldr-plural.c cldr-plural.h
 EXTRA_DIST += cldr-plural.c cldr-plural.h