"make pdf" fails on macOS due to incompatibility of echo

"Jun. T" <[email protected]> Fri, 16 Dec 2022 01:02:45 +0900
Newsgroups gmane.comp.graphics.gnuplot.devel
Message-ID <[email protected]>
With the current git master, 'make pdf' fails on two of my Macs.
The problem is in docs/Makefile.am:
                                                                    
201       ( echo "\usepackage{graphicx}" > gpinsetfigure.tex ; \
202         echo "\usepackage{picins}" >> gpinsetfigure.tex ; \        
203         echo "\newcommand{\gpinsetfigure}[1]{" >> gpinsetfigure.tex ; \
204         echo "  \parpic[r][rt]{\includegraphics[width=3in,keepaspectratio]{#1}}" >> gpinsetfigure.tex ; \                                    
205         echo "}" >> gpinsetfigure.tex ; \                        
206       ) ; \                                              
207     $(AM_V_GEN)touch $@                                          
208     $(AM_V_GEN)touch figurestyle

[1] On macOS (at least on some versions), echo builtin of /bin/sh interprets
 '\n' as a newline, and the line 203 will output:

(blank line)
ewcommand{\gpinsetfigure}[1]{

to gpinsetfigure.tex, and pdflatex fails.
(I don't know whether this is a bug or feature of macOS)

[2] (also on Linux, not serious) the '\' at the end of line 206
should be removed. Otherwise, 'make V=0 pdf' gives an error:

    @echo "  GEN     " pdf_figures;touch pdf_figures
/bin/sh: @echo: command not found

A possible patch is attached.

printf builtin is more portable than echo.

One of $(AM_V_GEN) is replaced by $(AM_V_at) because they give the
same output when 'make V=0'.

_______________________________________________
gnuplot-beta mailing list
[email protected]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
make_pdf.patch (application/octet-stream, 2.4 KB)
diff --git a/docs/Makefile.am b/docs/Makefile.am
index dffa5dde5..db73776b2 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -197,36 +197,33 @@ doc2ms_CPPFLAGS = -DALL_TERM_DOC $(AM_CPPFLAGS)
 ### PDF documentation can inset figures using either tikz+wrapfig or pdf+picins
 pdf_figures: $(GNUPLOT_EXE) $(srcdir)/plotstyles.gnu
 	$(AM_V_at)GNUPLOT_LIB=$(top_srcdir)/demo $(GNUPLOT_EXE) $(srcdir)/plotstyles.gnu
-	  rm -f gpinsetfigure.tex ; \
-	  ( echo "\usepackage{graphicx}" > gpinsetfigure.tex ; \
-	    echo "\usepackage{picins}" >> gpinsetfigure.tex ; \
-	    echo "\newcommand{\gpinsetfigure}[1]{" >> gpinsetfigure.tex ; \
-	    echo "  \parpic[r][rt]{\includegraphics[width=3in,keepaspectratio]{#1}}" >> gpinsetfigure.tex ; \
-	    echo "}" >> gpinsetfigure.tex ; \
-	  ) ; \
+	rm -f gpinsetfigure.tex
+	printf '%s\n' '\usepackage{graphicx}' \
+		'\usepackage{picins}' \
+		'\newcommand{\gpinsetfigure}[1]{' \
+		'  \parpic[r][rt]{\includegraphics[width=3in,keepaspectratio]{#1}}' \
+		'}' > gpinsetfigure.tex
 	$(AM_V_GEN)touch $@
-	$(AM_V_GEN)touch figurestyle
+	$(AM_V_at)touch figurestyle
 
 tikz_figures: $(GNUPLOT_EXE) $(srcdir)/plotstyles.gnu
 	$(AM_V_at)GNUPLOT_LIB=$(top_srcdir)/demo GNUTERM=tikz $(GNUPLOT_EXE) $(srcdir)/plotstyles.gnu
-	  rm -f gpinsetfigure.tex ; \
-	  ( echo "\usepackage{gnuplot-lua-tikz}" > gpinsetfigure.tex ; \
-	    echo "\usepackage{wrapfig}" >> gpinsetfigure.tex ; \
-	    echo "\newcommand{\gpinsetfigure}[1]{" >> gpinsetfigure.tex ; \
-	    echo "    \begin{wrapfigure}[10]{r}{3.0in}" >> gpinsetfigure.tex ; \
-	    echo "    \vspace{-20pt} \input{#1} \vspace{-20pt}" >> gpinsetfigure.tex ; \
-	    echo "    \end{wrapfigure}" >> gpinsetfigure.tex ; \
-	    echo "}" >> gpinsetfigure.tex ; \
-	  ) ; \
+	rm -f gpinsetfigure.tex
+	printf '%s\n' '\usepackage{gnuplot-lua-tikz}' \
+		'\usepackage{wrapfig}' \
+		'\newcommand{\gpinsetfigure}[1]{' \
+		'    \begin{wrapfigure}[10]{r}{3.0in}' \
+		'    \vspace{-20pt} \input{#1} \vspace{-20pt}' \
+		'    \end{wrapfigure}' \
+		'}' > gpinsetfigure.tex
 	$(AM_V_GEN)touch $@
-	$(AM_V_GEN)touch figurestyle
+	$(AM_V_at)touch figurestyle
 
 no_figures:
-	  rm -f gpinsetfigure.tex ; \
-	  ( echo "\newcommand{\gpinsetfigure}[1]{}" > gpinsetfigure.tex ; \
-	  ) ; \
+	rm -f gpinsetfigure.tex
+	printf '%s\n' '\newcommand{\gpinsetfigure}[1]{}' > gpinsetfigure.tex
 	$(AM_V_GEN)touch $@
-	$(AM_V_GEN)touch figurestyle
+	$(AM_V_at)touch figurestyle
 
 gpinsetfigure.tex: no_figures
 	$(AM_V_GEN) touch $@