Make mkfiles.pl less tied to PuTTY in particular, by inventing new
[u/mdw/putty] / mkfiles.pl
CommitLineData
3d541627 1#!/usr/bin/env perl
2#
e35fb54b 3# Cross-platform Makefile generator.
7603011f 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;
e35fb54b 11use Cwd;
f7f27309 12
e3109730 13open IN, "Recipe" or do {
14 # We want to deal correctly with being run from one of the
15 # subdirs in the source tree. So if we can't find Recipe here,
16 # try one level up.
17 chdir "..";
18 open IN, "Recipe" or die "unable to open Recipe file\n";
19};
7603011f 20
2dc6356a 21# HACK: One of the source files in `charset' is auto-generated by
22# sbcsgen.pl. We need to generate that _now_, before attempting
23# dependency analysis.
24eval 'chdir "charset"; require "sbcsgen.pl"; chdir ".."';
25
26@incdirs = ("", "charset/", "unix/", "mac/");
f7f27309 27
e35fb54b 28$divert = undef; # ref to scalar in which text is currently being put
7603011f 29$help = ""; # list of newline-free lines of help text
e35fb54b 30$project_name = "project"; # this is a good enough default
31%makefiles = (); # maps makefile types to output makefile pathnames
32%makefile_extra = (); # maps makefile types to extra Makefile text
c282cde3 33%programs = (); # maps prog name + type letter to listref of objects/resources
7603011f 34%groups = (); # maps group name to listref of objects/resources
3d541627 35
3d541627 36while (<IN>) {
7603011f 37 # Skip comments (unless the comments belong, for example because
e35fb54b 38 # they're part of a diversion).
39 next if /^\s*#/ and !defined $divert;
7603011f 40
3d541627 41 chomp;
7603011f 42 split;
e35fb54b 43 if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = \$help; next; }
44 if ($_[0] eq "!end") { $divert = undef; next; }
45 if ($_[0] eq "!name") { $project_name = $_[1]; next; }
46 if ($_[0] eq "!makefile" and &mfval($_[1])) { $makefiles{$_[1]}=$_[2]; next;}
47 if ($_[0] eq "!begin") {
48 if (&mfval($_[1])) {
49 $divert = \$makefile_extra{$_[1]};
50 } else {
51 $divert = \$dummy;
52 }
53 next;
54 }
7603011f 55 # If we're gathering help text, keep doing so.
e35fb54b 56 if (defined $divert) { ${$divert} .= "$_\n"; next; }
7603011f 57 # Ignore blank lines.
58 next if scalar @_ == 0;
59
60 # Now we have an ordinary line. See if it's an = line, a : line
61 # or a + line.
62 @objs = @_;
63
64 if ($_[0] eq "+") {
65 $listref = $lastlistref;
66 $prog = undef;
67 die "$.: unexpected + line\n" if !defined $lastlistref;
68 } elsif ($_[1] eq "=") {
69 $groups{$_[0]} = [] if !defined $groups{$_[0]};
70 $listref = $groups{$_[0]};
71 $prog = undef;
72 shift @objs; # eat the group name
73 } elsif ($_[1] eq ":") {
c282cde3 74 $listref = [];
7603011f 75 $prog = $_[0];
76 shift @objs; # eat the program name
3d541627 77 } else {
7603011f 78 die "$.: unrecognised line type\n";
3d541627 79 }
7603011f 80 shift @objs; # eat the +, the = or the :
81
82 while (scalar @objs > 0) {
83 $i = shift @objs;
84 if ($groups{$i}) {
85 foreach $j (@{$groups{$i}}) { unshift @objs, $j; }
a86a2725 86 } elsif (($i eq "[G]" or $i eq "[C]" or $i eq "[M]" or
e35fb54b 87 $i eq "[X]" or $i eq "[U]") and defined $prog) {
c282cde3 88 $type = substr($i,1,1);
7603011f 89 } else {
90 push @$listref, $i;
91 }
92 }
c282cde3 93 if ($prog and $type) {
94 die "multiple program entries for $prog [$type]\n"
e35fb54b 95 if defined $programs{$prog . "," . $type};
c282cde3 96 $programs{$prog . "," . $type} = $listref;
97 }
7603011f 98 $lastlistref = $listref;
3d541627 99}
7603011f 100
3d541627 101close IN;
7603011f 102
103# Now retrieve the complete list of objects and resource files, and
104# construct dependency data for them. While we're here, expand the
105# object list for each program, and complain if its type isn't set.
106@prognames = sort keys %programs;
107%depends = ();
108@scanlist = ();
109foreach $i (@prognames) {
c282cde3 110 ($prog, $type) = split ",", $i;
7603011f 111 # Strip duplicate object names.
112 $prev = undef;
113 @list = grep { $status = ($prev ne $_); $prev=$_; $status }
114 sort @{$programs{$i}};
115 $programs{$i} = [@list];
116 foreach $j (@list) {
117 # Dependencies for "x" start with "x.c".
118 # Dependencies for "x.res" start with "x.rc".
c88dc003 119 # Dependencies for "x.rsrc" start with "x.r".
7603011f 120 # Both types of file are pushed on the list of files to scan.
121 # Libraries (.lib) don't have dependencies at all.
122 if ($j =~ /^(.*)\.res$/) {
123 $file = "$1.rc";
124 $depends{$j} = [$file];
125 push @scanlist, $file;
c88dc003 126 } elsif ($j =~ /^(.*)\.rsrc$/) {
127 $file = "$1.r";
128 $depends{$j} = [$file];
129 push @scanlist, $file;
7603011f 130 } elsif ($j =~ /\.lib$/) {
131 # libraries don't have dependencies
132 } else {
133 $file = "$j.c";
134 $depends{$j} = [$file];
135 push @scanlist, $file;
136 }
137 }
138}
139
140# Scan each file on @scanlist and find further inclusions.
141# Inclusions are given by lines of the form `#include "otherfile"'
142# (system headers are automatically ignored by this because they'll
143# be given in angle brackets). Files included by this method are
144# added back on to @scanlist to be scanned in turn (if not already
145# done).
146#
147# Resource scripts (.rc) can also include a file by means of a line
148# ending `ICON "filename"'. Files included by this method are not
149# added to @scanlist because they can never include further files.
150#
151# In this pass we write out a hash %further which maps a source
152# file name into a listref containing further source file names.
153
154%further = ();
155while (scalar @scanlist > 0) {
156 $file = shift @scanlist;
157 next if defined $further{$file}; # skip if we've already done it
158 $resource = ($file =~ /\.rc$/ ? 1 : 0);
159 $further{$file} = [];
f7f27309 160 $dirfile = &findfile($file);
161 open IN, "$dirfile" or die "unable to open source file $file\n";
7603011f 162 while (<IN>) {
163 chomp;
164 /^\s*#include\s+\"([^\"]+)\"/ and do {
165 push @{$further{$file}}, $1;
166 push @scanlist, $1;
167 next;
168 };
169 /ICON\s+\"([^\"]+)\"\s*$/ and do {
170 push @{$further{$file}}, $1;
171 next;
172 }
173 }
174 close IN;
3d541627 175}
176
7603011f 177# Now we're ready to generate the final dependencies section. For
178# each key in %depends, we must expand the dependencies list by
179# iteratively adding entries from %further.
180foreach $i (keys %depends) {
181 %dep = ();
182 @scanlist = @{$depends{$i}};
183 foreach $i (@scanlist) { $dep{$i} = 1; }
184 while (scalar @scanlist > 0) {
185 $file = shift @scanlist;
186 foreach $j (@{$further{$file}}) {
187 if ($dep{$j} != 1) {
188 $dep{$j} = 1;
e35fb54b 189 push @{$depends{$i}}, $j;
190 push @scanlist, $j;
7603011f 191 }
192 }
193 }
194# printf "%s: %s\n", $i, join ' ',@{$depends{$i}};
3d541627 195}
196
e35fb54b 197# Validation of input.
198
199sub mfval($) {
200 my ($type) = @_;
201 # Returns true if the argument is a known makefile type. Otherwise,
202 # prints a warning and returns false;
203 if (grep { $type eq $_ }
204 ("vc","vcproj","cygwin","borland","lcc","gtk","mpw")) {
205 return 1;
206 }
207 warn "$.:unknown makefile type '$type'\n";
208 return 0;
209}
210
7603011f 211# Utility routines while writing out the Makefiles.
212
f7f27309 213sub findfile {
214 my ($name) = @_;
215 my $dir, $i, $outdir = "";
b6b40d9b 216 unless (defined $findfilecache{$name}) {
217 $i = 0;
218 foreach $dir (@incdirs) {
219 $outdir = $dir, $i++ if -f "$dir$name";
220 }
221 die "multiple instances of source file $name\n" if $i > 1;
222 $findfilecache{$name} = $outdir . $name;
f7f27309 223 }
b6b40d9b 224 return $findfilecache{$name};
f7f27309 225}
226
7603011f 227sub objects {
f7f27309 228 my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_;
7603011f 229 my @ret;
230 my ($i, $x, $y);
231 @ret = ();
232 foreach $i (@{$programs{$prog}}) {
f7f27309 233 $x = "";
c88dc003 234 if ($i =~ /^(.*)\.(res|rsrc)/) {
7603011f 235 $y = $1;
236 ($x = $rtmpl) =~ s/X/$y/;
7603011f 237 } elsif ($i =~ /^(.*)\.lib/) {
238 $y = $1;
239 ($x = $ltmpl) =~ s/X/$y/;
7603011f 240 } else {
241 ($x = $otmpl) =~ s/X/$i/;
7603011f 242 }
f7f27309 243 push @ret, $x if $x ne "";
7603011f 244 }
245 return join " ", @ret;
3d541627 246}
247
7603011f 248sub splitline {
a86a2725 249 my ($line, $width, $splitchar) = @_;
7603011f 250 my ($result, $len);
251 $len = (defined $width ? $width : 76);
a86a2725 252 $splitchar = (defined $splitchar ? $splitchar : '\\');
7603011f 253 while (length $line > $len) {
254 $line =~ /^(.{0,$len})\s(.*)$/ or $line =~ /^(.{$len,}?\s(.*)$/;
a86a2725 255 $result .= $1 . " ${splitchar}\n\t\t";
7603011f 256 $line = $2;
257 $len = 60;
258 }
259 return $result . $line;
260}
261
262sub deps {
a86a2725 263 my ($otmpl, $rtmpl, $prefix, $dirsep, $depchar, $splitchar) = @_;
7603011f 264 my ($i, $x, $y);
a86a2725 265 my @deps, @ret;
266 @ret = ();
267 $depchar ||= ':';
7603011f 268 foreach $i (sort keys %depends) {
c88dc003 269 if ($i =~ /^(.*)\.(res|rsrc)/) {
f7f27309 270 next if !defined $rtmpl;
7603011f 271 $y = $1;
272 ($x = $rtmpl) =~ s/X/$y/;
273 } else {
274 ($x = $otmpl) =~ s/X/$i/;
275 }
f7f27309 276 @deps = @{$depends{$i}};
277 @deps = map {
278 $_ = &findfile($_);
279 s/\//$dirsep/g;
280 $_ = $prefix . $_;
281 } @deps;
a86a2725 282 push @ret, {obj => $x, deps => [@deps]};
7603011f 283 }
a86a2725 284 return @ret;
3d541627 285}
286
f7f27309 287sub prognames {
288 my ($types) = @_;
c282cde3 289 my ($n, $prog, $type);
290 my @ret;
291 @ret = ();
292 foreach $n (@prognames) {
293 ($prog, $type) = split ",", $n;
294 push @ret, $n if index($types, $type) >= 0;
295 }
296 return @ret;
297}
298
299sub progrealnames {
300 my ($types) = @_;
301 my ($n, $prog, $type);
f7f27309 302 my @ret;
303 @ret = ();
304 foreach $n (@prognames) {
c282cde3 305 ($prog, $type) = split ",", $n;
306 push @ret, $prog if index($types, $type) >= 0;
f7f27309 307 }
308 return @ret;
309}
310
c76d309d 311sub manpages {
312 my ($types,$suffix) = @_;
313
314 # assume that all UNIX programs have a man page
315 if($suffix eq "1" && $types =~ /X/) {
316 return map("$_.1", &progrealnames($types));
317 }
318 return ();
319}
320
7603011f 321# Now we're ready to output the actual Makefiles.
322
e35fb54b 323if (defined $makefiles{'cygwin'}) {
3d541627 324
e35fb54b 325 ##-- CygWin makefile
326 open OUT, ">$makefiles{'cygwin'}"; select OUT;
327 print
328 "# Makefile for $project_name under cygwin.\n".
329 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
330 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
331 # gcc command line option is -D not /D
332 ($_ = $help) =~ s/=\/D/=-D/gs;
333 print $_;
334 print
335 "\n".
336 "# You can define this path to point at your tools if you need to\n".
337 "# TOOLPATH = c:\\cygwin\\bin\\ # or similar, if you're running Windows\n".
338 "# TOOLPATH = /pkg/mingw32msvc/i386-mingw32msvc/bin/\n".
339 "CC = \$(TOOLPATH)gcc\n".
340 "RC = \$(TOOLPATH)windres\n".
341 "# Uncomment the following two lines to compile under Winelib\n".
342 "# CC = winegcc\n".
343 "# RC = wrc\n".
344 "# You may also need to tell windres where to find include files:\n".
345 "# RCINC = --include-dir c:\\cygwin\\include\\\n".
346 "\n".
347 &splitline("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
348 " -D_NO_OLDNAMES -DNO_MULTIMON -I.")."\n".
349 "LDFLAGS = -mno-cygwin -s\n".
350 &splitline("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1".
351 " --define WINVER=0x0400 --define MINGW32_FIX=1")."\n".
352 "\n".
353 ".SUFFIXES:\n".
354 "\n".
355 "%.o: %.c\n".
356 "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) -c \$<\n".
357 "\n".
358 "%.res.o: %.rc\n".
359 "\t\$(RC) \$(FWHACK) \$(RCFL) \$(RCFLAGS) \$< \$\@\n".
360 "\n";
361 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("GC"));
362 print "\n\n";
363 foreach $p (&prognames("GC")) {
364 ($prog, $type) = split ",", $p;
365 $objstr = &objects($p, "X.o", "X.res.o", undef);
366 print &splitline($prog . ".exe: " . $objstr), "\n";
367 my $mw = $type eq "G" ? " -mwindows" : "";
368 $libstr = &objects($p, undef, undef, "-lX");
369 print &splitline("\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " .
370 "-Wl,-Map,$prog.map " .
371 $objstr . " $libstr", 69), "\n\n";
7603011f 372 }
e35fb54b 373 foreach $d (&deps("X.o", "X.res.o", "", "/")) {
374 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
375 "\n";
376 }
377 print "\n";
378 print $makefile_extra{'cygwin'};
379 print "\nclean:\n".
380 "\trm -f *.o *.exe *.res.o *.map\n".
a86a2725 381 "\n";
e35fb54b 382 select STDOUT; close OUT;
7603011f 383
7603011f 384}
e35fb54b 385
386##-- Borland makefile
387if (defined $makefiles{'borland'}) {
388 %stdlibs = ( # Borland provides many Win32 API libraries intrinsically
389 "advapi32" => 1,
390 "comctl32" => 1,
391 "comdlg32" => 1,
392 "gdi32" => 1,
393 "imm32" => 1,
394 "shell32" => 1,
395 "user32" => 1,
396 "winmm" => 1,
397 "winspool" => 1,
398 "wsock32" => 1,
399 );
400 open OUT, ">$makefiles{'borland'}"; select OUT;
401 print
402 "# Makefile for $project_name under Borland C.\n".
403 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
404 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
405 # bcc32 command line option is -D not /D
406 ($_ = $help) =~ s/=\/D/=-D/gs;
407 print $_;
408 print
409 "\n".
410 "# If you rename this file to `Makefile', you should change this line,\n".
411 "# so that the .rsp files still depend on the correct makefile.\n".
412 "MAKEFILE = Makefile.bor\n".
413 "\n".
414 "# C compilation flags\n".
415 "CFLAGS = -D_WINDOWS -DWINVER=0x0401\n".
416 "\n".
417 "# Get include directory for resource compiler\n".
418 "!if !\$d(BCB)\n".
419 "BCB = \$(MAKEDIR)\\..\n".
420 "!endif\n".
421 "\n".
422 ".c.obj:\n".
423 &splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT) \$(FWHACK)".
424 " \$(XFLAGS) \$(CFLAGS) /c \$*.c",69)."\n".
425 ".rc.res:\n".
426 &splitline("\tbrcc32 \$(FWHACK) \$(RCFL) -i \$(BCB)\\include -r".
427 " -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401 \$*.rc",69)."\n".
428 "\n";
429 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("GC"));
430 print "\n\n";
431 foreach $p (&prognames("GC")) {
432 ($prog, $type) = split ",", $p;
433 $objstr = &objects($p, "X.obj", "X.res", undef);
434 print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
435 my $ap = ($type eq "G") ? "-aa" : "-ap";
436 print "\tilink32 $ap -Gn -L\$(BCB)\\lib \@$prog.rsp\n\n";
7603011f 437 }
e35fb54b 438 foreach $p (&prognames("GC")) {
439 ($prog, $type) = split ",", $p;
440 print $prog, ".rsp: \$(MAKEFILE)\n";
441 $objstr = &objects($p, "X.obj", undef, undef);
442 @objlist = split " ", $objstr;
443 @objlines = ("");
444 foreach $i (@objlist) {
445 if (length($objlines[$#objlines] . " $i") > 50) {
446 push @objlines, "";
447 }
448 $objlines[$#objlines] .= " $i";
449 }
450 $c0w = ($type eq "G") ? "c0w32" : "c0x32";
451 print "\techo $c0w + > $prog.rsp\n";
452 for ($i=0; $i<=$#objlines; $i++) {
453 $plus = ($i < $#objlines ? " +" : "");
454 print "\techo$objlines[$i]$plus >> $prog.rsp\n";
455 }
456 print "\techo $prog.exe >> $prog.rsp\n";
457 $objstr = &objects($p, "X.obj", "X.res", undef);
458 @libs = split " ", &objects($p, undef, undef, "X");
459 @libs = grep { !$stdlibs{$_} } @libs;
460 unshift @libs, "cw32", "import32";
461 $libstr = join ' ', @libs;
462 print "\techo nul,$libstr, >> $prog.rsp\n";
463 print "\techo " . &objects($p, undef, "X.res", undef) . " >> $prog.rsp\n";
464 print "\n";
465 }
466 foreach $d (&deps("X.obj", "X.res", "", "\\")) {
467 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
468 "\n";
469 }
470 print "\n";
471 print $makefile_extra{'borland'};
472 print "\nclean:\n".
473 "\t-del *.obj\n".
474 "\t-del *.exe\n".
475 "\t-del *.res\n".
476 "\t-del *.pch\n".
477 "\t-del *.aps\n".
478 "\t-del *.il*\n".
479 "\t-del *.pdb\n".
480 "\t-del *.rsp\n".
481 "\t-del *.tds\n".
482 "\t-del *.\$\$\$\$\$\$\n";
483 select STDOUT; close OUT;
7603011f 484}
e35fb54b 485
486if (defined $makefiles{'vc'}) {
487 ##-- Visual C++ makefile
488 open OUT, ">$makefiles{'vc'}"; select OUT;
489 print
490 "# Makefile for $project_name under Visual C.\n".
491 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
492 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
493 print $help;
494 print
495 "\n".
496 "# If you rename this file to `Makefile', you should change this line,\n".
497 "# so that the .rsp files still depend on the correct makefile.\n".
498 "MAKEFILE = Makefile.vc\n".
499 "\n".
500 "# C compilation flags\n".
501 "CFLAGS = /nologo /W3 /O1 /D_WINDOWS /D_WIN32_WINDOWS=0x401 /DWINVER=0x401\n".
502 "LFLAGS = /incremental:no /fixed\n".
503 "\n".
504 ".c.obj:\n".
505 "\tcl \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) /c \$*.c\n".
506 ".rc.res:\n".
507 "\trc \$(FWHACK) \$(RCFL) -r -DWIN32 -D_WIN32 -DWINVER=0x0400 \$*.rc\n".
a86a2725 508 "\n";
e35fb54b 509 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("GC"));
510 print "\n\n";
511 foreach $p (&prognames("GC")) {
512 ($prog, $type) = split ",", $p;
513 $objstr = &objects($p, "X.obj", "X.res", undef);
514 print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
515 print "\tlink \$(LFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n";
516 }
517 foreach $p (&prognames("GC")) {
518 ($prog, $type) = split ",", $p;
519 print $prog, ".rsp: \$(MAKEFILE)\n";
520 $objstr = &objects($p, "X.obj", "X.res", "X.lib");
521 @objlist = split " ", $objstr;
522 @objlines = ("");
523 foreach $i (@objlist) {
524 if (length($objlines[$#objlines] . " $i") > 50) {
525 push @objlines, "";
526 }
527 $objlines[$#objlines] .= " $i";
528 }
529 $subsys = ($type eq "G") ? "windows" : "console";
530 print "\techo /nologo /subsystem:$subsys > $prog.rsp\n";
531 for ($i=0; $i<=$#objlines; $i++) {
532 print "\techo$objlines[$i] >> $prog.rsp\n";
533 }
534 print "\n";
535 }
536 foreach $d (&deps("X.obj", "X.res", "", "\\")) {
537 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
538 "\n";
539 }
540 print "\n";
541 print $makefile_extra{'vc'};
542 print "\nclean: tidy\n".
543 "\t-del *.exe\n\n".
544 "tidy:\n".
545 "\t-del *.obj\n".
546 "\t-del *.res\n".
547 "\t-del *.pch\n".
548 "\t-del *.aps\n".
549 "\t-del *.ilk\n".
550 "\t-del *.pdb\n".
551 "\t-del *.rsp\n".
552 "\t-del *.dsp\n".
553 "\t-del *.dsw\n".
554 "\t-del *.ncb\n".
555 "\t-del *.opt\n".
556 "\t-del *.plg\n".
557 "\t-del *.map\n".
558 "\t-del *.idb\n".
559 "\t-del debug.log\n";
560 select STDOUT; close OUT;
a86a2725 561}
f7f27309 562
e35fb54b 563if (defined $makefiles{'vcproj'}) {
58de2f3c 564
e35fb54b 565 $orig_dir = cwd;
566
567 ##-- MSVC 6 Workspace and projects
568 #
569 # Note: All files created in this section are written in binary
570 # mode, because although MSVC's command-line make can deal with
571 # LF-only line endings, MSVC project files really _need_ to be
572 # CRLF. Hence, in order for mkfiles.pl to generate usable project
573 # files even when run from Unix, I make sure all files are binary
574 # and explicitly write the CRLFs.
575 #
576 # Create directories if necessary
577 mkdir $makefiles{'vcproj'}
578 if(! -d $makefiles{'vcproj'});
579 chdir $makefiles{'vcproj'};
580 @deps = &deps("X.obj", "X.res", "", "\\");
581 %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;
582 # Create the project files
583 # Get names of all Windows projects (GUI and console)
584 my @prognames = &prognames("GC");
585 foreach $progname (@prognames) {
586 create_project(\%all_object_deps, $progname);
587 }
588 # Create the workspace file
589 open OUT, ">$project_name.dsw"; binmode OUT; select OUT;
590 print
591 "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n".
592 "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n".
593 "\r\n".
594 "###############################################################################\r\n".
595 "\r\n";
596 # List projects
597 foreach $progname (@prognames) {
598 ($windows_project, $type) = split ",", $progname;
599 print "Project: \"$windows_project\"=\".\\$windows_project\\$windows_project.dsp\" - Package Owner=<4>\r\n";
600 }
601 print
602 "\r\n".
603 "Package=<5>\r\n".
604 "{{{\r\n".
605 "}}}\r\n".
606 "\r\n".
607 "Package=<4>\r\n".
608 "{{{\r\n".
609 "}}}\r\n".
610 "\r\n".
611 "###############################################################################\r\n".
612 "\r\n".
613 "Global:\r\n".
614 "\r\n".
615 "Package=<5>\r\n".
616 "{{{\r\n".
617 "}}}\r\n".
618 "\r\n".
619 "Package=<3>\r\n".
620 "{{{\r\n".
621 "}}}\r\n".
622 "\r\n".
623 "###############################################################################\r\n".
624 "\r\n";
625 select STDOUT; close OUT;
626 chdir $orig_dir;
627
628 sub create_project {
629 my ($all_object_deps, $progname) = @_;
630 # Construct program's dependency info
631 %seen_objects = ();
632 %lib_files = ();
633 %source_files = ();
634 %header_files = ();
635 %resource_files = ();
636 @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");
637 foreach $object_file (@object_files) {
638 next if defined $seen_objects{$object_file};
639 $seen_objects{$object_file} = 1;
640 if($object_file =~ /\.lib$/io) {
641 $lib_files{$object_file} = 1;
642 next;
643 }
644 $object_deps = $all_object_deps{$object_file};
645 foreach $object_dep (@$object_deps) {
646 if($object_dep =~ /\.c$/io) {
647 $source_files{$object_dep} = 1;
648 next;
58de2f3c 649 }
e35fb54b 650 if($object_dep =~ /\.h$/io) {
651 $header_files{$object_dep} = 1;
652 next;
58de2f3c 653 }
e35fb54b 654 if($object_dep =~ /\.(rc|ico)$/io) {
655 $resource_files{$object_dep} = 1;
656 next;
58de2f3c 657 }
e35fb54b 658 }
659 }
660 $libs = join " ", sort keys %lib_files;
661 @source_files = sort keys %source_files;
662 @header_files = sort keys %header_files;
663 @resources = sort keys %resource_files;
664 ($windows_project, $type) = split ",", $progname;
665 mkdir $windows_project
666 if(! -d $windows_project);
667 chdir $windows_project;
668 $subsys = ($type eq "G") ? "windows" : "console";
669 open OUT, ">$windows_project.dsp"; binmode OUT; select OUT;
670 print
671 "# Microsoft Developer Studio Project File - Name=\"$windows_project\" - Package Owner=<4>\r\n".
672 "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n".
673 "# ** DO NOT EDIT **\r\n".
674 "\r\n".
675 "# TARGTYPE \"Win32 (x86) Application\" 0x0101\r\n".
676 "\r\n".
677 "CFG=$windows_project - Win32 Debug\r\n".
678 "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n".
679 "!MESSAGE use the Export Makefile command and run\r\n".
680 "!MESSAGE \r\n".
681 "!MESSAGE NMAKE /f \"$windows_project.mak\".\r\n".
682 "!MESSAGE \r\n".
683 "!MESSAGE You can specify a configuration when running NMAKE\r\n".
684 "!MESSAGE by defining the macro CFG on the command line. For example:\r\n".
685 "!MESSAGE \r\n".
686 "!MESSAGE NMAKE /f \"$windows_project.mak\" CFG=\"$windows_project - Win32 Debug\"\r\n".
687 "!MESSAGE \r\n".
688 "!MESSAGE Possible choices for configuration are:\r\n".
689 "!MESSAGE \r\n".
690 "!MESSAGE \"$windows_project - Win32 Release\" (based on \"Win32 (x86) Application\")\r\n".
691 "!MESSAGE \"$windows_project - Win32 Debug\" (based on \"Win32 (x86) Application\")\r\n".
692 "!MESSAGE \r\n".
693 "\r\n".
694 "# Begin Project\r\n".
695 "# PROP AllowPerConfigDependencies 0\r\n".
696 "# PROP Scc_ProjName \"\"\r\n".
697 "# PROP Scc_LocalPath \"\"\r\n".
698 "CPP=cl.exe\r\n".
699 "MTL=midl.exe\r\n".
700 "RSC=rc.exe\r\n".
701 "\r\n".
702 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
703 "\r\n".
704 "# PROP BASE Use_MFC 0\r\n".
705 "# PROP BASE Use_Debug_Libraries 0\r\n".
706 "# PROP BASE Output_Dir \"Release\"\r\n".
707 "# PROP BASE Intermediate_Dir \"Release\"\r\n".
708 "# PROP BASE Target_Dir \"\"\r\n".
709 "# PROP Use_MFC 0\r\n".
710 "# PROP Use_Debug_Libraries 0\r\n".
711 "# PROP Output_Dir \"Release\"\r\n".
712 "# PROP Intermediate_Dir \"Release\"\r\n".
713 "# PROP Ignore_Export_Lib 0\r\n".
714 "# PROP Target_Dir \"\"\r\n".
715 "# ADD BASE CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
716 "# ADD CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
717 "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
718 "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
719 "# ADD BASE RSC /l 0x809 /d \"NDEBUG\"\r\n".
720 "# ADD RSC /l 0x809 /d \"NDEBUG\"\r\n".
721 "BSC32=bscmake.exe\r\n".
722 "# ADD BASE BSC32 /nologo\r\n".
723 "# ADD BSC32 /nologo\r\n".
724 "LINK32=link.exe\r\n".
725 "# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:$subsys /machine:I386\r\n".
726 "# ADD LINK32 $libs /nologo /subsystem:$subsys /machine:I386\r\n".
727 "# SUBTRACT LINK32 /pdb:none\r\n".
728 "\r\n".
729 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
730 "\r\n".
731 "# PROP BASE Use_MFC 0\r\n".
732 "# PROP BASE Use_Debug_Libraries 1\r\n".
733 "# PROP BASE Output_Dir \"Debug\"\r\n".
734 "# PROP BASE Intermediate_Dir \"Debug\"\r\n".
735 "# PROP BASE Target_Dir \"\"\r\n".
736 "# PROP Use_MFC 0\r\n".
737 "# PROP Use_Debug_Libraries 1\r\n".
738 "# PROP Output_Dir \"Debug\"\r\n".
739 "# PROP Intermediate_Dir \"Debug\"\r\n".
740 "# PROP Ignore_Export_Lib 0\r\n".
741 "# PROP Target_Dir \"\"\r\n".
742 "# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
743 "# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
744 "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
745 "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
746 "# ADD BASE RSC /l 0x809 /d \"_DEBUG\"\r\n".
747 "# ADD RSC /l 0x809 /d \"_DEBUG\"\r\n".
748 "BSC32=bscmake.exe\r\n".
749 "# ADD BASE BSC32 /nologo\r\n".
750 "# ADD BSC32 /nologo\r\n".
751 "LINK32=link.exe\r\n".
752 "# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:$subsys /debug /machine:I386 /pdbtype:sept\r\n".
753 "# ADD LINK32 $libs /nologo /subsystem:$subsys /debug /machine:I386 /pdbtype:sept\r\n".
754 "# SUBTRACT LINK32 /pdb:none\r\n".
755 "\r\n".
756 "!ENDIF \r\n".
757 "\r\n".
758 "# Begin Target\r\n".
759 "\r\n".
760 "# Name \"$windows_project - Win32 Release\"\r\n".
761 "# Name \"$windows_project - Win32 Debug\"\r\n".
762 "# Begin Group \"Source Files\"\r\n".
763 "\r\n".
764 "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
765 foreach $source_file (@source_files) {
766 print
767 "# Begin Source File\r\n".
768 "\r\n".
769 "SOURCE=..\\..\\$source_file\r\n";
770 if($source_file =~ /ssh\.c/io) {
771 # Disable 'Edit and continue' as Visual Studio can't handle the macros
58de2f3c 772 print
e35fb54b 773 "\r\n".
774 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
775 "\r\n".
776 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
777 "\r\n".
778 "# ADD CPP /Zi\r\n".
779 "\r\n".
780 "!ENDIF \r\n".
781 "\r\n";
782 }
783 print "# End Source File\r\n";
784 }
785 print
786 "# End Group\r\n".
787 "# Begin Group \"Header Files\"\r\n".
788 "\r\n".
789 "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
790 foreach $header_file (@header_files) {
791 print
792 "# Begin Source File\r\n".
793 "\r\n".
794 "SOURCE=..\\..\\$header_file\r\n".
795 "# End Source File\r\n";
58de2f3c 796 }
e35fb54b 797 print
798 "# End Group\r\n".
799 "# Begin Group \"Resource Files\"\r\n".
800 "\r\n".
801 "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
802 foreach $resource_file (@resources) {
803 print
804 "# Begin Source File\r\n".
805 "\r\n".
806 "SOURCE=..\\..\\$resource_file\r\n".
807 "# End Source File\r\n";
808 }
809 print
810 "# End Group\r\n".
811 "# End Target\r\n".
812 "# End Project\r\n";
813 select STDOUT; close OUT;
814 chdir "..";
815 }
a86a2725 816}
a86a2725 817
e35fb54b 818if (defined $makefiles{'gtk'}) {
d37a507a 819
e35fb54b 820 ##-- X/GTK/Unix makefile
821 open OUT, ">$makefiles{'gtk'}"; select OUT;
822 print
823 "# Makefile for $project_name under X/GTK and Unix.\n".
824 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
825 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
826 # gcc command line option is -D not /D
827 ($_ = $help) =~ s/=\/D/=-D/gs;
828 print $_;
829 print
830 "\n".
831 "# You can define this path to point at your tools if you need to\n".
832 "# TOOLPATH = /opt/gcc/bin\n".
833 "CC = \$(TOOLPATH)cc\n".
834 "\n".
835 &splitline("CFLAGS = -O2 -Wall -Werror -g -I. -I.. -I../charset `gtk-config --cflags`")."\n".
836 "XLDFLAGS = `gtk-config --libs`\n".
837 "ULDFLAGS =#\n".
838 "INSTALL=install\n",
839 "INSTALL_PROGRAM=\$(INSTALL)\n",
840 "INSTALL_DATA=\$(INSTALL)\n",
841 "prefix=/usr/local\n",
842 "exec_prefix=\$(prefix)\n",
843 "bindir=\$(exec_prefix)/bin\n",
844 "mandir=\$(prefix)/man\n",
845 "man1dir=\$(mandir)/man1\n",
846 "\n".
847 ".SUFFIXES:\n".
848 "\n".
849 "%.o:\n".
850 "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) -c \$<\n".
851 "\n";
852 print &splitline("all:" . join "", map { " $_" } &progrealnames("XU"));
853 print "\n\n";
854 foreach $p (&prognames("XU")) {
855 ($prog, $type) = split ",", $p;
856 $objstr = &objects($p, "X.o", undef, undef);
857 print &splitline($prog . ": " . $objstr), "\n";
858 $libstr = &objects($p, undef, undef, "-lX");
859 print &splitline("\t\$(CC)" . $mw . " \$(${type}LDFLAGS) -o \$@ " .
860 $objstr . " $libstr", 69), "\n\n";
861 }
862 foreach $d (&deps("X.o", undef, "../", "/")) {
863 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
864 "\n";
865 }
866 print "\n";
867 print $makefile_extra{'gtk'};
868 print "\nclean:\n".
869 "\trm -f *.o". (join "", map { " $_" } &progrealnames("XU")) . "\n";
870 select STDOUT; close OUT;
871}
f8422c0b 872
e35fb54b 873if (defined $makefiles{'mpw'}) {
874 ##-- MPW Makefile
875 open OUT, ">$makefiles{'mpw'}"; select OUT;
876 print
877 "# Makefile for $project_name under MPW.\n#\n".
878 "# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
879 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
880 # MPW command line option is -d not /D
881 ($_ = $help) =~ s/=\/D/=-d /gs;
882 print $_;
883 print "\n\n".
884 "ROptions = `Echo \"{VER}\" | StreamEdit -e \"1,\$ replace /=(\xc5)\xa81\xb0/ 'STR=\xb6\xb6\xb6\xb6\xb6\"' \xa81 '\xb6\xb6\xb6\xb6\xb6\"'\"`".
885 "\n".
886 "C_68K = {C}\n".
887 "C_CFM68K = {C}\n".
888 "C_PPC = {PPCC}\n".
889 "C_Carbon = {PPCC}\n".
890 "\n".
891 "# -w 35 disables \"unused parameter\" warnings\n".
892 "COptions = -i : -i :: -i ::charset -w 35 -w err -proto strict -ansi on \xb6\n".
893 " -notOnce\n".
894 "COptions_68K = {COptions} -model far -opt time\n".
895 "# Enabling \"-opt space\" for CFM-68K gives me undefined references to\n".
896 "# _\$LDIVT and _\$LMODT.\n".
897 "COptions_CFM68K = {COptions} -model cfmSeg -opt time\n".
898 "COptions_PPC = {COptions} -opt size -traceback\n".
899 "COptions_Carbon = {COptions} -opt size -traceback -d TARGET_API_MAC_CARBON\n".
900 "\n".
901 "Link_68K = ILink\n".
902 "Link_CFM68K = ILink\n".
903 "Link_PPC = PPCLink\n".
904 "Link_Carbon = PPCLink\n".
905 "\n".
906 "LinkOptions = -c 'pTTY'\n".
907 "LinkOptions_68K = {LinkOptions} -br 68k -model far -compact\n".
908 "LinkOptions_CFM68K = {LinkOptions} -br 020 -model cfmseg -compact\n".
909 "LinkOptions_PPC = {LinkOptions}\n".
910 "LinkOptions_Carbon = -m __appstart -w {LinkOptions}\n".
911 "\n".
912 "Libs_68K = \"{CLibraries}StdCLib.far.o\" \xb6\n".
913 " \"{Libraries}MacRuntime.o\" \xb6\n".
914 " \"{Libraries}MathLib.far.o\" \xb6\n".
915 " \"{Libraries}IntEnv.far.o\" \xb6\n".
916 " \"{Libraries}Interface.o\" \xb6\n".
917 " \"{Libraries}Navigation.far.o\" \xb6\n".
918 " \"{Libraries}OpenTransport.o\" \xb6\n".
919 " \"{Libraries}OpenTransportApp.o\" \xb6\n".
920 " \"{Libraries}OpenTptInet.o\" \xb6\n".
921 " \"{Libraries}UnicodeConverterLib.far.o\"\n".
922 "\n".
923 "Libs_CFM = \"{SharedLibraries}InterfaceLib\" \xb6\n".
924 " \"{SharedLibraries}StdCLib\" \xb6\n".
925 " \"{SharedLibraries}AppearanceLib\" \xb6\n".
926 " -weaklib AppearanceLib \xb6\n".
927 " \"{SharedLibraries}NavigationLib\" \xb6\n".
928 " -weaklib NavigationLib \xb6\n".
929 " \"{SharedLibraries}TextCommon\" \xb6\n".
930 " -weaklib TextCommon \xb6\n".
931 " \"{SharedLibraries}UnicodeConverter\" \xb6\n".
932 " -weaklib UnicodeConverter\n".
933 "\n".
934 "Libs_CFM68K = {Libs_CFM} \xb6\n".
935 " \"{CFM68KLibraries}NuMacRuntime.o\"\n".
936 "\n".
937 "Libs_PPC = {Libs_CFM} \xb6\n".
938 " \"{SharedLibraries}ControlsLib\" \xb6\n".
939 " -weaklib ControlsLib \xb6\n".
940 " \"{SharedLibraries}WindowsLib\" \xb6\n".
941 " -weaklib WindowsLib \xb6\n".
942 " \"{SharedLibraries}OpenTransportLib\" \xb6\n".
943 " -weaklib OTClientLib \xb6\n".
944 " -weaklib OTClientUtilLib \xb6\n".
945 " \"{SharedLibraries}OpenTptInternetLib\" \xb6\n".
946 " -weaklib OTInetClientLib \xb6\n".
947 " \"{PPCLibraries}StdCRuntime.o\" \xb6\n".
948 " \"{PPCLibraries}PPCCRuntime.o\" \xb6\n".
949 " \"{PPCLibraries}CarbonAccessors.o\" \xb6\n".
950 " \"{PPCLibraries}OpenTransportAppPPC.o\" \xb6\n".
951 " \"{PPCLibraries}OpenTptInetPPC.o\"\n".
952 "\n".
953 "Libs_Carbon = \"{PPCLibraries}CarbonStdCLib.o\" \xb6\n".
954 " \"{PPCLibraries}StdCRuntime.o\" \xb6\n".
955 " \"{PPCLibraries}PPCCRuntime.o\" \xb6\n".
956 " \"{SharedLibraries}CarbonLib\" \xb6\n".
957 " \"{SharedLibraries}StdCLib\"\n".
958 "\n";
959 print &splitline("all \xc4 " . join(" ", &progrealnames("M")), undef, "\xb6");
960 print "\n\n";
961 foreach $p (&prognames("M")) {
962 ($prog, $type) = split ",", $p;
f8422c0b 963
e35fb54b 964 print &splitline("$prog \xc4 $prog.68k $prog.ppc $prog.carbon",
965 undef, "\xb6"), "\n\n";
c88dc003 966
e35fb54b 967 $rsrc = &objects($p, "", "X.rsrc", undef);
b941ca10 968
e35fb54b 969 foreach $arch (qw(68K CFM68K PPC Carbon)) {
970 $objstr = &objects($p, "X.\L$arch\E.o", "", undef);
971 print &splitline("$prog.\L$arch\E \xc4 $objstr $rsrc", undef, "\xb6");
972 print "\n";
973 print &splitline("\tDuplicate -y $rsrc {Targ}", 69, "\xb6"), "\n";
974 print &splitline("\t{Link_$arch} -o {Targ} -fragname $prog " .
975 "{LinkOptions_$arch} " .
976 $objstr . " {Libs_$arch}", 69, "\xb6"), "\n";
977 print &splitline("\tSetFile -a BMi {Targ}", 69, "\xb6"), "\n\n";
978 }
4e95095a 979
e35fb54b 980 }
981 foreach $d (&deps("", "X.rsrc", "::", ":")) {
982 next unless $d->{obj};
983 print &splitline(sprintf("%s \xc4 %s", $d->{obj}, join " ", @{$d->{deps}}),
984 undef, "\xb6"), "\n";
985 print "\tRez ", $d->{deps}->[0], " -o {Targ} {ROptions}\n\n";
986 }
987 foreach $arch (qw(68K CFM68K)) {
988 foreach $d (&deps("X.\L$arch\E.o", "", "::", ":")) {
989 next unless $d->{obj};
990 print &splitline(sprintf("%s \xc4 %s", $d->{obj},
991 join " ", @{$d->{deps}}),
992 undef, "\xb6"), "\n";
993 print "\t{C_$arch} ", $d->{deps}->[0],
994 " -o {Targ} {COptions_$arch}\n\n";
995 }
996 }
997 foreach $arch (qw(PPC Carbon)) {
998 foreach $d (&deps("X.\L$arch\E.o", "", "::", ":")) {
999 next unless $d->{obj};
1000 print &splitline(sprintf("%s \xc4 %s", $d->{obj},
1001 join " ", @{$d->{deps}}),
1002 undef, "\xb6"), "\n";
1003 # The odd stuff here seems to stop afpd getting confused.
1004 print "\techo -n > {Targ}\n";
1005 print "\tsetfile -t XCOF {Targ}\n";
1006 print "\t{C_$arch} ", $d->{deps}->[0],
1007 " -o {Targ} {COptions_$arch}\n\n";
1008 }
1009 }
1010 select STDOUT; close OUT;
4e95095a 1011}
1012
e35fb54b 1013if (defined $makefiles{'lcc'}) {
1014 ##-- lcc makefile
1015 open OUT, ">$makefiles{'lcc'}"; select OUT;
1016 print
1017 "# Makefile for $project_name under lcc.\n".
1018 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1019 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1020 # lcc command line option is -D not /D
1021 ($_ = $help) =~ s/=\/D/=-D/gs;
1022 print $_;
1023 print
1024 "\n".
1025 "# If you rename this file to `Makefile', you should change this line,\n".
1026 "# so that the .rsp files still depend on the correct makefile.\n".
1027 "MAKEFILE = Makefile.lcc\n".
1028 "\n".
1029 "# C compilation flags\n".
1030 "CFLAGS = -D_WINDOWS\n".
1031 "\n".
1032 "# Get include directory for resource compiler\n".
1033 "\n".
1034 ".c.obj:\n".
1035 &splitline("\tlcc -O -p6 \$(COMPAT) \$(FWHACK)".
1036 " \$(XFLAGS) \$(CFLAGS) \$*.c",69)."\n".
1037 ".rc.res:\n".
1038 &splitline("\tlrc \$(FWHACK) \$(RCFL) -r \$*.rc",69)."\n".
4e95095a 1039 "\n";
e35fb54b 1040 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("GC"));
1041 print "\n\n";
1042 foreach $p (&prognames("GC")) {
1043 ($prog, $type) = split ",", $p;
1044 $objstr = &objects($p, "X.obj", "X.res", undef);
1045 print &splitline("$prog.exe: " . $objstr ), "\n";
1046 $subsystemtype = undef;
1047 if ($type eq "G") { $subsystemtype = "-subsystem windows"; }
1048 my $libss = "shell32.lib wsock32.lib ws2_32.lib winspool.lib winmm.lib imm32.lib";
1049 print &splitline("\tlcclnk $subsystemtype -o $prog.exe $objstr $libss");
1050 print "\n\n";
1051 }
4e95095a 1052
e35fb54b 1053 foreach $d (&deps("X.obj", "X.res", "", "\\")) {
1054 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
1055 "\n";
1056 }
1057 print "\n";
1058 print $makefile_extra{'lcc'};
1059 print "\nclean:\n".
1060 "\t-del *.obj\n".
1061 "\t-del *.exe\n".
1062 "\t-del *.res\n";
4e95095a 1063
e35fb54b 1064 select STDOUT; close OUT;
1065}