| 1 | #! /bin/sh |
| 2 | # |
| 3 | # Encapsulates set/access of a components file, which records set of |
| 4 | # components that were built in a library. Intended to be used by |
| 5 | # GNUmakefiles and scripts. See ACE_wrappers/ace/GNUmakefile for an |
| 6 | # example. |
| 7 | # |
| 8 | usage="usage: $0 --ace | --orbsvcs | --tao \ |
| 9 | [--remove | --set \" <components list> \"]" |
| 10 | |
| 11 | #### |
| 12 | #### Make sure that ACE_ROOT, and TAO_ROOT are set. |
| 13 | #### |
| 14 | if [ ! "$ACE_ROOT" ]; then |
| 15 | echo $0': your ACE_ROOT environment variable is not set!' 1>&2 |
| 16 | exit -1 |
| 17 | fi |
| 18 | if [ ! "$TAO_ROOT" ]; then |
| 19 | TAO_ROOT=$ACE_ROOT/TAO |
| 20 | export TAO_ROOT |
| 21 | fi |
| 22 | |
| 23 | #### |
| 24 | #### Process command line arguments. |
| 25 | #### |
| 26 | if [ $# -ge 1 ]; then |
| 27 | case $1 in |
| 28 | --ace) components_file=$ACE_ROOT/ace/ACE_COMPONENTS.list ;; |
| 29 | --orbsvcs) |
| 30 | components_file=$TAO_ROOT/orbsvcs/orbsvcs/ORBSVCS_COMPONENTS.list ;; |
| 31 | --tao) components_file=$TAO_ROOT/tao/TAO_COMPONENTS.list ;; |
| 32 | *) echo $usage; exit -1 ;; |
| 33 | esac |
| 34 | shift |
| 35 | else |
| 36 | echo $usage |
| 37 | exit -1 |
| 38 | fi |
| 39 | |
| 40 | set_components=0 |
| 41 | append_components=0 |
| 42 | if [ $# -ge 1 ]; then |
| 43 | if [ $1 = '--set' ]; then |
| 44 | set_components=1 |
| 45 | shift |
| 46 | if [ $# -eq 1 ]; then |
| 47 | components=$1 |
| 48 | shift |
| 49 | else |
| 50 | echo $usage |
| 51 | exit -1 |
| 52 | fi |
| 53 | elif [ $1 = '--append' ]; then |
| 54 | append_components=1 |
| 55 | shift |
| 56 | if [ $# -eq 1 ]; then |
| 57 | components=$1 |
| 58 | shift |
| 59 | else |
| 60 | echo $usage |
| 61 | exit -1 |
| 62 | fi |
| 63 | elif [ $1 = '--remove' ]; then |
| 64 | rm -f $components_file |
| 65 | else |
| 66 | echo $usage |
| 67 | exit -1 |
| 68 | fi |
| 69 | fi |
| 70 | |
| 71 | if [ $set_components -eq 1 ]; then |
| 72 | #### |
| 73 | #### Update the components file, if it has changed since last set. |
| 74 | #### |
| 75 | if [ -f $components_file ]; then |
| 76 | if echo "$components" | diff - $components_file > /dev/null; then |
| 77 | : |
| 78 | else |
| 79 | echo "$components" > $components_file |
| 80 | fi |
| 81 | else |
| 82 | echo "$components" > $components_file |
| 83 | fi |
| 84 | elif [ $append_components -eq 1 ]; then |
| 85 | #### |
| 86 | #### Update the components file, if it has changed since last set. |
| 87 | #### |
| 88 | if [ -f $components_file ]; then |
| 89 | if cat $components_file | grep "$components" > /dev/null; then |
| 90 | : |
| 91 | else |
| 92 | (cat $components_file; echo "$components") | tr ' ' '\012' | sort -u > $components_file.$$ |
| 93 | mv -f $components_file.$$ $components_file |
| 94 | fi |
| 95 | else |
| 96 | echo "$components" > $components_file |
| 97 | fi |
| 98 | else |
| 99 | #### |
| 100 | #### Access the contents of the components file, if it exists. |
| 101 | #### |
| 102 | if [ -f $components_file ]; then |
| 103 | cat $components_file |
| 104 | fi |
| 105 | fi |