The R Project SVN R

Rev

Rev 7291 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7291 Rev 7357
Line 1... Line 1...
1
#!/bin/sh
1
#!/bin/sh
2
#
2
#
3
# ${R_HOME}/bin/build
3
# ${R_HOME}/bin/build
4
 
4
 
5
REVISION='$Revision: 1.4 $'
5
revision='$Revision: 1.5 $'
6
VERSION=`set - ${REVISION}; echo ${2}`
6
version=`set - ${revision}; echo ${2}`
7
VERSION="R package builder version ${VERSION}
7
version="R package builder ${version}
8
 
8
 
9
Copyright (C) 1999 R Development Core Team.
9
Copyright (C) 2000 R Development Core Team.
10
There is NO warranty.  You may redistribute this software under the
10
There is NO warranty.  You may redistribute this software under the
11
terms of the GNU General Public License.
11
terms of the GNU General Public License.
12
For more information about these matters, see the files named COPYING."
12
For more information about these matters, see the files named COPYING."
13
 
13
 
14
USAGE_MSG="Usage: R CMD build [options] pkgdir_1 ... pkgdir_n
14
usage="Usage: R CMD build [options] pkgdirs
15
 
15
 
16
Build R packages from package sources in the PKGDIR_i directories.
16
Build R packages from package sources in the directories specified by
17
A variety of diagnostic checks and cleanups are performed prior to
17
pkgdirs.  A variety of diagnostic checks and cleanups are performed
18
building the packages.
18
prior to building the packages.
-
 
19
 
-
 
20
If necessary for passing the checks, use the \`--vsize' and \`--nsize'
-
 
21
options to increase R's memory (\`--vanilla' is used by default).
19
 
22
 
20
Options:
23
Options:
-
 
24
  -d, --debug		turn on shell debugging (set -x)
21
  -h, --help       Display this help and exit successfully.
25
  -h, --help		print short help message and exit
22
  -v, --version    Display version information and exit successfully.
26
  -v, --version		print version info and exit
23
  --vsize=N        Set R's vector heap size to N bytes.
27
  --vsize=N		set R's vector heap size to N bytes
24
  --nsize=N        Set R's number of cons cells to N.
28
  --nsize=N		set R's number of cons cells to N
25
  --force          Force overwriting of (index) files.
29
  --force		force overwriting of (index) files  
26
 
30
 
27
Email bug reports to <r-bugs@lists.r-project.org>."
31
Email bug reports to <r-bugs@lists.r-project.org>."
28
 
32
 
29
R_opts="--vanilla"
33
R_opts="--vanilla"
30
DEBUG=false
34
debug=false
31
FORCE=false
35
force=false
32
PKGS=
36
pkgs=
33
 
-
 
34
START_DIR=`pwd`
-
 
35
 
37
 
36
## Parse argument command line
38
## Parse argument command line
37
while test -n "${1}"; do
39
while test -n "${1}"; do
38
  case ${1} in
40
  case ${1} in
39
    -h|--help)
41
    -h|--help)
40
      echo "${USAGE_MSG}"; exit 0 ;;
42
      echo "${usage}"; exit 0 ;;
41
    -v|--version)
43
    -v|--version)
42
      echo "${VERSION}"; exit 0 ;;
44
      echo "${version}"; exit 0 ;;
43
    -d|--debug)
45
    -d|--debug)
44
      DEBUG=true ;;
46
      debug=true ;;
45
    --force)
47
    --force)
46
      FORCE=true ;;
48
      force=true ;;
47
    --nsize=*)
49
    --nsize=*)
48
      R_NSIZE=`echo "${1}" | sed -e 's/[^=]*=//'` ;;
50
      R_opts="{R_opts} ${1}" ;;
49
    --vsize=*)
51
    --vsize=*)
50
      R_VSIZE=`echo "${1}" | sed -e 's/[^=]*=//'` ;;
52
      R_opts="{R_opts} ${1}" ;;
51
    *)
53
    *)
52
      PKGS="${PKGS} ${1}" ;;
54
      pkgs="${pkgs} ${1}" ;;
53
  esac
55
  esac
54
  shift
56
  shift
55
done
57
done
56
 
58
 
57
## Determine whether echo can suppress newlines.
59
## Determine whether echo can suppress newlines.
Line 64... Line 66...
64
else
66
else
65
  ECHO_N= ECHO_C='\c' ECHO_T=
67
  ECHO_N= ECHO_C='\c' ECHO_T=
66
fi
68
fi
67
 
69
 
68
## A few useful output functions
70
## A few useful output functions
-
 
71
checking () {
-
 
72
  if ${debug}; then
-
 
73
    echo "* checking $@ ..."
-
 
74
  else
69
checking () { echo ${ECHO_N} "* checking $@ ...${ECHO_C}"; }
75
    echo ${ECHO_N} "* checking $@ ...${ECHO_C}"
-
 
76
  fi
-
 
77
}
70
message () { echo "* $@"; }
78
message () { echo "* $@"; }
71
result () { echo "${ECHO_T} $@"; }
79
result () { echo "${ECHO_T} $@"; }
72
 
80
 
73
## For updating `INDEX' and `data/00Index;
81
## For updating `INDEX' and `data/00Index;
74
updateIndex () {
82
updateIndex () {
Line 77... Line 85...
77
  R CMD Rdindex ${Rdfiles} > ${newindex}
85
  R CMD Rdindex ${Rdfiles} > ${newindex}
78
  if cmp ${newindex} ${oldindex} > /dev/null; then
86
  if cmp ${newindex} ${oldindex} > /dev/null; then
79
    result "OK"
87
    result "OK"
80
  else
88
  else
81
    result "NO"
89
    result "NO"
82
    if ${FORCE}; then
90
    if ${force}; then
83
      echo "overwriting \`${oldindex}' as \`--force' was given"
91
      echo "overwriting \`${oldindex}' as \`--force' was given"
84
      cp ${newindex} ${oldindex}
92
      cp ${newindex} ${oldindex}
85
      else
93
      else
86
	echo "use \`--force' to overwrite the existing \`${oldindex}'"
94
	echo "use \`--force' to overwrite the existing \`${oldindex}'"
87
      fi
95
      fi
88
    fi
96
    fi
89
  rm -f ${newindex}
97
  rm -f ${newindex}
90
}
98
}
91
 
99
 
-
 
100
start_dir=`pwd`
-
 
101
 
92
## The work horse
102
## The work horse
93
buildpkg () {
103
buildpkg () {
94
  echo "Building package \`${1}' ..."
104
  echo "Building package \`${1}' ..."
95
 
105
 
96
  cd ${START_DIR}
106
  cd ${start_dir}
97
 
107
 
98
  checking "package dir"
108
  checking "package dir"
99
  if test -d ${1}; then
109
  if test -d ${1}; then
100
    dir=`cd ${1}; pwd`
110
    dir=`cd ${1}; pwd`
101
  else
111
  else
Line 226... Line 236...
226
    fi
236
    fi
227
  fi
237
  fi
228
 
238
 
229
  ## Check for undocumented objects 
239
  ## Check for undocumented objects 
230
  checking "for undocumented objects"
240
  checking "for undocumented objects"
231
  if test -n "${R_NSIZE}"; then
-
 
232
    R_opts="${R_opts} --nsize ${R_NSIZE}"
-
 
233
  fi
-
 
234
  if test -n "${R_VSIZE}"; then
-
 
235
    R_opts="${R_opts} --vsize ${R_VSIZE}"
-
 
236
  fi
-
 
237
  out=`echo "undoc(dir = \"${dir}\")" | R ${R_opts} | \
241
  out=`echo "undoc(dir = \"${dir}\")" | R ${R_opts} | \
238
    grep "^Error\\|^ *\\["`
242
    grep "^Error\\|^ *\\["`
239
  err=`echo "${out}" | grep "^Error"`
243
  err=`echo "${out}" | grep "^Error"`
240
  if test -z "${err}"; then
244
  if test -z "${err}"; then
241
    if test -n "${out}"; then
245
    if test -n "${out}"; then
Line 274... Line 278...
274
    ./cleanup
278
    ./cleanup
275
  fi
279
  fi
276
 
280
 
277
  ## And finally build the package
281
  ## And finally build the package
278
  cd ..
282
  cd ..
279
  message "building \`${START_DIR}/${package}_${version}.tar.gz'"
283
  message "building \`${start_dir}/${package}_${version}.tar.gz'"
280
  tar zcf ${START_DIR}/${package}_${version}.tar.gz ${package}
284
  tar zcf ${start_dir}/${package}_${version}.tar.gz ${package}
281
}
285
}
282
 
286
 
283
## The main loop
287
## The main loop
-
 
288
if ${debug}; then set -x; fi
284
for p in ${PKGS}; do buildpkg ${p}; echo; done
289
for p in ${pkgs}; do
-
 
290
  buildpkg ${p}
-
 
291
  echo
-
 
292
done
285
 
293
 
286
### Local Variables: ***
294
### Local Variables: ***
287
### mode: sh ***
295
### mode: sh ***
288
### sh-indentation: 2 ***
296
### sh-indentation: 2 ***
289
### End: ***
297
### End: ***