Index: mttroot/mtt/bin/mtt ================================================================== --- mttroot/mtt/bin/mtt +++ mttroot/mtt/bin/mtt @@ -12,10 +12,13 @@ ############################################################### ## Version control history ############################################################### ## $Header$ ## $Log$ +## Revision 1.163 1998/07/17 08:27:33 peterg +## Added find target +## ## Revision 1.162 1998/07/16 16:14:27 peterg ## Now stops if a transformation forces error. ## ## Revision 1.161 1998/07/08 11:21:32 peterg ## Added -I switch @@ -620,10 +623,11 @@ mtt_switches="$mtt_switches $1"; debug=debug ;; -v ) mtt_switches="$mtt_switches $1"; info_switch='-I'; + Verbose='verbose'; verbose=' -w ' ;; -I ) mtt_switches="$mtt_switches $1"; info_switch='-I' ;; -t ) @@ -632,11 +636,11 @@ tidy=tidy; verytidy=verytidy ;; -u ) tidy=untidy ;; -l ) - mtt_switches="$mtt_switches $1"; + mtt_switches="$mtt_switches $1 $2"; level=$2; shift ;; -A ) mtt_switches="$mtt_switches $1"; Solving='Solving';; --version) @@ -661,10 +665,15 @@ if [ -n "$directory" ]; then echo Using directory $directory echo fi fi + +#Print what's going on if in verbose mode +if [ -n "$Verbose" ]; then + echo Starting mtt $mtt_switches $1 $2 $3 $4 +fi #Check the principle paths mtt_check_vars $print # Exit if just printing paths @@ -896,37 +905,49 @@ exit fi # Copy components from the library if [ "$1" = "compcopy" ]; then + + #Pull out the base name (we may have a library as well) + name=`basename $2` + #set up source and destination dirs source=$3 if [ -z "$source" ]; then - source=$MTTPATH/lib/comp/compound + source=$MTT_COMPONENTS fi destination=$4 if [ -z "$destination" ]; then destination='.' fi # check that its not here already - file_exists=`ls $destination/$2_abg.fig 2> /dev/null` + file_exists=`ls $destination/"$name"_lbl.txt 2> /dev/null` if [ -n "$file_exists" ]; then if [ "$quiet" != "quiet" ]; then - echo $destination/$2_abg.fig exists already - no action taken + echo Component $name exists already - no action taken fi else - if [ -z "$source" ]; then - source=$MTTPATH/lib/comp/compound - fi - # if [ "$quiet" != "quiet" ]; then - echo Copying component $2 from $source to $destination - # fi if [ $source = "." ]; then cp -u *_*.* $destination else - find $source -name "$2_*.*" -exec cp {} $destination \; + comp_path=`mtt_find $source $2 path_only` + n_found=`echo $comp_path | wc | awk '{print $2}'` + + if [ "$n_found" = "1" ]; then + echo Copying $2 from $comp_path to $destination + cp $comp_path/*_*.* $destination + exit 0 + elif [ "$n_found" = "0" ]; then + echo Component $2 not found - is MTT_COMPONENTS set correctly? + exit 1 + elif [ "$n_found" > "1" ]; then + echo "Multiple versions of $2 found (see below) - use a more explicit alias" + mtt -q find $2 + exit 2 + fi fi fi exit fi @@ -1078,11 +1099,11 @@ mtt -u -q $mtt_switches -S "$Directory" $1 $2 $3 $4 mtt_status=$? # Exit on failure if [ "$mtt_status" != "0" ]; then - echo Exiting mtt with status $mtt_status + echo Exiting MTT with error $mtt_status exit 1 fi if [ "$3" != "view" ]; then if [ "$3" != "hview" ]; then @@ -1119,11 +1140,11 @@ %.dvi: %.tex # If level>0, try and get subsystem files ifneq ("$level","0") $1_abg.fig: - mtt -q -u compcopy $1 + mtt -q -u $mtt_switches compcopy $1 || exit 1 endif # Create an arg file if it doesn't exist $1_args.m: @@ -1456,12 +1477,13 @@ sub_sh2tex -l $1 endif #SUMMARY abg acausal bond graph (m) #Raw bond graph to acausal bond graph: mfile -$1_abg.m: $1_rbg.m $1_alias.m $1_sub.sh - sh $1_sub.sh "mtt $mtt_switches -q -u -l $level+1 " ' abg m' +$1_abg.m: $1_rbg.m $1_alias.m $1_sub.sh + lbl2component $1 | sh || exit 1 + (sh $1_sub.sh "mtt $mtt_switches -q -u -l $level+1 " ' abg m null || exit 1') || exit 1 rbg2abg_m $info_switch $1 #SUMMARY cbg causal bond graph (m) #Acausal bond graph to causal bond graph: mfile @@ -2034,9 +2056,17 @@ else echo Debugging - log files retained in LOGFILES mkdir -p LOGFILES mv -f *.log LOGFILES fi + +#Print what's going on if in verbose mode +if [ -n "$Verbose" ]; then + echo Finishing mtt $mtt_switches $1 $2 $3 $4 +fi if [ "$make_status" != "0" ]; then - exit 2 + echo Exiting MTT with error $make_status + exit 1 fi + +