Changeset 1562 for trunk/run_autotools
- Timestamp:
- Jun 11, 2010 7:43:09 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/run_autotools
r1191 r1562 1 1 #!/bin/sh 2 2 3 # Copyright (C) 2006, 2007 International Business Machines. 3 # Copyright (C) 2006, 2007, 2008, 2009, 2010 International Business Machines 4 # and others. 4 5 # All Rights Reserved. 5 6 # This file is distributed under the Common Public License. … … 9 10 # 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). 11 45 12 46 # Make sure we bail out if there is an error 13 47 set -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 57 createLink=0 58 if test -d BuildTools ; then 59 toolsDir=BuildTools 60 else 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 67 fi 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 72 if expr "$toolsDir" : '/.*' >/dev/null 2>&1 ; then 73 : 74 else 75 toolsDir=`pwd`/$toolsDir 76 fi 77 while expr "$toolsDir" : '.*/\.\./.*' >/dev/null 2>&1 ; do 78 toolsDir=`echo $toolsDir | sed -e 's,/[^/][^/]*/\.\./,/,'` 79 done 80 81 echo "BuildTools directory: $toolsDir" 82 83 # coin.m4 should live in the same directory. 84 85 if 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." 88 fi 14 89 15 90 ver_autoconf='2.59' … … 28 103 echo You are not using the correct version of autoconf 29 104 rm -f confauto.out 30 exit -2105 exit 2 31 106 fi 32 107 rm -f confauto.out … … 35 110 if test $autoconf_dir = `cd $AUTOTOOLS_DIR/bin; pwd`; then :; else 36 111 echo autoconf is not picked up from the correct location 37 exit -2112 exit 2 38 113 fi 39 114 … … 43 118 echo You are not using the correct version of automake 44 119 rm -f confauto.out 45 exit -2120 exit 2 46 121 fi 47 122 rm -f confauto.out … … 50 125 if test $autoconf_dir = `cd $AUTOTOOLS_DIR/bin; pwd`; then :; else 51 126 echo automake is not picked up from the correct location 52 exit -2127 exit 2 53 128 fi 54 129 … … 66 141 67 142 if test $# != 0; then 68 dirs="$*"143 srchDirs="$*" 69 144 else 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='.' 146 fi 147 candDirs= 148 for dir in $srchDirs ; do 149 tmp=`find $dir -name configure.ac | sed -e s%/configure.ac%%g` 150 candDirs="$candDirs $tmp" 151 done 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 156 dirs= 157 for 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 163 done 80 164 81 165 # Now compare against the skip entries in COIN_SKIP_PROJECTS. To match the 82 166 # entries we just collected, add `./' to the front of each skip entry. 83 167 84 pos_dirs=$dirs168 candDirs=$dirs 85 169 if test x${COIN_SKIP_PROJECTS+set} = xset ; then 86 170 dirs= … … 88 172 skip_dirs="$skip_dirs ./$dir" 89 173 done 90 for dir in $ pos_dirs ; do174 for dir in $candDirs ; do 91 175 skip=0 92 176 for skipdir in $skip_dirs ; do … … 99 183 dirs="$dirs $dir" 100 184 else 101 echo " $dir listed in COIN_SKIP_PROJECTS; skipping."185 echo " Skipping $dir listed in COIN_SKIP_PROJECTS." 102 186 fi 103 187 done 104 188 fi 105 189 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 190 echo "Running autotools in $dirs" 191 192 if test $createLink = 1 ; then 193 echo "Creating temporary link for ./BuildTools -> $toolsDir" 194 ln -s $toolsDir BuildTools 195 fi 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 201 autotoolsFiles="config.guess config.sub depcomp install-sh ltmain.sh missing" 202 echo "Copying autotools scripts into this directory." 203 for file in $autotoolsFiles ; do 204 cp BuildTools/$file . 205 done 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 210 echo "Running autotools in $dirs" 211 212 m4Files="$AUTOTOOLS_DIR/share/aclocal/libtool.m4 $toolsDir/coin.m4" 123 213 for dir in $dirs; do 124 214 (if test -r $dir/configure.ac; then 125 215 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" 129 233 if test -d m4; then 130 aclocal -I m4 || exit -1234 aclocal -I m4 || exit 1 131 235 else 132 aclocal || exit -1236 aclocal || exit 1 133 237 fi 134 238 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 142 250 else 251 # Serious confusion! Should not reach here. 143 252 echo "*** No configure.ac file in $dir - SKIPPING! ***" 144 253 fi 145 254 ) 146 255 if test $? -ne 0; then 147 exit -2;256 exit 2; 148 257 fi 149 258 done 259 260 if test $createLink = 1 ; then 261 echo "Removing temporary link for ./BuildTools" 262 rm BuildTools 263 fi
Note: See TracChangeset
for help on using the changeset viewer.