groff before CVS: release 1.06
[s-roff.git] / pic / make-dos-dist
blobe883657074bda6d4582b49dad07628bb654ca3c9
1 #! /bin/sh
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
7 # other versions.
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.
20 picdir=`pwd`
21 tarfile=pic_tar
22 tabs="yyexca yyact yypact yypgo yyr1 yyr2 yychk yydef"
23 tabtype=int
24 file1=pic_tab1.c
25 file2=pic_tab2.c
27 rm -fr temp
28 mkdir temp
29 cd temp
32 yacc -d $picdir/pic.y
34 for tab in $tabs; do echo "/$tabtype $tab\\[]/i\\
35 extern $tabtype $tab[];
36 /$tabtype $tab\\[]/,/;/{
37 w $file2
39 }"; done >split.sed
41 sed -f split.sed y.tab.c >$file1
43 rm -f split.sed y.tab.c
45 mv y.tab.h pic_tab.h
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"
54 for file in $picfiles
56 sed -e '/^#include/s/pic\.tab\.h/pic_tab.h/' $picdir/$file >$file
57 done
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
64 cat >makefile <<'EOF'
65 # Makefile for pic with Borland C++ 2.0.
66 CC=bcc -P -V
67 OLDCC=bcc -V
68 MODEL=l
69 WARN=
70 DEBUG=
71 MAP=-M
72 CFLAGS=-m$(MODEL) $(WARN) $(DEBUG) -I. -DSWITCHAR
73 LDFLAGS=-m$(MODEL) $(DEBUG) $(MAP)
75 OBJS=changelf.obj \
76 common.obj \
77 cset.obj \
78 errarg.obj \
79 error.obj \
80 fatal.obj \
81 filename.obj \
82 lex.obj \
83 lf.obj \
84 lineno.obj \
85 main.obj \
86 new.obj \
87 object.obj \
88 pic_tab1.obj \
89 pic_tab2.obj \
90 progname.obj \
91 ptable.obj \
92 string.obj \
93 strsave.obj \
94 tex.obj \
95 troff.obj \
96 version.obj \
97 getopt.obj \
98 strerror.obj
100 PROG=pic
102 .c.obj:
103 $(CC) -c $(CFLAGS) {$< }
105 $(PROG).exe: $(OBJS)
106 $(CC) $(LDFLAGS) -e$(PROG) @&&!
107 $(OBJS)
110 strerror.obj: strerror.c
111 $(OLDCC) -c $(CFLAGS) strerror.c
113 getopt.obj: getopt.c
114 $(OLDCC) -c $(CFLAGS) getopt.c
116 # Enable auto-dependency checking.
117 .autodepend
120 cat >osfcn.h <<'EOF'
121 #include <io.h>
123 extern "C" {
124 int getopt(int, char **, const char *);
125 extern int optind;
126 extern int opterr;
130 cat >getopt.c <<'EOF'
131 /* getopt() for those systems that don't have it. */
132 /* Derived from comp.sources.unix/volume3/att_getopt. */
134 #include <stdio.h>
135 #include <string.h>
137 #ifdef SWITCHAR
138 #include <dos.h>
139 #endif
141 int opterr = 1;
142 int optind = 1;
143 int optopt;
144 char *optarg;
146 #ifndef OPTION_CHAR
147 #define OPTION_CHAR '-'
148 #endif
150 int getopt(argc, argv, opts)
151 int argc;
152 char **argv;
153 char *opts;
155 #ifdef SWITCHAR
156 union REGS regs;
157 static char switchar = '\0';
158 #endif
159 static int sp = 1;
160 register int c;
161 register char *cp;
162 char *message;
163 #ifdef SWITCHAR
164 if (switchar == '\0') {
165 regs.x.ax = 0x3700;
166 intdos(&regs, &regs);
167 if (!regs.x.cflag)
168 switchar = regs.h.dl;
169 else
170 switchar = '/';
172 #endif
173 if (sp == 1) {
174 if (optind >= argc)
175 return EOF;
176 if ((
177 #ifdef SWITCHAR
178 argv[optind][0] != switchar &&
179 #endif
180 argv[optind][0] != OPTION_CHAR) || argv[optind][1] == '\0') {
181 #ifdef REORDER_ARGS
182 int i;
183 for (i = optind; i < argc; i++)
184 if ((
185 #ifdef SWITCHAR
186 argv[i][0] == switchar ||
187 #endif
188 argv[i][0] == OPTION_CHAR) && argv[i][1] != '\0')
189 break;
190 if (i < argc) {
191 c = argv[i][1];
192 #ifdef CASE_INSENSITIVE_OPTIONS
193 if (isupper(c))
194 c = tolower(c);
195 #endif
196 if (c != ':' && c != OPTION_CHAR && (cp = strchr(opts, c)) != NULL
197 && cp[1] == ':' && argv[i][2] == 0 && i < argc - 1) {
198 int j;
199 char *temp1 = argv[i];
200 char *temp2 = argv[i+1];
201 for (j = i - 1; j >= optind; j--)
202 argv[j+2] = argv[j];
203 argv[optind] = temp1;
204 argv[optind+1] = temp2;
206 else {
207 int j;
208 char *temp = argv[i];
209 for (j = i - 1; j >= optind; j--)
210 argv[j+1] = argv[j];
211 argv[optind] = temp;
214 else
215 #endif
216 return EOF;
218 if ((argv[optind][0] == OPTION_CHAR && argv[optind][1] == OPTION_CHAR
219 && argv[optind][2] == '\0')
220 #ifdef SWITCHAR
221 || (argv[optind][0] == switchar && argv[optind][1] == switchar
222 && argv[optind][2] == '\0')
223 #endif
225 optind++;
226 return(EOF);
229 optopt = c = argv[optind][sp];
230 #ifdef CASE_INSENSITIVE_OPTIONS
231 if (isascii(c) && isupper(c))
232 optopt = c = tolower(c);
233 #endif
234 if (c == ':' || (cp = strchr(opts, c)) == NULL) {
235 if (argv[optind][++sp] == '\0') {
236 optind++;
237 sp = 1;
239 message = ": illegal option -- ";
240 goto bad;
242 if (*++cp == ':') {
243 if (argv[optind][sp+1] != '\0')
244 optarg = &argv[optind++][sp+1];
245 else if (++optind >= argc) {
246 sp = 1;
247 message = ": option requires an argument -- ";
248 goto bad;
250 else
251 optarg = argv[optind++];
252 sp = 1;
254 else {
255 if (argv[optind][++sp] == '\0') {
256 sp = 1;
257 optind++;
259 optarg = NULL;
261 return c;
262 bad:
263 if (opterr) {
264 fputs(argv[0], stderr);
265 fputs(message, stderr);
266 fputc(optopt, stderr);
267 fputc('\n', stderr);
269 return '?';
273 Local Variables:
274 c-indent-level: 4
275 c-continued-statement-offset: 4
276 c-brace-offset: 4
277 c-argdecl-indent: 4
278 c-label-offset: -4
279 tab-width: 4
280 End:
284 for file in *; do sed -e 's/$/ /' $file >temp; mv temp $file; done
286 tar cf ../$tarfile *
287 cd ..
288 compress -b14 $tarfile
289 rm -fr temp
291 echo Now move $tarfile.Z to a MSDOS machine with Borland C++ 2.0,
292 echo unpack and compile with make -S.