groff-commit
[Top][All Lists]
Advanced

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

[groff] 03/03: doc/doc.am: Cope with Mac OS X.


From: G. Branden Robinson
Subject: [groff] 03/03: doc/doc.am: Cope with Mac OS X.
Date: Wed, 27 Oct 2021 00:30:31 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 2b3e0a672d426253025c32bff31fffe8439c47bc
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Oct 27 14:51:39 2021 +1100

    doc/doc.am: Cope with Mac OS X.
    
    * doc/doc.am: Make sed-based insertion of `lf` requests more portable: a
      dance is required to embed a literal newline inside a sed expression
      inside a shell command executed as part of a Make target rule.  We
      assume that neither the POSIX shell $'' operator nor a working
      printf(1) is available.
    
      (DOC_GROFF): Define a shell variable containing a literal newline,
      evading make(1) and echo(1)'s valiant attempts to consume it.
    
      (doc/pic.html, doc/webpage.html): Repeat trick, slightly modified
      since the dependency needs to be manually identified.
    
    Solution adapted from the GNU Autoconf manual, "Newlines in Make
    Rules".
---
 ChangeLog  | 16 ++++++++++++++++
 doc/doc.am | 26 ++++++++++++++++++++------
 2 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7f4e3d3..b60933a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2021-10-27  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * doc/doc.am: Make sed-based insertion of `lf` requests more
+       portable: a dance is required to embed a literal newline inside
+       a sed expression inside a shell command executed as part of a
+       Make target rule.  We assume that neither the POSIX shell $''
+       operator nor a working printf(1) is available.
+       (DOC_GROFF): Define a shell variable containing a literal
+       newline, evading make(1) and echo(1)'s valiant attempts to
+       consume it.
+       (doc/pic.html, doc/webpage.html): Repeat trick, slightly
+       modified since the dependency needs to be manually identified.
+
+       Solution adapted from the GNU Autoconf manual, "Newlines in Make
+       Rules".
+
 2021-10-26  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * tmac/an.tmac (TH): Stop populating `an-extra3` (the default
diff --git a/doc/doc.am b/doc/doc.am
index bee1902..6f26249 100644
--- a/doc/doc.am
+++ b/doc/doc.am
@@ -29,8 +29,20 @@ DOC_GROFF_ONLY=\
   $(GROFFBIN) -I$(abs_top_builddir) -M $(doc_srcdir) \
        $(TFLAG) $(FFLAG) -pet -ww -b
 
-DOC_GROFF = $(DOC_SED) -e '1i\
-.lf 1 $<' $< | $(DOC_GROFF_ONLY)
+# A dance is required to embed a literal newline inside a sed expression
+# inside a shell command executed as part of a Make target rule.
+#
+# Use the POSIX shell $'\n' feature when all platforms of interest
+# support it.
+#
+#DOC_GROFF = $(DOC_SED) -e 1i\$$'\n'".lf 1 $<"$$'\n' $< \
+#      | $(DOC_GROFF_ONLY)
+#
+# In the meantime, a shell variable must be prepared in each target rule
+# shell command using $(DOC_SED).  This solution is adapted from the GNU
+# Autoconf manual, "Newlines in Make Rules".
+DOC_GROFF = nlinit=`echo 'nl="'; echo '"'`; eval "$$nlinit"; \
+         $(DOC_SED) -e "1i\\$$nl.lf 1 $<$$nl" $< | $(DOC_GROFF_ONLY)
 
 # Other doc, installed in $(docdir)
 if BUILD_OTHERDOC
@@ -159,8 +171,9 @@ doc/pic.html: $(dist_devpsfont_DATA) 
$(nodist_devpsfont_DATA)
 doc/pic.html: $(doc_srcdir)/pic.ms $(devhtmlfont_DATA)
        $(GROFF_V)$(MKDIR_P) $(doc_builddir) \
        && cd $(doc_builddir) \
-       && $(DOC_SED) -e '1i\
-.lf 1 $(doc_srcdir)/pic.ms' $(doc_srcdir)/pic.ms \
+       && nlinit=`echo 'nl="'; echo '"'`; eval "$$nlinit"; \
+         $(DOC_SED) -e "1i\\$$nl.lf 1 $(doc_srcdir)/pic.ms$$nl" \
+         $(doc_srcdir)/pic.ms \
           | $(DOC_GROFF_ONLY) -P-p -P-Ipic -P-D$(imagedir) -P-jpic \
                               -Thtml -ms > pic.html
 
@@ -179,8 +192,9 @@ doc/webpage.html: \
   $(doc_srcdir)/groff.css
        $(GROFF_V)$(MKDIR_P) doc \
        && cd $(doc_builddir) \
-       && $(DOC_SED) -e '1i\
-.lf 1 $(doc_srcdir)/webpage.ms' $(doc_srcdir)/webpage.ms \
+       && nlinit=`echo 'nl="'; echo '"'`; eval "$$nlinit"; \
+         $(DOC_SED) -e "1i\\$$nl.lf 1 $(doc_srcdir)/webpage.ms$$nl" \
+         $(doc_srcdir)/webpage.ms \
           | $(DOC_GROFF_ONLY) -P-jwebpage -P-nrpb -P-Iwebpage \
                               -P-D$(imagedir) -Thtml -ms > webpage.html
 



reply via email to

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