The R Project SVN R

Rev

Rev 31770 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 31770 Rev 34111
1
#! /bin/sh
1
#! /bin/sh
2
 
2
 
3
## Rd2dvi -- Convert man pages (*.Rd help files) via LaTeX to DVI/PDF.
3
## Rd2dvi -- Convert man pages (*.Rd help files) via LaTeX to DVI/PDF.
4
##
4
##
5
## Examples:
5
## Examples:
6
##  R CMD Rd2dvi /path/to/Rsrc/src/library/base/man/Normal.Rd
6
##  R CMD Rd2dvi /path/to/Rsrc/src/library/base/man/Normal.Rd
7
##  R CMD Rd2dvi `grep -l "\\keyword{distr" \
7
##  R CMD Rd2dvi `grep -l "\\keyword{distr" \
8
##                  /path/to/Rsrc/src/library/base/man/*.Rd | sort | uniq`
8
##                  /path/to/Rsrc/src/library/base/man/*.Rd | sort | uniq`
9
 
9
 
10
revision='$Revision: 1.40 $'
10
revision='$Revision: 1.40 $'
11
version=`set - ${revision}; echo ${2}`
11
version=`set - ${revision}; echo ${2}`
12
version="Rd2dvi ${version}
12
version="Rd2dvi ${version}
13
 
13
 
14
Copyright (C) 2000-2001 The R Core Development Team.
14
Copyright (C) 2000-2001 The R Core Development Team.
15
This is free software; see the GNU General Public Licence version 2
15
This is free software; see the GNU General Public Licence version 2
16
or later for copying conditions.  There is NO warranty." 
16
or later for copying conditions.  There is NO warranty." 
17
 
17
 
18
usage="Usage: R CMD Rd2dvi [options] files
18
usage="Usage: R CMD Rd2dvi [options] files
19
 
19
 
20
Generate DVI (or PDF) output from the Rd sources specified by files, by
20
Generate DVI (or PDF) output from the Rd sources specified by files, by
21
either giving the paths to the files, or the path to a directory with
21
either giving the paths to the files, or the path to a directory with
22
the sources of a package.
22
the sources of a package.
23
 
23
 
24
Unless specified via option '--output', the basename of the output file
24
Unless specified via option '--output', the basename of the output file
25
equals the basename of argument 'files' if this specifies a package
25
equals the basename of argument 'files' if this specifies a package
26
(bundle) or a single file, and 'Rd2' otherwise.
26
(bundle) or a single file, and 'Rd2' otherwise.
27
 
27
 
28
Options:
28
Options:
29
  -h, --help		print short help message and exit
29
  -h, --help		print short help message and exit
30
  -v, --version		print Rd2dvi version info and exit
30
  -v, --version		print Rd2dvi version info and exit
31
      --batch		no interaction
31
      --batch		no interaction
32
      --debug		turn on shell debugging (set -x)
32
      --debug		turn on shell debugging (set -x)
33
      --no-clean	do not remove created temporary files
33
      --no-clean	do not remove created temporary files
34
      --no-preview	do not preview generated output file
34
      --no-preview	do not preview generated output file
35
      --os=NAME		use OS subdir 'NAME' (unix or windows)
35
      --os=NAME		use OS subdir 'NAME' (unix or windows)
36
      --OS=NAME		the same as '--os'
36
      --OS=NAME		the same as '--os'
37
  -o, --output=FILE	write output to FILE
37
  -o, --output=FILE	write output to FILE
38
      --pdf		generate PDF output
38
      --pdf		generate PDF output
39
      --title=NAME	use NAME as the title of the document
39
      --title=NAME	use NAME as the title of the document
40
  -V, --verbose		report on what is done
40
  -V, --verbose		report on what is done
41
 
41
 
42
Report bugs to <r-bugs@r-project.org>."
42
Report bugs to <r-bugs@r-project.org>."
43
 
43
 
44
start_dir=`pwd`
44
start_dir=`pwd`
45
 
45
 
46
batch=false
46
batch=false
47
clean=true
47
clean=true
48
debug=false
48
debug=false
49
out_ext="dvi"
49
out_ext="dvi"
50
output=""
50
output=""
51
preview=xdvi
51
preview=xdvi
52
verbose=false
52
verbose=false
53
OSdir=${R_OSTYPE-"unix"}
53
OSdir=${R_OSTYPE-"unix"}
54
 
54
 
-
 
55
: ${R_SHARE_DIR}=${R_HOME}/share
55
## Need a `safe' echo which does not interpret backslash-escaped
56
## Need a `safe' echo which does not interpret backslash-escaped
56
## characters in SysV style.
57
## characters in SysV style.
57
echo="sh ${R_HOME}/share/sh/echo.sh"
58
echo="sh ${R_SHARE_DIR}/sh/echo.sh"
58
 
59
 
59
while test -n "${1}"; do
60
while test -n "${1}"; do
60
  case ${1} in
61
  case ${1} in
61
    -h|--help)
62
    -h|--help)
62
      ${echo} "${usage}"; exit 0 ;;
63
      ${echo} "${usage}"; exit 0 ;;
63
    -v|--version)
64
    -v|--version)
64
      ${echo} "${version}"; exit 0 ;;
65
      ${echo} "${version}"; exit 0 ;;
65
    --batch)
66
    --batch)
66
      batch=true ;;
67
      batch=true ;;
67
    --debug)
68
    --debug)
68
      debug=true ;;
69
      debug=true ;;
69
    --no-clean)
70
    --no-clean)
70
      clean=false ;;
71
      clean=false ;;
71
    --no-preview)
72
    --no-preview)
72
      preview=false ;;
73
      preview=false ;;
73
    --pdf)
74
    --pdf)
74
      out_ext="pdf";
75
      out_ext="pdf";
75
      preview=false;
76
      preview=false;
76
      R_RD4DVI=${R_RD4PDF-"times,hyper"};
77
      R_RD4DVI=${R_RD4PDF-"times,hyper"};
77
      R_LATEXCMD=${PDFLATEX-pdflatex} ;;
78
      R_LATEXCMD=${PDFLATEX-pdflatex} ;;
78
    --title=*)
79
    --title=*)
79
      title=`echo "${1}" | sed -e 's/[^=]*=//'` ;;
80
      title=`echo "${1}" | sed -e 's/[^=]*=//'` ;;
80
    -o)
81
    -o)
81
      if test -n "`echo ${2} | sed 's/^-.*//'`"; then      
82
      if test -n "`echo ${2} | sed 's/^-.*//'`"; then      
82
	output="${2}"; shift
83
	output="${2}"; shift
83
      else
84
      else
84
	${echo} "ERROR: option '${1}' requires an argument"
85
	${echo} "ERROR: option '${1}' requires an argument"
85
	exit 1
86
	exit 1
86
      fi
87
      fi
87
      ;;
88
      ;;
88
    --output=*)
89
    --output=*)
89
      output=`echo "${1}" | sed -e 's/[^=]*=//'` ;;
90
      output=`echo "${1}" | sed -e 's/[^=]*=//'` ;;
90
    --OS=*|--os=*)
91
    --OS=*|--os=*)
91
      OSdir=`echo "${1}" | sed -e 's/[^=]*=//'` ;;
92
      OSdir=`echo "${1}" | sed -e 's/[^=]*=//'` ;;
92
    -V|--verbose)
93
    -V|--verbose)
93
      verbose=${echo} ;;
94
      verbose=${echo} ;;
94
    --|*)
95
    --|*)
95
      break ;;
96
      break ;;
96
  esac
97
  esac
97
  shift
98
  shift
98
done
99
done
99
 
100
 
100
if ${debug}; then set -x; fi
101
if ${debug}; then set -x; fi
101
 
102
 
102
. ${R_HOME}/share/sh/dcf.sh	# get_dcf_field()
103
. ${R_SHARE_DIR}/sh/dcf.sh	# get_dcf_field()
103
 
104
 
104
Rdconv_dir_or_files_to_LaTeX () {
105
Rdconv_dir_or_files_to_LaTeX () {
105
  ## Convert Rd files in a dir or a list of Rd files to LaTeX, appending
106
  ## Convert Rd files in a dir or a list of Rd files to LaTeX, appending
106
  ## the result to OUTFILE.
107
  ## the result to OUTFILE.
107
  ## Usage:
108
  ## Usage:
108
  ##   Rdconv_dir_or_files_to_LaTeX OUTFILE DIR
109
  ##   Rdconv_dir_or_files_to_LaTeX OUTFILE DIR
109
  ##   Rdconv_dir_or_files_to_LaTeX OUTFILE FILES
110
  ##   Rdconv_dir_or_files_to_LaTeX OUTFILE FILES
110
 
111
 
111
  ${verbose} $@
112
  ${verbose} $@
112
 
113
 
113
  out="${1}"
114
  out="${1}"
114
  shift
115
  shift
115
 
116
 
116
  if test -d ${1}; then
117
  if test -d ${1}; then
117
    files=`ls ${1}/*.[Rr]d`
118
    files=`ls ${1}/*.[Rr]d`
118
    if test -d ${1}/${OSdir}; then
119
    if test -d ${1}/${OSdir}; then
119
      files="${files} `ls ${1}/${OSdir}/*.[Rr]d`"
120
      files="${files} `ls ${1}/${OSdir}/*.[Rr]d`"
120
    fi
121
    fi
121
    files=`LC_ALL=C ${echo} ${files} | sort`
122
    files=`LC_ALL=C ${echo} ${files} | sort`
122
  else
123
  else
123
    files="${@}"
124
    files="${@}"
124
  fi
125
  fi
125
 
126
 
126
  echo "Converting Rd files to LaTeX ..."
127
  echo "Converting Rd files to LaTeX ..."
127
 
128
 
128
  for f in ${files}; do
129
  for f in ${files}; do
129
    ${echo} ${f}
130
    ${echo} ${f}
130
    ${R_CMD} Rdconv -t latex ${f} >> ${out}
131
    ${R_CMD} Rdconv -t latex ${f} >> ${out}
131
  done
132
  done
132
 
133
 
133
}
134
}
134
 
135
 
135
Rd_DESCRIPTION_to_LaTeX () {
136
Rd_DESCRIPTION_to_LaTeX () {
136
  ## Typeset the contents of a DESCRIPTION file in a LaTeX description
137
  ## Typeset the contents of a DESCRIPTION file in a LaTeX description
137
  ## list.
138
  ## list.
138
  ## Usage:
139
  ## Usage:
139
  ##   Rd_DESCRIPTION_to_LaTeX FILE
140
  ##   Rd_DESCRIPTION_to_LaTeX FILE
140
  
141
  
141
  fields=`sed '/^[ 	]/d; s/^\([^:]*\):.*$/\1/' $1`
142
  fields=`sed '/^[ 	]/d; s/^\([^:]*\):.*$/\1/' $1`
142
  ${echo} "\\begin{description}"
143
  ${echo} "\\begin{description}"
143
  ${echo} "\\raggedright{}"
144
  ${echo} "\\raggedright{}"
144
  for f in `${echo} "${fields}" | sed '/Package/d; /Bundle/d;'`; do
145
  for f in `${echo} "${fields}" | sed '/Package/d; /Bundle/d;'`; do
145
    text=`get_dcf_field ${f} ${1}`
146
    text=`get_dcf_field ${f} ${1}`
146
    ${echo} "\\item[${f}] \\AsIs{${text}}"
147
    ${echo} "\\item[${f}] \\AsIs{${text}}"
147
  done
148
  done
148
  ${echo} "\\end{description}"
149
  ${echo} "\\end{description}"
149
}
150
}
150
 
151
 
151
is_bundle=no
152
is_bundle=no
152
is_base_package=no
153
is_base_package=no
153
file_sed='s/[_$]/\\&/g'
154
file_sed='s/[_$]/\\&/g'
154
 
155
 
155
toc="\\Rdcontents{\\R{} topics documented:}"
156
toc="\\Rdcontents{\\R{} topics documented:}"
156
if test -d "${1}"; then
157
if test -d "${1}"; then
157
  if test -f ${1}/DESCRIPTION; then
158
  if test -f ${1}/DESCRIPTION; then
158
    if test -n "`grep '^Bundle:' ${1}/DESCRIPTION`"; then
159
    if test -n "`grep '^Bundle:' ${1}/DESCRIPTION`"; then
159
      echo "Hmm ... looks like a package bundle"
160
      echo "Hmm ... looks like a package bundle"
160
      is_bundle=yes
161
      is_bundle=yes
161
      bundle_name=`get_dcf_field Bundle "${1}/DESCRIPTION"`
162
      bundle_name=`get_dcf_field Bundle "${1}/DESCRIPTION"`
162
      bundle_pkgs=`get_dcf_field Contains "${1}/DESCRIPTION"`
163
      bundle_pkgs=`get_dcf_field Contains "${1}/DESCRIPTION"`
163
      title=${title-"Bundle \`${bundle_name}'"}
164
      title=${title-"Bundle \`${bundle_name}'"}
164
    else
165
    else
165
      echo "Hmm ... looks like a package"
166
      echo "Hmm ... looks like a package"
166
      package_name=`get_dcf_field Package "${1}/DESCRIPTION"`
167
      package_name=`get_dcf_field Package "${1}/DESCRIPTION"`
167
      title=${title-"Package \`${package_name}'"}
168
      title=${title-"Package \`${package_name}'"}
168
      dir=${1}/man
169
      dir=${1}/man
169
    fi
170
    fi
170
    test -z "${output}" && output="`basename ${1}`.${out_ext}"
171
    test -z "${output}" && output="`basename ${1}`.${out_ext}"
171
  elif test -f ${1}/DESCRIPTION.in && \
172
  elif test -f ${1}/DESCRIPTION.in && \
172
       test -n "`grep '^Priority: *base' ${1}/DESCRIPTION.in`"; then
173
       test -n "`grep '^Priority: *base' ${1}/DESCRIPTION.in`"; then
173
    is_base_package=yes
174
    is_base_package=yes
174
    echo "Hmm ... looks like a package from the R distribution"
175
    echo "Hmm ... looks like a package from the R distribution"
175
    package_name=`get_dcf_field Package "${1}/DESCRIPTION.in"`
176
    package_name=`get_dcf_field Package "${1}/DESCRIPTION.in"`
176
    title=${title-"Package \`${package_name}'"}
177
    title=${title-"Package \`${package_name}'"}
177
    dir=${1}/man
178
    dir=${1}/man
178
    test -z "${output}" && output="`basename ${1}`.${out_ext}"    
179
    test -z "${output}" && output="`basename ${1}`.${out_ext}"    
179
  else
180
  else
180
    if test -d ${1}/man; then
181
    if test -d ${1}/man; then
181
      dir=${1}/man
182
      dir=${1}/man
182
    else
183
    else
183
      dir=${1}
184
      dir=${1}
184
    fi
185
    fi
185
    subj0=`${echo} ${dir} | sed -e ${file_sed}`
186
    subj0=`${echo} ${dir} | sed -e ${file_sed}`
186
    subj="all in \\file{${subj0}}"
187
    subj="all in \\file{${subj0}}"
187
  fi
188
  fi
188
else
189
else
189
  if test ${#} -gt 1 ; then
190
  if test ${#} -gt 1 ; then
190
    subj=" etc.";
191
    subj=" etc.";
191
  else
192
  else
192
    subj=
193
    subj=
193
    toc=
194
    toc=
194
    if test -z "${output}"; then
195
    if test -z "${output}"; then
195
      output=`basename "${1}"`
196
      output=`basename "${1}"`
196
      output="`echo ${output} | sed 's/[Rr]d$//'`${out_ext}"
197
      output="`echo ${output} | sed 's/[Rr]d$//'`${out_ext}"
197
    fi
198
    fi
198
  fi
199
  fi
199
  subj0=`${echo} ${1} | sed -e ${file_sed}`
200
  subj0=`${echo} ${1} | sed -e ${file_sed}`
200
  subj="\\file{${subj0}}${subj}"
201
  subj="\\file{${subj0}}${subj}"
201
fi
202
fi
202
title=${title-"\\R{} documentation}} \\par\\bigskip{{\\Large of ${subj}"}
203
title=${title-"\\R{} documentation}} \\par\\bigskip{{\\Large of ${subj}"}
203
 
204
 
204
## Prepare for building the documentation.
205
## Prepare for building the documentation.
205
if test -z "${output}"; then
206
if test -z "${output}"; then
206
  output="Rd2.${out_ext}"
207
  output="Rd2.${out_ext}"
207
fi
208
fi
208
if test -f ${output}; then
209
if test -f ${output}; then
209
  ${echo} "file '${output}' exists; please remove first"
210
  ${echo} "file '${output}' exists; please remove first"
210
  exit 1
211
  exit 1
211
fi
212
fi
212
build_dir=.Rd2dvi${$}
213
build_dir=.Rd2dvi${$}
213
if test -d ${build_dir}; then
214
if test -d ${build_dir}; then
214
  rm -rf ${build_dir} || echo "cannot write to build dir" && exit 2
215
  rm -rf ${build_dir} || echo "cannot write to build dir" && exit 2
215
fi
216
fi
216
mkdir ${build_dir}
217
mkdir ${build_dir}
217
 
218
 
218
## Rd2.tex part 1: header
219
## Rd2.tex part 1: header
219
if test ${batch}; then
220
if test ${batch}; then
220
  cat > ${build_dir}/Rd2.tex <<EOF
221
  cat > ${build_dir}/Rd2.tex <<EOF
221
\\nonstopmode{}
222
\\nonstopmode{}
222
EOF
223
EOF
223
else
224
else
224
  cat > ${build_dir}/Rd2.tex <<EOF
225
  cat > ${build_dir}/Rd2.tex <<EOF
225
EOF
226
EOF
226
fi
227
fi
227
cat >> ${build_dir}/Rd2.tex <<EOF
228
cat >> ${build_dir}/Rd2.tex <<EOF
228
\\documentclass[${R_PAPERSIZE}paper]{book}
229
\\documentclass[${R_PAPERSIZE}paper]{book}
229
\\usepackage[${R_RD4DVI-ae}]{Rd}
230
\\usepackage[${R_RD4DVI-ae}]{Rd}
230
\\usepackage{makeidx}
231
\\usepackage{makeidx}
231
\\makeindex{}
232
\\makeindex{}
232
\\begin{document}
233
\\begin{document}
233
EOF
234
EOF
234
if test "${is_bundle}" = no; then
235
if test "${is_bundle}" = no; then
235
  cat >> ${build_dir}/Rd2.tex <<EOF
236
  cat >> ${build_dir}/Rd2.tex <<EOF
236
\\chapter*{}
237
\\chapter*{}
237
\\begin{center}
238
\\begin{center}
238
{\\textbf{\\huge ${title}}}
239
{\\textbf{\\huge ${title}}}
239
\\par\\bigskip{\\large \\today}
240
\\par\\bigskip{\\large \\today}
240
\\end{center}
241
\\end{center}
241
EOF
242
EOF
242
  if test -f ${1}/DESCRIPTION; then
243
  if test -f ${1}/DESCRIPTION; then
243
    Rd_DESCRIPTION_to_LaTeX ${1}/DESCRIPTION >> ${build_dir}/Rd2.tex
244
    Rd_DESCRIPTION_to_LaTeX ${1}/DESCRIPTION >> ${build_dir}/Rd2.tex
244
  fi
245
  fi
245
  if test "${is_base_package}" = yes; then
246
  if test "${is_base_package}" = yes; then
246
    R_version=unknown
247
    R_version=unknown
247
    if test -f ${1}/../../../VERSION; then
248
    if test -f ${1}/../../../VERSION; then
248
      R_version=`cat ${1}/../../../VERSION`
249
      R_version=`cat ${1}/../../../VERSION`
249
    fi
250
    fi
250
    Rd_DESCRIPTION_to_LaTeX ${1}/DESCRIPTION.in | \
251
    Rd_DESCRIPTION_to_LaTeX ${1}/DESCRIPTION.in | \
251
      sed "s/@VERSION@/${R_version}/" >> ${build_dir}/Rd2.tex
252
      sed "s/@VERSION@/${R_version}/" >> ${build_dir}/Rd2.tex
252
  fi
253
  fi
253
else
254
else
254
  cat >> ${build_dir}/Rd2.tex <<EOF
255
  cat >> ${build_dir}/Rd2.tex <<EOF
255
\\pagenumbering{Roman}
256
\\pagenumbering{Roman}
256
\\begin{titlepage}
257
\\begin{titlepage}
257
\\strut\\vfill
258
\\strut\\vfill
258
\\begin{center}
259
\\begin{center}
259
{\\textbf{\\Huge ${title}}}
260
{\\textbf{\\Huge ${title}}}
260
\\par\\bigskip{\\large \\today}
261
\\par\\bigskip{\\large \\today}
261
\\end{center}
262
\\end{center}
262
\\par\\bigskip
263
\\par\\bigskip
263
EOF
264
EOF
264
  Rd_DESCRIPTION_to_LaTeX ${1}/DESCRIPTION >> ${build_dir}/Rd2.tex
265
  Rd_DESCRIPTION_to_LaTeX ${1}/DESCRIPTION >> ${build_dir}/Rd2.tex
265
  cat >> ${build_dir}/Rd2.tex <<EOF
266
  cat >> ${build_dir}/Rd2.tex <<EOF
266
\\vfill\\vfill
267
\\vfill\\vfill
267
\\end{titlepage}
268
\\end{titlepage}
268
EOF
269
EOF
269
fi
270
fi
270
  
271
  
271
## Rd2.tex part 2: body
272
## Rd2.tex part 2: body
272
if test "${is_bundle}" = no; then
273
if test "${is_bundle}" = no; then
273
  ${echo} ${toc} >> ${build_dir}/Rd2.tex
274
  ${echo} ${toc} >> ${build_dir}/Rd2.tex
274
  Rdconv_dir_or_files_to_LaTeX ${build_dir}/Rd2.tex ${dir-${@}}
275
  Rdconv_dir_or_files_to_LaTeX ${build_dir}/Rd2.tex ${dir-${@}}
275
else
276
else
276
  cat >> ${build_dir}/Rd2.tex <<EOF
277
  cat >> ${build_dir}/Rd2.tex <<EOF
277
\\setcounter{secnumdepth}{-1}
278
\\setcounter{secnumdepth}{-1}
278
\\pagenumbering{roman}
279
\\pagenumbering{roman}
279
\\tableofcontents{}
280
\\tableofcontents{}
280
\\cleardoublepage{}
281
\\cleardoublepage{}
281
\\pagenumbering{arabic}
282
\\pagenumbering{arabic}
282
EOF
283
EOF
283
  for p in ${bundle_pkgs}; do
284
  for p in ${bundle_pkgs}; do
284
    ${echo} "Bundle package: '${p}'"
285
    ${echo} "Bundle package: '${p}'"
285
    ${echo} "\\chapter{Package \`${p}'}" >> ${build_dir}/Rd2.tex
286
    ${echo} "\\chapter{Package \`${p}'}" >> ${build_dir}/Rd2.tex
286
    if test -f ${1}/${p}/DESCRIPTION.in; then
287
    if test -f ${1}/${p}/DESCRIPTION.in; then
287
      Rd_DESCRIPTION_to_LaTeX ${1}/${p}/DESCRIPTION.in \
288
      Rd_DESCRIPTION_to_LaTeX ${1}/${p}/DESCRIPTION.in \
288
        >> ${build_dir}/Rd2.tex
289
        >> ${build_dir}/Rd2.tex
289
    fi
290
    fi
290
    Rdconv_dir_or_files_to_LaTeX ${build_dir}/Rd2.tex ${1}/${p}/man
291
    Rdconv_dir_or_files_to_LaTeX ${build_dir}/Rd2.tex ${1}/${p}/man
291
    ${echo} "\\clearpage{}" >> ${build_dir}/Rd2.tex
292
    ${echo} "\\clearpage{}" >> ${build_dir}/Rd2.tex
292
  done
293
  done
293
  ${echo} "\\cleardoublepage{}" >> ${build_dir}/Rd2.tex
294
  ${echo} "\\cleardoublepage{}" >> ${build_dir}/Rd2.tex
294
fi
295
fi
295
 
296
 
296
## Rd2.tex part 3: footer
297
## Rd2.tex part 3: footer
297
cat >> ${build_dir}/Rd2.tex <<EOF
298
cat >> ${build_dir}/Rd2.tex <<EOF
298
\\printindex{}
299
\\printindex{}
299
\\end{document}
300
\\end{document}
300
EOF
301
EOF
301
 
302
 
302
## <FIXME>
303
## <FIXME>
303
## Need to do something smarter about the exit status in batch mode.
304
## Need to do something smarter about the exit status in batch mode.
304
status=0
305
status=0
305
## <FIXME>
306
## <FIXME>
306
 
307
 
307
echo "Creating ${out_ext} output from LaTeX ..."
308
echo "Creating ${out_ext} output from LaTeX ..."
308
cd ${build_dir}
309
cd ${build_dir}
309
${R_LATEXCMD-latex} Rd2 || status=1
310
${R_LATEXCMD-latex} Rd2 || status=1
310
${R_MAKEINDEXCMD-makeindex} Rd2
311
${R_MAKEINDEXCMD-makeindex} Rd2
311
${R_LATEXCMD-latex} Rd2
312
${R_LATEXCMD-latex} Rd2
312
if test "${out_ext}" = pdf; then
313
if test "${out_ext}" = pdf; then
313
  ${R_LATEXCMD-latex} Rd2
314
  ${R_LATEXCMD-latex} Rd2
314
fi
315
fi
315
cd ${start_dir}
316
cd ${start_dir}
316
${echo} "Saving output to '${output}' ..."
317
${echo} "Saving output to '${output}' ..."
317
cp ${build_dir}/Rd2.${out_ext} ${output}
318
cp ${build_dir}/Rd2.${out_ext} ${output}
318
echo "Done"
319
echo "Done"
319
 
320
 
320
if ${clean}; then
321
if ${clean}; then
321
  rm -rf ${build_dir}
322
  rm -rf ${build_dir}
322
else
323
else
323
  ${echo} "You may want to clean up by 'rm -rf ${build_dir}'"
324
  ${echo} "You may want to clean up by 'rm -rf ${build_dir}'"
324
fi
325
fi
325
${preview} ${output}
326
${preview} ${output}
326
exit ${status}
327
exit ${status}
327
 
328
 
328
### Local Variables: ***
329
### Local Variables: ***
329
### mode: sh ***
330
### mode: sh ***
330
### sh-indentation: 2 ***
331
### sh-indentation: 2 ***
331
### End: ***
332
### End: ***