3 # This creates a compressed (14 bits) tar file that can be copied to a DOS
4 # machine, unpacked and compiled with Borland C++ 2.0.
6 # This is for groff version 1.04. It will probably need work for
9 # The grammar is yacced here, because I don't have a yacc on my DOS
10 # machine. The resulting .tab.c file is split up; I found the
11 # compiler ran out of memory otherwise. The sed command that does the
12 # splitting assumes you're using the SunOS 4.1.1 yacc.
13 # (Bison-generated parsers need alloca() which Borland C++ does not
14 # have.) You'll need to tweak it for other yaccs: in particular you'll
15 # need to change the `tabs' variable, so that it matches the names of
16 # the external arrays of ints generated by your version yacc: it is
17 # these that are split off into another file. You may also need to
18 # change tabtype to `short' if the tables are arrays of shorts.
22 tabs
="yyexca yyact yypact yypgo yyr1 yyr2 yychk yydef"
34 for tab
in $tabs; do echo "/$tabtype $tab\\[]/i\\
35 extern $tabtype $tab[];
36 /$tabtype $tab\\[]/,/;/{
41 sed -f split.
sed y.tab.c
>$file1
43 rm -f split.
sed y.tab.c
47 libfiles
="change_lf.c cset.c cset.h errarg.c errarg.h error.c error.h \
48 fatal.c filename.c version.c lf.c lib.h lineno.c new.c string.c \
49 stringclass.h progname.c strerror.c strsave.c ptable.c ptable.h"
51 picfiles
="common.c common.h lex.c main.c object.c object.h output.h \
52 pic.h position.h tex.c text.h troff.c"
56 sed -e '/^#include/s/pic\.tab\.h/pic_tab.h/' $picdir/$file >$file
59 for file in $libfiles; do cp $picdir/..
/lib
/$file $file; done
61 mv stringclass.h stringcl.h
62 mv change_lf.c changelf.c
65 # Makefile for pic with Borland C++ 2.0.
72 CFLAGS=-m$(MODEL) $(WARN) $(DEBUG) -I. -DSWITCHAR
73 LDFLAGS=-m$(MODEL) $(DEBUG) $(MAP)
103 $(CC) -c $(CFLAGS) {$< }
106 $(CC) $(LDFLAGS) -e$(PROG) @&&!
110 strerror.obj: strerror.c
111 $(OLDCC) -c $(CFLAGS) strerror.c
114 $(OLDCC) -c $(CFLAGS) getopt.c
116 # Enable auto-dependency checking.
124 int getopt(int, char **, const char *);
130 cat >getopt.c
<<'EOF'
131 /* getopt() for those systems that don't have it. */
132 /* Derived from comp.sources.unix/volume3/att_getopt. */
147 #define OPTION_CHAR '-'
150 int getopt(argc, argv, opts)
157 static char switchar = '\0';
164 if (switchar == '\0') {
166 intdos(®s, ®s);
168 switchar = regs.h.dl;
178 argv
[optind
][0] != switchar
&&
180 argv
[optind
][0] != OPTION_CHAR
) || argv
[optind
][1] == '\0') {
183 for (i
= optind
; i
< argc
; i
++)
186 argv
[i
][0] == switchar ||
188 argv
[i
][0] == OPTION_CHAR
) && argv
[i
][1] != '\0')
192 #ifdef CASE_INSENSITIVE_OPTIONS
196 if (c
!= ':' && c
!= OPTION_CHAR
&& (cp = strchr
(opts
, c
)) != NULL
197 && cp[1] == ':' && argv
[i
][2] == 0 && i
< argc
- 1) {
199 char
*temp1
= argv
[i
];
200 char
*temp2
= argv
[i
+1];
201 for (j
= i
- 1; j
>= optind
; j--
)
203 argv
[optind
] = temp1
;
204 argv
[optind
+1] = temp2
;
208 char
*temp
= argv
[i
];
209 for (j
= i
- 1; j
>= optind
; j--
)
218 if ((argv
[optind
][0] == OPTION_CHAR
&& argv
[optind
][1] == OPTION_CHAR
219 && argv
[optind
][2] == '\0')
221 ||
(argv
[optind
][0] == switchar
&& argv
[optind
][1] == switchar
222 && argv
[optind
][2] == '\0')
229 optopt
= c
= argv
[optind
][sp
];
230 #ifdef CASE_INSENSITIVE_OPTIONS
231 if (isascii
(c
) && isupper
(c
))
232 optopt
= c
= tolower
(c
);
234 if (c
== ':' ||
(cp = strchr
(opts
, c
)) == NULL
) {
235 if (argv
[optind
][++sp
] == '\0') {
239 message
= ": illegal option -- ";
243 if (argv
[optind
][sp
+1] != '\0')
244 optarg
= &argv
[optind
++][sp
+1];
245 else if (++optind
>= argc
) {
247 message
= ": option requires an argument -- ";
251 optarg
= argv
[optind
++];
255 if (argv
[optind
][++sp
] == '\0') {
264 fputs
(argv
[0], stderr
);
265 fputs
(message
, stderr
);
266 fputc
(optopt
, stderr
);
275 c-continued-statement-offset
: 4
284 for file in *; do sed -e 's/$/
/' $file >temp
; mv temp
$file; done
288 compress -b14 $tarfile
291 echo Now move
$tarfile.Z to a MSDOS machine with Borland C
++ 2.0,
292 echo unpack and compile with
make -S.