Substantial overhaul of Mac build system. We now have working PowerPC builds,
[u/mdw/putty] / mkfiles.pl
1 #!/usr/bin/env perl
2 #
3 # Makefile generator for PuTTY.
4 #
5 # Reads the file `Recipe' to determine the list of generated
6 # executables and their component objects. Then reads the source
7 # files to compute #include dependencies. Finally, writes out the
8 # various target Makefiles.
9
10 use FileHandle;
11
12 open IN, "Recipe" or die "unable to open Recipe file\n";
13
14 @incdirs = ("", "unix/", "mac/");
15
16 $help = ""; # list of newline-free lines of help text
17 %programs = (); # maps prog name + type letter to listref of objects/resources
18 %groups = (); # maps group name to listref of objects/resources
19
20 while (<IN>) {
21 # Skip comments (unless the comments belong, for example because
22 # they're part of the help text).
23 next if /^\s*#/ and !$in_help;
24
25 chomp;
26 split;
27 if ($_[0] eq "!begin" and $_[1] eq "help") { $in_help = 1; next; }
28 if ($_[0] eq "!end" and $in_help) { $in_help = 0; next; }
29 # If we're gathering help text, keep doing so.
30 if ($in_help) { $help .= "$_\n"; next; }
31 # Ignore blank lines.
32 next if scalar @_ == 0;
33
34 # Now we have an ordinary line. See if it's an = line, a : line
35 # or a + line.
36 @objs = @_;
37
38 if ($_[0] eq "+") {
39 $listref = $lastlistref;
40 $prog = undef;
41 die "$.: unexpected + line\n" if !defined $lastlistref;
42 } elsif ($_[1] eq "=") {
43 $groups{$_[0]} = [] if !defined $groups{$_[0]};
44 $listref = $groups{$_[0]};
45 $prog = undef;
46 shift @objs; # eat the group name
47 } elsif ($_[1] eq ":") {
48 $listref = [];
49 $prog = $_[0];
50 shift @objs; # eat the program name
51 } else {
52 die "$.: unrecognised line type\n";
53 }
54 shift @objs; # eat the +, the = or the :
55
56 while (scalar @objs > 0) {
57 $i = shift @objs;
58 if ($groups{$i}) {
59 foreach $j (@{$groups{$i}}) { unshift @objs, $j; }
60 } elsif (($i eq "[G]" or $i eq "[C]" or $i eq "[M]" or
61 $i eq "[X]" or $i eq "[U]") and defined $prog) {
62 $type = substr($i,1,1);
63 } else {
64 push @$listref, $i;
65 }
66 }
67 if ($prog and $type) {
68 die "multiple program entries for $prog [$type]\n"
69 if defined $programs{$prog . "," . $type};
70 $programs{$prog . "," . $type} = $listref;
71 }
72 $lastlistref = $listref;
73 }
74
75 close IN;
76
77 # Now retrieve the complete list of objects and resource files, and
78 # construct dependency data for them. While we're here, expand the
79 # object list for each program, and complain if its type isn't set.
80 @prognames = sort keys %programs;
81 %depends = ();
82 @scanlist = ();
83 foreach $i (@prognames) {
84 ($prog, $type) = split ",", $i;
85 # Strip duplicate object names.
86 $prev = undef;
87 @list = grep { $status = ($prev ne $_); $prev=$_; $status }
88 sort @{$programs{$i}};
89 $programs{$i} = [@list];
90 foreach $j (@list) {
91 # Dependencies for "x" start with "x.c".
92 # Dependencies for "x.res" start with "x.rc".
93 # Both types of file are pushed on the list of files to scan.
94 # Libraries (.lib) don't have dependencies at all.
95 if ($j =~ /^(.*)\.res$/) {
96 $file = "$1.rc";
97 $depends{$j} = [$file];
98 push @scanlist, $file;
99 } elsif ($j =~ /\.lib$/) {
100 # libraries don't have dependencies
101 } else {
102 $file = "$j.c";
103 $depends{$j} = [$file];
104 push @scanlist, $file;
105 }
106 }
107 }
108
109 # Scan each file on @scanlist and find further inclusions.
110 # Inclusions are given by lines of the form `#include "otherfile"'
111 # (system headers are automatically ignored by this because they'll
112 # be given in angle brackets). Files included by this method are
113 # added back on to @scanlist to be scanned in turn (if not already
114 # done).
115 #
116 # Resource scripts (.rc) can also include a file by means of a line
117 # ending `ICON "filename"'. Files included by this method are not
118 # added to @scanlist because they can never include further files.
119 #
120 # In this pass we write out a hash %further which maps a source
121 # file name into a listref containing further source file names.
122
123 %further = ();
124 while (scalar @scanlist > 0) {
125 $file = shift @scanlist;
126 next if defined $further{$file}; # skip if we've already done it
127 $resource = ($file =~ /\.rc$/ ? 1 : 0);
128 $further{$file} = [];
129 $dirfile = &findfile($file);
130 open IN, "$dirfile" or die "unable to open source file $file\n";
131 while (<IN>) {
132 chomp;
133 /^\s*#include\s+\"([^\"]+)\"/ and do {
134 push @{$further{$file}}, $1;
135 push @scanlist, $1;
136 next;
137 };
138 /ICON\s+\"([^\"]+)\"\s*$/ and do {
139 push @{$further{$file}}, $1;
140 next;
141 }
142 }
143 close IN;
144 }
145
146 # Now we're ready to generate the final dependencies section. For
147 # each key in %depends, we must expand the dependencies list by
148 # iteratively adding entries from %further.
149 foreach $i (keys %depends) {
150 %dep = ();
151 @scanlist = @{$depends{$i}};
152 foreach $i (@scanlist) { $dep{$i} = 1; }
153 while (scalar @scanlist > 0) {
154 $file = shift @scanlist;
155 foreach $j (@{$further{$file}}) {
156 if ($dep{$j} != 1) {
157 $dep{$j} = 1;
158 push @{$depends{$i}}, $j;
159 push @scanlist, $j;
160 }
161 }
162 }
163 # printf "%s: %s\n", $i, join ' ',@{$depends{$i}};
164 }
165
166 # Utility routines while writing out the Makefiles.
167
168 sub findfile {
169 my ($name) = @_;
170 my $dir, $i, $outdir = "";
171 $i = 0;
172 foreach $dir (@incdirs) {
173 $outdir = $dir, $i++ if -f "$dir$name";
174 }
175 die "multiple instances of source file $name\n" if $i > 1;
176 return "$outdir$name";
177 }
178
179 sub objects {
180 my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_;
181 my @ret;
182 my ($i, $x, $y);
183 @ret = ();
184 foreach $i (@{$programs{$prog}}) {
185 $x = "";
186 if ($i =~ /^(.*)\.res/) {
187 $y = $1;
188 ($x = $rtmpl) =~ s/X/$y/;
189 } elsif ($i =~ /^(.*)\.lib/) {
190 $y = $1;
191 ($x = $ltmpl) =~ s/X/$y/;
192 } else {
193 ($x = $otmpl) =~ s/X/$i/;
194 }
195 push @ret, $x if $x ne "";
196 }
197 return join " ", @ret;
198 }
199
200 sub splitline {
201 my ($line, $width, $splitchar) = @_;
202 my ($result, $len);
203 $len = (defined $width ? $width : 76);
204 $splitchar = (defined $splitchar ? $splitchar : '\\');
205 while (length $line > $len) {
206 $line =~ /^(.{0,$len})\s(.*)$/ or $line =~ /^(.{$len,}?\s(.*)$/;
207 $result .= $1 . " ${splitchar}\n\t\t";
208 $line = $2;
209 $len = 60;
210 }
211 return $result . $line;
212 }
213
214 sub deps {
215 my ($otmpl, $rtmpl, $prefix, $dirsep, $depchar, $splitchar) = @_;
216 my ($i, $x, $y);
217 my @deps, @ret;
218 @ret = ();
219 $depchar ||= ':';
220 foreach $i (sort keys %depends) {
221 if ($i =~ /^(.*)\.res/) {
222 next if !defined $rtmpl;
223 $y = $1;
224 ($x = $rtmpl) =~ s/X/$y/;
225 } else {
226 ($x = $otmpl) =~ s/X/$i/;
227 }
228 @deps = @{$depends{$i}};
229 @deps = map {
230 $_ = &findfile($_);
231 s/\//$dirsep/g;
232 $_ = $prefix . $_;
233 } @deps;
234 push @ret, {obj => $x, deps => [@deps]};
235 }
236 return @ret;
237 }
238
239 sub prognames {
240 my ($types) = @_;
241 my ($n, $prog, $type);
242 my @ret;
243 @ret = ();
244 foreach $n (@prognames) {
245 ($prog, $type) = split ",", $n;
246 push @ret, $n if index($types, $type) >= 0;
247 }
248 return @ret;
249 }
250
251 sub progrealnames {
252 my ($types) = @_;
253 my ($n, $prog, $type);
254 my @ret;
255 @ret = ();
256 foreach $n (@prognames) {
257 ($prog, $type) = split ",", $n;
258 push @ret, $prog if index($types, $type) >= 0;
259 }
260 return @ret;
261 }
262
263 sub manpages {
264 my ($types,$suffix) = @_;
265
266 # assume that all UNIX programs have a man page
267 if($suffix eq "1" && $types =~ /X/) {
268 return map("$_.1", &progrealnames($types));
269 }
270 return ();
271 }
272
273 # Now we're ready to output the actual Makefiles.
274
275 ##-- CygWin makefile
276 open OUT, ">Makefile.cyg"; select OUT;
277 print
278 "# Makefile for PuTTY under cygwin.\n".
279 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
280 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
281 # gcc command line option is -D not /D
282 ($_ = $help) =~ s/=\/D/=-D/gs;
283 print $_;
284 print
285 "\n".
286 "# You can define this path to point at your tools if you need to\n".
287 "# TOOLPATH = c:\\cygwin\\bin\\ # or similar, if you're running Windows\n".
288 "# TOOLPATH = /pkg/mingw32msvc/i386-mingw32msvc/bin/\n".
289 "CC = \$(TOOLPATH)gcc\n".
290 "RC = \$(TOOLPATH)windres\n".
291 "# You may also need to tell windres where to find include files:\n".
292 "# RCINC = --include-dir c:\\cygwin\\include\\\n".
293 "\n".
294 &splitline("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
295 " -DNO_SECURITY -D_NO_OLDNAMES -DNO_MULTIMON -I.")."\n".
296 "LDFLAGS = -mno-cygwin -s\n".
297 &splitline("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1".
298 " --define WINVER=0x0400 --define MINGW32_FIX=1")."\n".
299 "\n".
300 ".SUFFIXES:\n".
301 "\n".
302 "%.o: %.c\n".
303 "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) -c \$<\n".
304 "\n".
305 "%.res.o: %.rc\n".
306 "\t\$(RC) \$(FWHACK) \$(RCFL) \$(RCFLAGS) \$< \$\@\n".
307 "\n";
308 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("GC"));
309 print "\n\n";
310 foreach $p (&prognames("GC")) {
311 ($prog, $type) = split ",", $p;
312 $objstr = &objects($p, "X.o", "X.res.o", undef);
313 print &splitline($prog . ".exe: " . $objstr), "\n";
314 my $mw = $type eq "G" ? " -mwindows" : "";
315 $libstr = &objects($p, undef, undef, "-lX");
316 print &splitline("\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " .
317 $objstr . " $libstr", 69), "\n\n";
318 }
319 foreach $d (&deps("X.o", "X.res.o", "", "/")) {
320 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
321 "\n";
322 }
323 print
324 "\n".
325 "version.o: FORCE;\n".
326 "# Hack to force version.o to be rebuilt always\n".
327 "FORCE:\n".
328 "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) \$(VER) -c version.c\n".
329 "clean:\n".
330 "\trm -f *.o *.exe *.res.o\n".
331 "\n";
332 select STDOUT; close OUT;
333
334 ##-- Borland makefile
335 %stdlibs = ( # Borland provides many Win32 API libraries intrinsically
336 "advapi32" => 1,
337 "comctl32" => 1,
338 "comdlg32" => 1,
339 "gdi32" => 1,
340 "imm32" => 1,
341 "shell32" => 1,
342 "user32" => 1,
343 "winmm" => 1,
344 "winspool" => 1,
345 "wsock32" => 1,
346 );
347 open OUT, ">Makefile.bor"; select OUT;
348 print
349 "# Makefile for PuTTY under Borland C.\n".
350 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
351 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
352 # bcc32 command line option is -D not /D
353 ($_ = $help) =~ s/=\/D/=-D/gs;
354 print $_;
355 print
356 "\n".
357 "# If you rename this file to `Makefile', you should change this line,\n".
358 "# so that the .rsp files still depend on the correct makefile.\n".
359 "MAKEFILE = Makefile.bor\n".
360 "\n".
361 "# C compilation flags\n".
362 "CFLAGS = -D_WINDOWS -DWINVER=0x0401\n".
363 "\n".
364 "# Get include directory for resource compiler\n".
365 "!if !\$d(BCB)\n".
366 "BCB = \$(MAKEDIR)\\..\n".
367 "!endif\n".
368 "\n".
369 ".c.obj:\n".
370 &splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT) \$(FWHACK)".
371 " \$(XFLAGS) \$(CFLAGS) /c \$*.c",69)."\n".
372 ".rc.res:\n".
373 &splitline("\tbrcc32 \$(FWHACK) \$(RCFL) -i \$(BCB)\\include -r".
374 " -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401 \$*.rc",69)."\n".
375 "\n";
376 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("GC"));
377 print "\n\n";
378 foreach $p (&prognames("GC")) {
379 ($prog, $type) = split ",", $p;
380 $objstr = &objects($p, "X.obj", "X.res", undef);
381 print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
382 my $ap = ($type eq "G") ? "-aa" : "-ap";
383 print "\tilink32 $ap -Gn -L\$(BCB)\\lib \@$prog.rsp\n\n";
384 }
385 foreach $p (&prognames("GC")) {
386 ($prog, $type) = split ",", $p;
387 print $prog, ".rsp: \$(MAKEFILE)\n";
388 $objstr = &objects($p, "X.obj", undef, undef);
389 @objlist = split " ", $objstr;
390 @objlines = ("");
391 foreach $i (@objlist) {
392 if (length($objlines[$#objlines] . " $i") > 50) {
393 push @objlines, "";
394 }
395 $objlines[$#objlines] .= " $i";
396 }
397 $c0w = ($type eq "G") ? "c0w32" : "c0x32";
398 print "\techo $c0w + > $prog.rsp\n";
399 for ($i=0; $i<=$#objlines; $i++) {
400 $plus = ($i < $#objlines ? " +" : "");
401 print "\techo$objlines[$i]$plus >> $prog.rsp\n";
402 }
403 print "\techo $prog.exe >> $prog.rsp\n";
404 $objstr = &objects($p, "X.obj", "X.res", undef);
405 @libs = split " ", &objects($p, undef, undef, "X");
406 @libs = grep { !$stdlibs{$_} } @libs;
407 unshift @libs, "cw32", "import32";
408 $libstr = join ' ', @libs;
409 print "\techo nul,$libstr, >> $prog.rsp\n";
410 print "\techo " . &objects($p, undef, "X.res", undef) . " >> $prog.rsp\n";
411 print "\n";
412 }
413 foreach $d (&deps("X.obj", "X.res", "", "\\")) {
414 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
415 "\n";
416 }
417 print
418 "\n".
419 "version.o: FORCE\n".
420 "# Hack to force version.o to be rebuilt always\n".
421 "FORCE:\n".
422 "\tbcc32 \$(FWHACK) \$(VER) \$(CFLAGS) /c version.c\n\n".
423 "clean:\n".
424 "\t-del *.obj\n".
425 "\t-del *.exe\n".
426 "\t-del *.res\n".
427 "\t-del *.pch\n".
428 "\t-del *.aps\n".
429 "\t-del *.il*\n".
430 "\t-del *.pdb\n".
431 "\t-del *.rsp\n".
432 "\t-del *.tds\n".
433 "\t-del *.\$\$\$\$\$\$\n";
434 select STDOUT; close OUT;
435
436 ##-- Visual C++ makefile
437 open OUT, ">Makefile.vc"; select OUT;
438 print
439 "# Makefile for PuTTY under Visual C.\n".
440 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
441 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
442 print $help;
443 print
444 "\n".
445 "# If you rename this file to `Makefile', you should change this line,\n".
446 "# so that the .rsp files still depend on the correct makefile.\n".
447 "MAKEFILE = Makefile.vc\n".
448 "\n".
449 "# C compilation flags\n".
450 "CFLAGS = /nologo /W3 /O1 /D_WINDOWS /D_WIN32_WINDOWS=0x401 /DWINVER=0x401\n".
451 "LFLAGS = /incremental:no /fixed\n".
452 "\n".
453 ".c.obj:\n".
454 "\tcl \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) /c \$*.c\n".
455 ".rc.res:\n".
456 "\trc \$(FWHACK) \$(RCFL) -r -DWIN32 -D_WIN32 -DWINVER=0x0400 \$*.rc\n".
457 "\n";
458 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("GC"));
459 print "\n\n";
460 foreach $p (&prognames("GC")) {
461 ($prog, $type) = split ",", $p;
462 $objstr = &objects($p, "X.obj", "X.res", undef);
463 print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
464 print "\tlink \$(LFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n";
465 }
466 foreach $p (&prognames("GC")) {
467 ($prog, $type) = split ",", $p;
468 print $prog, ".rsp: \$(MAKEFILE)\n";
469 $objstr = &objects($p, "X.obj", "X.res", "X.lib");
470 @objlist = split " ", $objstr;
471 @objlines = ("");
472 foreach $i (@objlist) {
473 if (length($objlines[$#objlines] . " $i") > 50) {
474 push @objlines, "";
475 }
476 $objlines[$#objlines] .= " $i";
477 }
478 $subsys = ($type eq "G") ? "windows" : "console";
479 print "\techo /nologo /subsystem:$subsys > $prog.rsp\n";
480 for ($i=0; $i<=$#objlines; $i++) {
481 print "\techo$objlines[$i] >> $prog.rsp\n";
482 }
483 print "\n";
484 }
485 foreach $d (&deps("X.obj", "X.res", "", "\\")) {
486 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
487 "\n";
488 }
489 print
490 "\n".
491 "# Hack to force version.o to be rebuilt always\n".
492 "version.obj: *.c *.h *.rc\n".
493 "\tcl \$(FWHACK) \$(VER) \$(CFLAGS) /c version.c\n\n".
494 "clean: tidy\n".
495 "\t-del *.exe\n\n".
496 "tidy:\n".
497 "\t-del *.obj\n".
498 "\t-del *.res\n".
499 "\t-del *.pch\n".
500 "\t-del *.aps\n".
501 "\t-del *.ilk\n".
502 "\t-del *.pdb\n".
503 "\t-del *.rsp\n".
504 "\t-del *.dsp\n".
505 "\t-del *.dsw\n".
506 "\t-del *.ncb\n".
507 "\t-del *.opt\n".
508 "\t-del *.plg\n".
509 "\t-del *.map\n".
510 "\t-del *.idb\n".
511 "\t-del debug.log\n";
512 select STDOUT; close OUT;
513
514 ##-- X/GTK/Unix makefile
515 open OUT, ">unix/Makefile.gtk"; select OUT;
516 print
517 "# Makefile for PuTTY under X/GTK and Unix.\n".
518 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
519 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
520 # gcc command line option is -D not /D
521 ($_ = $help) =~ s/=\/D/=-D/gs;
522 print $_;
523 print
524 "\n".
525 "# You can define this path to point at your tools if you need to\n".
526 "# TOOLPATH = /opt/gcc/bin\n".
527 "CC = \$(TOOLPATH)cc\n".
528 "\n".
529 &splitline("CFLAGS = -Wall -g -I. -I.. `gtk-config --cflags`")."\n".
530 "XLDFLAGS = `gtk-config --libs`\n".
531 "ULDFLAGS =#\n".
532 "INSTALL=install\n",
533 "INSTALL_PROGRAM=\$(INSTALL)\n",
534 "INSTALL_DATA=\$(INSTALL)\n",
535 "prefix=/usr/local\n",
536 "exec_prefix=\$(prefix)\n",
537 "bindir=\$(exec_prefix)/bin\n",
538 "mandir=\$(prefix)/man\n",
539 "man1dir=\$(mandir)/man1\n",
540 "\n".
541 ".SUFFIXES:\n".
542 "\n".
543 "%.o:\n".
544 "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) -c \$<\n".
545 "\n";
546 print &splitline("all:" . join "", map { " $_" } &progrealnames("XU"));
547 print "\n\n";
548 foreach $p (&prognames("XU")) {
549 ($prog, $type) = split ",", $p;
550 $objstr = &objects($p, "X.o", undef, undef);
551 print &splitline($prog . ": " . $objstr), "\n";
552 $libstr = &objects($p, undef, undef, "-lX");
553 print &splitline("\t\$(CC)" . $mw . " \$(${type}LDFLAGS) -o \$@ " .
554 $objstr . " $libstr", 69), "\n\n";
555 }
556 foreach $d (&deps("X.o", undef, "../", "/")) {
557 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
558 "\n";
559 }
560 print
561 "\n".
562 "version.o: FORCE;\n".
563 "# Hack to force version.o to be rebuilt always\n".
564 "FORCE:\n".
565 "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) \$(VER) -c ../version.c\n".
566 "clean:\n".
567 "\trm -f *.o". (join "", map { " $_" } &progrealnames("XU")) . "\n".
568 "\n",
569 "install:\n",
570 map("\t\$(INSTALL_PROGRAM) -m 755 $_ \$(bindir)/$_\n", &progrealnames("XU")),
571 map("\t\$(INSTALL_DATA) -m 644 $_ \$(man1dir)/$_\n", &manpages("XU", "1")),
572 "\n",
573 "install-strip:\n",
574 "\t\$(MAKE) install INSTALL_PROGRAM=\"\$(INSTALL_PROGRAM) -s\"\n",
575 "\n";
576 select STDOUT; close OUT;
577
578 ##-- MPW Makefile
579 open OUT, ">mac/Makefile.mpw"; select OUT;
580 print <<END;
581 # Makefile for PuTTY under MPW.
582 #
583 # This file was created by `mkfiles.pl' from the `Recipe' file.
584 # DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.
585 END
586 # MPW command line option is -d not /D
587 ($_ = $help) =~ s/=\/D/=-d /gs;
588 print $_;
589 print <<END;
590
591 # -w 35 disables "unused parameter" warnings
592 COptions = -i : -i :: -w 35 -w err -proto strict
593 COptions_68K = {COptions} -model far -opt space
594 COptions_PPC = {COptions} -opt size
595
596 LinkOptions = -c 'pTTY'
597 LinkOptions_68K = {LinkOptions} -br 68k -model far -compact
598 LinkOptions_PPC = {LinkOptions}
599
600 Libs_68K = "{CLibraries}StdCLib.far.o" \xb6
601 "{Libraries}MacRuntime.o" \xb6
602 "{Libraries}MathLib.far.o" \xb6
603 "{Libraries}IntEnv.far.o" \xb6
604 "{Libraries}Interface.o" \xb6
605 "{Libraries}OpenTransport.o" \xb6
606 "{Libraries}OpenTransportApp.o" \xb6
607 "{Libraries}OpenTptInet.o" \xb6
608 "{Libraries}UnicodeConverterLib.far.o"
609
610 Libs_CFM = "{SharedLibraries}InterfaceLib" \xb6
611 "{SharedLibraries}StdCLib" \xb6
612 "{SharedLibraries}MathLib" \xb6
613 "{SharedLibraries}AppearanceLib" \xb6
614 -weaklib AppearanceLib \xb6
615 "{SharedLibraries}OpenTransportLib" \xb6
616 -weaklib OTGlobalLib \xb6
617 -weaklib OTUtilityLib \xb6
618 -weaklib OTClientUtilLib \xb6
619 -weaklib OTClientLib \xb6
620 -weaklib OTStreamUnixLib \xb6
621 -weaklib OTXTILib \xb6
622 -weaklib OTConfigLib \xb6
623 -weaklib OTNtvUtilLib \xb6
624 -weaklib OTNativeClientLib \xb6
625 "{SharedLibraries}OpenTptInternetLib" \xb6
626 -weaklib OTInetClientLib \xb6
627 "{SharedLibraries}TextCommon" \xb6
628 -weaklib TextCommon \xb6
629 "{SharedLibraries}UnicodeConverter" \xb6
630 -weaklib UnicodeConverter
631
632 Libs_PPC = {Libs_CFM} \xb6
633 "{PPCLibraries}StdCRuntime.o" \xb6
634 "{PPCLibraries}PPCCRuntime.o" \xb6
635 "{PPCLibraries}CarbonAccessors.o" \xb6
636 "{PPCLibraries}OpenTransportAppPPC.o" \xb6
637 "{PPCLibraries}OpenTptInetPPC.o"
638
639 END
640 print &splitline("all \xc4 " . join(" ", &progrealnames("M")), undef, "\xb6");
641 print "\n\n";
642 foreach $p (&prognames("M")) {
643 ($prog, $type) = split ",", $p;
644
645 print &splitline("$prog \xc4 $prog.68k $prog.ppc", undef, "\xb6"), "\n\n";
646
647 $objstr = &objects($p, "X.68k.o", undef, undef);
648 print &splitline("$prog.68k \xc4 $objstr", undef, "\xb6"), "\n";
649 print &splitline("\tILink -o {Targ} {LinkOptions_68K} " .
650 $objstr . " {Libs_68K}", 69, "\xb6"), "\n\n";
651
652 $objstr = &objects($p, "X.ppc.o", undef, undef);
653 print &splitline("$prog.ppc \xc4 $objstr", undef, "\xb6"), "\n";
654 print &splitline("\tPPCLink -o {Targ} {LinkOptions_PPC} " .
655 $objstr . " {Libs_PPC}", 69, "\xb6"), "\n\n";
656 }
657 foreach $d (&deps("X.68k.o", undef, "::", ":")) {
658 print &splitline(sprintf("%s \xc4 %s", $d->{obj}, join " ", @{$d->{deps}}),
659 undef, "\xb6"), "\n";
660 print "\t{C} ", $d->{deps}->[0], " -o {Targ} {COptions_68K}\n\n";
661 }
662 foreach $d (&deps("X.ppc.o", undef, "::", ":")) {
663 print &splitline(sprintf("%s \xc4 %s", $d->{obj}, join " ", @{$d->{deps}}),
664 undef, "\xb6"), "\n";
665 # The odd stuff here seems to stop afpd getting confused.
666 print "\techo -n > {Targ}\n";
667 print "\tsetfile -t XCOF {Targ}\n";
668 print "\t{PPCC} ", $d->{deps}->[0], " -o {Targ} {COptions_PPC}\n\n";
669 }
670 select STDOUT; close OUT;