| 1 |
#!/bin/csh |
| 2 |
################################################################ |
| 3 |
## Copyright (C) 1998,1999 Joergen Backelin |
| 4 |
## |
| 5 |
## Bergman is distributed in the hope that it will be useful, |
| 6 |
## but WITHOUT ANY WARRANTY. No author or distributor |
| 7 |
## accepts responsibility to anyone for the consequences of using it |
| 8 |
## or for whether it serves any particular purpose or works at all, |
| 9 |
## unless (s)he says so in writing. Refer to the Bergman General |
| 10 |
## Public License for full details. |
| 11 |
|
| 12 |
## Everyone is granted permission to copy, modify and redistribute |
| 13 |
## bergman, but only under the conditions described in the |
| 14 |
## Bergman General Public License. A copy of this license is |
| 15 |
## supposed to have been given to you along with bergman so you |
| 16 |
## can know your rights and responsibilities. It should be in a |
| 17 |
## file named copyright. Among other things, the copyright notice |
| 18 |
## and this notice must be preserved on all copies. |
| 19 |
################################################################ |
| 20 |
|
| 21 |
# This might be called from a shell where the bergman |
| 22 |
# environment variables are set. Alternatively: |
| 23 |
#source ../bin/$MACHINE/shellenv #or something |
| 24 |
|
| 25 |
# However, the machine type is relevant only for the conv |
| 26 |
# variant to employ. Thus in this variant all relevant stuff simply |
| 27 |
# should be given as five arguments, in the following order: |
| 28 |
# src, auxil, xsrc, xauxil, conv. |
| 29 |
|
| 30 |
# CHANGES: |
| 31 |
|
| 32 |
# 2001-08-17: Added *version files./JoeB |
| 33 |
|
| 34 |
# 2000-08-11: Added fv* and version files./JoeB |
| 35 |
|
| 36 |
# 1999-11-26: Corrected -nt file compare test to -ot. |
| 37 |
|
| 38 |
if ($#argv != 5) then |
| 39 |
echo wrong number of arguments to caseconv\; should be 5, is $#argv |
| 40 |
exit |
| 41 |
endif |
| 42 |
|
| 43 |
if ( ! ( -d $1)) then |
| 44 |
echo \ The argument $1 to caseconv should have been a directory, |
| 45 |
echo the original bergman source directory. |
| 46 |
exit |
| 47 |
endif |
| 48 |
|
| 49 |
if ( ! ( -d $2)) then |
| 50 |
echo \ The argument $2 to caseconv should have been a directory, |
| 51 |
echo the original bergman auxiliary files directory. |
| 52 |
exit |
| 53 |
endif |
| 54 |
|
| 55 |
if ( ! ( -d $3 || { mkdir $3 } )) then |
| 56 |
echo \ The argument $3 to caseconv should have been a directory, |
| 57 |
echo or have been possible to create as a new directory, |
| 58 |
echo the switched cases bergman source directory. |
| 59 |
exit |
| 60 |
endif |
| 61 |
|
| 62 |
if ( ! ( -d $4 || { mkdir $4 } )) then |
| 63 |
echo \ The argument $4 to caseconv should have been a directory, |
| 64 |
echo or have been possible to create as a new directory, |
| 65 |
echo the switched cases bergman auxiliary files directory. |
| 66 |
exit |
| 67 |
endif |
| 68 |
|
| 69 |
# We also should have the rights to make subdirectories and write |
| 70 |
# on the catalogues 3 and 4. For the purpose, I create temporary |
| 71 |
# directories Tstwrpr.tmp. If this doesn't work, then we exit with |
| 72 |
# an error message. |
| 73 |
|
| 74 |
# In theory, one reason for failure could be the user having created |
| 75 |
# a file or a directory with this name. However, the use of permanent |
| 76 |
# "tmp" files is not recommended ... . |
| 77 |
|
| 78 |
if ( ! { mkdir $3/Tstwrpr.tmp } ) then |
| 79 |
echo \ I could not write Tstwrpr.tmp on $3, whence I exit |
| 80 |
echo Check your write access and try again |
| 81 |
exit |
| 82 |
endif |
| 83 |
rmdir $3/Tstwrpr.tmp |
| 84 |
|
| 85 |
if ( ! { mkdir $4/Tstwrpr.tmp } ) then |
| 86 |
echo \ I could not write Tstwrpr.tmp on $4, whence I exit |
| 87 |
echo Check your write access and try again |
| 88 |
exit |
| 89 |
endif |
| 90 |
rmdir $4/Tstwrpr.tmp |
| 91 |
|
| 92 |
# Here or earlier a compilation of "conv", the converter |
| 93 |
# command to be used below in order to create the case |
| 94 |
# converted source files, should be performed (if necessary?) |
| 95 |
# Or, compiled converter could be provided as standards, |
| 96 |
# together with the source file for emergencies and extensions. |
| 97 |
# Right now, I just assume the converter to exist. |
| 98 |
|
| 99 |
if ( ! ( -x $5)) then |
| 100 |
echo \ The argument $5 to caseconv should have been an |
| 101 |
echo executable file, the compiled case converter. |
| 102 |
exit |
| 103 |
endif |
| 104 |
|
| 105 |
# We also should check whether or not execution of $5 |
| 106 |
# seems to work. The following is crude, but at least |
| 107 |
# detects a few errors: |
| 108 |
|
| 109 |
cat <<EOCAT >$3/Tstwrpr.tmp |
| 110 |
% A minor test file |
| 111 |
(COND ((COULD this Work?) T)) |
| 112 |
EOCAT |
| 113 |
$5 $3/Tstwrpr.tmp $4/Tstwrpr.tmp |
| 114 |
if ( ! ( -f $4/Tstwrpr.tmp )) then |
| 115 |
echo \ Although $5 is an executable file, it does not |
| 116 |
echo seem to work in this context. Check if it is of |
| 117 |
echo the right architecture. |
| 118 |
exit |
| 119 |
endif |
| 120 |
rm -f $3/Tstwrpr.tmp $4/Tstwrpr.tmp |
| 121 |
|
| 122 |
# The first four arguments now are intelligible as directory |
| 123 |
# names, as viewed from the present directory. However, we |
| 124 |
# need to move around, and still find our way. Thus, let's |
| 125 |
# define temporary variables, containing the full pathnames of |
| 126 |
# the directories! This we do without use of pushd/popd, in |
| 127 |
# order to suppress excess diagnostics printing. |
| 128 |
|
| 129 |
setenv tmphere $cwd |
| 130 |
cd $1; setenv tmpsrc $cwd; cd $tmphere |
| 131 |
cd $2; setenv tmpauxil $cwd; cd $tmphere |
| 132 |
cd $3; setenv tmpxsrc $cwd; cd $tmphere |
| 133 |
cd $4; setenv tmpxauxil $cwd; cd $tmphere |
| 134 |
|
| 135 |
#### However, we still may have the problem with $5. The file |
| 136 |
#### might not be discernible from the other directories; and |
| 137 |
#### I do not see how to perform an expansion of its full |
| 138 |
#### pathname. |
| 139 |
|
| 140 |
# Therefore, in this version I make a horrible amount of cd's, |
| 141 |
# just in order never to execute the converter file from a |
| 142 |
# place where it might not be found. |
| 143 |
|
| 144 |
setenv tmpconv $5 |
| 145 |
|
| 146 |
# Here a make kind of update hopefully is performed: |
| 147 |
# If some of the relevant source files are newer than their |
| 148 |
# case converted counterparts, or such counterparts do not |
| 149 |
# exist, then new conversion counterparts should be created. |
| 150 |
|
| 151 |
# src files conversions --> xsrc: |
| 152 |
cd $tmpsrc |
| 153 |
foreach srcfl (*.sl redif.red) |
| 154 |
if ( ! ( -e $tmpxsrc/$srcfl && { test $srcfl -ot $tmpxsrc/$srcfl } )) then |
| 155 |
rm -f $tmpxsrc/$srcfl |
| 156 |
cd $tmphere |
| 157 |
$tmpconv $tmpsrc/$srcfl $tmpxsrc/$srcfl |
| 158 |
cd $tmpsrc |
| 159 |
endif |
| 160 |
end |
| 161 |
|
| 162 |
# if ( -f redif.red ) then |
| 163 |
# rm -f $tmpxsrc/redif.red |
| 164 |
# cd $tmphere |
| 165 |
# $tmpconv $tmpsrc/redif.red $tmpxsrc/redif.red |
| 166 |
# cd $tmpsrc |
| 167 |
# endif |
| 168 |
|
| 169 |
|
| 170 |
if ( -d stg ) then |
| 171 |
cd stg |
| 172 |
if ( ! ( -d $tmpxsrc/stg)) mkdir $tmpxsrc/stg |
| 173 |
foreach srcfl (*.sl) |
| 174 |
if ( ! ( -e $tmpxsrc/stg/$srcfl && { test $srcfl -ot $tmpxsrc/stg/$srcfl } )) then |
| 175 |
rm -f $tmpxsrc/stg/$srcfl |
| 176 |
cd $tmphere |
| 177 |
$tmpconv $tmpsrc/stg/$srcfl $tmpxsrc/stg/$srcfl |
| 178 |
cd $tmpsrc/stg |
| 179 |
endif |
| 180 |
end |
| 181 |
cd $tmpsrc |
| 182 |
endif |
| 183 |
|
| 184 |
if ( -d anick ) then |
| 185 |
cd anick |
| 186 |
if ( ! ( -d $tmpxsrc/anick)) mkdir $tmpxsrc/anick |
| 187 |
foreach srcfl (*.sl) |
| 188 |
if ( ! ( -e $tmpxsrc/anick/$srcfl && { test $srcfl -ot $tmpxsrc/anick/$srcfl } )) then |
| 189 |
rm -f $tmpxsrc/anick/$srcfl |
| 190 |
cd $tmphere |
| 191 |
$tmpconv $tmpsrc/anick/$srcfl $tmpxsrc/anick/$srcfl |
| 192 |
cd $tmpsrc |
| 193 |
endif |
| 194 |
end |
| 195 |
cd $tmpsrc/anick |
| 196 |
endif |
| 197 |
|
| 198 |
# auxil files conversions --> xauxil: |
| 199 |
cd $tmpauxil |
| 200 |
foreach srcfl (*.sl) |
| 201 |
if ( ! ( -e $tmpxauxil/$srcfl && { test $srcfl -ot $tmpxauxil/$srcfl } )) then |
| 202 |
rm -f $tmpxauxil/$srcfl |
| 203 |
cd $tmphere |
| 204 |
$tmpconv $tmpauxil/$srcfl $tmpxauxil/$srcfl |
| 205 |
cd $tmpauxil |
| 206 |
endif |
| 207 |
end |
| 208 |
|
| 209 |
cd $tmpxauxil |
| 210 |
rm -f envtail* head* hook* fv* *version |
| 211 |
cd $tmpauxil |
| 212 |
cp -p envtail* head* hook* fv* *version $tmpxauxil |
| 213 |
|
| 214 |
if ( -f caseconv ) cp -p caseconv $tmpxauxil |
| 215 |
|
| 216 |
cd $tmphere |
| 217 |
|
| 218 |
$tmpconv $tmpauxil/mkprimefile $tmpxauxil/mkprimefile |