Changeset 1595


Ignore:
Timestamp:
Jul 8, 2010 5:20:16 PM (9 years ago)
Author:
lou
Message:

Restore command line specification of directories. Add parameters to request
help and suppress recursive search for configure.ac files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/run_autotools

    r1580 r1595  
    8282if test -d BuildTools || test -L BuildTools ; then
    8383  toolsDir=BuildTools
    84   echo toolsDir is $toolsDir
    8584else
    8685  createLink=1
     
    8988
    9089# Create an absolute path if we don't have one, because we'll be moving
    91 # around. Clean up the path by removing `XXX/..' sequences.
     90# around. Clean up the path by removing `XXX/..', '/./', '//' sequences.
    9291
    9392if expr "$toolsDir" : '/.*' >/dev/null 2>&1 ; then
     
    9998  toolsDir=`echo $toolsDir | sed -e 's,/[^/][^/]*/\.\./,/,'`
    10099done
     100toolsDir=`echo $toolsDir | sed -e 's,/\./,/,g' -e 's,//,/,g'`
    101101
    102102# Test to be sure that run_autotools is coming from the BuildTools directory.
     
    172172fi
    173173
    174 # Find directories which contain a file configure.ac. When all is said and
    175 # done, each entry in dirs will be of the form `./path/to/directory'
    176 
    177 if test $# != 0; then
    178   srchDirs="$*"
    179 else
    180   srchDirs='.'
    181 fi
     174# Set up to process parameters. No parameters is the default.
     175
     176printHelp=0
     177doRecurse=1
     178userSpecifiedDirs=0
     179dirsToProcess=
     180
     181# Process the parameters. A parameter without an opening `-' is assumed to be
     182# a spec for a directory to be processed.
     183
     184while test $# -gt 0 && test $printHelp = 0 ; do
     185  case "$1" in
     186    -h* | --h* )
     187         printHelp=1
     188         ;;
     189    -nr* | --no-recursion )
     190         doRecurse=0
     191         ;;
     192     -* ) echo "$0: unrecognised command line switch '"$1"'."
     193          printHelp=1
     194          ;;
     195      * ) dirsToProcess="$dirsToProcess $1"
     196          userSpecifiedDirs=1
     197          ;;
     198  esac
     199  shift
     200done
     201
     202# Help?
     203
     204if test $printHelp = 1 ; then
     205  cat <<EOF
     206usage: run_autotools [-h] [-nr] [ directory directory ... ]
     207
     208  -h  | --help           print help message and exit
     209  -nr | --no-recursion   do not do recursive search for configure.ac files
     210
     211  If no directories are specified, the tree rooted at the current directory
     212  is searched recursively for directories with configure.ac files containing
     213  COIN configuration macros (AC_COIN_*) and autotools is run in those
     214  directories. Directories listed in COIN_SKIP_PROJECTS are skipped.
     215  If directories are specified on the command line, the search for configure.ac
     216  files is restricted to the specified directories.
     217
     218  If directories are specified on the command line *and* --no-recursion is
     219  given, the specified directories are processed with no checks.
     220EOF
     221  exit
     222fi
     223
     224# Did the user give directories on the command line? If not, assume the current
     225# directory.
     226
     227if test -z "$dirsToProcess" ; then
     228  dirsToProcess='.'
     229fi
     230
     231# If recursion is permitted, find directories which contain a file
     232# configure.ac. When all is said and done, each entry in dirs will be of the
     233# form `./path/to/directory'
     234
    182235candDirs=
    183 for dir in $srchDirs ; do
    184   tmp=`find $dir -name configure.ac | sed -e s%/configure.ac%%g`
    185   candDirs="$candDirs $tmp"
    186 done
    187 
    188 # Winnow the candidates. Process a directory only if the configure.ac file
    189 # contains at least one macro that starts with AC_COIN_
    190 
    191 dirs=
    192 for dir in $candDirs; do
    193   if grep AC_COIN_ $dir/configure.ac >/dev/null 2>&1 ; then
    194     dirs="$dirs $dir"
    195   else
    196     echo "  Skipping foreign configure.ac in $dir."
    197   fi
    198 done
     236if test $doRecurse = 1 ; then
     237  for dir in $dirsToProcess ; do
     238    tmp=`find $dir -name configure.ac | sed -e s%/configure.ac%%g`
     239    case "$candDirs" in
     240      *"$tmp"* )
     241          ;;
     242      * )
     243          candDirs="$candDirs $tmp"
     244          ;;
     245      esac
     246  done
     247else
     248  candDirs=$dirsToProcess
     249fi
     250
     251# Did the user specify these directories *and* forbid recursion? In that case,
     252# use the directories exactly as given. If not, winnow the candidates.
     253# Process a directory only if the configure.ac file contains at least one
     254# macro that starts with AC_COIN_, and it's not listed in COIN_SKIP_PROJECTS.
     255
     256if test $userSpecifiedDirs = 1 && test $doRecurse = 0 ; then
     257  dirs=$candDirs
     258else
     259  dirs=
     260  for dir in $candDirs; do
     261    if grep AC_COIN_ $dir/configure.ac >/dev/null 2>&1 ; then
     262      dirs="$dirs $dir"
     263    else
     264      echo "  Skipping foreign configure.ac in $dir."
     265    fi
     266  done
    199267
    200268# Now compare against the skip entries in COIN_SKIP_PROJECTS. To match the
    201269# entries we just collected, add `./' to the front of each skip entry.
    202270
    203 candDirs=$dirs
    204 if test x${COIN_SKIP_PROJECTS+set} = xset ; then
    205   dirs=
    206   for dir in $COIN_SKIP_PROJECTS ; do
    207     skip_dirs="$skip_dirs ./$dir"
    208   done
    209   for dir in $candDirs ; do
    210     skip=0
    211     for skipdir in $skip_dirs ; do
    212       if test $dir = $skipdir ; then
    213         skip=1
    214         break
     271  candDirs=$dirs
     272  if test x${COIN_SKIP_PROJECTS+set} = xset ; then
     273    dirs=
     274    for dir in $COIN_SKIP_PROJECTS ; do
     275      skip_dirs="$skip_dirs ./$dir"
     276    done
     277    for dir in $candDirs ; do
     278      skip=0
     279      for skipdir in $skip_dirs ; do
     280        if test $dir = $skipdir ; then
     281          skip=1
     282          break
     283        fi
     284      done
     285      if test $skip = 0 ; then
     286        dirs="$dirs $dir"
     287      else
     288        echo "  Skipping $dir listed in COIN_SKIP_PROJECTS."
    215289      fi
    216290    done
    217     if test $skip = 0 ; then
    218       dirs="$dirs $dir"
    219     else
    220       echo "  Skipping $dir listed in COIN_SKIP_PROJECTS."
    221     fi
    222   done
     291  fi
    223292fi
    224293
Note: See TracChangeset for help on using the changeset viewer.