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
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","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{'mpw'}) {
1160 open OUT
, ">$makefiles{'mpw'}"; select OUT
;
1162 "# Makefile for $project_name under MPW.\n#\n".
1163 "# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1164 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1165 # MPW command line option is -d not /D
1166 ($_ = $help) =~ s/=\/D/=-d
/gs
;
1169 "ROptions = `Echo \"{VER}\" | StreamEdit -e \"1,\$ replace /=(\xc5)\xa81\xb0/ 'STR=\xb6\xb6\xb6\xb6\xb6\"' \xa81 '\xb6\xb6\xb6\xb6\xb6\"'\"`".
1174 "C_Carbon = {PPCC}\n".
1176 "# -w 35 disables \"unused parameter\" warnings\n".
1177 "COptions = -i : -i :: -i ::charset -w 35 -w err -proto strict -ansi on \xb6\n".
1179 "COptions_68K = {COptions} -model far -opt time\n".
1180 "# Enabling \"-opt space\" for CFM-68K gives me undefined references to\n".
1181 "# _\$LDIVT and _\$LMODT.\n".
1182 "COptions_CFM68K = {COptions} -model cfmSeg -opt time\n".
1183 "COptions_PPC = {COptions} -opt size -traceback\n".
1184 "COptions_Carbon = {COptions} -opt size -traceback -d TARGET_API_MAC_CARBON\n".
1186 "Link_68K = ILink\n".
1187 "Link_CFM68K = ILink\n".
1188 "Link_PPC = PPCLink\n".
1189 "Link_Carbon = PPCLink\n".
1191 "LinkOptions = -c 'pTTY'\n".
1192 "LinkOptions_68K = {LinkOptions} -br 68k -model far -compact\n".
1193 "LinkOptions_CFM68K = {LinkOptions} -br 020 -model cfmseg -compact\n".
1194 "LinkOptions_PPC = {LinkOptions}\n".
1195 "LinkOptions_Carbon = -m __appstart -w {LinkOptions}\n".
1197 "Libs_68K = \"{CLibraries}StdCLib.far.o\" \xb6\n".
1198 " \"{Libraries}MacRuntime.o\" \xb6\n".
1199 " \"{Libraries}MathLib.far.o\" \xb6\n".
1200 " \"{Libraries}IntEnv.far.o\" \xb6\n".
1201 " \"{Libraries}Interface.o\" \xb6\n".
1202 " \"{Libraries}Navigation.far.o\" \xb6\n".
1203 " \"{Libraries}OpenTransport.o\" \xb6\n".
1204 " \"{Libraries}OpenTransportApp.o\" \xb6\n".
1205 " \"{Libraries}OpenTptInet.o\" \xb6\n".
1206 " \"{Libraries}UnicodeConverterLib.far.o\"\n".
1208 "Libs_CFM = \"{SharedLibraries}InterfaceLib\" \xb6\n".
1209 " \"{SharedLibraries}StdCLib\" \xb6\n".
1210 " \"{SharedLibraries}AppearanceLib\" \xb6\n".
1211 " -weaklib AppearanceLib \xb6\n".
1212 " \"{SharedLibraries}NavigationLib\" \xb6\n".
1213 " -weaklib NavigationLib \xb6\n".
1214 " \"{SharedLibraries}TextCommon\" \xb6\n".
1215 " -weaklib TextCommon \xb6\n".
1216 " \"{SharedLibraries}UnicodeConverter\" \xb6\n".
1217 " -weaklib UnicodeConverter\n".
1219 "Libs_CFM68K = {Libs_CFM} \xb6\n".
1220 " \"{CFM68KLibraries}NuMacRuntime.o\"\n".
1222 "Libs_PPC = {Libs_CFM} \xb6\n".
1223 " \"{SharedLibraries}ControlsLib\" \xb6\n".
1224 " -weaklib ControlsLib \xb6\n".
1225 " \"{SharedLibraries}WindowsLib\" \xb6\n".
1226 " -weaklib WindowsLib \xb6\n".
1227 " \"{SharedLibraries}OpenTransportLib\" \xb6\n".
1228 " -weaklib OTClientLib \xb6\n".
1229 " -weaklib OTClientUtilLib \xb6\n".
1230 " \"{SharedLibraries}OpenTptInternetLib\" \xb6\n".
1231 " -weaklib OTInetClientLib \xb6\n".
1232 " \"{PPCLibraries}StdCRuntime.o\" \xb6\n".
1233 " \"{PPCLibraries}PPCCRuntime.o\" \xb6\n".
1234 " \"{PPCLibraries}CarbonAccessors.o\" \xb6\n".
1235 " \"{PPCLibraries}OpenTransportAppPPC.o\" \xb6\n".
1236 " \"{PPCLibraries}OpenTptInetPPC.o\"\n".
1238 "Libs_Carbon = \"{PPCLibraries}CarbonStdCLib.o\" \xb6\n".
1239 " \"{PPCLibraries}StdCRuntime.o\" \xb6\n".
1240 " \"{PPCLibraries}PPCCRuntime.o\" \xb6\n".
1241 " \"{SharedLibraries}CarbonLib\" \xb6\n".
1242 " \"{SharedLibraries}StdCLib\"\n".
1244 print &splitline
("all \xc4 " . join(" ", &progrealnames
("M")), undef, "\xb6");
1246 foreach $p (&prognames
("M")) {
1247 ($prog, $type) = split ",", $p;
1249 print &splitline
("$prog \xc4 $prog.68k $prog.ppc $prog.carbon",
1250 undef, "\xb6"), "\n\n";
1252 $rsrc = &objects
($p, "", "X.rsrc", undef);
1254 foreach $arch (qw(68K CFM68K PPC Carbon)) {
1255 $objstr = &objects
($p, "X.\L$arch\E.o", "", undef);
1256 print &splitline
("$prog.\L$arch\E \xc4 $objstr $rsrc", undef, "\xb6");
1258 print &splitline
("\tDuplicate -y $rsrc {Targ}", 69, "\xb6"), "\n";
1259 print &splitline
("\t{Link_$arch} -o {Targ} -fragname $prog " .
1260 "{LinkOptions_$arch} " .
1261 $objstr . " {Libs_$arch}", 69, "\xb6"), "\n";
1262 print &splitline
("\tSetFile -a BMi {Targ}", 69, "\xb6"), "\n\n";
1266 foreach $d (&deps
("", "X.rsrc", "::", ":")) {
1267 next unless $d->{obj
};
1268 print &splitline
(sprintf("%s \xc4 %s", $d->{obj
}, join " ", @
{$d->{deps
}}),
1269 undef, "\xb6"), "\n";
1270 print "\tRez ", $d->{deps
}->[0], " -o {Targ} {ROptions}\n\n";
1272 foreach $arch (qw(68K CFM68K)) {
1273 foreach $d (&deps
("X.\L$arch\E.o", "", "::", ":")) {
1274 next unless $d->{obj
};
1275 print &splitline
(sprintf("%s \xc4 %s", $d->{obj
},
1276 join " ", @
{$d->{deps
}}),
1277 undef, "\xb6"), "\n";
1278 print "\t{C_$arch} ", $d->{deps
}->[0],
1279 " -o {Targ} {COptions_$arch}\n\n";
1282 foreach $arch (qw(PPC Carbon)) {
1283 foreach $d (&deps
("X.\L$arch\E.o", "", "::", ":")) {
1284 next unless $d->{obj
};
1285 print &splitline
(sprintf("%s \xc4 %s", $d->{obj
},
1286 join " ", @
{$d->{deps
}}),
1287 undef, "\xb6"), "\n";
1288 # The odd stuff here seems to stop afpd getting confused.
1289 print "\techo -n > {Targ}\n";
1290 print "\tsetfile -t XCOF {Targ}\n";
1291 print "\t{C_$arch} ", $d->{deps
}->[0],
1292 " -o {Targ} {COptions_$arch}\n\n";
1295 select STDOUT
; close OUT
;
1298 if (defined $makefiles{'lcc'}) {
1300 $dirpfx = &dirpfx
($makefiles{'lcc'}, "\\");
1303 open OUT
, ">$makefiles{'lcc'}"; select OUT
;
1305 "# Makefile for $project_name under lcc.\n".
1306 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1307 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1308 # lcc command line option is -D not /D
1309 ($_ = $help) =~ s/=\/D/=-D
/gs
;
1313 "# If you rename this file to `Makefile', you should change this line,\n".
1314 "# so that the .rsp files still depend on the correct makefile.\n".
1315 "MAKEFILE = Makefile.lcc\n".
1317 "# C compilation flags\n".
1318 "CFLAGS = -D_WINDOWS " .
1319 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
1322 "# Get include directory for resource compiler\n".
1324 print &splitline
("all:" . join "", map { " $_.exe" } &progrealnames
("G:C"));
1326 foreach $p (&prognames
("G:C")) {
1327 ($prog, $type) = split ",", $p;
1328 $objstr = &objects
($p, "X.obj", "X.res", undef);
1329 print &splitline
("$prog.exe: " . $objstr ), "\n";
1330 $subsystemtype = undef;
1331 if ($type eq "G") { $subsystemtype = "-subsystem windows"; }
1332 my $libss = "shell32.lib wsock32.lib ws2_32.lib winspool.lib winmm.lib imm32.lib";
1333 print &splitline
("\tlcclnk $subsystemtype -o $prog.exe $objstr $libss");
1337 foreach $d (&deps
("X.obj", "X.res", $dirpfx, "\\")) {
1338 print &splitline
(sprintf("%s: %s", $d->{obj
}, join " ", @
{$d->{deps
}})),
1340 if ($d->{obj
} =~ /\.res$/) {
1341 print &splitline
("\tlrc \$(FWHACK) \$(RCFL) -r \$*.rc",69)."\n";
1343 $deflist = join "", map { " -D$_" } @
{$d->{defs
}};
1344 print &splitline
("\tlcc -O -p6 \$(COMPAT) \$(FWHACK) \$(CFLAGS)".
1345 " \$(XFLAGS)$deflist ".$d->{deps
}->[0]." -o \$\@",69)."\n";
1349 print $makefile_extra{'lcc'};
1355 select STDOUT
; close OUT
;
1358 if (defined $makefiles{'nestedvm'}) {
1359 $mftyp = 'nestedvm';
1360 $dirpfx = &dirpfx
($makefiles{'nestedvm'}, "/");
1362 ##-- NestedVM makefile
1363 open OUT
, ">$makefiles{'nestedvm'}"; select OUT
;
1365 "# Makefile for $project_name under NestedVM.\n".
1366 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1367 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1368 # gcc command line option is -D not /D
1369 ($_ = $help) =~ s/=\/D/=-D
/gs
;
1373 "# This path points at the nestedvm root directory\n".
1374 "NESTEDVM = /opt/nestedvm\n".
1375 "# You can define this path to point at your tools if you need to\n".
1376 "TOOLPATH = \$(NESTEDVM)/upstream/install/bin\n".
1377 "CC = \$(TOOLPATH)/mips-unknown-elf-gcc\n".
1379 &splitline
("CFLAGS = -O2 -Wall -Werror -DSLOW_SYSTEM -g " .
1380 (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
1382 print &splitline
("all:" . join "", map { " $_.jar" } &progrealnames
("X"));
1384 foreach $p (&prognames
("X")) {
1385 ($prog, $type) = split ",", $p;
1386 $objstr = &objects
($p, "X.o", undef, undef);
1387 $objstr =~ s/gtk\.o/nestedvm\.o/g;
1388 print &splitline
($prog . ".mips: " . $objstr), "\n";
1389 $libstr = &objects
($p, undef, undef, "-lX");
1390 print &splitline
("\t\$(CC) \$(${type}LDFLAGS) -o \$@ " .
1391 $objstr . " $libstr -lm", 69), "\n\n";
1393 foreach $d (&deps
("X.o", undef, $dirpfx, "/")) {
1395 $ddeps= join " ", @
{$d->{deps
}};
1396 $oobjs =~ s/gtk/nestedvm/g;
1397 $ddeps =~ s/gtk/nestedvm/g;
1398 print &splitline
(sprintf("%s: %s", $oobjs, $ddeps)),
1400 $deflist = join "", map { " -D$_" } @
{$d->{defs
}};
1401 print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist" .
1402 " -c \$< -o \$\@\n";
1405 print $makefile_extra{'nestedvm'};
1407 "\trm -rf *.o *.mips *.class *.html *.jar org applet.manifest\n";
1408 select STDOUT
; close OUT
;
1411 if (defined $makefiles{'osx'}) {
1413 $dirpfx = &dirpfx
($makefiles{'osx'}, "/");
1414 @osxarchs = ('ppc', 'i386');
1416 ##-- Mac OS X makefile
1417 open OUT
, ">$makefiles{'osx'}"; select OUT
;
1419 "# Makefile for $project_name under Mac OS X.\n".
1420 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1421 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1422 # gcc command line option is -D not /D
1423 ($_ = $help) =~ s/=\/D/=-D
/gs
;
1426 "CC = \$(TOOLPATH)gcc\n".
1427 "LIPO = \$(TOOLPATH)lipo\n".
1429 &splitline
("CFLAGS = -O2 -Wall -Werror -g " .
1430 (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
1431 "LDFLAGS = -framework Cocoa\n".
1432 &splitline
("all:" . join "", map { " $_" } &progrealnames
("MX:U")) .
1434 $makefile_extra{'osx'} .
1436 ".SUFFIXES: .o .c .m\n".
1439 foreach $p (&prognames
("MX")) {
1440 ($prog, $type) = split ",", $p;
1441 $icon = &special
($p, ".icns");
1442 $infoplist = &special
($p, "info.plist");
1443 print "${prog}.app:\n\tmkdir -p \$\@\n";
1444 print "${prog}.app/Contents: ${prog}.app\n\tmkdir -p \$\@\n";
1445 print "${prog}.app/Contents/MacOS: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1446 $targets = "${prog}.app/Contents/MacOS/$prog";
1447 if (defined $icon) {
1448 print "${prog}.app/Contents/Resources: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1449 print "${prog}.app/Contents/Resources/${prog}.icns: ${prog}.app/Contents/Resources $icon\n\tcp $icon \$\@\n";
1450 $targets .= " ${prog}.app/Contents/Resources/${prog}.icns";
1452 if (defined $infoplist) {
1453 print "${prog}.app/Contents/Info.plist: ${prog}.app/Contents/Resources $infoplist\n\tcp $infoplist \$\@\n";
1454 $targets .= " ${prog}.app/Contents/Info.plist";
1456 $targets .= " \$(${prog}_extra)";
1457 print &splitline
("${prog}: $targets", 69) . "\n\n";
1458 $libstr = &objects
($p, undef, undef, "-lX");
1460 foreach $arch (@osxarchs) {
1461 $objstr = &objects
($p, "X.${arch}.o", undef, undef);
1462 print &splitline
("${prog}.${arch}.bin: " . $objstr), "\n";
1463 print &splitline
("\t\$(CC) -arch ${arch} -mmacosx-version-min=10.3 \$(LDFLAGS) -o \$@ " .
1464 $objstr . " $libstr", 69), "\n\n";
1465 $archbins .= " ${prog}.${arch}.bin";
1467 print &splitline
("${prog}.app/Contents/MacOS/$prog: ".
1468 "${prog}.app/Contents/MacOS" . $archbins), "\n";
1469 print &splitline
("\t\$(LIPO) -create $archbins -output \$@", 69), "\n\n";
1471 foreach $p (&prognames
("U")) {
1472 ($prog, $type) = split ",", $p;
1473 $libstr = &objects
($p, undef, undef, "-lX");
1475 foreach $arch (@osxarchs) {
1476 $objstr = &objects
($p, "X.${arch}.o", undef, undef);
1477 print &splitline
("${prog}.${arch}: " . $objstr), "\n";
1478 print &splitline
("\t\$(CC) -arch ${arch} -mmacosx-version-min=10.3 \$(ULDFLAGS) -o \$@ " .
1479 $objstr . " $libstr", 69), "\n\n";
1480 $archbins .= " ${prog}.${arch}";
1482 print &splitline
("${prog}:" . $archbins), "\n";
1483 print &splitline
("\t\$(LIPO) -create $archbins -output \$@", 69), "\n\n";
1485 foreach $arch (@osxarchs) {
1486 foreach $d (&deps
("X.${arch}.o", undef, $dirpfx, "/")) {
1487 print &splitline
(sprintf("%s: %s", $d->{obj
}, join " ", @
{$d->{deps
}})),
1489 $deflist = join "", map { " -D$_" } @
{$d->{defs
}};
1490 if ($d->{deps
}->[0] =~ /\.m$/) {
1491 print "\t\$(CC) -arch $arch -mmacosx-version-min=10.3 -x objective-c \$(COMPAT) \$(FWHACK) \$(CFLAGS)".
1492 " \$(XFLAGS)$deflist -c \$< -o \$\@\n";
1494 print "\t\$(CC) -arch $arch -mmacosx-version-min=10.3 \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist" .
1495 " -c \$< -o \$\@\n";
1500 "\trm -f *.o *.dmg". (join "", map { my $a=$_; (" $a", map { " ${a}.$_" } @osxarchs) } &progrealnames
("U")) . "\n".
1502 select STDOUT
; close OUT
;