[Rd] bash help please

Duncan Murdoch murdoch at stats.uwo.ca
Tue Sep 6 16:56:23 CEST 2005


I'd like to make MikTeX the default TeX package in 2.2.0, but we still 
need to let people use other packages.  The problem is that MikTeX wants 
a command line option --include-directory $R_HOME/share/texmf, while 
other packages specify includes via environment variables, and barf when 
they see the unexpected option.

The choice should be controlled by the user's settings in the MkRules 
file.  For example, I'll put something like this there:

ifneq ($(strip $(BUILD)),CROSS)
# Define to use MikTeX
#
PDFLATEX = pdflatex --include-directory=$(RHOME)/share/texmf
LATEX = latex --include-directory=$(RHOME)/share/texmf
PDFTEX = pdftex --include-directory=$(RHOME)/share/texmf
TEX = tex --include-directory=$(RHOME)/share/texmf
#
# Define to use other TeX
#
# PDFLATEX = pdflatex
# LATEX = latex
# PDFTEX = pdftex
# TEX = tex
else
PDFLATEX = pdflatex
LATEX = latex
PDFTEX = pdftex
TEX = tex
endif

My problem is that I don't know enough about Bourne shell scripting and 
GNU make to have this affect Rd2dvi (and possibly other Rcmd commands, I 
haven't looked yet).

Specifically, we need to have Rd2dvi.sh import these definitions from 
src/gnuwin32/MkRules, which may have been edited by the user since 
Rd2dvi.sh was built.  A complication is that if the user has already 
defined environment variables named PDFLATEX, LATEX, etc, we don't want 
to overwrite them.

One way would be to tell users to rebuild Rd2dvi.sh.  However, it would 
be easier if Rd2dvi.sh could import the changes automatically.

I was thinking of putting something like this into Rd2dvi.sh:

if test ${R_HOME}/src/gnuwin32/MkRules -nt ${R_HOME}/bin/setTeXenv.sh; then
   make -f ${R_HOME}/src/gnuwin32/Makefile ${R_HOME}/bin/setTeXenv.sh
fi
sh setTeXenv.sh

and then have the Makefile build the setTeXenv.sh script--but what 
should it contain?  Alternatively, can GNU make export environtment 
variables directly, and skip creating this new script?

Advice from shell hackers is welcomed!

Duncan Murdoch



More information about the R-devel mailing list