Changeset 1580


Ignore:
Timestamp:
Jun 16, 2010 4:29:31 PM (10 years ago)
Author:
lou
Message:

Added warning when directory holding run_autotools doesn't match BuildTools?
directory. Added trap to remove temporary links on error exit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/run_autotools

    r1562 r1580  
    4747set -e
    4848
     49# Define a cleanup function. We'll set a trap below, just before we start to
     50# do actual work.
     51
     52cleanupOnErrorExit ()
     53{ for link in $topLink $subLink ; do
     54    echo Trap: removing $link
     55    rm -f $link
     56  done
     57  cd $startDir
     58}
     59
    4960# Note that vanilla sh doesn't like negative exit values.
    5061
     62# Determine the location of run_autotools.  If there are no '/' chars in
     63# the command name, we're running in the current directory (almost certainly
     64# not what's wanted). Otherwise, strip the command name, leaving the prefix.
     65
     66startDir=`pwd`
     67if expr "$0" : '.*/.*' >/dev/null 2>&1 ; then
     68  runautotoolDir=`echo $0 | sed -e 's,\(.*\)/[^/]*,\1,'`
     69else
     70  runautotoolDir='.'
     71fi
     72runautotoolDir=$startDir/$runautotoolDir
     73while expr "$runautotoolDir" : '.*/\.\./.*' >/dev/null 2>&1 ; do
     74  runautotoolDir=`echo $runautotoolDir | sed -e 's,/[^/][^/]*/\.\./,/,'`
     75done
     76
    5177# Determine the location of BuildTools. If there's a BuildTools subdirectory
    52 # in the current directory, that's it.  Otherwise, assume that the directory
    53 # holding this run_autotools script is BuildTools.  If there are no '/' chars
    54 # in the command name, we're running in the current directory Otherwise,
    55 # strip the command name, leaving the prefix.
     78# in the current directory, that's it.  Otherwise, assume that runautotooldDir
     79# is BuildTools. Allow that the user may have linked to a BuildTools.
    5680
    5781createLink=0
    58 if test -d BuildTools ; then
     82if test -d BuildTools || test -L BuildTools ; then
    5983  toolsDir=BuildTools
     84  echo toolsDir is $toolsDir
    6085else
    6186  createLink=1
    62   if expr "$0" : '.*/.*' >/dev/null 2>&1 ; then
    63     toolsDir=`echo $0 | sed -e 's,\(.*\)/[^/]*,\1,'`
    64   else
    65     toolsDir='.'
    66   fi
     87  toolsDir=$runautotoolDir
    6788fi
    6889
     
    7394  :
    7495else
    75   toolsDir=`pwd`/$toolsDir
     96  toolsDir=$startDir/$toolsDir
    7697fi
    7798while expr "$toolsDir" : '.*/\.\./.*' >/dev/null 2>&1 ; do
     
    79100done
    80101
     102# Test to be sure that run_autotools is coming from the BuildTools directory.
     103
     104if test $createLink = 0 && test "$toolsDir" != "$runautotoolDir" ; then
     105  echo "WARNING: using run_autotools from $runautotoolDir"
     106  echo "         but BuildTools is $toolsDir."
     107  echo "         Consider carefully if this is what you wanted to do."
     108fi
     109
    81110echo "BuildTools directory: $toolsDir"
    82111
    83 # coin.m4 should live in the same directory.
     112# coin.m4 should live in the same directory, but this failure is fatal.
    84113
    85114if test ! -r $toolsDir/coin.m4 ; then
    86   echo "Cannot find Coin autotools macro file coin.m4. It should"
     115  echo "Cannot find Coin autotools macro file $toolsDir/coin.m4. It should"
    87116  echo "be in the BuildTools directory."
    88 fi
     117  exit 1
     118fi
     119
     120# As is the failure to find the correct versions of autoconf or automake.
    89121
    90122ver_autoconf='2.59'
     
    128160fi
    129161
     162# Failure to find the correct version of libtool isn't fatal here, but
     163# the user should be warned.
     164
    130165grep_version=`echo  $ver_libtool | sed -e 's/\\./\\\\\\./g'`
    131166ltfile=$AUTOTOOLS_DIR/share/libtool/ltmain.sh
    132167if test -r $ltfile; then :; else
    133   echo Cannot file $ltfile
     168  echo WARNING: Cannot file libtool shell $ltfile
    134169fi
    135170if $EGREP $grep_version $ltfile >/dev/null 2>&1; then :; else
    136   echo You are not using the correct verion of libtool
     171  echo WARNING: You are not using the correct version of libtool
    137172fi
    138173
     
    188223fi
    189224
     225# Set a trap so that we'll clean up any links on exit, for whatever reason.
     226# Note that this executes on normal exit, too, so don't do anything rash.
     227
     228topLink=
     229subLink=
     230trap 'exit_status=$?
     231  cleanupOnErrorExit
     232  exit $exit_status' 0
     233
     234# Get down to business
     235
    190236echo "Running autotools in $dirs"
    191237
     
    193239  echo "Creating temporary link for ./BuildTools -> $toolsDir"
    194240  ln -s $toolsDir BuildTools
     241  topLink="$startDir/BuildTools"
    195242fi
    196243
     
    212259m4Files="$AUTOTOOLS_DIR/share/aclocal/libtool.m4 $toolsDir/coin.m4"
    213260for dir in $dirs; do
    214   (if test -r $dir/configure.ac; then
    215      cd $dir
    216      tmpBT=0
    217      echo "Processing $dir ..."
    218      # Avoid repeat actions for current directory (".")
    219      if test -f install-sh && test "$dir" != "." ; then
    220        if test ! -d BuildTools ; then
    221          ln -s $toolsDir BuildTools
    222          tmpBT=1
    223          echo "  creating temporary link for ./BuildTools -> $toolsDir"
    224        fi
    225        echo "  refreshing autotools scripts in this directory."
    226        for file in $autotoolsFiles ; do
    227          cp BuildTools/$file .
    228        done
    229      fi
    230      echo "  creating acinclude.m4 in $dir"
    231      cat $m4Files > acinclude.m4
    232      echo "  running aclocal in $dir"
    233      if test -d m4; then
    234        aclocal -I m4 || exit 1
    235      else
    236        aclocal || exit 1
    237      fi
    238      if grep AC_CONFIG_HEADER configure.ac >/dev/null 2>&1; then
    239        echo "  running autoheader in $dir"
    240        autoheader || exit 1
    241      fi
    242      echo "  running automake in $dir"
    243      automake || exit 1
    244      echo "  running autoconf in $dir"
    245      autoconf || exit 1
    246      if test $tmpBT = 1 ; then
    247        echo "  removing temporary link for ./BuildTools"
    248        rm BuildTools
    249      fi
    250    else
    251      # Serious confusion! Should not reach here.
    252      echo "*** No configure.ac file in $dir - SKIPPING! ***"
    253    fi
    254   )
    255   if test $? -ne 0; then
    256     exit 2;
     261  if test -r $dir/configure.ac; then
     262    cd $dir
     263    tmpBT=0
     264    echo "Processing $dir ..."
     265    # Avoid repeat actions for current directory (".")
     266    if test -f install-sh && test "$dir" != "." ; then
     267      if test ! -d BuildTools ; then
     268        ln -s $toolsDir BuildTools
     269        tmpBT=1
     270        subLink="`pwd`/BuildTools"
     271        echo "  creating temporary link for ./BuildTools -> $toolsDir"
     272      fi
     273      echo "  refreshing autotools scripts in this directory."
     274      for file in $autotoolsFiles ; do
     275        cp BuildTools/$file .
     276      done
     277    fi
     278    echo "  creating acinclude.m4 in $dir"
     279    cat $m4Files > acinclude.m4
     280    echo "  running aclocal in $dir"
     281    if test -d m4; then
     282      aclocal -I m4 || exit 1
     283    else
     284      aclocal || exit 1
     285    fi
     286    if grep AC_CONFIG_HEADER configure.ac >/dev/null 2>&1; then
     287      echo "  running autoheader in $dir"
     288      autoheader || exit 1
     289    fi
     290    echo "  running automake in $dir"
     291    automake || exit 1
     292    echo "  running autoconf in $dir"
     293    autoconf || exit 1
     294    if test $tmpBT = 1 ; then
     295      echo "  removing temporary link for ./BuildTools"
     296      rm BuildTools
     297      subLink=
     298    fi
     299    cd $startDir
     300  else
     301    # Serious confusion! Should not reach here.
     302    echo "*** No configure.ac file in $dir - SKIPPING! ***"
    257303  fi
    258304done
     
    261307  echo "Removing temporary link for ./BuildTools"
    262308  rm BuildTools
    263 fi
     309  topLink=
     310fi
     311
Note: See TracChangeset for help on using the changeset viewer.