# HG changeset patch # User jwe # Date 782171981 0 # Node ID 433ab56e62cd167a31ff93fd8ed6d308bdf62880 # Parent 1865b672511144d86be9efe4202460defda87027 [project @ 1994-10-14 21:58:37 by jwe] diff --git a/doinstall.sh b/doinstall.sh --- a/doinstall.sh +++ b/doinstall.sh @@ -7,55 +7,127 @@ # Department of Chemical Engineering # The University of Texas at Austin +# ask octave to tell us the version number +version=`./octave -v 2>/dev/null | sed -e 's/[^0-9.]*\([0-9.]*\).*/\1/' -e q` + +if test -z "$version" +then + echo "doinstall.sh: unable to extract version number from Octave!" + exit 1 +fi + +# ==================== Where To Install Things ==================== + +# The default location for installation. Everything is placed in +# subdirectories of this directory. The default values for many of +# the variables below are expressed in terms of this one, so you may +# not need to change them. This defaults to /usr/local. prefix=/usr/local -if test $# -eq 1 ; then + +prefix="/usr/local" +if test $# -eq 1 +then prefix=$1 else - if test $# -gt 1 ; then + if test $# -gt 1 + then echo "usage: doinstall.sh [prefix-directory]" exit 1 fi fi -# ask octave to tell us the version number -version=`./octave -v 2>/dev/null | sed -e 's/[^0-9.]*\([0-9.]*\).*/\1/' -e q` +# Like `prefix', but used for architecture-specific files. +exec_prefix="$prefix" + +# Where to install Octave and other binaries that people will want to +# run directly. +bindir="$exec_prefix/bin" + +# Where to install architecture-independent data files. ${fcnfiledir} +# and ${localfcnfiledir} are subdirectories of this. +datadir="$prefix/lib" + +# Where to install and expect libraries like libcruft.a, liboctave.a, +# and libreadline.a, executable files to be run by Octave rather than +# directly by users, and other architecture-dependent data. +# ${archlibdir} is a subdirectory of this. +libdir="$exec_prefix/lib" -if test -z "$version" ; then - echo "doinstall.sh: unable to extract version number from Octave!" - exit 1 -fi +# Where to install Octave's include files. The default is +# ${prefix}/include/octave +includedir="$prefix/include/octave" + +# Where to install Octave's man pages, and what extension they should +# have. The default is ${prefix}/man/man1 +mandir="$prefix/man/man1" +manext="1" + +# Where to install and expect the info files describing Octave.. +infodir="$prefix/info" + +# ==================== Octave-specific directories ==================== + +# These variables hold the values Octave will actually use. They are +# based on the values of the standard Make variables above. -# where to install binaries. -bindir=$prefix/bin +# Where to install the function file distributed with +# Octave. This includes the Octave version, so that the +# function files for different versions of Octave will install +# themselves in separate directories. +fcnfiledir="$datadir/octave/$version/m" + +# Directories Octave should search for function files specific +# to this site (i.e. customizations), before consulting +# ${fcnfiledir}. This should be a colon-separated list of +# directories. +localfcnfilepath="$datadir/octave/site/m//" + +# Where to put executables to be run by Octave rather than +# the user. This path usually includes the Octave version +# and configuration name, so that multiple configurations +# for multiple versions of Octave may be installed at once. +archlibdir="$libdir/octave/$version/exec/$target_host_type" -# where to install M-files -libsubdir=$prefix/lib/octave/$version +# Where to put object files that will by dynamically loaded. +# This path usually includes the Octave version and configuration +# name, so that multiple configurations for multiple versions of +# Octave may be installed at once. +octfiledir="$libdir/octave/$version/oct/$target_host_type" -# where to install Info files -infodir=$prefix/info +# Directories Octave should search for object files that will be +# dynamically loaded and that are specific to this site +# (i.e. customizations), before consulting ${octfiledir}. This should +# be a colon-separated list of directories. +localoctfilepath="$datadir/octave/site/oct/$target_host_type//" + +# Where Octave will search to find its function files. Before +# changing this, check to see if your purpose wouldn't +# better be served by changing localfcnfilepath. This +# should be a colon-separated list of directories. +fcnfilepath=".:$localoctfilepath:$localfcnfilepath:$octfiledir//:$fcnfiledir//" + +# Where Octave will search to find image files. +imagedir="$fcnfiledir/imagelib" +imagepath=".:$imagedir//" cat << EOF -Installing octave in subdirectories of $prefix: +Installing octave in subdirectories of $prefix. - Binaries: $bindir - M-files: $libsubdir - Info files: $infodir + Binaries: $bindir + Function files: $fcnfiledir + Info files: $infodir + Man page: $mandir EOF -for d in $bindir $libsubdir $infodir ; do - if test -d $d ; then - true - else - echo "making $d" - ./mkpath $d - chmod 755 $d - fi -done -chmod 755 $prefix/lib -chmod 755 $prefix/lib/octave +DIRS_TO_MAKE="$bindir $datadir $libdir $includedir $mandir $infodir \ + $fcnfiledir $archlibdir $octfiledir $imagedir" -if test "$prefix" = /usr/local ; then +./mkinstalldirs $DIRS_TO_MAKE +chmod 755 $DIRS_TO_MAKE + +if test "$prefix" = /usr/local +then echo "installing ./octave as $bindir/octave" cp ./octave $bindir/octave chmod 755 $bindir/octave @@ -70,20 +142,25 @@ chmod 755 $bindir/octave.bin fi -echo "installing M-files in $libsubdir" -for f in scripts/*.m ; do - file=`basename $f` - echo $file - cp $f $libsubdir/$file - chmod 644 $libsubdir/$file -done +echo "installing function files in $fcnfiledir" +( cd scripts + ../mkinstalldirs `find . -type d | sed "s,^,$fcnfiledir/,"` + for f in `find . -name '*.m'` + do + cp $f $fcnfiledir/$f + chmod 644 $fcnfiledir/$f + done ) echo "installing info files in $infodir" -for f in doc/octave.info* ; do +for f in doc/octave.info* +do file=`basename $f` - echo $file cp $f $infodir/$file chmod 644 $infodir/$file done +echo "installing man page in $mandir" +cp doc/octave.1 $mandir/octave.$manext +chmod 644 $mandir/octave.$manext + exit 0 diff --git a/src/variables.cc b/src/variables.cc --- a/src/variables.cc +++ b/src/variables.cc @@ -288,15 +288,18 @@ int count = 0; char *ptr = s; - while (strstr (ptr, prefix)) + char *next = 0; + while ((next = strstr (ptr, prefix))) { - ptr += len_prefix; + ptr = next + len_prefix; count++; } int grow_size = count * (len_home - len_prefix); - int len_retval = strlen (s) + grow_size; + int len_s = strlen (s); + + int len_retval = len_s + count * grow_size; retval = new char [len_retval+1]; @@ -304,21 +307,23 @@ char *p2 = p1; char *pdest = retval; - for (int i = 0; i < count; i++) +// Is this really a good way to do this? + + while (count >= 0) { p2 = strstr (p1, prefix); if (! p2) { - error ("unable to substitute OCTAVE_HOME"); - return retval; + memcpy (pdest, p1, strlen (p1)+1); + break; } - - if (p1 == p2) + else if (p1 == p2) { memcpy (pdest, home, len_home); pdest += len_home; p1 += len_prefix; + count--; } else {