]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
build: Fix #line statements in bison-generated files.
authorBruno Haible <bruno@clisp.org>
Sun, 25 Nov 2018 01:11:21 +0000 (02:11 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 25 Nov 2018 01:11:21 +0000 (02:11 +0100)
* gettext-tools/src/Makefile.am (po-gram-gen.c, cldr-plural.c): Override the
Automake .y.c rule.
(po-gram-gen.h, cldr-plural.h): Remove separate target.
(po-gram-gen2.h): Generate in the source directory.

gettext-tools/src/Makefile.am

index 7d0c7d8217e579f5094a4bb074b6350be66ab89b..399febb55d377013b2edb1bb3497b5bc72c9636c 100644 (file)
 
 AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies subdir-objects
 EXTRA_DIST =
+BUILT_SOURCES =
 MOSTLYCLEANFILES = core *.stackdump
 CLEANFILES =
 DISTCLEANFILES =
+MAINTAINERCLEANFILES =
 
 RM = rm -f
 
@@ -462,19 +464,58 @@ endif
 
 # Special rules for bison and flex generated files.
 
-BUILT_SOURCES = \
-  po-gram-gen.c po-gram-gen.h po-gram-gen2.h cldr-plural.c cldr-plural.h
+# 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.
+# Therefore we override this rule.
+
+po-gram-gen.c po-gram-gen.h: po-gram-gen.y
+       $(AM_V_GEN)$(SHELL) $(YLWRAP) $(srcdir)/po-gram-gen.y \
+                                     y.tab.c po-gram-gen.c \
+                                     y.tab.h po-gram-gen.h \
+                                     y.output po-gram-gen.output \
+                                     -- $(YACC) $(YFLAGS) $(AM_YFLAGS) \
+       && sed -e 's|".*/po-gram-gen.y"|"po-gram-gen.y"|' < po-gram-gen.c > po-gram-gen.c-tmp \
+       && rm -f po-gram-gen.c \
+       && mv po-gram-gen.c-tmp $(srcdir)/po-gram-gen.c \
+       && { test '$(srcdir)' = . || mv po-gram-gen.h $(srcdir)/po-gram-gen.h; }
+BUILT_SOURCES += po-gram-gen.c po-gram-gen.h
+MOSTLYCLEANFILES += po-gram-gen.c-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 \
+       && mv po-gram-gen2.h-tmp $(srcdir)/po-gram-gen2.h
+BUILT_SOURCES += po-gram-gen2.h
+MOSTLYCLEANFILES += po-gram-gen2.h-tmp
+MAINTAINERCLEANFILES += po-gram-gen2.h
+EXTRA_DIST += po-gram-gen2.h
 
 po-lex.o po-lex.lo: po-gram-gen2.h
-po-gram-gen2.h: po-gram-gen.h
-       srcdir=''; \
-       test -f ./po-gram-gen.h || srcdir=$(srcdir)/; \
-       $(SED) -e 's/yy/po_gram_/g' -e 's/extern /extern DLL_VARIABLE /' \
-         $${srcdir}po-gram-gen.h > $@-tmp && \
-       mv $@-tmp $@
-po-gram-gen.h: po-gram-gen.c
-
-cldr-plural.h: cldr-plural.c
+
+cldr-plural.c cldr-plural.h: cldr-plural.y
+       $(AM_V_GEN)$(SHELL) $(YLWRAP) $(srcdir)/cldr-plural.y \
+                                     y.tab.c cldr-plural.c \
+                                     y.tab.h cldr-plural.h \
+                                     y.output cldr-plural.output \
+                                     -- $(YACC) $(YFLAGS) $(AM_YFLAGS) \
+       && sed -e 's|".*/cldr-plural.y"|"cldr-plural.y"|' < cldr-plural.c > cldr-plural.c-tmp \
+       && rm -f cldr-plural.c \
+       && mv cldr-plural.c-tmp $(srcdir)/cldr-plural.c \
+       && { test '$(srcdir)' = . || mv cldr-plural.h $(srcdir)/cldr-plural.h; }
+BUILT_SOURCES += cldr-plural.c cldr-plural.h
+MOSTLYCLEANFILES += cldr-plural.c-tmp
+MAINTAINERCLEANFILES += cldr-plural.c cldr-plural.h
+EXTRA_DIST += cldr-plural.c cldr-plural.h
 
 
 # Special rules for installation of auxiliary programs.