]> git.draconx.ca Git - dxcommon.git/commitdiff
gettext.mk: Fix installation rules with some shells.
authorNick Bowler <nbowler@draconx.ca>
Tue, 21 Nov 2023 03:57:23 +0000 (22:57 -0500)
committerNick Bowler <nbowler@draconx.ca>
Tue, 21 Nov 2023 05:28:35 +0000 (00:28 -0500)
The following syntax is not portable to certain shells:

  for f in ; do stuff; done

When no translations are installed, a command just like this is
generated in the installation rules.  Instead of doing nothing
as desired, HP-UX 11 /bin/sh, heirloom-sh, and presumably also
old Solaris /bin/sh will exit with an error.

To work around this problem, we can stuff the list into a shell
variable and then use that in the for loop.

snippet/gettext.mk

index 38001147d57d974d1a071afd78c3c3e424ac913e..8f6865b8fb5c0e319e8ea4be361099cb26e44fd7 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright © 2011-2012 Nick Bowler
+# Copyright © 2011-2012, 2023 Nick Bowler
 #
 # Automake fragment to distribute and install gettext .po/.mo files, intended
 # for use in a non-recursive build setup.  This does not include rules to
@@ -25,33 +25,31 @@ MAINTAINERCLEANFILES += $(ALL_MOFILES)
 
 install-data-local: install-mofiles
 install-mofiles: $(MOFILES)
-       for mo in $?; do \
-               lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
-               test x"$$lang" = x"" && exit 1; \
-               inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
-               (set -x; $(MKDIR_P) "$$inst") \
-                       || exit $$?; \
-               (set -x; $(INSTALL_DATA) "$$mo" "$$inst/$(PACKAGE).mo") \
-                       || exit $$?; \
+       mos='$?'; for mo in $$mos; do \
+         lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
+         test x"$$lang" = x"" && exit 1; \
+         inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
+         (set -x; $(MKDIR_P) "$$inst") || exit; \
+         (set -x; $(INSTALL_DATA) "$$mo" "$$inst/$(PACKAGE).mo") || exit; \
        done
 .PHONY: install-mofiles
 
 installdirs-local: installdirs-mofiles
 installdirs-mofiles:
-       for mo in $(MOFILES); do \
-               lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
-               test x"$$lang" = x"" && exit 1; \
-               inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
-               (set -x; $(MKDIR_P) "$$inst") || exit $$?; \
+       mos='$(MOFILES)'; for mo in $$mos; do \
+         lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
+         test x"$$lang" = x"" && exit 1; \
+         inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
+         (set -x; $(MKDIR_P) "$$inst") || exit; \
        done
 .PHONY: installdirs-mofiles
 
 uninstall-local: uninstall-mofiles
 uninstall-mofiles:
-       for mo in $(ALL_MOFILES); do \
-               lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
-               test x"$$lang" = x"" && exit 1; \
-               inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
-               (set -x; cd "$$inst" && rm -f '$(PACKAGE).mo'); \
+       mos='$(ALL_MOFILES)'; for mo in $$mos; do \
+         lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
+         test x"$$lang" = x"" && exit 1; \
+         inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
+         (set -x; cd "$$inst" && rm -f '$(PACKAGE).mo'); \
        done
 .PHONY: uninstall-mofiles