Skip to content

Commit be3d012

Browse files
author
Neil Matthew
committed
Updated ca script to generate .a68 line numbers in output .c
Updated ca script to echo commands only if -v (verbose) specified
1 parent 15809fe commit be3d012

File tree

1 file changed

+63
-44
lines changed

1 file changed

+63
-44
lines changed

scripts/ca

Lines changed: 63 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
CC="none"
1212
ARCH=$(uname -m)
1313
OS=$(uname -s)
14-
echo "Architecture is $ARCH, Operating system is $OS"
14+
ECHO=":"
1515

1616
case $ARCH in
1717
"i386")
@@ -34,7 +34,6 @@ case $ARCH in
3434
exit 1
3535
;;
3636
esac
37-
echo "Using compiler: $CC"
3837

3938
if [ "$OS" = "Darwin" ]; then
4039
PROGRAM=/usr/local/bin/a68toc
@@ -51,39 +50,42 @@ CHECK=-DA68_CHECK
5150
DEBUG=n
5251
DESTDIR=${HOME}/lib
5352
LIBRARIES=-L${DESTDIR}
53+
MUNGE=n
5454
UNAME="-uname seedfile"
5555
WEBDIR="-w${DESTDIR}"
5656

5757
usage() {
5858
echo "Usage:"
59-
echo " ca [-c] [-C c-flag] [-d m-files-dir] [-g] [-h|--help] "
60-
echo " [-I inc-dir] [-L link-dir] [-l link-lib]"
59+
echo " ca [-c] [-C c-flag] [-d m-files-dir] [-g] [-G] [-h|--help] "
60+
echo " [-I inc-dir] [-L link-dir] [-l link-lib]"
6161
echo " [-M lib-dir] [-m mod-lib]"
62-
echo " [-u uname] [-w web68-dirs] module-path[.a68|.w68]"
63-
echo
64-
echo " -c Omit array bound checking in the compiled program"
65-
echo " -C Specify a flag for the C compiler (may be repeated)"
66-
echo " -d Specify a directory to be searched for .m files"
67-
echo " -g Switch on debugging"
68-
echo " -h --help Print this help message"
69-
echo " -I Specify an include directory for C header files"
70-
echo " May be repeated"
71-
echo " -L Specify a directory to search for linking libraries"
72-
echo " May be repeated"
73-
echo " -l Specify a library to be searched for functions"
74-
echo " The directory can be specified immediately following"
75-
echo " the -l or separated by a space. May be repeated"
76-
echo " -M Specify a directory for a module library"
77-
echo " -m Specify a module library. The .a and leading lib can"
78-
echo " be omitted"
79-
echo " -u Specify where the compiler will get its seed for unique"
80-
echo " names. Possible values are: seedfile, cfile, or seven"
81-
echo " uppercase letters. Default is seedfile"
82-
echo " -w Specify additional directories for tang to search for"
83-
echo " include files (may be repeated). The directory can be"
84-
echo " specified immediately following the -w or separated by"
85-
echo " a space"
86-
echo
62+
echo " [-u uname] [-v] [-w web68-dirs] module-path[.a68|.w68]"
63+
echo
64+
echo " -c Omit array bound checking in the compiled program"
65+
echo " -C Specify a flag for the C compiler (may be repeated)"
66+
echo " -d Specify a directory to be searched for .m files"
67+
echo " -g Switch on debugging"
68+
echo " -G Preserve .a68 file line numbers for debugging"
69+
echo " -h --help Print this help message"
70+
echo " -I Specify an include directory for C header files"
71+
echo " May be repeated"
72+
echo " -L Specify a directory to search for linking libraries"
73+
echo " May be repeated"
74+
echo " -l Specify a library to be searched for functions"
75+
echo " The directory can be specified immediately following"
76+
echo " the -l or separated by a space. May be repeated"
77+
echo " -M Specify a directory for a module library"
78+
echo " -m Specify a module library. The .a and leading lib can"
79+
echo " be omitted"
80+
echo " -u Specify where the compiler will get its seed for unique"
81+
echo " names. Possible values are: seedfile, cfile, or seven"
82+
echo " uppercase letters. Default is seedfile"
83+
echo " -v Verbose. Echo command lines for each compilation step"
84+
echo " -w Specify additional directories for tang to search for"
85+
echo " include files (may be repeated). The directory can be"
86+
echo " specified immediately following the -w or separated by"
87+
echo " a space"
88+
echo
8789
echo "Defaults:"
8890
echo " A68DIRS =${A68DIRS}"
8991
echo " Use -d to add to this"
@@ -139,10 +141,10 @@ do
139141
-c) CHECK=""
140142
shift 1
141143
;;
142-
-C)
143-
add_to CFLAGS $2
144-
shift 2
145-
;;
144+
-C)
145+
add_to CFLAGS $2
146+
shift 2
147+
;;
146148
-d)
147149
add_to A68DIRS $2
148150
shift 2
@@ -153,6 +155,10 @@ do
153155
DEBUG=y
154156
shift 1
155157
;;
158+
-G)
159+
MUNGE=y
160+
shift 1
161+
;;
156162
-h|--help)
157163
usage
158164
;;
@@ -169,9 +175,9 @@ do
169175
shift 2
170176
;;
171177
-l*)
172-
add_to LIBRARY ${1#-l}
173-
shift 1
174-
;;
178+
add_to LIBRARY ${1#-l}
179+
shift 1
180+
;;
175181
-m)
176182
add_to DESTLIB $2
177183
shift 2
@@ -184,14 +190,18 @@ do
184190
UNAME="-uname $2"
185191
shift 2
186192
;;
193+
-v)
194+
ECHO="echo"
195+
shift 1
196+
;;
187197
-w)
188198
add_to WEBDIR $2
189199
shift 2
190200
;;
191-
-w*)
192-
add_to WEBDIR ${1#-w}
193-
shift 1
194-
;;
201+
-w*)
202+
add_to WEBDIR ${1#-w}
203+
shift 1
204+
;;
195205
-*|+*)
196206
echo "ca: Unknown option $1"
197207
exit 1
@@ -204,6 +214,9 @@ do
204214
esac
205215
done
206216

217+
${ECHO} "Architecture is $ARCH, Operating system is $OS"
218+
${ECHO} "Using compiler: $CC"
219+
207220
# Check the filename and run tang if required
208221
if [ "${FILE}" != "${W68S}" ]
209222
then
@@ -233,13 +246,19 @@ else
233246
fi
234247

235248
# Translate to C and compile
236-
echo ${PROGRAM} -s -v -lib ${ROOT} ${A68DIRS} ${UNAME} ${A68S}.a68
237-
${PROGRAM} -s -v -lib ${ROOT} ${A68DIRS} ${UNAME} ${A68S}.a68
249+
${ECHO} ${PROGRAM} -s -v -lib ${ROOT} ${A68DIRS} ${UNAME} ${A68S}.a68
250+
${PROGRAM} -s -v -lib ${ROOT} ${A68DIRS} ${UNAME} ${A68S}.a68
238251
RES=$?
239252

240253
if [ ${RES} -eq 0 ]
241254
then
242-
echo ${CC} -O0 ${CHECK} ${CFLAGS} ${INCLUDES} -o ${A68S}.o -c ${A68S}.c
255+
if [ "${MUNGE}" == "y" ]
256+
then
257+
mv ${A68S}.c .${A68S}.c
258+
${ECHO} sed -E "s/ \/\* line ([0-9]+): \*\//#line \1 \"${A68S}.a68\"/" ${A68S}.c
259+
sed -E "s/ \/\* line ([0-9]+): \*\//#line \1 \"${A68S}.a68\"/" < .${A68S}.c >${A68S}.c
260+
fi
261+
${ECHO} ${CC} -O0 ${CHECK} ${CFLAGS} ${INCLUDES} -o ${A68S}.o -c ${A68S}.c
243262
${CC} -O0 ${CHECK} ${CFLAGS} ${INCLUDES} -o ${A68S}.o -c ${A68S}.c
244263
RES=$?
245264
if [ ${RES} -ne 0 ]
@@ -252,7 +271,7 @@ fi
252271

253272
if [ "${TYPE}" == "p" ]
254273
then # Link the program
255-
echo ${CC} -o ${A68S} ${ROOT}/Afirst.o ${A68S}.o ${LIBRARIES} -la68s -la68 -la68gc -lm -lc
274+
${ECHO} ${CC} -o ${A68S} ${ROOT}/Afirst.o ${A68S}.o ${LIBRARIES} -la68s -la68 -la68gc -lm -lc
256275
${CC} -o ${A68S} ${ROOT}/Afirst.o ${A68S}.o ${LIBRARIES} -la68s -la68 -la68gc -lm -lc
257276
RES=$?
258277
if [ ${RES} -ne 0 ]

0 commit comments

Comments
 (0)