3 # Cross-platform Makefile generator.
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.
10 # PuTTY specifics which could still do with removing:
11 # - Mac makefile is not portabilised at all. Include directories
12 # are hardwired, and also the libraries are fixed. This is
13 # mainly because I was too scared to go anywhere near it.
14 # - sbcsgen.pl is still run at startup.
16 # Other things undone:
17 # - special-define objects (foo.o[PREPROCSYMBOL]) are not
18 # supported in the mac or vcproj makefiles.
26 open $in, "Recipe" or do {
27 # We want to deal correctly with being run from one of the
28 # subdirs in the source tree. So if we can't find Recipe here,
31 open $in, "Recipe" or die "unable to open Recipe file\n";
35 # HACK: One of the source files in `charset' is auto-generated by
36 # sbcsgen.pl. We need to generate that _now_, before attempting
37 # dependency analysis.
38 eval 'chdir "charset"; require "sbcsgen.pl"; chdir ".."';
42 $divert = undef; # ref to scalar in which text is currently being put
43 $help = ""; # list of newline-free lines of help text
44 $project_name = "project"; # this is a good enough default
45 %makefiles = (); # maps makefile types to output makefile pathnames
46 %makefile_extra = (); # maps makefile types to extra Makefile text
47 %programs = (); # maps prog name + type letter to listref of objects/resources
48 %groups = (); # maps group name to listref of objects/resources
50 @allobjs = (); # all object file names
52 readinput
: while (1) {
53 $in = $filestack[$#filestack];
54 while (not defined ($_ = <$in>)) {
55 close $filestack[$#filestack];
57 last readinput
if 0 == scalar @filestack;
58 $in = $filestack[$#filestack];
63 # If we're gathering help text, keep doing so.
64 if (defined $divert) {
65 if ((defined $_[0]) && $_[0] eq "!end") {
72 # Skip comments and blank lines.
73 next if /^\s*#/ or scalar @_ == 0;
75 if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = \
$help; next; }
76 if ($_[0] eq "!name") { $project_name = $_[1]; next; }
77 if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; }
78 if ($_[0] eq "!makefile" and &mfval
($_[1])) { $makefiles{$_[1]}=$_[2]; next;}
79 if ($_[0] eq "!specialobj" and &mfval
($_[1])) { $specialobj{$_[1]}->{$_[2]} = 1; next;}
80 if ($_[0] eq "!begin") {
81 if ($_[1] =~ /^>(.*)/) {
82 $divert = \
$auxfiles{$1};
83 } elsif (&mfval
($_[1])) {
84 $divert = \
$makefile_extra{$_[1]};
88 if ($_[0] eq "!include") {
90 for ($i = 1; $i <= $#_; $i++) {
91 push @newfiles, (sort glob $_[$i]);
93 for ($i = $#newfiles; $i >= 0; $i--) {
94 $file = $newfiles[$i];
96 open $f, "<$file" or die "unable to open include file '$file'\n";
102 # Now we have an ordinary line. See if it's an = line, a : line
107 $listref = $lastlistref;
109 die "$.: unexpected + line\n" if !defined $lastlistref;
110 } elsif ($_[1] eq "=") {
112 $listref = $groups{$_[0]};
114 shift @objs; # eat the group name
115 } elsif ($_[1] eq "+=") {
116 $groups{$_[0]} = [] if !defined $groups{$_[0]};
117 $listref = $groups{$_[0]};
119 shift @objs; # eat the group name
120 } elsif ($_[1] eq ":") {
123 shift @objs; # eat the program name
125 die "$.: unrecognised line type: '$_'\n";
127 shift @objs; # eat the +, the = or the :
129 while (scalar @objs > 0) {
132 foreach $j (@
{$groups{$i}}) { unshift @objs, $j; }
133 } elsif (($i eq "[G]" or $i eq "[C]" or $i eq "[M]" or $i eq "[Q]" or
134 $i eq "[X]" or $i eq "[U]" or $i eq "[MX]") and defined $prog) {
135 $type = substr($i,1,(length $i)-2);
138 # Object files with a trailing question mark are optional:
139 # the build can proceed fine without them, so we only use
140 # them if their primary source files are present.
142 $i = undef unless defined &finddep
($i);
143 } elsif ($i =~ /\|/) {
144 # Object file descriptions containing a vertical bar are
145 # lists of choices: we use the _first_ one whose primary
146 # source file is present.
147 @options = split /\|/, $i;
149 foreach $k (@options) {
150 $j=$k, last if defined &finddep
($k);
152 die "no alternative found for $i\n" unless defined $j;
161 if ($prog and $type) {
162 die "multiple program entries for $prog [$type]\n"
163 if defined $programs{$prog . "," . $type};
164 $programs{$prog . "," . $type} = $listref;
166 $lastlistref = $listref;
169 foreach $aux (sort keys %auxfiles) {
171 print AUX
$auxfiles{$aux};
175 # Find object file names with predefines (in square brackets after
176 # the module name), and decide on actual object names for them.
177 foreach $i (@allobjs) {
181 $usedobjname{$i} = 1;
184 foreach $i (@allobjs) {
185 if ($i =~ /^(.*)\[([^\]]*)/) {
186 $defs{$i} = [ split ",",$2 ];
187 $srcname{$i} = $s = $1;
191 $maxlen = 8 if $maxlen < 8;
192 $chop = $maxlen - length $index;
193 $chop = length $s if $chop > length $s;
194 $chop = 0 if $chop < 0;
195 $name = substr($s, 0, $chop) . $index;
196 $index++, next if $usedobjname{$name};
197 $objname{$i} = $name;
198 $usedobjname{$name} = 1;
204 # Now retrieve the complete list of objects and resource files, and
205 # construct dependency data for them. While we're here, expand the
206 # object list for each program, and complain if its type isn't set.
207 @prognames = sort keys %programs;
210 foreach $i (@prognames) {
211 ($prog, $type) = split ",", $i;
212 # Strip duplicate object names.
214 @list = grep { $status = ($prev ne $_); $prev=$_; $status }
215 sort @
{$programs{$i}};
216 $programs{$i} = [@list];
217 foreach $jj (@list) {
219 $file = &finddep
($j);
221 $depends{$jj} = [$file];
222 push @scanlist, $file;
227 # Scan each file on @scanlist and find further inclusions.
228 # Inclusions are given by lines of the form `#include "otherfile"'
229 # (system headers are automatically ignored by this because they'll
230 # be given in angle brackets). Files included by this method are
231 # added back on to @scanlist to be scanned in turn (if not already
234 # Resource scripts (.rc) can also include a file by means of a line
235 # ending `ICON "filename"'. Files included by this method are not
236 # added to @scanlist because they can never include further files.
238 # In this pass we write out a hash %further which maps a source
239 # file name into a listref containing further source file names.
242 while (scalar @scanlist > 0) {
243 $file = shift @scanlist;
244 next if defined $further{$file}; # skip if we've already done it
245 $further{$file} = [];
246 $dirfile = &findfile
($file);
247 open IN
, "$dirfile" or die "unable to open source file $file\n";
250 /^\s*#include\s+\"([^\"]+)\"/ and do {
251 push @
{$further{$file}}, $1;
255 /ICON\s+\"([^\"]+)\"\s*$/ and do {
256 push @
{$further{$file}}, $1;
263 # Now we're ready to generate the final dependencies section. For
264 # each key in %depends, we must expand the dependencies list by
265 # iteratively adding entries from %further.
266 foreach $i (keys %depends) {
268 @scanlist = @
{$depends{$i}};
269 foreach $i (@scanlist) { $dep{$i} = 1; }
270 while (scalar @scanlist > 0) {
271 $file = shift @scanlist;
272 foreach $j (@
{$further{$file}}) {
275 push @
{$depends{$i}}, $j;
280 # printf "%s: %s\n", $i, join ' ',@{$depends{$i}};
283 # Validation of input.
287 # Returns true if the argument is a known makefile type. Otherwise,
288 # prints a warning and returns false;
289 if (grep { $type eq $_ }
290 ("vc","vcproj","cygwin","borland","lcc","gtk","qt","mpw","nestedvm","osx","wce")) {
293 warn "$.:unknown makefile type '$type'\n";
297 # Utility routines while writing out the Makefiles.
300 my ($path) = shift @_;
301 my ($sep) = shift @_;
304 while (($i = index $path, $sep) >= 0) {
305 $path = substr $path, ($i + length $sep);
316 unless (defined $findfilecache{$name}) {
318 foreach $dir (@srcdirs) {
319 $outdir = $dir, $i++ if -f
"$dir$name";
321 die "multiple instances of source file $name\n" if $i > 1;
322 $findfilecache{$name} = (defined $outdir ?
$outdir . $name : undef);
324 return $findfilecache{$name};
330 # Find the first dependency of an object.
332 # Dependencies for "x" start with "x.c" or "x.m" (depending on
334 # Dependencies for "x.res" start with "x.rc".
335 # Dependencies for "x.rsrc" start with "x.r".
336 # Both types of file are pushed on the list of files to scan.
337 # Libraries (.lib) don't have dependencies at all.
338 if ($j =~ /^(.*)\.res$/) {
340 } elsif ($j =~ /^(.*)\.rsrc$/) {
342 } elsif ($j !~ /\./) {
344 $file = "$j.m" unless &findfile
($file);
346 # For everything else, we assume it's its own dependency.
349 $file = undef unless &findfile
($file);
354 my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_;
357 ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ?
$_ : "" } ($otmpl, $rtmpl, $ltmpl);
359 foreach $ii (@
{$programs{$prog}}) {
362 if ($i =~ /^(.*)\.(res|rsrc)/) {
364 ($x = $rtmpl) =~ s/X/$y/;
365 } elsif ($i =~ /^(.*)\.lib/) {
367 ($x = $ltmpl) =~ s/X/$y/;
368 } elsif ($i !~ /\./) {
369 ($x = $otmpl) =~ s/X/$i/;
371 push @ret, $x if $x ne "";
373 return join " ", @ret;
377 my ($prog, $suffix) = @_;
381 foreach $ii (@
{$programs{$prog}}) {
383 if (substr($i, (length $i) - (length $suffix)) eq $suffix) {
387 return join " ", @ret;
391 my ($line, $width, $splitchar) = @_;
394 $len = (defined $width ?
$width : 76);
395 $splitchar = (defined $splitchar ?
$splitchar : '\\');
396 while (length $line > $len) {
397 $line =~ /^(.{0,$len})\s(.*)$/ or $line =~ /^(.{$len,}?\s(.*)$/;
399 $result .= " ${splitchar}\n\t\t" if $2 ne '';
403 return $result . $line;
407 my ($otmpl, $rtmpl, $prefix, $dirsep, $depchar, $splitchar) = @_;
413 foreach $ii (sort keys %depends) {
415 next if $specialobj{$mftyp}->{$i};
416 if ($i =~ /^(.*)\.(res|rsrc)/) {
417 next if !defined $rtmpl;
419 ($x = $rtmpl) =~ s/X/$y/;
421 ($x = $otmpl) =~ s/X/$i/;
423 @deps = @
{$depends{$ii}};
424 # Skip things which are their own dependency.
425 next if grep { $_ eq $i } @deps;
431 push @ret, {obj
=> $x, deps
=> [@deps], defs
=> $defs{$ii}};
438 my ($n, $prog, $type);
441 foreach $n (@prognames) {
442 ($prog, $type) = split ",", $n;
443 push @ret, $n if index(":$types:", ":$type:") >= 0;
450 my ($n, $prog, $type);
453 foreach $n (@prognames) {
454 ($prog, $type) = split ",", $n;
455 push @ret, $prog if index(":$types:", ":$type:") >= 0;
461 my ($types,$suffix) = @_;
463 # assume that all UNIX programs have a man page
464 if($suffix eq "1" && $types =~ /:X:/) {
465 return map("$_.1", &progrealnames
($types));
470 # Now we're ready to output the actual Makefiles.
472 if (defined $makefiles{'cygwin'}) {
474 $dirpfx = &dirpfx
($makefiles{'cygwin'}, "/");
477 open OUT
, ">$makefiles{'cygwin'}"; select OUT
;
479 "# Makefile for $project_name under cygwin.\n".
480 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
481 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
482 # gcc command line option is -D not /D
483 ($_ = $help) =~ s/=\/D/=-D
/gs
;
487 "# You can define this path to point at your tools if you need to\n".
488 "# TOOLPATH = c:\\cygwin\\bin\\ # or similar, if you're running Windows\n".
489 "# TOOLPATH = /pkg/mingw32msvc/i386-mingw32msvc/bin/\n".
490 "CC = \$(TOOLPATH)gcc\n".
491 "RC = \$(TOOLPATH)windres\n".
492 "# Uncomment the following two lines to compile under Winelib\n".
495 "# You may also need to tell windres where to find include files:\n".
496 "# RCINC = --include-dir c:\\cygwin\\include\\\n".
498 &splitline
("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
499 " -D_NO_OLDNAMES -DNO_MULTIMON -DNO_HTMLHELP " .
500 (join " ", map {"-I$dirpfx$_"} @srcdirs)) .
502 "LDFLAGS = -mno-cygwin -s\n".
503 &splitline
("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1".
504 " --define WINVER=0x0400 --define MINGW32_FIX=1 " .
505 (join " ", map {"--include $dirpfx$_"} @srcdirs) )."\n".
507 print &splitline
("all:" . join "", map { " $_.exe" } &progrealnames
("G:C"));
509 foreach $p (&prognames
("G:C")) {
510 ($prog, $type) = split ",", $p;
511 $objstr = &objects
($p, "X.o", "X.res.o", undef);
512 print &splitline
($prog . ".exe: " . $objstr), "\n";
513 my $mw = $type eq "G" ?
" -mwindows" : "";
514 $libstr = &objects
($p, undef, undef, "-lX");
515 print &splitline
("\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " .
516 "-Wl,-Map,$prog.map " .
517 $objstr . " $libstr", 69), "\n\n";
519 foreach $d (&deps
("X.o", "X.res.o", $dirpfx, "/")) {
520 print &splitline
(sprintf("%s: %s", $d->{obj
}, join " ", @
{$d->{deps
}})),
522 if ($d->{obj
} =~ /\.res\.o$/) {
523 print "\t\$(RC) \$(FWHACK) \$(RCFL) \$(RCFLAGS) \$< \$\@\n";
525 $deflist = join "", map { " -D$_" } @
{$d->{defs
}};
526 print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS)" .
527 " \$(XFLAGS)$deflist -c \$< -o \$\@\n";
531 print $makefile_extra{'cygwin'};
533 "\trm -f *.o *.exe *.res.o *.map\n".
535 select STDOUT
; close OUT
;
539 ##-- Borland makefile
540 if (defined $makefiles{'borland'}) {
542 $dirpfx = &dirpfx
($makefiles{'borland'}, "\\");
544 %stdlibs = ( # Borland provides many Win32 API libraries intrinsically
556 open OUT
, ">$makefiles{'borland'}"; select OUT
;
558 "# Makefile for $project_name under Borland C.\n".
559 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
560 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
561 # bcc32 command line option is -D not /D
562 ($_ = $help) =~ s/=\/D/=-D
/gs
;
566 "# If you rename this file to `Makefile', you should change this line,\n".
567 "# so that the .rsp files still depend on the correct makefile.\n".
568 "MAKEFILE = Makefile.bor\n".
570 "# C compilation flags\n".
571 "CFLAGS = -D_WINDOWS -DWINVER=0x0401\n".
573 "# Get include directory for resource compiler\n".
575 "BCB = \$(MAKEDIR)\\..\n".
578 print &splitline
("all:" . join "", map { " $_.exe" } &progrealnames
("G:C"));
580 foreach $p (&prognames
("G:C")) {
581 ($prog, $type) = split ",", $p;
582 $objstr = &objects
($p, "X.obj", "X.res", undef);
583 print &splitline
("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
584 my $ap = ($type eq "G") ?
"-aa" : "-ap";
585 print "\tilink32 $ap -Gn -L\$(BCB)\\lib \@$prog.rsp\n\n";
587 foreach $p (&prognames
("G:C")) {
588 ($prog, $type) = split ",", $p;
589 print $prog, ".rsp: \$(MAKEFILE)\n";
590 $objstr = &objects
($p, "X.obj", undef, undef);
591 @objlist = split " ", $objstr;
593 foreach $i (@objlist) {
594 if (length($objlines[$#objlines] . " $i") > 50) {
597 $objlines[$#objlines] .= " $i";
599 $c0w = ($type eq "G") ?
"c0w32" : "c0x32";
600 print "\techo $c0w + > $prog.rsp\n";
601 for ($i=0; $i<=$#objlines; $i++) {
602 $plus = ($i < $#objlines ?
" +" : "");
603 print "\techo$objlines[$i]$plus >> $prog.rsp\n";
605 print "\techo $prog.exe >> $prog.rsp\n";
606 $objstr = &objects
($p, "X.obj", "X.res", undef);
607 @libs = split " ", &objects
($p, undef, undef, "X");
608 @libs = grep { !$stdlibs{$_} } @libs;
609 unshift @libs, "cw32", "import32";
610 $libstr = join ' ', @libs;
611 print "\techo nul,$libstr, >> $prog.rsp\n";
612 print "\techo " . &objects
($p, undef, "X.res", undef) . " >> $prog.rsp\n";
615 foreach $d (&deps
("X.obj", "X.res", $dirpfx, "\\")) {
616 print &splitline
(sprintf("%s: %s", $d->{obj
}, join " ", @
{$d->{deps
}})),
618 if ($d->{obj
} =~ /\.res$/) {
619 print &splitline
("\tbrcc32 \$(FWHACK) \$(RCFL) " .
620 "-i \$(BCB)\\include -r -DNO_WINRESRC_H -DWIN32".
621 " -D_WIN32 -DWINVER=0x0401 \$*.rc",69)."\n";
623 $deflist = join "", map { " -D$_" } @
{$d->{defs
}};
624 print &splitline
("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT)" .
625 " \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist ".
626 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
627 " /o$d->{obj} /c ".$d->{deps
}->[0],69)."\n";
631 print $makefile_extra{'borland'};
642 "\t-del *.\$\$\$\$\$\$\n";
643 select STDOUT
; close OUT
;
646 if (defined $makefiles{'vc'}) {
648 $dirpfx = &dirpfx
($makefiles{'vc'}, "\\");
650 ##-- Visual C++ makefile
651 open OUT
, ">$makefiles{'vc'}"; select OUT
;
653 "# Makefile for $project_name under Visual C.\n".
654 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
655 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
659 "# If you rename this file to `Makefile', you should change this line,\n".
660 "# so that the .rsp files still depend on the correct makefile.\n".
661 "MAKEFILE = Makefile.vc\n".
663 "# C compilation flags\n".
664 "CFLAGS = /nologo /W3 /O1 /D_WINDOWS /D_WIN32_WINDOWS=0x401 /DWINVER=0x401 /I.\n".
665 "LFLAGS = /incremental:no /fixed\n".
667 print &splitline
("all:" . join "", map { " $_.exe" } &progrealnames
("G:C"));
669 foreach $p (&prognames
("G:C")) {
670 ($prog, $type) = split ",", $p;
671 $objstr = &objects
($p, "X.obj", "X.res", undef);
672 print &splitline
("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
673 print "\tlink \$(LFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n";
675 foreach $p (&prognames
("G:C")) {
676 ($prog, $type) = split ",", $p;
677 print $prog, ".rsp: \$(MAKEFILE)\n";
678 $objstr = &objects
($p, "X.obj", "X.res", "X.lib");
679 @objlist = split " ", $objstr;
681 foreach $i (@objlist) {
682 if (length($objlines[$#objlines] . " $i") > 50) {
685 $objlines[$#objlines] .= " $i";
687 $subsys = ($type eq "G") ?
"windows" : "console";
688 print "\techo /nologo /subsystem:$subsys > $prog.rsp\n";
689 for ($i=0; $i<=$#objlines; $i++) {
690 print "\techo$objlines[$i] >> $prog.rsp\n";
694 foreach $d (&deps
("X.obj", "X.res", $dirpfx, "\\")) {
695 print &splitline
(sprintf("%s: %s", $d->{obj
}, join " ", @
{$d->{deps
}})),
697 if ($d->{obj
} =~ /\.res$/) {
698 print "\trc \$(FWHACK) \$(RCFL) -r -DWIN32 -D_WIN32 ".
699 "-DWINVER=0x0400 -fo".$d->{obj
}." ".$d->{deps
}->[0]."\n";
701 $deflist = join "", map { " /D$_" } @
{$d->{defs
}};
702 print "\tcl \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist".
703 " /c ".$d->{deps
}->[0]." /Fo$d->{obj}\n";
707 print $makefile_extra{'vc'};
708 print "\nclean: tidy\n".
725 "\t-del debug.log\n";
726 select STDOUT
; close OUT
;
729 if (defined $makefiles{'wce'}) {
731 $dirpfx = &dirpfx
($makefiles{'wce'}, "\\");
733 ##-- eMbedded Visual C PocketPC makefile
734 open OUT
, ">$makefiles{'wce'}"; select OUT
;
736 "# Makefile for $project_name on PocketPC using eMbedded Visual C.\n".
737 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
738 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
742 "# If you rename this file to `Makefile', you should change this line,\n".
743 "# so that the .rsp files still depend on the correct makefile.\n".
744 "MAKEFILE = Makefile.wce\n".
746 "# This makefile expects the environment to have been set up by one\n".
747 "# of the PocketPC batch files wcearmv4.bat and wceemulator.bat. No\n".
748 "# other build targets are currently supported, because they would\n".
749 "# need a section in this if statement.\n".
750 "!if \"\$(TARGETCPU)\" == \"emulator\"\n".
751 "PLATFORM_DEFS=/D \"_i386_\" /D \"i_386_\" /D \"_X86_\" /D \"x86\"\n".
753 "BASELIBS=commctrl.lib coredll.lib corelibc.lib aygshell.lib\n".
756 "PLATFORM_DEFS=/D \"ARM\" /D \"_ARM_\" /D \"ARMV4\"\n".
758 "BASELIBS=commctrl.lib coredll.lib aygshell.lib\n".
762 "# C compilation flags\n".
763 "CFLAGS = /nologo /W3 /O1 /MC /D _WIN32_WCE=420 /D \"WIN32_PLATFORM_PSPC=400\" /D UNDER_CE=420 \\\n".
764 " \$(PLATFORM_DEFS) \\\n".
765 " /D \"UNICODE\" /D \"_UNICODE\" /D \"NDEBUG\" /D \"NO_HTMLHELP\"\n".
767 "LFLAGS = /nologo /incremental:no \\\n".
768 " /base:0x00010000 /stack:0x10000,0x1000 /entry:WinMainCRTStartup \\\n".
769 " /nodefaultlib:libc.lib /nodefaultlib:libcmt.lib /nodefaultlib:msvcrt.lib /nodefaultlib:OLDNAMES.lib \\\n".
770 " /subsystem:windowsce,4.20 /align:4096 /MACHINE:\$(MACHINE)\n".
772 "RCFL = /d UNDER_CE=420 /d _WIN32_WCE=420 /d \"WIN32_PLATFORM_PSPC=400\" \\\n".
773 " \$(PLATFORM_DEFS) \\\n".
774 " /d \"NDEBUG\" /d \"UNICODE\" /d \"_UNICODE\"\n".
776 print &splitline
("all:" . join "", map { " $_.exe" } &progrealnames
("G"));
778 foreach $p (&prognames
("G")) {
779 ($prog, $type) = split ",", $p;
780 $objstr = &objects
($p, "X.obj", "X.res", undef);
781 print &splitline
("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
782 print "\tlink \$(LFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n";
784 foreach $p (&prognames
("G")) {
785 ($prog, $type) = split ",", $p;
786 print $prog, ".rsp: \$(MAKEFILE)\n";
787 $objstr = &objects
($p, "X.obj", "X.res", undef);
788 @objlist = split " ", $objstr;
790 foreach $i (@objlist) {
791 if (length($objlines[$#objlines] . " $i") > 50) {
794 $objlines[$#objlines] .= " $i";
796 print "\techo \$(BASELIBS) > $prog.rsp\n";
797 for ($i=0; $i<=$#objlines; $i++) {
798 print "\techo$objlines[$i] >> $prog.rsp\n";
802 foreach $d (&deps
("X.obj", "X.res", $dirpfx, "\\")) {
803 print &splitline
(sprintf("%s: %s", $d->{obj
}, join " ", @
{$d->{deps
}})),
805 if ($d->{obj
} =~ /\.res$/) {
806 print "\trc \$(FWHACK) \$(RCFL) -r -fo".
807 $d->{obj
}." ".$d->{deps
}->[0]."\n";
809 $deflist = join "", map { " /D$_" } @
{$d->{defs
}};
810 print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist".
811 " /c ".$d->{deps
}->[0]." /Fo$d->{obj}\n";
815 print $makefile_extra{'wce'};
816 print "\nclean: tidy\n".
833 "\t-del debug.log\n";
834 select STDOUT
; close OUT
;
837 if (defined $makefiles{'vcproj'}) {
842 ##-- MSVC 6 Workspace and projects
844 # Note: All files created in this section are written in binary
845 # mode, because although MSVC's command-line make can deal with
846 # LF-only line endings, MSVC project files really _need_ to be
847 # CRLF. Hence, in order for mkfiles.pl to generate usable project
848 # files even when run from Unix, I make sure all files are binary
849 # and explicitly write the CRLFs.
851 # Create directories if necessary
852 mkdir $makefiles{'vcproj'}
853 if(! -d
$makefiles{'vcproj'});
854 chdir $makefiles{'vcproj'};
855 @deps = &deps
("X.obj", "X.res", "", "\\");
856 %all_object_deps = map {$_->{obj
} => $_->{deps
}} @deps;
857 # Create the project files
858 # Get names of all Windows projects (GUI and console)
859 my @prognames = &prognames
("G:C");
860 foreach $progname (@prognames) {
861 create_project
(\
%all_object_deps, $progname);
863 # Create the workspace file
864 open OUT
, ">$project_name.dsw"; binmode OUT
; select OUT
;
866 "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n".
867 "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n".
869 "###############################################################################\r\n".
872 foreach $progname (@prognames) {
873 ($windows_project, $type) = split ",", $progname;
874 print "Project: \"$windows_project\"=\".\\$windows_project\\$windows_project.dsp\" - Package Owner=<4>\r\n";
886 "###############################################################################\r\n".
898 "###############################################################################\r\n".
900 select STDOUT
; close OUT
;
904 my ($all_object_deps, $progname) = @_;
905 # Construct program's dependency info
910 %resource_files = ();
911 @object_files = split " ", &objects
($progname, "X.obj", "X.res", "X.lib");
912 foreach $object_file (@object_files) {
913 next if defined $seen_objects{$object_file};
914 $seen_objects{$object_file} = 1;
915 if($object_file =~ /\.lib$/io) {
916 $lib_files{$object_file} = 1;
919 $object_deps = $all_object_deps{$object_file};
920 foreach $object_dep (@
$object_deps) {
921 if($object_dep =~ /\.c$/io) {
922 $source_files{$object_dep} = 1;
925 if($object_dep =~ /\.h$/io) {
926 $header_files{$object_dep} = 1;
929 if($object_dep =~ /\.(rc|ico)$/io) {
930 $resource_files{$object_dep} = 1;
935 $libs = join " ", sort keys %lib_files;
936 @source_files = sort keys %source_files;
937 @header_files = sort keys %header_files;
938 @resources = sort keys %resource_files;
939 ($windows_project, $type) = split ",", $progname;
940 mkdir $windows_project
941 if(! -d
$windows_project);
942 chdir $windows_project;
943 $subsys = ($type eq "G") ?
"windows" : "console";
944 open OUT
, ">$windows_project.dsp"; binmode OUT
; select OUT
;
946 "# Microsoft Developer Studio Project File - Name=\"$windows_project\" - Package Owner=<4>\r\n".
947 "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n".
948 "# ** DO NOT EDIT **\r\n".
950 "# TARGTYPE \"Win32 (x86) Application\" 0x0101\r\n".
952 "CFG=$windows_project - Win32 Debug\r\n".
953 "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n".
954 "!MESSAGE use the Export Makefile command and run\r\n".
956 "!MESSAGE NMAKE /f \"$windows_project.mak\".\r\n".
958 "!MESSAGE You can specify a configuration when running NMAKE\r\n".
959 "!MESSAGE by defining the macro CFG on the command line. For example:\r\n".
961 "!MESSAGE NMAKE /f \"$windows_project.mak\" CFG=\"$windows_project - Win32 Debug\"\r\n".
963 "!MESSAGE Possible choices for configuration are:\r\n".
965 "!MESSAGE \"$windows_project - Win32 Release\" (based on \"Win32 (x86) Application\")\r\n".
966 "!MESSAGE \"$windows_project - Win32 Debug\" (based on \"Win32 (x86) Application\")\r\n".
969 "# Begin Project\r\n".
970 "# PROP AllowPerConfigDependencies 0\r\n".
971 "# PROP Scc_ProjName \"\"\r\n".
972 "# PROP Scc_LocalPath \"\"\r\n".
977 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
979 "# PROP BASE Use_MFC 0\r\n".
980 "# PROP BASE Use_Debug_Libraries 0\r\n".
981 "# PROP BASE Output_Dir \"Release\"\r\n".
982 "# PROP BASE Intermediate_Dir \"Release\"\r\n".
983 "# PROP BASE Target_Dir \"\"\r\n".
984 "# PROP Use_MFC 0\r\n".
985 "# PROP Use_Debug_Libraries 0\r\n".
986 "# PROP Output_Dir \"Release\"\r\n".
987 "# PROP Intermediate_Dir \"Release\"\r\n".
988 "# PROP Ignore_Export_Lib 0\r\n".
989 "# PROP Target_Dir \"\"\r\n".
990 "# ADD BASE CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
991 "# ADD CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
992 "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
993 "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
994 "# ADD BASE RSC /l 0x809 /d \"NDEBUG\"\r\n".
995 "# ADD RSC /l 0x809 /d \"NDEBUG\"\r\n".
996 "BSC32=bscmake.exe\r\n".
997 "# ADD BASE BSC32 /nologo\r\n".
998 "# ADD BSC32 /nologo\r\n".
999 "LINK32=link.exe\r\n".
1000 "# 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".
1001 "# ADD LINK32 $libs /nologo /subsystem:$subsys /machine:I386\r\n".
1002 "# SUBTRACT LINK32 /pdb:none\r\n".
1004 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
1006 "# PROP BASE Use_MFC 0\r\n".
1007 "# PROP BASE Use_Debug_Libraries 1\r\n".
1008 "# PROP BASE Output_Dir \"Debug\"\r\n".
1009 "# PROP BASE Intermediate_Dir \"Debug\"\r\n".
1010 "# PROP BASE Target_Dir \"\"\r\n".
1011 "# PROP Use_MFC 0\r\n".
1012 "# PROP Use_Debug_Libraries 1\r\n".
1013 "# PROP Output_Dir \"Debug\"\r\n".
1014 "# PROP Intermediate_Dir \"Debug\"\r\n".
1015 "# PROP Ignore_Export_Lib 0\r\n".
1016 "# PROP Target_Dir \"\"\r\n".
1017 "# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
1018 "# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
1019 "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
1020 "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
1021 "# ADD BASE RSC /l 0x809 /d \"_DEBUG\"\r\n".
1022 "# ADD RSC /l 0x809 /d \"_DEBUG\"\r\n".
1023 "BSC32=bscmake.exe\r\n".
1024 "# ADD BASE BSC32 /nologo\r\n".
1025 "# ADD BSC32 /nologo\r\n".
1026 "LINK32=link.exe\r\n".
1027 "# 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".
1028 "# ADD LINK32 $libs /nologo /subsystem:$subsys /debug /machine:I386 /pdbtype:sept\r\n".
1029 "# SUBTRACT LINK32 /pdb:none\r\n".
1033 "# Begin Target\r\n".
1035 "# Name \"$windows_project - Win32 Release\"\r\n".
1036 "# Name \"$windows_project - Win32 Debug\"\r\n".
1037 "# Begin Group \"Source Files\"\r\n".
1039 "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
1040 foreach $source_file (@source_files) {
1042 "# Begin Source File\r\n".
1044 "SOURCE=..\\..\\$source_file\r\n";
1045 if($source_file =~ /ssh\.c/io) {
1046 # Disable 'Edit and continue' as Visual Studio can't handle the macros
1049 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
1051 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
1053 "# ADD CPP /Zi\r\n".
1058 print "# End Source File\r\n";
1062 "# Begin Group \"Header Files\"\r\n".
1064 "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
1065 foreach $header_file (@header_files) {
1067 "# Begin Source File\r\n".
1069 "SOURCE=..\\..\\$header_file\r\n".
1070 "# End Source File\r\n";
1074 "# Begin Group \"Resource Files\"\r\n".
1076 "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
1077 foreach $resource_file (@resources) {
1079 "# Begin Source File\r\n".
1081 "SOURCE=..\\..\\$resource_file\r\n".
1082 "# End Source File\r\n";
1087 "# End Project\r\n";
1088 select STDOUT
; close OUT
;
1093 if (defined $makefiles{'gtk'}) {
1095 $dirpfx = &dirpfx
($makefiles{'gtk'}, "/");
1097 ##-- X/GTK/Unix makefile
1098 open OUT
, ">$makefiles{'gtk'}"; select OUT
;
1100 "# Makefile for $project_name under X/GTK and Unix.\n".
1101 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1102 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1103 # gcc command line option is -D not /D
1104 ($_ = $help) =~ s/=\/D/=-D
/gs
;
1108 "# You can define this path to point at your tools if you need to\n".
1109 "# TOOLPATH = /opt/gcc/bin\n".
1110 "CC := \$(TOOLPATH)\$(CC)\n".
1111 "# You can manually set this to `gtk-config' or `pkg-config gtk+-1.2'\n".
1112 "# (depending on what works on your system) if you want to enforce\n".
1113 "# building with GTK 1.2, or you can set it to `pkg-config gtk+-2.0'\n".
1114 "# if you want to enforce 2.0. The default is to try 2.0 and fall back\n".
1115 "# to 1.2 if it isn't found.\n".
1116 "GTK_CONFIG = sh -c 'pkg-config gtk+-2.0 \$\$0 2>/dev/null || gtk-config \$\$0'\n".
1118 &splitline
("CFLAGS := -O2 -Wall -Werror -ansi -pedantic -g " .
1119 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
1120 " `\$(GTK_CONFIG) --cflags` \$(CFLAGS)")."\n".
1121 "XLIBS = `\$(GTK_CONFIG) --libs`\n".
1123 "INSTALL=install\n",
1124 "INSTALL_PROGRAM=\$(INSTALL)\n",
1125 "INSTALL_DATA=\$(INSTALL)\n",
1126 "prefix=/usr/local\n",
1127 "exec_prefix=\$(prefix)\n",
1128 "bindir=\$(exec_prefix)/bin\n",
1129 "gamesdir=\$(exec_prefix)/games\n",
1130 "mandir=\$(prefix)/man\n",
1131 "man1dir=\$(mandir)/man1\n",
1133 print &splitline
("all:" . join "", map { " $_" } &progrealnames
("X:U"));
1135 foreach $p (&prognames
("X:U")) {
1136 ($prog, $type) = split ",", $p;
1137 $objstr = &objects
($p, "X.o", undef, undef);
1138 print &splitline
($prog . ": " . $objstr), "\n";
1139 $libstr = &objects
($p, undef, undef, "-lX");
1140 print &splitline
("\t\$(CC) -o \$@ $objstr $libstr \$(XLFLAGS) \$(${type}LIBS)", 69),
1143 foreach $d (&deps
("X.o", undef, $dirpfx, "/")) {
1144 print &splitline
(sprintf("%s: %s", $d->{obj
}, join " ", @
{$d->{deps
}})),
1146 $deflist = join "", map { " -D$_" } @
{$d->{defs
}};
1147 print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist" .
1148 " -c \$< -o \$\@\n";
1151 print $makefile_extra{'gtk'};
1153 "\trm -f *.o". (join "", map { " $_" } &progrealnames
("X:U")) . "\n";
1154 select STDOUT
; close OUT
;
1157 if (defined $makefiles{'qt'}) {
1159 $dirpfx = &dirpfx
($makefiles{'qt'}, "/");
1161 ##-- Qt/Unix makefile
1162 open OUT
, ">$makefiles{'qt'}"; select OUT
;
1164 "# Makefile for $project_name under Qt and Unix.\n".
1165 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1166 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1167 # gcc command line option is -D not /D
1168 ($_ = $help) =~ s/=\/D/=-D
/gs
;
1172 "# You can define this path to point at your tools if you need to\n".
1173 "# TOOLPATH = /opt/gcc/bin\n".
1174 "CC := \$(TOOLPATH)\$(CC)\n".
1176 &splitline
("CFLAGS := -O2 -Wall -Werror -ansi -g " .
1177 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
1178 " -I/usr/share/qt4/include \$(CFLAGS)")."\n".
1179 "QLIBS = -lQtGui -lQtCore\n".
1181 "INSTALL=install\n",
1182 "INSTALL_PROGRAM=\$(INSTALL)\n",
1183 "INSTALL_DATA=\$(INSTALL)\n",
1184 "prefix=/usr/local\n",
1185 "exec_prefix=\$(prefix)\n",
1186 "bindir=\$(exec_prefix)/bin\n",
1187 "gamesdir=\$(exec_prefix)/games\n",
1188 "mandir=\$(prefix)/man\n",
1189 "man1dir=\$(mandir)/man1\n",
1191 print &splitline
("all:" . join "", map { " $_" } &progrealnames
("X:U"));
1193 foreach $p (&prognames
("Q:U")) {
1194 ($prog, $type) = split ",", $p;
1195 $objstr = &objects
($p, "X.o", undef, undef);
1196 print &splitline
($prog . ": " . $objstr), "\n";
1197 $libstr = &objects
($p, undef, undef, "-lX");
1198 print &splitline
("\t\$(CXX) -o \$@ $objstr $libstr \$(XFLAGS) \$(${type}LIBS)", 69),
1201 foreach $d (&deps
("X.o", undef, $dirpfx, "/")) {
1202 print &splitline
(sprintf("%s: %s", $d->{obj
}, join " ", @
{$d->{deps
}})),
1204 $deflist = join "", map { " -D$_" } @
{$d->{defs
}};
1205 print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist" .
1206 " -c \$< -o \$\@\n";
1209 print $makefile_extra{'qt'};
1211 "\trm -f *.o". (join "", map { " $_" } &progrealnames
("X:U")) . "\n";
1212 select STDOUT
; close OUT
;
1213 mkdir "qtopia" if(! -d
"qtopia");
1214 open OUT
, ">qtopia/qbuild.pro"; select OUT
;
1216 "# qbuild project for $project_name.\n".
1217 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1218 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n".
1220 "TEMPLATE = subdirs\n";
1221 my $subdirstr = "SUBDIRS = common";
1222 foreach $p (&prognames
("Q")) {
1223 ($prog, $type) = split ",", $p;
1224 $subdirstr .= " $prog";
1225 print "$prog.depends = common\n";
1227 print "$subdirstr\n";
1228 select STDOUT
; close OUT
;
1229 foreach $p (&prognames
("Q")) {
1230 ($prog, $type) = split ",", $p;
1231 mkdir "qtopia/$prog" if(! -d
"qtopia/$prog");
1232 open OUT
, ">qtopia/$prog/qbuild.pro"; select OUT
;
1234 "# qbuild project for $project_name/$prog.\n".
1235 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1236 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n".
1239 "CONFIG += qtopia\n".
1240 "INCLUDEPATH += ../common\n".
1241 "LIBS += -L../common -lcommon\n".
1242 "DEPENDS += ../common".
1245 "SOURCES = ../../$prog.c\n".
1246 "DEFINES += STYLUS_BASED\n".
1250 " files=$prog.desktop\n".
1251 " path=/apps/Games\n".
1255 " files=../../icons/$prog-48d24.png\n".
1256 " path=/pics/sgt-puzzles\n".
1259 select STDOUT
; close OUT
;
1260 open OUT
, ">qtopia/$prog/$prog.desktop"; select OUT
;
1262 "[Desktop Entry]\n".
1265 "Icon=sgt-puzzles/$prog-48d24\n".
1267 "Type=Application\n".
1268 "Categories=Qt;Game;\n";
1269 select STDOUT
; close OUT
;
1273 if (defined $makefiles{'mpw'}) {
1276 open OUT
, ">$makefiles{'mpw'}"; select OUT
;
1278 "# Makefile for $project_name under MPW.\n#\n".
1279 "# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1280 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1281 # MPW command line option is -d not /D
1282 ($_ = $help) =~ s/=\/D/=-d
/gs
;
1285 "ROptions = `Echo \"{VER}\" | StreamEdit -e \"1,\$ replace /=(\xc5)\xa81\xb0/ 'STR=\xb6\xb6\xb6\xb6\xb6\"' \xa81 '\xb6\xb6\xb6\xb6\xb6\"'\"`".
1290 "C_Carbon = {PPCC}\n".
1292 "# -w 35 disables \"unused parameter\" warnings\n".
1293 "COptions = -i : -i :: -i ::charset -w 35 -w err -proto strict -ansi on \xb6\n".
1295 "COptions_68K = {COptions} -model far -opt time\n".
1296 "# Enabling \"-opt space\" for CFM-68K gives me undefined references to\n".
1297 "# _\$LDIVT and _\$LMODT.\n".
1298 "COptions_CFM68K = {COptions} -model cfmSeg -opt time\n".
1299 "COptions_PPC = {COptions} -opt size -traceback\n".
1300 "COptions_Carbon = {COptions} -opt size -traceback -d TARGET_API_MAC_CARBON\n".
1302 "Link_68K = ILink\n".
1303 "Link_CFM68K = ILink\n".
1304 "Link_PPC = PPCLink\n".
1305 "Link_Carbon = PPCLink\n".
1307 "LinkOptions = -c 'pTTY'\n".
1308 "LinkOptions_68K = {LinkOptions} -br 68k -model far -compact\n".
1309 "LinkOptions_CFM68K = {LinkOptions} -br 020 -model cfmseg -compact\n".
1310 "LinkOptions_PPC = {LinkOptions}\n".
1311 "LinkOptions_Carbon = -m __appstart -w {LinkOptions}\n".
1313 "Libs_68K = \"{CLibraries}StdCLib.far.o\" \xb6\n".
1314 " \"{Libraries}MacRuntime.o\" \xb6\n".
1315 " \"{Libraries}MathLib.far.o\" \xb6\n".
1316 " \"{Libraries}IntEnv.far.o\" \xb6\n".
1317 " \"{Libraries}Interface.o\" \xb6\n".
1318 " \"{Libraries}Navigation.far.o\" \xb6\n".
1319 " \"{Libraries}OpenTransport.o\" \xb6\n".
1320 " \"{Libraries}OpenTransportApp.o\" \xb6\n".
1321 " \"{Libraries}OpenTptInet.o\" \xb6\n".
1322 " \"{Libraries}UnicodeConverterLib.far.o\"\n".
1324 "Libs_CFM = \"{SharedLibraries}InterfaceLib\" \xb6\n".
1325 " \"{SharedLibraries}StdCLib\" \xb6\n".
1326 " \"{SharedLibraries}AppearanceLib\" \xb6\n".
1327 " -weaklib AppearanceLib \xb6\n".
1328 " \"{SharedLibraries}NavigationLib\" \xb6\n".
1329 " -weaklib NavigationLib \xb6\n".
1330 " \"{SharedLibraries}TextCommon\" \xb6\n".
1331 " -weaklib TextCommon \xb6\n".
1332 " \"{SharedLibraries}UnicodeConverter\" \xb6\n".
1333 " -weaklib UnicodeConverter\n".
1335 "Libs_CFM68K = {Libs_CFM} \xb6\n".
1336 " \"{CFM68KLibraries}NuMacRuntime.o\"\n".
1338 "Libs_PPC = {Libs_CFM} \xb6\n".
1339 " \"{SharedLibraries}ControlsLib\" \xb6\n".
1340 " -weaklib ControlsLib \xb6\n".
1341 " \"{SharedLibraries}WindowsLib\" \xb6\n".
1342 " -weaklib WindowsLib \xb6\n".
1343 " \"{SharedLibraries}OpenTransportLib\" \xb6\n".
1344 " -weaklib OTClientLib \xb6\n".
1345 " -weaklib OTClientUtilLib \xb6\n".
1346 " \"{SharedLibraries}OpenTptInternetLib\" \xb6\n".
1347 " -weaklib OTInetClientLib \xb6\n".
1348 " \"{PPCLibraries}StdCRuntime.o\" \xb6\n".
1349 " \"{PPCLibraries}PPCCRuntime.o\" \xb6\n".
1350 " \"{PPCLibraries}CarbonAccessors.o\" \xb6\n".
1351 " \"{PPCLibraries}OpenTransportAppPPC.o\" \xb6\n".
1352 " \"{PPCLibraries}OpenTptInetPPC.o\"\n".
1354 "Libs_Carbon = \"{PPCLibraries}CarbonStdCLib.o\" \xb6\n".
1355 " \"{PPCLibraries}StdCRuntime.o\" \xb6\n".
1356 " \"{PPCLibraries}PPCCRuntime.o\" \xb6\n".
1357 " \"{SharedLibraries}CarbonLib\" \xb6\n".
1358 " \"{SharedLibraries}StdCLib\"\n".
1360 print &splitline
("all \xc4 " . join(" ", &progrealnames
("M")), undef, "\xb6");
1362 foreach $p (&prognames
("M")) {
1363 ($prog, $type) = split ",", $p;
1365 print &splitline
("$prog \xc4 $prog.68k $prog.ppc $prog.carbon",
1366 undef, "\xb6"), "\n\n";
1368 $rsrc = &objects
($p, "", "X.rsrc", undef);
1370 foreach $arch (qw(68K CFM68K PPC Carbon)) {
1371 $objstr = &objects
($p, "X.\L$arch\E.o", "", undef);
1372 print &splitline
("$prog.\L$arch\E \xc4 $objstr $rsrc", undef, "\xb6");
1374 print &splitline
("\tDuplicate -y $rsrc {Targ}", 69, "\xb6"), "\n";
1375 print &splitline
("\t{Link_$arch} -o {Targ} -fragname $prog " .
1376 "{LinkOptions_$arch} " .
1377 $objstr . " {Libs_$arch}", 69, "\xb6"), "\n";
1378 print &splitline
("\tSetFile -a BMi {Targ}", 69, "\xb6"), "\n\n";
1382 foreach $d (&deps
("", "X.rsrc", "::", ":")) {
1383 next unless $d->{obj
};
1384 print &splitline
(sprintf("%s \xc4 %s", $d->{obj
}, join " ", @
{$d->{deps
}}),
1385 undef, "\xb6"), "\n";
1386 print "\tRez ", $d->{deps
}->[0], " -o {Targ} {ROptions}\n\n";
1388 foreach $arch (qw(68K CFM68K)) {
1389 foreach $d (&deps
("X.\L$arch\E.o", "", "::", ":")) {
1390 next unless $d->{obj
};
1391 print &splitline
(sprintf("%s \xc4 %s", $d->{obj
},
1392 join " ", @
{$d->{deps
}}),
1393 undef, "\xb6"), "\n";
1394 print "\t{C_$arch} ", $d->{deps
}->[0],
1395 " -o {Targ} {COptions_$arch}\n\n";
1398 foreach $arch (qw(PPC Carbon)) {
1399 foreach $d (&deps
("X.\L$arch\E.o", "", "::", ":")) {
1400 next unless $d->{obj
};
1401 print &splitline
(sprintf("%s \xc4 %s", $d->{obj
},
1402 join " ", @
{$d->{deps
}}),
1403 undef, "\xb6"), "\n";
1404 # The odd stuff here seems to stop afpd getting confused.
1405 print "\techo -n > {Targ}\n";
1406 print "\tsetfile -t XCOF {Targ}\n";
1407 print "\t{C_$arch} ", $d->{deps
}->[0],
1408 " -o {Targ} {COptions_$arch}\n\n";
1411 select STDOUT
; close OUT
;
1414 if (defined $makefiles{'lcc'}) {
1416 $dirpfx = &dirpfx
($makefiles{'lcc'}, "\\");
1419 open OUT
, ">$makefiles{'lcc'}"; select OUT
;
1421 "# Makefile for $project_name under lcc.\n".
1422 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1423 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1424 # lcc command line option is -D not /D
1425 ($_ = $help) =~ s/=\/D/=-D
/gs
;
1429 "# If you rename this file to `Makefile', you should change this line,\n".
1430 "# so that the .rsp files still depend on the correct makefile.\n".
1431 "MAKEFILE = Makefile.lcc\n".
1433 "# C compilation flags\n".
1434 "CFLAGS = -D_WINDOWS " .
1435 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
1438 "# Get include directory for resource compiler\n".
1440 print &splitline
("all:" . join "", map { " $_.exe" } &progrealnames
("G:C"));
1442 foreach $p (&prognames
("G:C")) {
1443 ($prog, $type) = split ",", $p;
1444 $objstr = &objects
($p, "X.obj", "X.res", undef);
1445 print &splitline
("$prog.exe: " . $objstr ), "\n";
1446 $subsystemtype = undef;
1447 if ($type eq "G") { $subsystemtype = "-subsystem windows"; }
1448 my $libss = "shell32.lib wsock32.lib ws2_32.lib winspool.lib winmm.lib imm32.lib";
1449 print &splitline
("\tlcclnk $subsystemtype -o $prog.exe $objstr $libss");
1453 foreach $d (&deps
("X.obj", "X.res", $dirpfx, "\\")) {
1454 print &splitline
(sprintf("%s: %s", $d->{obj
}, join " ", @
{$d->{deps
}})),
1456 if ($d->{obj
} =~ /\.res$/) {
1457 print &splitline
("\tlrc \$(FWHACK) \$(RCFL) -r \$*.rc",69)."\n";
1459 $deflist = join "", map { " -D$_" } @
{$d->{defs
}};
1460 print &splitline
("\tlcc -O -p6 \$(COMPAT) \$(FWHACK) \$(CFLAGS)".
1461 " \$(XFLAGS)$deflist ".$d->{deps
}->[0]." -o \$\@",69)."\n";
1465 print $makefile_extra{'lcc'};
1471 select STDOUT
; close OUT
;
1474 if (defined $makefiles{'nestedvm'}) {
1475 $mftyp = 'nestedvm';
1476 $dirpfx = &dirpfx
($makefiles{'nestedvm'}, "/");
1478 ##-- NestedVM makefile
1479 open OUT
, ">$makefiles{'nestedvm'}"; select OUT
;
1481 "# Makefile for $project_name under NestedVM.\n".
1482 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1483 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1484 # gcc command line option is -D not /D
1485 ($_ = $help) =~ s/=\/D/=-D
/gs
;
1489 "# This path points at the nestedvm root directory\n".
1490 "NESTEDVM = /opt/nestedvm\n".
1491 "# You can define this path to point at your tools if you need to\n".
1492 "TOOLPATH = \$(NESTEDVM)/upstream/install/bin\n".
1493 "CC = \$(TOOLPATH)/mips-unknown-elf-gcc\n".
1495 &splitline
("CFLAGS = -O2 -Wall -Werror -DSLOW_SYSTEM -g " .
1496 (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
1498 print &splitline
("all:" . join "", map { " $_.jar" } &progrealnames
("X"));
1500 foreach $p (&prognames
("X")) {
1501 ($prog, $type) = split ",", $p;
1502 $objstr = &objects
($p, "X.o", undef, undef);
1503 $objstr =~ s/gtk\.o/nestedvm\.o/g;
1504 print &splitline
($prog . ".mips: " . $objstr), "\n";
1505 $libstr = &objects
($p, undef, undef, "-lX");
1506 print &splitline
("\t\$(CC) \$(${type}LDFLAGS) -o \$@ " .
1507 $objstr . " $libstr -lm", 69), "\n\n";
1509 foreach $d (&deps
("X.o", undef, $dirpfx, "/")) {
1511 $ddeps= join " ", @
{$d->{deps
}};
1512 $oobjs =~ s/gtk/nestedvm/g;
1513 $ddeps =~ s/gtk/nestedvm/g;
1514 print &splitline
(sprintf("%s: %s", $oobjs, $ddeps)),
1516 $deflist = join "", map { " -D$_" } @
{$d->{defs
}};
1517 print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist" .
1518 " -c \$< -o \$\@\n";
1521 print $makefile_extra{'nestedvm'};
1523 "\trm -rf *.o *.mips *.class *.html *.jar org applet.manifest\n";
1524 select STDOUT
; close OUT
;
1527 if (defined $makefiles{'osx'}) {
1529 $dirpfx = &dirpfx
($makefiles{'osx'}, "/");
1530 @osxarchs = ('ppc', 'i386');
1532 ##-- Mac OS X makefile
1533 open OUT
, ">$makefiles{'osx'}"; select OUT
;
1535 "# Makefile for $project_name under Mac OS X.\n".
1536 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1537 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1538 # gcc command line option is -D not /D
1539 ($_ = $help) =~ s/=\/D/=-D
/gs
;
1542 "CC = \$(TOOLPATH)gcc\n".
1543 "LIPO = \$(TOOLPATH)lipo\n".
1545 &splitline
("CFLAGS = -O2 -Wall -Werror -g " .
1546 (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
1547 "LDFLAGS = -framework Cocoa\n".
1548 &splitline
("all:" . join "", map { " $_" } &progrealnames
("MX:U")) .
1550 $makefile_extra{'osx'} .
1552 ".SUFFIXES: .o .c .m\n".
1555 foreach $p (&prognames
("MX")) {
1556 ($prog, $type) = split ",", $p;
1557 $icon = &special
($p, ".icns");
1558 $infoplist = &special
($p, "info.plist");
1559 print "${prog}.app:\n\tmkdir -p \$\@\n";
1560 print "${prog}.app/Contents: ${prog}.app\n\tmkdir -p \$\@\n";
1561 print "${prog}.app/Contents/MacOS: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1562 $targets = "${prog}.app/Contents/MacOS/$prog";
1563 if (defined $icon) {
1564 print "${prog}.app/Contents/Resources: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1565 print "${prog}.app/Contents/Resources/${prog}.icns: ${prog}.app/Contents/Resources $icon\n\tcp $icon \$\@\n";
1566 $targets .= " ${prog}.app/Contents/Resources/${prog}.icns";
1568 if (defined $infoplist) {
1569 print "${prog}.app/Contents/Info.plist: ${prog}.app/Contents/Resources $infoplist\n\tcp $infoplist \$\@\n";
1570 $targets .= " ${prog}.app/Contents/Info.plist";
1572 $targets .= " \$(${prog}_extra)";
1573 print &splitline
("${prog}: $targets", 69) . "\n\n";
1574 $libstr = &objects
($p, undef, undef, "-lX");
1576 foreach $arch (@osxarchs) {
1577 $objstr = &objects
($p, "X.${arch}.o", undef, undef);
1578 print &splitline
("${prog}.${arch}.bin: " . $objstr), "\n";
1579 print &splitline
("\t\$(CC) -arch ${arch} -mmacosx-version-min=10.3 \$(LDFLAGS) -o \$@ " .
1580 $objstr . " $libstr", 69), "\n\n";
1581 $archbins .= " ${prog}.${arch}.bin";
1583 print &splitline
("${prog}.app/Contents/MacOS/$prog: ".
1584 "${prog}.app/Contents/MacOS" . $archbins), "\n";
1585 print &splitline
("\t\$(LIPO) -create $archbins -output \$@", 69), "\n\n";
1587 foreach $p (&prognames
("U")) {
1588 ($prog, $type) = split ",", $p;
1589 $libstr = &objects
($p, undef, undef, "-lX");
1591 foreach $arch (@osxarchs) {
1592 $objstr = &objects
($p, "X.${arch}.o", undef, undef);
1593 print &splitline
("${prog}.${arch}: " . $objstr), "\n";
1594 print &splitline
("\t\$(CC) -arch ${arch} -mmacosx-version-min=10.3 \$(ULDFLAGS) -o \$@ " .
1595 $objstr . " $libstr", 69), "\n\n";
1596 $archbins .= " ${prog}.${arch}";
1598 print &splitline
("${prog}:" . $archbins), "\n";
1599 print &splitline
("\t\$(LIPO) -create $archbins -output \$@", 69), "\n\n";
1601 foreach $arch (@osxarchs) {
1602 foreach $d (&deps
("X.${arch}.o", undef, $dirpfx, "/")) {
1603 print &splitline
(sprintf("%s: %s", $d->{obj
}, join " ", @
{$d->{deps
}})),
1605 $deflist = join "", map { " -D$_" } @
{$d->{defs
}};
1606 if ($d->{deps
}->[0] =~ /\.m$/) {
1607 print "\t\$(CC) -arch $arch -mmacosx-version-min=10.3 -x objective-c \$(COMPAT) \$(FWHACK) \$(CFLAGS)".
1608 " \$(XFLAGS)$deflist -c \$< -o \$\@\n";
1610 print "\t\$(CC) -arch $arch -mmacosx-version-min=10.3 \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist" .
1611 " -c \$< -o \$\@\n";
1616 "\trm -f *.o *.dmg". (join "", map { my $a=$_; (" $a", map { " ${a}.$_" } @osxarchs) } &progrealnames
("U")) . "\n".
1618 select STDOUT
; close OUT
;