Changeset 1596 for trunk/run_autotools
- Timestamp:
- Jul 8, 2010 8:40:44 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/run_autotools
r1595 r1596 15 15 # Directories specified on the command line are recursively searched 16 16 # for configure.ac files. Install-sh signals an independent unit. 17 # Modified: Lou Hafer SFU 2010-07-08 18 # More mods to maintain flexibility but be a bit less aggressive about 19 # forcing installation of autotools auxilliary scripts. Also add some 20 # command line options and restore ability to specify individual 21 # directories on the command line. 17 22 18 23 # run_autotools takes care of running the autotools (automake, autoconf, … … 20 25 # libtool execute at configuration, build, and installation. 21 26 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_. 27 # Run_autotools can be given a set of directories on the command line; if none 28 # are specified, it assumes the current directory (`,'). Subdirectories are 29 # searched for configure.ac files unless suppressed with the -nr option. 30 # Autotools will consider a directory for processing if any AC_COIN_ macro is 31 # present in the configure.ac file. Should it be necessary to fool this script 32 # into processing a file that otherwise contains no COIN macros, just add a 33 # line with AC_COIN_. The resulting list is winnowed to remove directories 34 # specified in COIN_SKIP_PROJECTS. 35 36 # Each directory processed gets a temporary link to BuildTools, unless a 37 # BuildTools subdirectory is already present. Mostly this is a convenience, but 38 # one thing makes it mandatory: Many Makefile.am files in COIN use an include 39 # directive to pull in BuildTools/Makemain.inc. There's no way I (lh) can see 40 # to alter the path that's hardcoded in the include directive. Just to make it 41 # more interesting, COIN projects are generally constructed with the assumption 42 # that BuildTools will be one or two directories up, so you'll see things like 43 # `include ../BuildTools/Makemain.inc'. run_autotools doesn't understand this 44 # hierarchy, so it keeps all those temporary BuildTools links until the very 45 # end. That way, it works with the old-style COIN organisation where a 46 # BuildTools directory is pulled in as an external in the top directory of a 47 # package, and with the new-style independent organisation, where there may be 48 # only a single copy of BuildTools out there somewhere. 41 49 42 50 # 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). 51 # script, it is treated as an independent unit (i.e., you can run `make 52 # install' from this directory) and the set of auxilliary scripts is refreshed 53 # from BuildTools. You can force installation of install-sh and associated 54 # scripts with the -i option. It's good to read the autoconf documentation for 55 # AC_CONFIG_AUX_DIR if this doesn't make sense to you. 45 56 46 57 # Make sure we bail out if there is an error … … 51 62 52 63 cleanupOnErrorExit () 53 { for link in $ topLink $subLink; do64 { for link in $buildtoolsLinks; do 54 65 echo Trap: removing $link 55 66 rm -f $link … … 63 74 # the command name, we're running in the current directory (almost certainly 64 75 # not what's wanted). Otherwise, strip the command name, leaving the prefix. 76 # Convert the prefix to an absolute path, if needed, and clean it up, removing 77 # `XXX/..', '/./', '//' sequences. 65 78 66 79 startDir=`pwd` … … 70 83 runautotoolDir='.' 71 84 fi 72 runautotoolDir=$startDir/$runautotoolDir 85 if expr "$runautotoolDir" : '/.*' >/dev/null 2>&1 ; then 86 : 87 else 88 runautotoolDir=$startDir/$runautotoolDir 89 fi 73 90 while expr "$runautotoolDir" : '.*/\.\./.*' >/dev/null 2>&1 ; do 74 91 runautotoolDir=`echo $runautotoolDir | sed -e 's,/[^/][^/]*/\.\./,/,'` 75 92 done 76 77 # Determine the location of BuildTools. If there's a BuildTools subdirectory 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. 80 81 createLink=0 82 if test -d BuildTools || test -L BuildTools ; then 83 toolsDir=BuildTools 84 else 85 createLink=1 86 toolsDir=$runautotoolDir 87 fi 88 89 # Create an absolute path if we don't have one, because we'll be moving 90 # around. Clean up the path by removing `XXX/..', '/./', '//' sequences. 91 92 if expr "$toolsDir" : '/.*' >/dev/null 2>&1 ; then 93 : 94 else 95 toolsDir=$startDir/$toolsDir 96 fi 97 while expr "$toolsDir" : '.*/\.\./.*' >/dev/null 2>&1 ; do 98 toolsDir=`echo $toolsDir | sed -e 's,/[^/][^/]*/\.\./,/,'` 99 done 100 toolsDir=`echo $toolsDir | sed -e 's,/\./,/,g' -e 's,//,/,g'` 101 102 # Test to be sure that run_autotools is coming from the BuildTools directory. 103 104 if 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." 108 fi 109 110 echo "BuildTools directory: $toolsDir" 111 112 # coin.m4 should live in the same directory, but this failure is fatal. 113 114 if test ! -r $toolsDir/coin.m4 ; then 115 echo "Cannot find Coin autotools macro file $toolsDir/coin.m4. It should" 116 echo "be in the BuildTools directory." 117 exit 1 118 fi 119 120 # As is the failure to find the correct versions of autoconf or automake. 93 runautotoolDir=`echo $runautotoolDir | sed -e 's,/\./,/,g' -e 's,//,/,g'` 94 95 # Make sure we're using the correct versions of the autotools. Failure to 96 # satisfy this requirement is a fatal error. 121 97 122 98 ver_autoconf='2.59' … … 176 152 printHelp=0 177 153 doRecurse=1 154 forceScripts=0 178 155 userSpecifiedDirs=0 179 156 dirsToProcess= … … 190 167 doRecurse=0 191 168 ;; 192 -* ) echo "$0: unrecognised command line switch '"$1"'." 193 printHelp=1 194 ;; 195 * ) dirsToProcess="$dirsToProcess $1" 196 userSpecifiedDirs=1 197 ;; 169 -i | --independent ) 170 forceScripts=1 171 doRecurse=0 172 ;; 173 -* ) echo "$0: unrecognised command line switch '"$1"'." 174 printHelp=1 175 ;; 176 * ) dirsToProcess="$dirsToProcess $1" 177 userSpecifiedDirs=1 178 ;; 198 179 esac 199 180 shift … … 208 189 -h | --help print help message and exit 209 190 -nr | --no-recursion do not do recursive search for configure.ac files 191 -i | --independent install scripts necessary for an independent unit 210 192 211 193 If no directories are specified, the tree rooted at the current directory … … 218 200 If directories are specified on the command line *and* --no-recursion is 219 201 given, the specified directories are processed with no checks. 202 203 The --independent option will force installation of install-sh and other 204 scripts necessary for a unit that is installed independently. This will 205 be forced in *all* directories processed. Most often what is desired is 206 to install these scripts in the top-level directory of a unit, so -i 207 forces -nr. It's a good idea to explicitly specify the directories you want 208 to process. 220 209 EOF 221 210 exit … … 305 294 echo "Running autotools in $dirs" 306 295 307 if test $createLink = 1 ; then 308 echo "Creating temporary link for ./BuildTools -> $toolsDir" 309 ln -s $toolsDir BuildTools 310 topLink="$startDir/BuildTools" 311 fi 312 313 # Copy over files that are used during configure, build, and install. Their 314 # location will be frozen in files created by automake and autoconf, so they 315 # must be present in order to move with the directory tree. 296 # And now the main event. Process each directory. 297 298 echo "Running autotools in $dirs" 316 299 317 300 autotoolsFiles="config.guess config.sub depcomp install-sh ltmain.sh missing" 318 echo "Copying autotools scripts into this directory." 319 for file in $autotoolsFiles ; do 320 cp BuildTools/$file . 321 done 322 323 # And now the main event. Presence of install-sh in a directory is the 324 # trigger for processing as an independent unit. 325 326 echo "Running autotools in $dirs" 327 328 m4Files="$AUTOTOOLS_DIR/share/aclocal/libtool.m4 $toolsDir/coin.m4" 301 m4Files="$AUTOTOOLS_DIR/share/aclocal/libtool.m4" 302 buildtoolsLinks= 303 329 304 for dir in $dirs; do 330 305 if test -r $dir/configure.ac; then 331 306 cd $dir 332 tmpBT=0333 307 echo "Processing $dir ..." 334 # Avoid repeat actions for current directory (".") 335 if test -f install-sh && test "$dir" != "." ; then 336 if test ! -d BuildTools ; then 308 309 # Do we need a BuildTools subdirectory here? The criteria is that install-sh 310 # already exists, or Makefile.am (which may include Makemain.inc), or we're 311 # forcing installation of the configure scripts. Assuming we need BuildTools, 312 # what BuildTools should we use? If a BuildTools is already present, that's 313 # it. Otherwise, assume that runautotooldDir is BuildTools. Allow that the 314 # user may have linked to a BuildTools. 315 316 needScripts=0 317 if test -f install-sh || test $forceScripts = 1 ; then 318 needScripts=1 319 fi 320 if test -f Makefile.am || test $needScripts = 1 ; then 321 if test -d BuildTools || test -L BuildTools ; then 322 createLink=0 323 toolsDir=`pwd`/BuildTools 324 else 325 createLink=1 326 toolsDir=$runautotoolDir 327 fi 328 echo " BuildTools directory: $toolsDir" 329 330 # Test to be sure that run_autotools is coming from the BuildTools directory. 331 332 if test $createLink = 0 && test "$toolsDir" != "$runautotoolDir" ; then 333 echo "WARNING: using run_autotools from $runautotoolDir" 334 echo " but BuildTools is $toolsDir." 335 echo " Consider carefully if this is what you wanted to do." 336 fi 337 338 # coin.m4 should live in the same directory; failure is fatal. 339 340 if test ! -r $toolsDir/coin.m4 ; then 341 echo "Cannot find Coin autotools macro file $toolsDir/coin.m4." 342 echo "It should be in the BuildTools directory." 343 exit 1 344 fi 345 346 # Install a link, if needed. 347 348 if test $createLink = 1 ; then 337 349 ln -s $toolsDir BuildTools 338 tmpBT=1 339 subLink="`pwd`/BuildTools" 350 buildtoolsLinks="$buildtoolsLinks `pwd`/BuildTools" 340 351 echo " creating temporary link for ./BuildTools -> $toolsDir" 341 352 fi 342 echo " refreshing autotools scripts in this directory." 343 for file in $autotoolsFiles ; do 344 cp BuildTools/$file . 345 done 353 354 # And refresh the autotools scripts, if needed. 355 356 if test $needScripts = 1 ; then 357 echo " refreshing autotools scripts in this directory." 358 for file in $autotoolsFiles ; do 359 cp BuildTools/$file . 360 done 361 fi 362 346 363 fi 364 365 # Get on with running the autotools. 366 347 367 echo " creating acinclude.m4 in $dir" 348 cat $m4Files > acinclude.m4368 cat $m4Files $toolsDir/coin.m4 > acinclude.m4 349 369 echo " running aclocal in $dir" 350 370 if test -d m4; then … … 361 381 echo " running autoconf in $dir" 362 382 autoconf || exit 1 363 if test $tmpBT = 1 ; then364 echo " removing temporary link for ./BuildTools"365 rm BuildTools366 subLink=367 fi368 383 cd $startDir 369 384 else … … 373 388 done 374 389 375 if test $createLink = 1 ; then 376 echo "Removing temporary link for ./BuildTools" 377 rm BuildTools 378 topLink= 379 fi 380 390 # Remove the links. Yeah, the trap will do this, but it never hurts to clean 391 # up properly. 392 393 if test -n $buildtoolsLinks ; then 394 echo "Removing temporary links to BuildTools." 395 for link in $buildtoolsLinks ; do 396 # echo " removing temporary link for BuildTools: $link" 397 rm $link 398 done 399 buildtoolsLinks= 400 fi 401 402 exit 403
Note: See TracChangeset
for help on using the changeset viewer.