The R Project SVN R

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2195 hornik 1
#!/bin/sh
2
#
4580 hornik 3
# ${R_HOME}/bin/SHLIB
2195 hornik 4
 
5
# @configure_input@
6
 
23868 hornik 7
revision='$Revision: 1.28 $'
7357 hornik 8
version=`set - ${revision}; echo ${2}`
11515 hornik 9
version="R shared library builder ${version}
2261 maechler 10
 
23868 hornik 11
Copyright (C) 2000-2003 The R Core Development Team.
11515 hornik 12
This is free software; see the GNU General Public Licence version 2
13
or later for copying conditions.  There is NO warranty."
7357 hornik 14
 
11515 hornik 15
usage="Usage: R CMD SHLIB [options] files
16
 
7357 hornik 17
Build a shared library for dynamic loading from the specified source or
18
object files (which are automagically made from their sources).  If not
20002 hornik 19
given via '--output', the name for the library is determined from the
7357 hornik 20
first file.
21
 
22
Options:
23
  -h, --help		print short help message and exit
11515 hornik 24
  -v, --version		print version info and exit
7357 hornik 25
  -o, --output=LIB	use LIB as (full) name for the built library
26
 
10633 hornik 27
Report bugs to <r-bugs@r-project.org>."
7357 hornik 28
 
29
objs=
12256 pd 30
shlib=
17371 hornik 31
MAKE=${MAKE-'@MAKE@'}
14097 hornik 32
makefiles="-f ${R_HOME}/share/make/shlib.mk"
15168 pd 33
shlib_libadd='@SHLIB_LIBADD@'
9979 hornik 34
with_cxx=false
11221 hornik 35
with_f77=false
2195 hornik 36
 
2261 maechler 37
while test -n "${1}"; do
38
  case ${1} in
7357 hornik 39
    -h|--help)
40
       echo "${usage}"; exit 0 ;;
41
    -v|--version)
42
       echo "${version}"; exit 0 ;;
2261 maechler 43
    -o)
12256 pd 44
      shlib=${2}; shift ;;
7357 hornik 45
    --output=*)
12256 pd 46
      shlib=`echo "${1}" | sed -e 's/[^=]*=//'` ;;
20534 ripley 47
    *.cc|*.cpp|*.C)
9979 hornik 48
      with_cxx=true
12256 pd 49
      if test -z "${shlib}"; then
15659 ripley 50
	shlib="`echo ${1} | sed 's/\.[^\.][^\.]*$/@SHLIB_EXT@/'`"
2261 maechler 51
      fi
7357 hornik 52
      objs="${objs} `echo ${1} | sed 's/\.[^\.][^\.]*$/.o/'`"
2261 maechler 53
      ;;
11221 hornik 54
    *.f)
55
      with_f77=true
12256 pd 56
      if test -z "${shlib}"; then
15659 ripley 57
	shlib="`echo ${1} | sed 's/\.[^\.][^\.]*$/@SHLIB_EXT@/'`"
8653 hornik 58
      fi
59
      objs="${objs} `echo ${1} | sed 's/\.[^\.][^\.]*$/.o/'`"
60
      ;;
11221 hornik 61
    *.[co])
12256 pd 62
      if test -z "${shlib}"; then
15659 ripley 63
	shlib="`echo ${1} | sed 's/\.[^\.][^\.]*$/@SHLIB_EXT@/'`"
11221 hornik 64
      fi
65
      objs="${objs} `echo ${1} | sed 's/\.[^\.][^\.]*$/.o/'`"
66
      ;;
2261 maechler 67
  esac
68
  shift
69
done
70
 
15758 hornik 71
makeobjs="OBJECTS=\"${objs}\""
7699 hornik 72
if test -r Makevars; then
73
  makefiles="-f Makevars ${makefiles}"
12256 pd 74
  if grep '^ *OBJS *=' Makevars >/dev/null; then
15758 hornik 75
    makeobjs="OBJECTS='\$(OBJS)'"
76
  fi
77
  if grep '^ *OBJECTS *=' Makevars >/dev/null; then
12256 pd 78
    makeobjs=
79
  fi
7699 hornik 80
fi
2779 hornik 81
 
12256 pd 82
makeargs="SHLIB=\"${shlib}\""
9979 hornik 83
if ${with_cxx}; then
11618 hornik 84
  makeargs="SHLIB_LDFLAGS='\$(SHLIB_CXXLDFLAGS)' ${makeargs}"
85
  makeargs="SHLIB_LD='\$(SHLIB_CXXLD)' ${makeargs}"
11221 hornik 86
fi
87
if ${with_f77}; then
15168 pd 88
  if test -z "${shlib_libadd}"; then
89
    makeargs="${makeargs} SHLIB_LIBADD='\$(FLIBS)'"
90
  else
91
    makeargs="${makeargs} SHLIB_LIBADD='\$(FLIBS) ${shlib_libadd}'"
92
  fi
9979 hornik 93
fi
7699 hornik 94
 
23868 hornik 95
if test -f ${R_HOME}/bin/libR@DYLIB_EXT@; then
12996 hornik 96
  LIBR="-L${R_HOME}/bin -lR"
97
else
98
  LIBR=
99
fi
100
makeargs="${makeargs} LIBR=\"${LIBR}\""
101
 
12256 pd 102
eval ${MAKE} ${makefiles} ${makeargs} ${makeobjs}
11221 hornik 103
 
2195 hornik 104
### Local Variables: ***
105
### mode: sh ***
7218 hornik 106
### sh-indentation: 2 ***
2195 hornik 107
### End: ***