Changeset 1562


Ignore:
Timestamp:
Jun 11, 2010 7:43:09 PM (10 years ago)
Author:
lou
Message:

Substantial revisions to allow more independent placement of projects.
BuildTools? can be anywere. Directory where run_autotools executes is assumed
to be the top of an independent unit. Configure.ac in subdirectories processed
based on presence of AC_COIN_ macros. Presence of install-sh triggers
processing as an independent unit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/run_autotools

    r1191 r1562  
    11#!/bin/sh
    22
    3 # Copyright (C) 2006, 2007  International Business Machines.
     3# Copyright (C) 2006, 2007, 2008, 2009, 2010  International Business Machines
     4# and others.
    45# All Rights Reserved.
    56# This file is distributed under the Common Public License.
     
    910#
    1011# Author: Andreas Waechter     IBM      2006-04-14
     12# Modified: Lou Hafer          SFU      2010-06-11
     13#      Mods to allow variations from standard package structure. Decision to
     14#      process a configure.ac file is based on presence of COIN macros.
     15#      Directories specified on the command line are recursively searched
     16#      for configure.ac files. Install-sh signals an independent unit.
     17
     18# run_autotools takes care of running the autotools (automake, autoconf,
     19# and helpers) and also makes a few arrangements for when configure and
     20# libtool execute at configuration, build, and installation.
     21
     22# The operating assumption is that run_autotools is run in the top level of a
     23# directory tree, and that directory tree is the top of an independent unit. If
     24# there is no BuildTools subdirectory present, run_autotools will create
     25# a link to the directory where it lives, which is assumed to be a BuildTools
     26# directory somewhere else. The advantage to this approach is that BuildTools
     27# appears to live in a known location (constant within the directory tree
     28# of the unit).  This is necessary for proper handling by automake of some
     29# standard COIN includes in Makefile.am which reference files in BuildTools.
     30# run_autotools will also copy a number of autotools scripts (required for
     31# build and installation of any independent unit) from BuildTools into the
     32# directory where it is run. This, too, is required. The location of these
     33# files is frozen when automake and autoconf run, and they must move with
     34# the independent unit because they will be required when configure is run
     35# and the unit is built and installed.
     36
     37# Subdirectories are searched for configure.ac files. Autotools will be run
     38# in these directories if any AC_COIN_ macro is present in the configure.ac
     39# file. Should it be necessary to fool this script into processing a file that
     40# otherwise contains no COIN macros, just add a line with AC_COIN_.
     41
     42# If any subdirectory queued for processing is found to contain an install-sh
     43# script, it is treated as an independent unit (BuildTools link and script
     44# copies).
    1145
    1246# Make sure we bail out if there is an error
    1347set -e
     48
     49# Note that vanilla sh doesn't like negative exit values.
     50
     51# 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.
     56
     57createLink=0
     58if test -d BuildTools ; then
     59  toolsDir=BuildTools
     60else
     61  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
     67fi
     68
     69# Create an absolute path if we don't have one, because we'll be moving
     70# around. Clean up the path by removing `XXX/..' sequences.
     71
     72if expr "$toolsDir" : '/.*' >/dev/null 2>&1 ; then
     73  :
     74else
     75  toolsDir=`pwd`/$toolsDir
     76fi
     77while expr "$toolsDir" : '.*/\.\./.*' >/dev/null 2>&1 ; do
     78  toolsDir=`echo $toolsDir | sed -e 's,/[^/][^/]*/\.\./,/,'`
     79done
     80
     81echo "BuildTools directory: $toolsDir"
     82
     83# coin.m4 should live in the same directory.
     84
     85if test ! -r $toolsDir/coin.m4 ; then
     86  echo "Cannot find Coin autotools macro file coin.m4. It should"
     87  echo "be in the BuildTools directory."
     88fi
    1489
    1590ver_autoconf='2.59'
     
    28103  echo You are not using the correct version of autoconf
    29104  rm -f confauto.out
    30   exit -2
     105  exit 2
    31106fi
    32107rm -f confauto.out
     
    35110if test $autoconf_dir = `cd $AUTOTOOLS_DIR/bin; pwd`; then :; else
    36111  echo autoconf is not picked up from the correct location
    37   exit -2
     112  exit 2
    38113fi
    39114
     
    43118  echo You are not using the correct version of automake
    44119  rm -f confauto.out
    45   exit -2
     120  exit 2
    46121fi
    47122rm -f confauto.out
     
    50125if test $autoconf_dir = `cd $AUTOTOOLS_DIR/bin; pwd`; then :; else
    51126  echo automake is not picked up from the correct location
    52   exit -2
     127  exit 2
    53128fi
    54129
     
    66141
    67142if test $# != 0; then
    68   dirs="$*"
     143  srchDirs="$*"
    69144else
    70   pos_dirs=`find . -name configure.ac | sed -e s%/configure.ac%%g | grep -v 'ThirdParty/[^/]*/[^/]*'`
    71   dirs=
    72   for dir in $pos_dirs; do
    73     if test -r $dir/configure.ac; then
    74       dirs="$dirs $dir"
    75     else
    76       echo "$dir/configure.ac doesn't appear to be a regular file; skipping."
    77     fi
    78   done
    79 fi
     145  srchDirs='.'
     146fi
     147candDirs=
     148for dir in $srchDirs ; do
     149  tmp=`find $dir -name configure.ac | sed -e s%/configure.ac%%g`
     150  candDirs="$candDirs $tmp"
     151done
     152
     153# Winnow the candidates. Process a directory only if the configure.ac file
     154# contains at least one macro that starts with AC_COIN_
     155
     156dirs=
     157for dir in $candDirs; do
     158  if grep AC_COIN_ $dir/configure.ac >/dev/null 2>&1 ; then
     159    dirs="$dirs $dir"
     160  else
     161    echo "  Skipping foreign configure.ac in $dir."
     162  fi
     163done
    80164
    81165# Now compare against the skip entries in COIN_SKIP_PROJECTS. To match the
    82166# entries we just collected, add `./' to the front of each skip entry.
    83167
    84 pos_dirs=$dirs
     168candDirs=$dirs
    85169if test x${COIN_SKIP_PROJECTS+set} = xset ; then
    86170  dirs=
     
    88172    skip_dirs="$skip_dirs ./$dir"
    89173  done
    90   for dir in $pos_dirs ; do
     174  for dir in $candDirs ; do
    91175    skip=0
    92176    for skipdir in $skip_dirs ; do
     
    99183      dirs="$dirs $dir"
    100184    else
    101       echo "$dir listed in COIN_SKIP_PROJECTS; skipping."
     185      echo "  Skipping $dir listed in COIN_SKIP_PROJECTS."
    102186    fi
    103187  done
    104188fi
    105189
    106 echo Running autotools in $dirs
    107 
    108 currdir=`pwd`
    109 if test -r $currdir/BuildTools/coin.m4; then
    110   toolsdir=$currdir/BuildTools
    111 else
    112   echo Cannot find BuildTools directory.
    113   exit
    114 fi
    115 
    116 echo Copying autotools scripts into this directory
    117 cp $toolsdir/config.guess $toolsdir/config.sub $toolsdir/depcomp $toolsdir/install-sh $toolsdir/ltmain.sh $toolsdir/missing .
    118 
    119 if test x$AUTOTOOLS_DIR = x; then
    120   AUTOTOOLS_DIR=$HOME
    121 fi
    122 
     190echo "Running autotools in $dirs"
     191
     192if test $createLink = 1 ; then
     193  echo "Creating temporary link for ./BuildTools -> $toolsDir"
     194  ln -s $toolsDir BuildTools
     195fi
     196
     197# Copy over files that are used during configure, build, and install. Their
     198# location will be frozen in files created by automake and autoconf, so they
     199# must be present in order to move with the directory tree.
     200
     201autotoolsFiles="config.guess config.sub depcomp install-sh ltmain.sh missing"
     202echo "Copying autotools scripts into this directory."
     203for file in $autotoolsFiles ; do
     204  cp BuildTools/$file .
     205done
     206
     207# And now the main event.  Presence of install-sh in a directory is the
     208# trigger for processing as an independent unit.
     209
     210echo "Running autotools in $dirs"
     211
     212m4Files="$AUTOTOOLS_DIR/share/aclocal/libtool.m4 $toolsDir/coin.m4"
    123213for dir in $dirs; do
    124214  (if test -r $dir/configure.ac; then
    125215     cd $dir
    126      echo creating acinclude.m4 in $dir
    127      cat $AUTOTOOLS_DIR/share/aclocal/libtool.m4 $toolsdir/coin.m4> acinclude.m4
    128      echo running aclocal in $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"
    129233     if test -d m4; then
    130        aclocal -I m4 || exit -1
     234       aclocal -I m4 || exit 1
    131235     else
    132        aclocal || exit -1
     236       aclocal || exit 1
    133237     fi
    134238     if grep AC_CONFIG_HEADER configure.ac >/dev/null 2>&1; then
    135        echo running autoheader in $dir
    136        autoheader || exit -1
    137      fi
    138      echo running automake in $dir
    139      automake || exit -1
    140      echo running autoconf in $dir
    141      autoconf || exit -1
     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
    142250   else
     251     # Serious confusion! Should not reach here.
    143252     echo "*** No configure.ac file in $dir - SKIPPING! ***"
    144253   fi
    145254  )
    146255  if test $? -ne 0; then
    147     exit -2;
     256    exit 2;
    148257  fi
    149258done
     259
     260if test $createLink = 1 ; then
     261  echo "Removing temporary link for ./BuildTools"
     262  rm BuildTools
     263fi
Note: See TracChangeset for help on using the changeset viewer.