Put prototypes for the functions exported by wcwidth.c in putty.h, and remove
[u/mdw/putty] / mkfiles.pl
CommitLineData
3d541627 1#!/usr/bin/env perl
2#
7603011f 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
f7f27309 10use FileHandle;
11
7603011f 12open IN, "Recipe" or die "unable to open Recipe file\n";
13
615f7a0d 14@incdirs = ("", "unix/", "mac/");
f7f27309 15
7603011f 16$help = ""; # list of newline-free lines of help text
c282cde3 17%programs = (); # maps prog name + type letter to listref of objects/resources
7603011f 18%groups = (); # maps group name to listref of objects/resources
3d541627 19
3d541627 20while (<IN>) {
7603011f 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
3d541627 25 chomp;
7603011f 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 ":") {
c282cde3 48 $listref = [];
7603011f 49 $prog = $_[0];
50 shift @objs; # eat the program name
3d541627 51 } else {
7603011f 52 die "$.: unrecognised line type\n";
3d541627 53 }
7603011f 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; }
a86a2725 60 } elsif (($i eq "[G]" or $i eq "[C]" or $i eq "[M]" or
32bb2723 61 $i eq "[X]" or $i eq "[U]") and defined $prog) {
c282cde3 62 $type = substr($i,1,1);
7603011f 63 } else {
64 push @$listref, $i;
65 }
66 }
c282cde3 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 }
7603011f 72 $lastlistref = $listref;
3d541627 73}
7603011f 74
3d541627 75close IN;
7603011f 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 = ();
83foreach $i (@prognames) {
c282cde3 84 ($prog, $type) = split ",", $i;
7603011f 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 = ();
124while (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} = [];
f7f27309 129 $dirfile = &findfile($file);
130 open IN, "$dirfile" or die "unable to open source file $file\n";
7603011f 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;
3d541627 144}
145
7603011f 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.
149foreach $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}};
3d541627 164}
165
7603011f 166# Utility routines while writing out the Makefiles.
167
f7f27309 168sub 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
7603011f 179sub objects {
f7f27309 180 my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_;
7603011f 181 my @ret;
182 my ($i, $x, $y);
183 @ret = ();
184 foreach $i (@{$programs{$prog}}) {
f7f27309 185 $x = "";
7603011f 186 if ($i =~ /^(.*)\.res/) {
187 $y = $1;
188 ($x = $rtmpl) =~ s/X/$y/;
7603011f 189 } elsif ($i =~ /^(.*)\.lib/) {
190 $y = $1;
191 ($x = $ltmpl) =~ s/X/$y/;
7603011f 192 } else {
193 ($x = $otmpl) =~ s/X/$i/;
7603011f 194 }
f7f27309 195 push @ret, $x if $x ne "";
7603011f 196 }
197 return join " ", @ret;
3d541627 198}
199
7603011f 200sub splitline {
a86a2725 201 my ($line, $width, $splitchar) = @_;
7603011f 202 my ($result, $len);
203 $len = (defined $width ? $width : 76);
a86a2725 204 $splitchar = (defined $splitchar ? $splitchar : '\\');
7603011f 205 while (length $line > $len) {
206 $line =~ /^(.{0,$len})\s(.*)$/ or $line =~ /^(.{$len,}?\s(.*)$/;
a86a2725 207 $result .= $1 . " ${splitchar}\n\t\t";
7603011f 208 $line = $2;
209 $len = 60;
210 }
211 return $result . $line;
212}
213
214sub deps {
a86a2725 215 my ($otmpl, $rtmpl, $prefix, $dirsep, $depchar, $splitchar) = @_;
7603011f 216 my ($i, $x, $y);
a86a2725 217 my @deps, @ret;
218 @ret = ();
219 $depchar ||= ':';
7603011f 220 foreach $i (sort keys %depends) {
221 if ($i =~ /^(.*)\.res/) {
f7f27309 222 next if !defined $rtmpl;
7603011f 223 $y = $1;
224 ($x = $rtmpl) =~ s/X/$y/;
225 } else {
226 ($x = $otmpl) =~ s/X/$i/;
227 }
f7f27309 228 @deps = @{$depends{$i}};
229 @deps = map {
230 $_ = &findfile($_);
231 s/\//$dirsep/g;
232 $_ = $prefix . $_;
233 } @deps;
a86a2725 234 push @ret, {obj => $x, deps => [@deps]};
7603011f 235 }
a86a2725 236 return @ret;
3d541627 237}
238
f7f27309 239sub prognames {
240 my ($types) = @_;
c282cde3 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
251sub progrealnames {
252 my ($types) = @_;
253 my ($n, $prog, $type);
f7f27309 254 my @ret;
255 @ret = ();
256 foreach $n (@prognames) {
c282cde3 257 ($prog, $type) = split ",", $n;
258 push @ret, $prog if index($types, $type) >= 0;
f7f27309 259 }
260 return @ret;
261}
262
c76d309d 263sub 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
7603011f 273# Now we're ready to output the actual Makefiles.
274
3d541627 275##-- CygWin makefile
276open OUT, ">Makefile.cyg"; select OUT;
277print
7603011f 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";
3d541627 281# gcc command line option is -D not /D
7603011f 282($_ = $help) =~ s/=\/D/=-D/gs;
3d541627 283print $_;
284print
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".
7603011f 294&splitline("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
295 " -DNO_SECURITY -D_NO_OLDNAMES -DNO_MULTIMON -I.")."\n".
f730b86a 296"LDFLAGS = -mno-cygwin -s\n".
7603011f 297&splitline("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1".
298 " --define WINVER=0x0400 --define MINGW32_FIX=1")."\n".
3d541627 299"\n".
300".SUFFIXES:\n".
301"\n".
201e9294 302"%.o: %.c\n".
cf03419b 303"\t\$(CC) \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) -c \$<\n".
3d541627 304"\n".
f730b86a 305"%.res.o: %.rc\n".
6ed3635b 306"\t\$(RC) \$(FWHACK) \$(RCFL) \$(RCFLAGS) \$< \$\@\n".
3d541627 307"\n";
c282cde3 308print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("GC"));
14232990 309print "\n\n";
f7f27309 310foreach $p (&prognames("GC")) {
c282cde3 311 ($prog, $type) = split ",", $p;
7603011f 312 $objstr = &objects($p, "X.o", "X.res.o", undef);
c282cde3 313 print &splitline($prog . ".exe: " . $objstr), "\n";
314 my $mw = $type eq "G" ? " -mwindows" : "";
7603011f 315 $libstr = &objects($p, undef, undef, "-lX");
316 print &splitline("\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " .
317 $objstr . " $libstr", 69), "\n\n";
3d541627 318}
a86a2725 319foreach $d (&deps("X.o", "X.res.o", "", "/")) {
320 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
321 "\n";
322}
3d541627 323print
324"\n".
74091dff 325"version.o: FORCE;\n".
3d541627 326"# Hack to force version.o to be rebuilt always\n".
327"FORCE:\n".
7603011f 328"\t\$(CC) \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) \$(VER) -c version.c\n".
3d541627 329"clean:\n".
7603011f 330"\trm -f *.o *.exe *.res.o\n".
3d541627 331"\n";
332select STDOUT; close OUT;
333
334##-- Borland makefile
7603011f 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);
3d541627 347open OUT, ">Makefile.bor"; select OUT;
348print
7603011f 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";
3d541627 352# bcc32 command line option is -D not /D
7603011f 353($_ = $help) =~ s/=\/D/=-D/gs;
3d541627 354print $_;
355print
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".
a401e5f3 361"# C compilation flags\n".
95912ebc 362"CFLAGS = -D_WINDOWS -DWINVER=0x0401\n".
a401e5f3 363"\n".
3d541627 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".
8aa5bfd9 370&splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT) \$(FWHACK)".
7603011f 371 " \$(XFLAGS) \$(CFLAGS) /c \$*.c",69)."\n".
3d541627 372".rc.res:\n".
7603011f 373&splitline("\tbrcc32 \$(FWHACK) \$(RCFL) -i \$(BCB)\\include -r".
374 " -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401 \$*.rc",69)."\n".
3d541627 375"\n";
c282cde3 376print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("GC"));
3d541627 377print "\n\n";
f7f27309 378foreach $p (&prognames("GC")) {
c282cde3 379 ($prog, $type) = split ",", $p;
7603011f 380 $objstr = &objects($p, "X.obj", "X.res", undef);
c282cde3 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";
3d541627 384}
f7f27309 385foreach $p (&prognames("GC")) {
c282cde3 386 ($prog, $type) = split ",", $p;
387 print $prog, ".rsp: \$(MAKEFILE)\n";
7603011f 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 }
c282cde3 397 $c0w = ($type eq "G") ? "c0w32" : "c0x32";
398 print "\techo $c0w + > $prog.rsp\n";
a7088bde 399 for ($i=0; $i<=$#objlines; $i++) {
400 $plus = ($i < $#objlines ? " +" : "");
c282cde3 401 print "\techo$objlines[$i]$plus >> $prog.rsp\n";
3d541627 402 }
c282cde3 403 print "\techo $prog.exe >> $prog.rsp\n";
7603011f 404 $objstr = &objects($p, "X.obj", "X.res", undef);
405 @libs = split " ", &objects($p, undef, undef, "X");
406 @libs = grep { !$stdlibs{$_} } @libs;
6d2d5e8d 407 unshift @libs, "cw32", "import32";
408 $libstr = join ' ', @libs;
c282cde3 409 print "\techo nul,$libstr, >> $prog.rsp\n";
410 print "\techo " . &objects($p, undef, "X.res", undef) . " >> $prog.rsp\n";
3d541627 411 print "\n";
412}
a86a2725 413foreach $d (&deps("X.obj", "X.res", "", "\\")) {
414 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
415 "\n";
416}
3d541627 417print
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".
2e792012 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";
3d541627 434select STDOUT; close OUT;
7603011f 435
436##-- Visual C++ makefile
437open OUT, ">Makefile.vc"; select OUT;
438print
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";
442print $help;
443print
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";
c282cde3 458print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("GC"));
7603011f 459print "\n\n";
f7f27309 460foreach $p (&prognames("GC")) {
c282cde3 461 ($prog, $type) = split ",", $p;
7603011f 462 $objstr = &objects($p, "X.obj", "X.res", undef);
c282cde3 463 print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
464 print "\tlink \$(LFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n";
7603011f 465}
f7f27309 466foreach $p (&prognames("GC")) {
c282cde3 467 ($prog, $type) = split ",", $p;
468 print $prog, ".rsp: \$(MAKEFILE)\n";
7603011f 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 }
c282cde3 478 $subsys = ($type eq "G") ? "windows" : "console";
479 print "\techo /nologo /subsystem:$subsys > $prog.rsp\n";
7603011f 480 for ($i=0; $i<=$#objlines; $i++) {
c282cde3 481 print "\techo$objlines[$i] >> $prog.rsp\n";
7603011f 482 }
483 print "\n";
484}
a86a2725 485foreach $d (&deps("X.obj", "X.res", "", "\\")) {
486 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
487 "\n";
488}
7603011f 489print
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";
512select STDOUT; close OUT;
f7f27309 513
514##-- X/GTK/Unix makefile
515open OUT, ">unix/Makefile.gtk"; select OUT;
516print
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;
522print $_;
523print
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".
1709795f 529&splitline("CFLAGS = -Wall -g -I. -I.. `gtk-config --cflags`")."\n".
32bb2723 530"XLDFLAGS = `gtk-config --libs`\n".
531"ULDFLAGS =#\n".
c76d309d 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",
f7f27309 540"\n".
541".SUFFIXES:\n".
542"\n".
1709795f 543"%.o:\n".
f7f27309 544"\t\$(CC) \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) -c \$<\n".
545"\n";
32bb2723 546print &splitline("all:" . join "", map { " $_" } &progrealnames("XU"));
f7f27309 547print "\n\n";
32bb2723 548foreach $p (&prognames("XU")) {
c282cde3 549 ($prog, $type) = split ",", $p;
f7f27309 550 $objstr = &objects($p, "X.o", undef, undef);
c282cde3 551 print &splitline($prog . ": " . $objstr), "\n";
f7f27309 552 $libstr = &objects($p, undef, undef, "-lX");
32bb2723 553 print &splitline("\t\$(CC)" . $mw . " \$(${type}LDFLAGS) -o \$@ " .
f7f27309 554 $objstr . " $libstr", 69), "\n\n";
555}
a86a2725 556foreach $d (&deps("X.o", undef, "../", "/")) {
557 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
558 "\n";
559}
f7f27309 560print
561"\n".
562"version.o: FORCE;\n".
563"# Hack to force version.o to be rebuilt always\n".
564"FORCE:\n".
c282cde3 565"\t\$(CC) \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) \$(VER) -c ../version.c\n".
f7f27309 566"clean:\n".
32bb2723 567"\trm -f *.o". (join "", map { " $_" } &progrealnames("XU")) . "\n".
c76d309d 568"\n",
569"install:\n",
32bb2723 570map("\t\$(INSTALL_PROGRAM) -m 755 $_ \$(bindir)/$_\n", &progrealnames("XU")),
571map("\t\$(INSTALL_DATA) -m 644 $_ \$(man1dir)/$_\n", &manpages("XU", "1")),
c76d309d 572"\n",
573"install-strip:\n",
574"\t\$(MAKE) install INSTALL_PROGRAM=\"\$(INSTALL_PROGRAM) -s\"\n",
f7f27309 575"\n";
576select STDOUT; close OUT;
a86a2725 577
578##-- MPW Makefile
579open OUT, ">mac/Makefile.mpw"; select OUT;
580print <<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.
585END
586# MPW command line option is -d not /D
587($_ = $help) =~ s/=\/D/=-d /gs;
588print $_;
589print <<END;
590
b7f3320b 591# -w 53 disables "unused parameter" warnings
592COptions = -i : -i :: -w 35
a86a2725 593COptions_68K = {COptions} -proto strict -model far
b7f3320b 594COptions_PPC = {COptions}
a86a2725 595ILinkOptions = -t 'APPL' -c 'pTTY' -br 68k -model far
596
728c2c88 597Libs_68K = "{CLibraries}StdCLib.far.o" \xb6
a86a2725 598 "{Libraries}MacRuntime.o" \xb6
599 "{Libraries}MathLib.far.o" \xb6
728c2c88 600 "{Libraries}IntEnv.far.o" \xb6
a86a2725 601 "{Libraries}Interface.o" \xb6
602 "{Libraries}OpenTransport.o" \xb6
603 "{Libraries}OpenTransportApp.o" \xb6
8768ce31 604 "{Libraries}OpenTptInet.o" \xb6
605 "{Libraries}UnicodeConverterLib.far.o"
a86a2725 606
607Libs_PPC = "{SharedLibraries}InterfaceLib" \xb6
608 "{SharedLibraries}StdCLib" \xb6
609 "{SharedLibraries}MathLib" \xb6
610 "{SharedLibraries}AppearanceLib" \xb6
611 -weaklib AppearanceLib \xb6
612 "{SharedLibraries}OpenTransportLib" \xb6
613 -weaklib OTGlobalLib \xb6
614 -weaklib OTUtilityLib \xb6
615 -weaklib OTClientUtilLib \xb6
616 -weaklib OTClientLib \xb6
617 -weaklib OTStreamUnixLib \xb6
618 -weaklib OTXTILib \xb6
619 -weaklib OTConfigLib \xb6
620 -weaklib OTNtvUtilLib \xb6
621 -weaklib OTNativeClientLib \xb6
622 "{SharedLibraries}OpenTptInternetLib" \xb6
623 -weaklib OTInetClientLib \xb6
624 "{PPCLibraries}StdCRuntime.o" \xb6
625 "{PPCLibraries}PPCCRuntime.o" \xb6
626 "{PPCLibraries}OpenTransportAppPPC.o" \xb6
627 "{PPCLibraries}OpenTptInetPPC.o"
628
629
630END
631print &splitline("all \xc4 " . join(" ", &progrealnames("M")), undef, "\xb6");
632print "\n\n";
633foreach $p (&prognames("M")) {
634 ($prog, $type) = split ",", $p;
635 $objstr = &objects($p, "X.c.o", undef, undef);
636 print &splitline($prog . " \xc4 " . $objstr, undef, "\xb6"), "\n";
637 print &splitline("\tILink -o {Targ} {ILinkOptions} " .
638 $objstr . " {Libs_68K}", 69, "\xb6"), "\n\n";
639}
640foreach $d (&deps("X.c.o", undef, "::", ":")) {
641 print &splitline(sprintf("%s \xc4 %s", $d->{obj}, join " ", @{$d->{deps}}),
642 undef, "\xb6"), "\n";
643 print "\t{C} ", $d->{deps}->[0], " -o {Targ} {COptions_68K}\n\n";
644}
645foreach $d (&deps("X.c.x", undef, "::", ":")) {
646 print &splitline(sprintf("%s \xc4 %s", $d->{obj}, join " ", @{$d->{deps}}),
647 undef, "\xb6"), "\n";
648 # The odd stuff here seems to stop afpd getting confused.
649 print "\techo -n > {Targ}\n";
650 print "\tsetfile -t XCOF {Targ}\n";
651 print "\t{PPCC} ", $d->{deps}->[0], " -o {Targ} {COptions_PPC}\n\n";
652}
653select STDOUT; close OUT;