source: trunk/run_autotools @ 1562

Last change on this file since 1562 was 1562, checked in by lou, 11 years ago

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.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 8.4 KB
Line 
1#!/bin/sh
2
3# Copyright (C) 2006, 2007, 2008, 2009, 2010  International Business Machines
4# and others.
5# All Rights Reserved.
6# This file is distributed under the Common Public License.
7# It is part of the BuildTools project in COIN-OR (www.coin-or.org)
8#
9## $Id: run_autotools 1562 2010-06-11 23:43:09Z lou $
10#
11# 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).
45
46# Make sure we bail out if there is an error
47set -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
89
90ver_autoconf='2.59'
91ver_automake='1.9.6'
92ver_libtool='1.5.22'
93EGREP='grep -E'
94
95# Check if the correct version of the autotools is used
96if test x$AUTOTOOLS_DIR = x; then
97  AUTOTOOLS_DIR=$HOME
98fi
99
100grep_version=`echo  $ver_autoconf | sed -e 's/\\./\\\\\\./g'`
101autoconf --version > confauto.out 2>&1
102if $EGREP $grep_version confauto.out >/dev/null 2>&1; then :; else
103  echo You are not using the correct version of autoconf
104  rm -f confauto.out
105  exit 2
106fi
107rm -f confauto.out
108autoconf_dir=`which autoconf | sed -e 's=/autoconf=='`
109autoconf_dir=`cd $autoconf_dir; pwd`
110if test $autoconf_dir = `cd $AUTOTOOLS_DIR/bin; pwd`; then :; else
111  echo autoconf is not picked up from the correct location
112  exit 2
113fi
114
115grep_version=`echo  $ver_automake | sed -e 's/\\./\\\\\\./g'`
116automake --version > confauto.out 2>&1
117if $EGREP $grep_version confauto.out >/dev/null 2>&1; then :; else
118  echo You are not using the correct version of automake
119  rm -f confauto.out
120  exit 2
121fi
122rm -f confauto.out
123autoconf_dir=`which automake | sed -e 's=/automake=='`
124autoconf_dir=`cd $autoconf_dir; pwd`
125if test $autoconf_dir = `cd $AUTOTOOLS_DIR/bin; pwd`; then :; else
126  echo automake is not picked up from the correct location
127  exit 2
128fi
129
130grep_version=`echo  $ver_libtool | sed -e 's/\\./\\\\\\./g'`
131ltfile=$AUTOTOOLS_DIR/share/libtool/ltmain.sh
132if test -r $ltfile; then :; else
133  echo Cannot file $ltfile
134fi
135if $EGREP $grep_version $ltfile >/dev/null 2>&1; then :; else
136  echo You are not using the correct verion of libtool
137fi
138
139# Find directories which contain a file configure.ac. When all is said and
140# done, each entry in dirs will be of the form `./path/to/directory'
141
142if test $# != 0; then
143  srchDirs="$*"
144else
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
164
165# Now compare against the skip entries in COIN_SKIP_PROJECTS. To match the
166# entries we just collected, add `./' to the front of each skip entry.
167
168candDirs=$dirs
169if test x${COIN_SKIP_PROJECTS+set} = xset ; then
170  dirs=
171  for dir in $COIN_SKIP_PROJECTS ; do
172    skip_dirs="$skip_dirs ./$dir"
173  done
174  for dir in $candDirs ; do
175    skip=0
176    for skipdir in $skip_dirs ; do
177      if test $dir = $skipdir ; then
178        skip=1
179        break
180      fi
181    done
182    if test $skip = 0 ; then
183      dirs="$dirs $dir"
184    else
185      echo "  Skipping $dir listed in COIN_SKIP_PROJECTS."
186    fi
187  done
188fi
189
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"
213for 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;
257  fi
258done
259
260if test $createLink = 1 ; then
261  echo "Removing temporary link for ./BuildTools"
262  rm BuildTools
263fi
Note: See TracBrowser for help on using the repository browser.