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 if ($ARGV[0] eq "-U") {
27 # Convenience for Unix users: -U means that after we finish what
28 # we're doing here, we also run mkauto.sh and then 'configure'. So
29 # it's a one-stop shop for regenerating the actual end-product
32 # Arguments supplied after -U go to configure.
38 die "unrecognised command-line argument '$ARGV[0]'\n";
44 open $in, "Recipe" or do {
45 # We want to deal correctly with being run from one of the
46 # subdirs in the source tree. So if we can't find Recipe here,
49 open $in, "Recipe" or die "unable to open Recipe file\n";
53 # HACK: One of the source files in `charset' is auto-generated by
54 # sbcsgen.pl. We need to generate that _now_, before attempting
55 # dependency analysis.
56 eval 'chdir "charset"; require "sbcsgen.pl"; chdir ".."';
60 $divert = undef; # ref to array of refs of scalars in which text is
62 $help = ""; # list of newline-free lines of help text
63 $project_name = "project"; # this is a good enough default
64 %makefiles = (); # maps makefile types to output makefile pathnames
65 %makefile_extra = (); # maps makefile types to extra Makefile text
66 %programs = (); # maps prog name + type letter to listref of objects/resources
67 %groups = (); # maps group name to listref of objects/resources
69 @allobjs = (); # all object file names
71 readinput: while (1) {
72 $in = $filestack[$#filestack];
73 while (not defined ($_ = <$in>)) {
74 close $filestack[$#filestack];
76 last readinput if 0 == scalar @filestack;
77 $in = $filestack[$#filestack];
82 # If we're gathering help text, keep doing so.
83 if (defined $divert) {
84 if ((defined $_[0]) && $_[0] eq "!end") {
87 for my $ref (@$divert) {
93 # Skip comments and blank lines.
94 next if /^\s*#/ or scalar @_ == 0;
96 if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = [\$help]; next; }
97 if ($_[0] eq "!name") { $project_name = $_[1]; next; }
98 if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; }
99 if ($_[0] eq "!makefile" and &mfval($_[1])) { $makefiles{$_[1]}=$_[2]; next;}
100 if ($_[0] eq "!specialobj" and &mfval($_[1])) { $specialobj{$_[1]}->{$_[2]} = 1; next;}
101 if ($_[0] eq "!cflags" and &mfval($_[1])) {
102 ($rest = $_) =~ s/^\s*\S+\s+\S+\s+\S+\s*//; # find rest of input line
103 $rest = 1 if $rest eq "";
104 $cflags{$_[1]}->{$_[2]} = $rest;
107 if ($_[0] eq "!begin") {
111 for my $component (@args) {
112 if ($component =~ /^>(.*)/) {
113 push @$divert, \$auxfiles{$1};
114 } elsif ($component =~ /^([^_]*)(_.*)?$/ and &mfval($1)) {
115 push @$divert, \$makefile_extra{$component};
120 if ($_[0] eq "!include") {
122 for ($i = 1; $i <= $#_; $i++) {
123 push @newfiles, (sort glob $_[$i]);
125 for ($i = $#newfiles; $i >= 0; $i--) {
126 $file = $newfiles[$i];
128 open $f, "<$file" or die "unable to open include file '$file'\n";
134 # Now we have an ordinary line. See if it's an = line, a : line
139 $listref = $lastlistref;
141 die "$.: unexpected + line\n" if !defined $lastlistref;
142 } elsif ($_[1] eq "=") {
144 $listref = $groups{$_[0]};
146 shift @objs; # eat the group name
147 } elsif ($_[1] eq "+=") {
148 $groups{$_[0]} = [] if !defined $groups{$_[0]};
149 $listref = $groups{$_[0]};
151 shift @objs; # eat the group name
152 } elsif ($_[1] eq ":") {
155 shift @objs; # eat the program name
157 die "$.: unrecognised line type: '$_'\n";
159 shift @objs; # eat the +, the = or the :
161 while (scalar @objs > 0) {
164 foreach $j (@{$groups{$i}}) { unshift @objs, $j; }
165 } elsif (($i eq "[G]" or $i eq "[C]" or $i eq "[M]" or
166 $i eq "[X]" or $i eq "[U]" or $i eq "[MX]") and defined $prog) {
167 $type = substr($i,1,(length $i)-2);
170 # Object files with a trailing question mark are optional:
171 # the build can proceed fine without them, so we only use
172 # them if their primary source files are present.
174 $i = undef unless defined &finddep($i);
175 } elsif ($i =~ /\|/) {
176 # Object file descriptions containing a vertical bar are
177 # lists of choices: we use the _first_ one whose primary
178 # source file is present.
179 @options = split /\|/, $i;
181 foreach $k (@options) {
182 $j=$k, last if defined &finddep($k);
184 die "no alternative found for $i\n" unless defined $j;
193 if ($prog and $type) {
194 die "multiple program entries for $prog [$type]\n"
195 if defined $programs{$prog . "," . $type};
196 $programs{$prog . "," . $type} = $listref;
198 $lastlistref = $listref;
201 foreach $aux (sort keys %auxfiles) {
203 print AUX $auxfiles{$aux};
207 # Find object file names with predefines (in square brackets after
208 # the module name), and decide on actual object names for them.
209 foreach $i (@allobjs) {
213 $usedobjname{$i} = 1;
216 foreach $i (@allobjs) {
217 if ($i =~ /^(.*)\[([^\]]*)/) {
218 $defs{$i} = [ split ",",$2 ];
219 $srcname{$i} = $s = $1;
223 $maxlen = 8 if $maxlen < 8;
224 $chop = $maxlen - length $index;
225 $chop = length $s if $chop > length $s;
226 $chop = 0 if $chop < 0;
227 $name = substr($s, 0, $chop) . $index;
228 $index++, next if $usedobjname{$name};
229 $objname{$i} = $name;
230 $usedobjname{$name} = 1;
236 # Now retrieve the complete list of objects and resource files, and
237 # construct dependency data for them. While we're here, expand the
238 # object list for each program, and complain if its type isn't set.
239 @prognames = sort keys %programs;
242 foreach $i (@prognames) {
243 ($prog, $type) = split ",", $i;
244 # Strip duplicate object names.
246 @list = grep { $status = ($prev ne $_); $prev=$_; $status }
247 sort @{$programs{$i}};
248 $programs{$i} = [@list];
249 foreach $jj (@list) {
251 $file = &finddep($j);
253 $depends{$jj} = [$file];
254 push @scanlist, $file;
259 # Scan each file on @scanlist and find further inclusions.
260 # Inclusions are given by lines of the form `#include "otherfile"'
261 # (system headers are automatically ignored by this because they'll
262 # be given in angle brackets). Files included by this method are
263 # added back on to @scanlist to be scanned in turn (if not already
266 # Resource scripts (.rc) can also include a file by means of a line
267 # ending `ICON "filename"'. Files included by this method are not
268 # added to @scanlist because they can never include further files.
270 # In this pass we write out a hash %further which maps a source
271 # file name into a listref containing further source file names.
274 while (scalar @scanlist > 0) {
275 $file = shift @scanlist;
276 next if defined $further{$file}; # skip if we've already done it
277 $further{$file} = [];
278 $dirfile = &findfile($file);
279 open IN, "$dirfile" or die "unable to open source file $file\n";
282 /^\s*#include\s+\"([^\"]+)\"/ and do {
283 push @{$further{$file}}, $1;
287 /ICON\s+\"([^\"]+)\"\s*$/ and do {
288 push @{$further{$file}}, $1;
295 # Now we're ready to generate the final dependencies section. For
296 # each key in %depends, we must expand the dependencies list by
297 # iteratively adding entries from %further.
298 foreach $i (keys %depends) {
300 @scanlist = @{$depends{$i}};
301 foreach $i (@scanlist) { $dep{$i} = 1; }
302 while (scalar @scanlist > 0) {
303 $file = shift @scanlist;
304 foreach $j (@{$further{$file}}) {
307 push @{$depends{$i}}, $j;
312 # printf "%s: %s\n", $i, join ' ',@{$depends{$i}};
315 # Validation of input.
319 # Returns true if the argument is a known makefile type. Otherwise,
320 # prints a warning and returns false;
321 if (grep { $type eq $_ }
322 ("vc","vcproj","cygwin","borland","lcc","gtk","am","mpw","nestedvm","osx","wce","gnustep","emcc","clangcl")) {
325 warn "$.:unknown makefile type '$type'\n";
329 # Utility routines while writing out the Makefiles.
332 my ($path) = shift @_;
333 my ($sep) = shift @_;
336 while (($i = index $path, $sep) >= 0) {
337 $path = substr $path, ($i + length $sep);
348 unless (defined $findfilecache{$name}) {
350 foreach $dir (@srcdirs) {
351 $outdir = $dir, $i++ if -f "$dir$name";
353 die "multiple instances of source file $name\n" if $i > 1;
354 $findfilecache{$name} = (defined $outdir ? $outdir . $name : undef);
356 return $findfilecache{$name};
362 # Find the first dependency of an object.
364 # Dependencies for "x" start with "x.c" or "x.m" (depending on
366 # Dependencies for "x.res" start with "x.rc".
367 # Dependencies for "x.rsrc" start with "x.r".
368 # Both types of file are pushed on the list of files to scan.
369 # Libraries (.lib) don't have dependencies at all.
370 if ($j =~ /^(.*)\.res$/) {
372 } elsif ($j =~ /^(.*)\.rsrc$/) {
374 } elsif ($j !~ /\./) {
376 $file = "$j.m" unless &findfile($file);
378 # For everything else, we assume it's its own dependency.
381 $file = undef unless &findfile($file);
386 my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_;
389 ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ? $_ : "" } ($otmpl, $rtmpl, $ltmpl);
391 foreach $ii (@{$programs{$prog}}) {
394 if ($i =~ /^(.*)\.(res|rsrc)/) {
396 ($x = $rtmpl) =~ s/X/$y/;
397 } elsif ($i =~ /^(.*)\.lib/) {
399 ($x = $ltmpl) =~ s/X/$y/;
400 } elsif ($i !~ /\./) {
401 ($x = $otmpl) =~ s/X/$i/;
403 push @ret, $x if $x ne "";
405 return join " ", @ret;
409 my ($prog, $suffix) = @_;
413 foreach $ii (@{$programs{$prog}}) {
415 if (substr($i, (length $i) - (length $suffix)) eq $suffix) {
419 return join " ", @ret;
423 my ($line, $width, $splitchar) = @_;
426 $len = (defined $width ? $width : 76);
427 $splitchar = (defined $splitchar ? $splitchar : '\\');
428 while (length $line > $len) {
429 $line =~ /^(.{0,$len})\s(.*)$/ or $line =~ /^(.{$len,}?\s(.*)$/;
431 $result .= " ${splitchar}\n\t\t" if $2 ne '';
435 return $result . $line;
439 my ($otmpl, $rtmpl, $prefix, $dirsep, $depchar, $splitchar) = @_;
445 foreach $ii (sort keys %depends) {
447 next if $specialobj{$mftyp}->{$i};
448 if ($i =~ /^(.*)\.(res|rsrc)/) {
449 next if !defined $rtmpl;
451 ($x = $rtmpl) =~ s/X/$y/;
453 ($x = $otmpl) =~ s/X/$i/;
455 @deps = @{$depends{$ii}};
456 # Skip things which are their own dependency.
457 next if grep { $_ eq $i } @deps;
463 push @ret, {obj => $x, deps => [@deps], defs => $defs{$ii}};
470 my ($n, $prog, $type);
473 foreach $n (@prognames) {
474 ($prog, $type) = split ",", $n;
475 push @ret, $n if index(":$types:", ":$type:") >= 0;
482 my ($n, $prog, $type);
485 foreach $n (@prognames) {
486 ($prog, $type) = split ",", $n;
487 push @ret, $prog if index(":$types:", ":$type:") >= 0;
493 my ($types,$suffix) = @_;
495 # assume that all UNIX programs have a man page
496 if($suffix eq "1" && $types =~ /:X:/) {
497 return map("$_.1", &progrealnames($types));
504 # Now we're ready to output the actual Makefiles.
506 if (defined $makefiles{'clangcl'}) {
508 $dirpfx = &dirpfx($makefiles{'clangcl'}, "/");
510 ##-- Makefile for cross-compiling using clang-cl, lld-link, and
511 ## MinGW's windres for resource compilation.
513 # This makefile allows a complete Linux-based cross-compile, but
514 # using the real Visual Studio header files and libraries. In
515 # order to run it, you will need:
517 # - MinGW windres on your PATH.
518 # * On Ubuntu as of 16.04, you can apt-get install
519 # binutils-mingw-w64-x86-64 and binutils-mingw-w64-i686
520 # which will provide (respectively) 64- and 32-bit versions,
521 # under the names to which RCCMD is defined below.
522 # - clang-cl and lld-link on your PATH.
523 # * I built these from the up-to-date LLVM project trunk git
524 # repositories, as of 2017-02-05.
525 # - case-mashed copies of the Visual Studio include directories.
526 # * On a real VS installation, run vcvars32.bat and look at
527 # the resulting value of %INCLUDE%. Take a full copy of each
528 # of those directories, and inside the copy, for each
529 # include file that has an uppercase letter in its name,
530 # make a lowercased symlink to it. Additionally, one of the
531 # directories will contain files called driverspecs.h and
532 # specstrings.h, and those will need symlinks called
533 # DriverSpecs.h and SpecStrings.h.
534 # * Now, on Linux, define the environment variable INCLUDE to
535 # be a list, separated by *semicolons* (in the Windows
536 # style), of those directories, but before all of them you
537 # must also include lib/clang/5.0.0/include from the clang
538 # installation area (which contains in particular a
539 # clang-compatible stdarg.h overriding the Visual Studio
541 # - similarly case-mashed copies of the library directories.
542 # * Again, on a real VS installation, run vcvars32 or
543 # vcvarsx86_amd64 (as appropriate), look at %LIB%, make a
544 # copy of each directory, and provide symlinks within that
545 # directory so that all the files can be opened as
547 # * Then set LIB to be a semicolon-separated list of those
548 # directories (but you'll need to change which set of
549 # directories depending on whether you want to do a 32-bit
551 # - for a 64-bit build, set 'Platform=x64' in the environment as
552 # well, or else on the make command line.
553 # * This is a variable understood only by this makefile - none
554 # of the tools we invoke will know it - but it's consistent
555 # with the way the VS scripts like vcvarsx86_amd64.bat set
556 # things up, and since the environment has to change
557 # _anyway_ between 32- and 64-bit builds (different set of
558 # paths in $LIB) it's reasonable to have the choice of
559 # compilation target driven by another environment variable
560 # set in parallel with that one.
561 # - for older versions of the VS libraries you may also have to
562 # set EXTRA_console and/or EXTRA_windows to the name of an
563 # object file manually extracted from one of those libraries.
564 # * This is because old VS seems to manage its startup code by
565 # having libcmt.lib contain lots of *crt0.obj objects, one
566 # for each possible user entry point (main, WinMain and the
567 # wide-char versions of both), of which the linker arranges
568 # to include the right one by special-case code. But lld
569 # only seems to mimic half of that code - it does include
570 # the right crt0 object, but it doesn't also deliberately
571 # _avoid_ including the _wrong_ ones, and since all those
572 # objects define a common set of global symbols for other
573 # parts of the library to use, lld may well select an
574 # arbitrary one of them the first time it sees a reference
575 # to one of those global symbols, and then later also select
576 # the _right_ one for the application's entry point, causing
577 # a multiple-definitions crash.
578 # * So the workaround is to explicitly include the right
579 # *crt0.obj file on the linker command line before lld even
580 # begins searching libraries. Hence, for a console
581 # application, you might extract crt0.obj from the library
582 # in question and set EXTRA_console=crt0.obj, and for a GUI
583 # application, do the same with wincrt0.obj. Then this
584 # makefile will include the right one of those objects
585 # alongside the matching /subsystem linker option.
587 open OUT, ">$makefiles{'clangcl'}"; select OUT;
589 "# Makefile for cross-compiling $project_name using clang-cl, lld-link,\n".
590 "# and MinGW's windres, using GNU make on Linux.\n".
591 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
592 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
596 "CCCMD = clang-cl\n".
597 "ifeq (\$(Platform),x64)\n".
598 "CCTARGET = x86_64-pc-windows-msvc18.0.0\n".
599 "RCCMD = x86_64-w64-mingw32-windres\n".
601 "CCTARGET = i386-pc-windows-msvc18.0.0\n".
602 "RCCMD = i686-w64-mingw32-windres\n".
604 "CC = \$(CCCMD) --target=\$(CCTARGET)\n".
605 &splitline("RC = \$(RCCMD) --preprocessor=\$(CCCMD) ".
606 "--preprocessor-arg=/TC --preprocessor-arg=/E")."\n".
609 "# C compilation flags\n".
610 &splitline("CFLAGS = /nologo /W3 /O1 " .
611 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
612 " /D_WINDOWS /D_WIN32_WINDOWS=0x401 /DWINVER=0x401 ".
613 "/D_CRT_SECURE_NO_WARNINGS")."\n".
614 "LFLAGS = /incremental:no /dynamicbase /nxcompat\n".
615 &splitline("RCFLAGS = ".(join " ", map {"-I$dirpfx$_"} @srcdirs).
616 " -DWIN32 -D_WIN32 -DWINVER=0x0400 --define MINGW32_FIX=1")."\n".
619 print &splitline("all:" . join "", map { " \$(BUILDDIR)$_.exe" } &progrealnames("G:C"));
621 foreach $p (&prognames("G:C")) {
622 ($prog, $type) = split ",", $p;
623 $objstr = &objects($p, "\$(BUILDDIR)X.obj", "\$(BUILDDIR)X.res", undef);
624 print &splitline("\$(BUILDDIR)$prog.exe: " . $objstr), "\n";
626 $objstr = &objects($p, "\$(BUILDDIR)X.obj", "\$(BUILDDIR)X.res", "X.lib");
627 $subsys = ($type eq "G") ? "windows" : "console";
628 print &splitline("\t\$(LD) \$(LFLAGS) \$(XLFLAGS) ".
629 "/out:\$(BUILDDIR)$prog.exe ".
630 "/lldmap:\$(BUILDDIR)$prog.map ".
631 "/subsystem:$subsys\$(SUBSYSVER) ".
632 "\$(EXTRA_$subsys) $objstr")."\n\n";
634 foreach $d (&deps("\$(BUILDDIR)X.obj", "\$(BUILDDIR)X.res", $dirpfx, "/", "vc")) {
635 print &splitline(sprintf("%s: %s", $d->{obj},
636 join " ", @{$d->{deps}})), "\n";
637 if ($d->{obj} =~ /\.res$/) {
638 print "\t\$(RC) \$(RCFLAGS) ".$d->{deps}->[0]." -o ".$d->{obj}."\n\n";
640 $deflist = join "", map { " /D$_" } @{$d->{defs}};
641 print "\t\$(CC) /Fo\$(BUILDDIR)".$d->{obj}." \$(COMPAT) \$(CFLAGS) \$(XFLAGS)$deflist /c \$<\n\n";
645 &splitline("\trm -f \$(BUILDDIR)*.obj \$(BUILDDIR)*.exe ".
646 "\$(BUILDDIR)*.res \$(BUILDDIR)*.map ".
647 "\$(BUILDDIR)*.exe.manifest")."\n";
648 select STDOUT; close OUT;
651 if (defined $makefiles{'cygwin'}) {
653 $dirpfx = &dirpfx($makefiles{'cygwin'}, "/");
656 open OUT, ">$makefiles{'cygwin'}"; select OUT;
658 "# Makefile for $project_name under cygwin.\n".
659 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
660 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
661 # gcc command line option is -D not /D
662 ($_ = $help) =~ s/=\/D/=-D/gs;
666 "# You can define this path to point at your tools if you need to\n".
667 "# TOOLPATH = c:\\cygwin\\bin\\ # or similar, if you're running Windows\n".
668 "# TOOLPATH = /pkg/mingw32msvc/i386-mingw32msvc/bin/\n".
669 "CC = \$(TOOLPATH)gcc\n".
670 "RC = \$(TOOLPATH)windres\n".
671 "# Uncomment the following two lines to compile under Winelib\n".
674 "# You may also need to tell windres where to find include files:\n".
675 "# RCINC = --include-dir c:\\cygwin\\include\\\n".
677 &splitline("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
678 " -D_NO_OLDNAMES -DNO_MULTIMON -DNO_HTMLHELP " .
679 (join " ", map {"-I$dirpfx$_"} @srcdirs)) .
681 "LDFLAGS = -mno-cygwin -s\n".
682 &splitline("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1".
683 " --define WINVER=0x0400 --define MINGW32_FIX=1 " .
684 (join " ", map {"--include $dirpfx$_"} @srcdirs) )."\n".
686 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
688 foreach $p (&prognames("G:C")) {
689 ($prog, $type) = split ",", $p;
690 $objstr = &objects($p, "X.o", "X.res.o", undef);
691 print &splitline($prog . ".exe: " . $objstr), "\n";
692 my $mw = $type eq "G" ? " -mwindows" : "";
693 $libstr = &objects($p, undef, undef, "-lX");
694 print &splitline("\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " .
695 "-Wl,-Map,$prog.map " .
696 $objstr . " $libstr", 69), "\n\n";
698 foreach $d (&deps("X.o", "X.res.o", $dirpfx, "/")) {
699 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
701 if ($d->{obj} =~ /\.res\.o$/) {
702 print "\t\$(RC) \$(FWHACK) \$(RCFL) \$(RCFLAGS) \$< \$\@\n";
704 $deflist = join "", map { " -D$_" } @{$d->{defs}};
705 print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS)" .
706 " \$(XFLAGS)$deflist -c \$< -o \$\@\n";
710 print $makefile_extra{'cygwin'} || "";
712 "\trm -f *.o *.exe *.res.o *.map\n".
714 select STDOUT; close OUT;
718 ##-- Borland makefile
719 if (defined $makefiles{'borland'}) {
721 $dirpfx = &dirpfx($makefiles{'borland'}, "\\");
723 %stdlibs = ( # Borland provides many Win32 API libraries intrinsically
735 open OUT, ">$makefiles{'borland'}"; select OUT;
737 "# Makefile for $project_name under Borland C.\n".
738 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
739 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
740 # bcc32 command line option is -D not /D
741 ($_ = $help) =~ s/=\/D/=-D/gs;
745 "# If you rename this file to `Makefile', you should change this line,\n".
746 "# so that the .rsp files still depend on the correct makefile.\n".
747 "MAKEFILE = Makefile.bor\n".
749 "# C compilation flags\n".
750 "CFLAGS = -D_WINDOWS -DWINVER=0x0401\n".
752 "# Get include directory for resource compiler\n".
754 "BCB = \$(MAKEDIR)\\..\n".
757 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
759 foreach $p (&prognames("G:C")) {
760 ($prog, $type) = split ",", $p;
761 $objstr = &objects($p, "X.obj", "X.res", undef);
762 print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
763 my $ap = ($type eq "G") ? "-aa" : "-ap";
764 print "\tilink32 $ap -Gn -L\$(BCB)\\lib \@$prog.rsp\n\n";
766 foreach $p (&prognames("G:C")) {
767 ($prog, $type) = split ",", $p;
768 print $prog, ".rsp: \$(MAKEFILE)\n";
769 $objstr = &objects($p, "X.obj", undef, undef);
770 @objlist = split " ", $objstr;
772 foreach $i (@objlist) {
773 if (length($objlines[$#objlines] . " $i") > 50) {
776 $objlines[$#objlines] .= " $i";
778 $c0w = ($type eq "G") ? "c0w32" : "c0x32";
779 print "\techo $c0w + > $prog.rsp\n";
780 for ($i=0; $i<=$#objlines; $i++) {
781 $plus = ($i < $#objlines ? " +" : "");
782 print "\techo$objlines[$i]$plus >> $prog.rsp\n";
784 print "\techo $prog.exe >> $prog.rsp\n";
785 $objstr = &objects($p, "X.obj", "X.res", undef);
786 @libs = split " ", &objects($p, undef, undef, "X");
787 @libs = grep { !$stdlibs{$_} } @libs;
788 unshift @libs, "cw32", "import32";
789 $libstr = join ' ', @libs;
790 print "\techo nul,$libstr, >> $prog.rsp\n";
791 print "\techo " . &objects($p, undef, "X.res", undef) . " >> $prog.rsp\n";
794 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\")) {
795 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
797 if ($d->{obj} =~ /\.res$/) {
798 print &splitline("\tbrcc32 \$(FWHACK) \$(RCFL) " .
799 "-i \$(BCB)\\include -r -DNO_WINRESRC_H -DWIN32".
800 " -D_WIN32 -DWINVER=0x0401 \$*.rc",69)."\n";
802 $deflist = join "", map { " -D$_" } @{$d->{defs}};
803 print &splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT)" .
804 " \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist ".
805 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
806 " /o$d->{obj} /c ".$d->{deps}->[0],69)."\n";
810 print $makefile_extra{'borland'} || "";
821 "\t-del *.\$\$\$\$\$\$\n";
822 select STDOUT; close OUT;
825 if (defined $makefiles{'vc'}) {
827 $dirpfx = &dirpfx($makefiles{'vc'}, "\\");
829 ##-- Visual C++ makefile
830 open OUT, ">$makefiles{'vc'}"; select OUT;
832 "# Makefile for $project_name under Visual C.\n".
833 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
834 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
838 "# If you rename this file to `Makefile', you should change this line,\n".
839 "# so that the .rsp files still depend on the correct makefile.\n".
840 "MAKEFILE = Makefile.vc\n".
842 "# C compilation flags\n".
843 "CFLAGS = /nologo /W3 /O1 /D_WINDOWS /D_WIN32_WINDOWS=0x401 /DWINVER=0x401 /I.\n".
844 "LFLAGS = /incremental:no /fixed\n".
846 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
848 foreach $p (&prognames("G:C")) {
849 ($prog, $type) = split ",", $p;
850 $objstr = &objects($p, "X.obj", "X.res", undef);
851 print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
852 print "\tlink \$(LFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n";
854 foreach $p (&prognames("G:C")) {
855 ($prog, $type) = split ",", $p;
856 print $prog, ".rsp: \$(MAKEFILE)\n";
857 $objstr = &objects($p, "X.obj", "X.res", "X.lib");
858 @objlist = split " ", $objstr;
860 foreach $i (@objlist) {
861 if (length($objlines[$#objlines] . " $i") > 50) {
864 $objlines[$#objlines] .= " $i";
866 $subsys = ($type eq "G") ? "windows" : "console";
867 print "\techo /nologo /subsystem:$subsys > $prog.rsp\n";
868 for ($i=0; $i<=$#objlines; $i++) {
869 print "\techo$objlines[$i] >> $prog.rsp\n";
873 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\")) {
874 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
876 if ($d->{obj} =~ /\.res$/) {
877 print "\trc \$(FWHACK) \$(RCFL) -r -DWIN32 -D_WIN32 ".
878 "-DWINVER=0x0400 -fo".$d->{obj}." ".$d->{deps}->[0]."\n";
880 $deflist = join "", map { " /D$_" } @{$d->{defs}};
881 print "\tcl \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist".
882 " /c ".$d->{deps}->[0]." /Fo$d->{obj}\n";
886 print $makefile_extra{'vc'} || "";
887 print "\nclean: tidy\n".
904 "\t-del debug.log\n";
905 select STDOUT; close OUT;
908 if (defined $makefiles{'wce'}) {
910 $dirpfx = &dirpfx($makefiles{'wce'}, "\\");
912 ##-- eMbedded Visual C PocketPC makefile
913 open OUT, ">$makefiles{'wce'}"; select OUT;
915 "# Makefile for $project_name on PocketPC using eMbedded Visual C.\n".
916 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
917 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
921 "# If you rename this file to `Makefile', you should change this line,\n".
922 "# so that the .rsp files still depend on the correct makefile.\n".
923 "MAKEFILE = Makefile.wce\n".
925 "# This makefile expects the environment to have been set up by one\n".
926 "# of the PocketPC batch files wcearmv4.bat and wceemulator.bat. No\n".
927 "# other build targets are currently supported, because they would\n".
928 "# need a section in this if statement.\n".
929 "!if \"\$(TARGETCPU)\" == \"emulator\"\n".
930 "PLATFORM_DEFS=/D \"_i386_\" /D \"i_386_\" /D \"_X86_\" /D \"x86\"\n".
932 "BASELIBS=commctrl.lib coredll.lib corelibc.lib aygshell.lib\n".
935 "PLATFORM_DEFS=/D \"ARM\" /D \"_ARM_\" /D \"ARMV4\"\n".
937 "BASELIBS=commctrl.lib coredll.lib aygshell.lib\n".
941 "# C compilation flags\n".
942 "CFLAGS = /nologo /W3 /O1 /MC /D _WIN32_WCE=420 /D \"WIN32_PLATFORM_PSPC=400\" /D UNDER_CE=420 \\\n".
943 " \$(PLATFORM_DEFS) \\\n".
944 " /D \"UNICODE\" /D \"_UNICODE\" /D \"NDEBUG\" /D \"NO_HTMLHELP\"\n".
946 "LFLAGS = /nologo /incremental:no \\\n".
947 " /base:0x00010000 /stack:0x10000,0x1000 /entry:WinMainCRTStartup \\\n".
948 " /nodefaultlib:libc.lib /nodefaultlib:libcmt.lib /nodefaultlib:msvcrt.lib /nodefaultlib:OLDNAMES.lib \\\n".
949 " /subsystem:windowsce,4.20 /align:4096 /MACHINE:\$(MACHINE)\n".
951 "RCFL = /d UNDER_CE=420 /d _WIN32_WCE=420 /d \"WIN32_PLATFORM_PSPC=400\" \\\n".
952 " \$(PLATFORM_DEFS) \\\n".
953 " /d \"NDEBUG\" /d \"UNICODE\" /d \"_UNICODE\"\n".
955 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G"));
957 foreach $p (&prognames("G")) {
958 ($prog, $type) = split ",", $p;
959 $objstr = &objects($p, "X.obj", "X.res", undef);
960 print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
961 print "\tlink \$(LFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n";
963 foreach $p (&prognames("G")) {
964 ($prog, $type) = split ",", $p;
965 print $prog, ".rsp: \$(MAKEFILE)\n";
966 $objstr = &objects($p, "X.obj", "X.res", undef);
967 @objlist = split " ", $objstr;
969 foreach $i (@objlist) {
970 if (length($objlines[$#objlines] . " $i") > 50) {
973 $objlines[$#objlines] .= " $i";
975 print "\techo \$(BASELIBS) > $prog.rsp\n";
976 for ($i=0; $i<=$#objlines; $i++) {
977 print "\techo$objlines[$i] >> $prog.rsp\n";
981 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\")) {
982 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
984 if ($d->{obj} =~ /\.res$/) {
985 print "\trc \$(FWHACK) \$(RCFL) -r -fo".
986 $d->{obj}." ".$d->{deps}->[0]."\n";
988 $deflist = join "", map { " /D$_" } @{$d->{defs}};
989 print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist".
990 " /c ".$d->{deps}->[0]." /Fo$d->{obj}\n";
994 print $makefile_extra{'wce'} || "";
995 print "\nclean: tidy\n".
1012 "\t-del debug.log\n";
1013 select STDOUT; close OUT;
1016 if (defined $makefiles{'vcproj'}) {
1019 ##-- MSVC 6 Workspace and projects
1021 # Note: All files created in this section are written in binary
1022 # mode, because although MSVC's command-line make can deal with
1023 # LF-only line endings, MSVC project files really _need_ to be
1024 # CRLF. Hence, in order for mkfiles.pl to generate usable project
1025 # files even when run from Unix, I make sure all files are binary
1026 # and explicitly write the CRLFs.
1028 # Create directories if necessary
1029 mkdir $makefiles{'vcproj'}
1030 if(! -d $makefiles{'vcproj'});
1031 chdir $makefiles{'vcproj'};
1032 @deps = &deps("X.obj", "X.res", "", "\\");
1033 %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;
1034 # Create the project files
1035 # Get names of all Windows projects (GUI and console)
1036 my @prognames = &prognames("G:C");
1037 foreach $progname (@prognames) {
1038 create_project(\%all_object_deps, $progname);
1040 # Create the workspace file
1041 open OUT, ">$project_name.dsw"; binmode OUT; select OUT;
1043 "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n".
1044 "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n".
1046 "###############################################################################\r\n".
1049 foreach $progname (@prognames) {
1050 ($windows_project, $type) = split ",", $progname;
1051 print "Project: \"$windows_project\"=\".\\$windows_project\\$windows_project.dsp\" - Package Owner=<4>\r\n";
1063 "###############################################################################\r\n".
1075 "###############################################################################\r\n".
1077 select STDOUT; close OUT;
1080 sub create_project {
1081 my ($all_object_deps, $progname) = @_;
1082 # Construct program's dependency info
1087 %resource_files = ();
1088 @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");
1089 foreach $object_file (@object_files) {
1090 next if defined $seen_objects{$object_file};
1091 $seen_objects{$object_file} = 1;
1092 if($object_file =~ /\.lib$/io) {
1093 $lib_files{$object_file} = 1;
1096 $object_deps = $all_object_deps{$object_file};
1097 foreach $object_dep (@$object_deps) {
1098 if($object_dep =~ /\.c$/io) {
1099 $source_files{$object_dep} = 1;
1102 if($object_dep =~ /\.h$/io) {
1103 $header_files{$object_dep} = 1;
1106 if($object_dep =~ /\.(rc|ico)$/io) {
1107 $resource_files{$object_dep} = 1;
1112 $libs = join " ", sort keys %lib_files;
1113 @source_files = sort keys %source_files;
1114 @header_files = sort keys %header_files;
1115 @resources = sort keys %resource_files;
1116 ($windows_project, $type) = split ",", $progname;
1117 mkdir $windows_project
1118 if(! -d $windows_project);
1119 chdir $windows_project;
1120 $subsys = ($type eq "G") ? "windows" : "console";
1121 open OUT, ">$windows_project.dsp"; binmode OUT; select OUT;
1123 "# Microsoft Developer Studio Project File - Name=\"$windows_project\" - Package Owner=<4>\r\n".
1124 "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n".
1125 "# ** DO NOT EDIT **\r\n".
1127 "# TARGTYPE \"Win32 (x86) Application\" 0x0101\r\n".
1129 "CFG=$windows_project - Win32 Debug\r\n".
1130 "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n".
1131 "!MESSAGE use the Export Makefile command and run\r\n".
1133 "!MESSAGE NMAKE /f \"$windows_project.mak\".\r\n".
1135 "!MESSAGE You can specify a configuration when running NMAKE\r\n".
1136 "!MESSAGE by defining the macro CFG on the command line. For example:\r\n".
1138 "!MESSAGE NMAKE /f \"$windows_project.mak\" CFG=\"$windows_project - Win32 Debug\"\r\n".
1140 "!MESSAGE Possible choices for configuration are:\r\n".
1142 "!MESSAGE \"$windows_project - Win32 Release\" (based on \"Win32 (x86) Application\")\r\n".
1143 "!MESSAGE \"$windows_project - Win32 Debug\" (based on \"Win32 (x86) Application\")\r\n".
1146 "# Begin Project\r\n".
1147 "# PROP AllowPerConfigDependencies 0\r\n".
1148 "# PROP Scc_ProjName \"\"\r\n".
1149 "# PROP Scc_LocalPath \"\"\r\n".
1154 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
1156 "# PROP BASE Use_MFC 0\r\n".
1157 "# PROP BASE Use_Debug_Libraries 0\r\n".
1158 "# PROP BASE Output_Dir \"Release\"\r\n".
1159 "# PROP BASE Intermediate_Dir \"Release\"\r\n".
1160 "# PROP BASE Target_Dir \"\"\r\n".
1161 "# PROP Use_MFC 0\r\n".
1162 "# PROP Use_Debug_Libraries 0\r\n".
1163 "# PROP Output_Dir \"Release\"\r\n".
1164 "# PROP Intermediate_Dir \"Release\"\r\n".
1165 "# PROP Ignore_Export_Lib 0\r\n".
1166 "# PROP Target_Dir \"\"\r\n".
1167 "# ADD BASE CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
1168 "# ADD CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
1169 "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
1170 "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
1171 "# ADD BASE RSC /l 0x809 /d \"NDEBUG\"\r\n".
1172 "# ADD RSC /l 0x809 /d \"NDEBUG\"\r\n".
1173 "BSC32=bscmake.exe\r\n".
1174 "# ADD BASE BSC32 /nologo\r\n".
1175 "# ADD BSC32 /nologo\r\n".
1176 "LINK32=link.exe\r\n".
1177 "# 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".
1178 "# ADD LINK32 $libs /nologo /subsystem:$subsys /machine:I386\r\n".
1179 "# SUBTRACT LINK32 /pdb:none\r\n".
1181 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
1183 "# PROP BASE Use_MFC 0\r\n".
1184 "# PROP BASE Use_Debug_Libraries 1\r\n".
1185 "# PROP BASE Output_Dir \"Debug\"\r\n".
1186 "# PROP BASE Intermediate_Dir \"Debug\"\r\n".
1187 "# PROP BASE Target_Dir \"\"\r\n".
1188 "# PROP Use_MFC 0\r\n".
1189 "# PROP Use_Debug_Libraries 1\r\n".
1190 "# PROP Output_Dir \"Debug\"\r\n".
1191 "# PROP Intermediate_Dir \"Debug\"\r\n".
1192 "# PROP Ignore_Export_Lib 0\r\n".
1193 "# PROP Target_Dir \"\"\r\n".
1194 "# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
1195 "# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
1196 "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
1197 "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
1198 "# ADD BASE RSC /l 0x809 /d \"_DEBUG\"\r\n".
1199 "# ADD RSC /l 0x809 /d \"_DEBUG\"\r\n".
1200 "BSC32=bscmake.exe\r\n".
1201 "# ADD BASE BSC32 /nologo\r\n".
1202 "# ADD BSC32 /nologo\r\n".
1203 "LINK32=link.exe\r\n".
1204 "# 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".
1205 "# ADD LINK32 $libs /nologo /subsystem:$subsys /debug /machine:I386 /pdbtype:sept\r\n".
1206 "# SUBTRACT LINK32 /pdb:none\r\n".
1210 "# Begin Target\r\n".
1212 "# Name \"$windows_project - Win32 Release\"\r\n".
1213 "# Name \"$windows_project - Win32 Debug\"\r\n".
1214 "# Begin Group \"Source Files\"\r\n".
1216 "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
1217 foreach $source_file (@source_files) {
1219 "# Begin Source File\r\n".
1221 "SOURCE=..\\..\\$source_file\r\n";
1222 if($source_file =~ /ssh\.c/io) {
1223 # Disable 'Edit and continue' as Visual Studio can't handle the macros
1226 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
1228 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
1230 "# ADD CPP /Zi\r\n".
1235 print "# End Source File\r\n";
1239 "# Begin Group \"Header Files\"\r\n".
1241 "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
1242 foreach $header_file (@header_files) {
1244 "# Begin Source File\r\n".
1246 "SOURCE=..\\..\\$header_file\r\n".
1247 "# End Source File\r\n";
1251 "# Begin Group \"Resource Files\"\r\n".
1253 "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
1254 foreach $resource_file (@resources) {
1256 "# Begin Source File\r\n".
1258 "SOURCE=..\\..\\$resource_file\r\n".
1259 "# End Source File\r\n";
1264 "# End Project\r\n";
1265 select STDOUT; close OUT;
1270 if (defined $makefiles{'gtk'}) {
1272 $dirpfx = &dirpfx($makefiles{'gtk'}, "/");
1274 ##-- X/GTK/Unix makefile
1275 open OUT, ">$makefiles{'gtk'}"; select OUT;
1277 "# Makefile for $project_name under X/GTK and Unix.\n".
1278 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1279 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1280 # gcc command line option is -D not /D
1281 ($_ = $help) =~ s/=\/D/=-D/gs;
1285 "# You can define this path to point at your tools if you need to\n".
1286 "# TOOLPATH = /opt/gcc/bin\n".
1287 "CC := \$(TOOLPATH)\$(CC)\n".
1288 "# You can manually set this to `gtk-config' or `pkg-config gtk+-1.2'\n".
1289 "# (depending on what works on your system) if you want to enforce\n".
1290 "# building with GTK 1.2, or you can set it to `pkg-config gtk+-2.0'\n".
1291 "# if you want to enforce 2.0. The default is to try 2.0 and fall back\n".
1292 "# to 1.2 if it isn't found.\n".
1293 "GTK_CONFIG = sh -c 'pkg-config gtk+-2.0 \$\$0 2>/dev/null || gtk-config \$\$0'\n".
1295 &splitline("CFLAGS := -O2 -Wall -Werror -ansi -pedantic -g " .
1296 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
1297 " `\$(GTK_CONFIG) --cflags` \$(CFLAGS)")."\n".
1298 "XLIBS = `\$(GTK_CONFIG) --libs` -lm\n".
1300 "INSTALL=install\n",
1301 "INSTALL_PROGRAM=\$(INSTALL)\n",
1302 "INSTALL_DATA=\$(INSTALL)\n",
1303 "prefix=/usr/local\n",
1304 "exec_prefix=\$(prefix)\n",
1305 "bindir=\$(exec_prefix)/bin\n",
1306 "gamesdir=\$(exec_prefix)/games\n",
1307 "mandir=\$(prefix)/man\n",
1308 "man1dir=\$(mandir)/man1\n",
1310 print &splitline("all:" . join "", map { " \$(BINPREFIX)$_" }
1311 &progrealnames("X:U"));
1313 foreach $p (&prognames("X:U")) {
1314 ($prog, $type) = split ",", $p;
1315 $objstr = &objects($p, "X.o", undef, undef);
1316 print &splitline("\$(BINPREFIX)" . $prog . ": " . $objstr), "\n";
1317 $libstr = &objects($p, undef, undef, "-lX");
1318 print &splitline("\t\$(CC) -o \$@ $objstr $libstr \$(XLFLAGS) \$(${type}LIBS)", 69),
1321 foreach $d (&deps("X.o", undef, $dirpfx, "/")) {
1322 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
1324 $deflist = join "", map { " -D$_" } @{$d->{defs}};
1325 print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist" .
1326 " -c \$< -o \$\@\n";
1329 print $makefile_extra{'gtk'} || "";
1331 "\trm -f *.o". (join "", map { " \$(BINPREFIX)$_" } &progrealnames("X:U")) . "\n";
1332 select STDOUT; close OUT;
1335 if (defined $makefiles{'am'}) {
1337 die "Makefile.am in a subdirectory is not supported\n"
1338 if &dirpfx($makefiles{'am'}, "/") ne "";
1340 ##-- Unix/autoconf Makefile.am
1341 open OUT, ">$makefiles{'am'}"; select OUT;
1343 "# Makefile.am for $project_name under Unix with Autoconf/Automake.\n".
1344 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1345 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n\n";
1347 print $makefile_extra{'am_begin'} || "";
1349 # All programs go in noinstprogs by default. If you want them
1350 # installed anywhere else, you have to also add them to
1351 # bin_PROGRAMS using '!begin am'. (Automake doesn't seem to mind
1352 # having a program name in _both_ of bin_PROGRAMS and
1355 foreach $p (&prognames("X:U")) {
1356 ($prog, $type) = split ",", $p;
1357 push @noinstprogs, $prog;
1359 print &splitline(join " ", "noinst_PROGRAMS", "=", @noinstprogs), "\n";
1362 %amspeciallibs = ();
1365 foreach $d (&deps("X", undef, "", "/", "am")) {
1366 my $obj = $d->{obj};
1367 my $use_archive = 0;
1369 if (defined $d->{defs}) {
1370 # This file needs to go in an archive, so that we can
1371 # change the preprocess flags to include some -Ds
1373 $archivecppflags{$obj} = [map { " -D$_" } @{$d->{defs}}];
1375 if (defined $cflags{'am'} && $cflags{'am'}->{$obj}) {
1376 # This file needs to go in an archive, so that we can
1377 # change the compile flags as specified in Recipe
1379 $archivecflags{$obj} = [$cflags{'am'}->{$obj}];
1382 $amspeciallibs{$obj} = "lib${obj}.a";
1383 $amlibobjname{$obj} = "lib${obj}_a-" .
1384 basename($d->{deps}->[0], ".c", ".m") .
1387 $objtosrc{$obj} = $d->{deps};
1388 map { $allsources{$_} = 1 } @{$d->{deps}};
1391 # 2014-02-22: as of automake-1.14 we begin to get complained at if
1392 # we don't use this option
1393 print "AUTOMAKE_OPTIONS = subdir-objects\n\n";
1395 # Complete list of source and header files. Not used by the
1396 # auto-generated parts of this makefile, but Recipe might like to
1397 # have it available as a variable so that mandatory-rebuild things
1398 # (version.o) can conveniently be made to depend on it.
1399 print &splitline(join " ", "allsources", "=",
1400 sort {$a cmp $b} keys %allsources), "\n\n";
1402 @amcppflags = map {"-I\$(srcdir)/$_"} @srcdirs;
1403 print &splitline(join " ", "AM_CPPFLAGS", "=", @amcppflags, "\n");
1405 @amcflags = ("\$(GTK_CFLAGS)", "\$(WARNINGOPTS)");
1406 print &splitline(join " ", "AM_CFLAGS", "=", @amcflags), "\n";
1409 foreach $p (&prognames("X:U")) {
1410 ($prog, $type) = split ",", $p;
1411 @progsources = ("${prog}_SOURCES", "=");
1414 $objstr = &objects($p, "X", undef, undef);
1415 foreach $obj (split / /,$objstr) {
1416 if ($amspeciallibs{$obj}) {
1417 $amlibsused{$obj} = 1;
1418 push @ldadd, $amlibobjname{$obj};
1420 map { $sourcefiles{$_} = 1 } @{$objtosrc{$obj}};
1423 push @progsources, sort { $a cmp $b } keys %sourcefiles;
1424 print &splitline(join " ", @progsources), "\n";
1426 push @ldadd, "\$(GTK_LIBS)";
1429 print &splitline(join " ", "${prog}_LDADD", "=", @ldadd), "\n";
1433 foreach $obj (sort { $a cmp $b } keys %amlibsused) {
1434 print &splitline(join " ", "lib${obj}_a_SOURCES", "=",
1435 @{$objtosrc{$obj}}), "\n";
1436 print &splitline(join " ", "lib${obj}_a_CPPFLAGS", "=",
1437 @amcflags, @{$archivecppflags{$obj}}), "\n"
1438 if $archivecppflags{$obj};
1439 print &splitline(join " ", "lib${obj}_a_CFLAGS", "=",
1440 @amcflags, @{$archivecflags{$obj}}), "\n"
1441 if $archivecflags{$obj};
1443 print &splitline(join " ", "noinst_LIBRARIES", "=",
1445 map { $amspeciallibs{$_} }
1449 print $makefile_extra{'am'} || "";
1450 select STDOUT; close OUT;
1453 if (defined $makefiles{'mpw'}) {
1456 open OUT, ">$makefiles{'mpw'}"; select OUT;
1458 "# Makefile for $project_name under MPW.\n#\n".
1459 "# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1460 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1461 # MPW command line option is -d not /D
1462 ($_ = $help) =~ s/=\/D/=-d /gs;
1465 "ROptions = `Echo \"{VER}\" | StreamEdit -e \"1,\$ replace /=(\xc5)\xa81\xb0/ 'STR=\xb6\xb6\xb6\xb6\xb6\"' \xa81 '\xb6\xb6\xb6\xb6\xb6\"'\"`".
1470 "C_Carbon = {PPCC}\n".
1472 "# -w 35 disables \"unused parameter\" warnings\n".
1473 "COptions = -i : -i :: -i ::charset -w 35 -w err -proto strict -ansi on \xb6\n".
1475 "COptions_68K = {COptions} -model far -opt time\n".
1476 "# Enabling \"-opt space\" for CFM-68K gives me undefined references to\n".
1477 "# _\$LDIVT and _\$LMODT.\n".
1478 "COptions_CFM68K = {COptions} -model cfmSeg -opt time\n".
1479 "COptions_PPC = {COptions} -opt size -traceback\n".
1480 "COptions_Carbon = {COptions} -opt size -traceback -d TARGET_API_MAC_CARBON\n".
1482 "Link_68K = ILink\n".
1483 "Link_CFM68K = ILink\n".
1484 "Link_PPC = PPCLink\n".
1485 "Link_Carbon = PPCLink\n".
1487 "LinkOptions = -c 'pTTY'\n".
1488 "LinkOptions_68K = {LinkOptions} -br 68k -model far -compact\n".
1489 "LinkOptions_CFM68K = {LinkOptions} -br 020 -model cfmseg -compact\n".
1490 "LinkOptions_PPC = {LinkOptions}\n".
1491 "LinkOptions_Carbon = -m __appstart -w {LinkOptions}\n".
1493 "Libs_68K = \"{CLibraries}StdCLib.far.o\" \xb6\n".
1494 " \"{Libraries}MacRuntime.o\" \xb6\n".
1495 " \"{Libraries}MathLib.far.o\" \xb6\n".
1496 " \"{Libraries}IntEnv.far.o\" \xb6\n".
1497 " \"{Libraries}Interface.o\" \xb6\n".
1498 " \"{Libraries}Navigation.far.o\" \xb6\n".
1499 " \"{Libraries}OpenTransport.o\" \xb6\n".
1500 " \"{Libraries}OpenTransportApp.o\" \xb6\n".
1501 " \"{Libraries}OpenTptInet.o\" \xb6\n".
1502 " \"{Libraries}UnicodeConverterLib.far.o\"\n".
1504 "Libs_CFM = \"{SharedLibraries}InterfaceLib\" \xb6\n".
1505 " \"{SharedLibraries}StdCLib\" \xb6\n".
1506 " \"{SharedLibraries}AppearanceLib\" \xb6\n".
1507 " -weaklib AppearanceLib \xb6\n".
1508 " \"{SharedLibraries}NavigationLib\" \xb6\n".
1509 " -weaklib NavigationLib \xb6\n".
1510 " \"{SharedLibraries}TextCommon\" \xb6\n".
1511 " -weaklib TextCommon \xb6\n".
1512 " \"{SharedLibraries}UnicodeConverter\" \xb6\n".
1513 " -weaklib UnicodeConverter\n".
1515 "Libs_CFM68K = {Libs_CFM} \xb6\n".
1516 " \"{CFM68KLibraries}NuMacRuntime.o\"\n".
1518 "Libs_PPC = {Libs_CFM} \xb6\n".
1519 " \"{SharedLibraries}ControlsLib\" \xb6\n".
1520 " -weaklib ControlsLib \xb6\n".
1521 " \"{SharedLibraries}WindowsLib\" \xb6\n".
1522 " -weaklib WindowsLib \xb6\n".
1523 " \"{SharedLibraries}OpenTransportLib\" \xb6\n".
1524 " -weaklib OTClientLib \xb6\n".
1525 " -weaklib OTClientUtilLib \xb6\n".
1526 " \"{SharedLibraries}OpenTptInternetLib\" \xb6\n".
1527 " -weaklib OTInetClientLib \xb6\n".
1528 " \"{PPCLibraries}StdCRuntime.o\" \xb6\n".
1529 " \"{PPCLibraries}PPCCRuntime.o\" \xb6\n".
1530 " \"{PPCLibraries}CarbonAccessors.o\" \xb6\n".
1531 " \"{PPCLibraries}OpenTransportAppPPC.o\" \xb6\n".
1532 " \"{PPCLibraries}OpenTptInetPPC.o\"\n".
1534 "Libs_Carbon = \"{PPCLibraries}CarbonStdCLib.o\" \xb6\n".
1535 " \"{PPCLibraries}StdCRuntime.o\" \xb6\n".
1536 " \"{PPCLibraries}PPCCRuntime.o\" \xb6\n".
1537 " \"{SharedLibraries}CarbonLib\" \xb6\n".
1538 " \"{SharedLibraries}StdCLib\"\n".
1540 print &splitline("all \xc4 " . join(" ", &progrealnames("M")), undef, "\xb6");
1542 foreach $p (&prognames("M")) {
1543 ($prog, $type) = split ",", $p;
1545 print &splitline("$prog \xc4 $prog.68k $prog.ppc $prog.carbon",
1546 undef, "\xb6"), "\n\n";
1548 $rsrc = &objects($p, "", "X.rsrc", undef);
1550 foreach $arch (qw(68K CFM68K PPC Carbon)) {
1551 $objstr = &objects($p, "X.\L$arch\E.o", "", undef);
1552 print &splitline("$prog.\L$arch\E \xc4 $objstr $rsrc", undef, "\xb6");
1554 print &splitline("\tDuplicate -y $rsrc {Targ}", 69, "\xb6"), "\n";
1555 print &splitline("\t{Link_$arch} -o {Targ} -fragname $prog " .
1556 "{LinkOptions_$arch} " .
1557 $objstr . " {Libs_$arch}", 69, "\xb6"), "\n";
1558 print &splitline("\tSetFile -a BMi {Targ}", 69, "\xb6"), "\n\n";
1562 foreach $d (&deps("", "X.rsrc", "::", ":")) {
1563 next unless $d->{obj};
1564 print &splitline(sprintf("%s \xc4 %s", $d->{obj}, join " ", @{$d->{deps}}),
1565 undef, "\xb6"), "\n";
1566 print "\tRez ", $d->{deps}->[0], " -o {Targ} {ROptions}\n\n";
1568 foreach $arch (qw(68K CFM68K)) {
1569 foreach $d (&deps("X.\L$arch\E.o", "", "::", ":")) {
1570 next unless $d->{obj};
1571 print &splitline(sprintf("%s \xc4 %s", $d->{obj},
1572 join " ", @{$d->{deps}}),
1573 undef, "\xb6"), "\n";
1574 print "\t{C_$arch} ", $d->{deps}->[0],
1575 " -o {Targ} {COptions_$arch}\n\n";
1578 foreach $arch (qw(PPC Carbon)) {
1579 foreach $d (&deps("X.\L$arch\E.o", "", "::", ":")) {
1580 next unless $d->{obj};
1581 print &splitline(sprintf("%s \xc4 %s", $d->{obj},
1582 join " ", @{$d->{deps}}),
1583 undef, "\xb6"), "\n";
1584 # The odd stuff here seems to stop afpd getting confused.
1585 print "\techo -n > {Targ}\n";
1586 print "\tsetfile -t XCOF {Targ}\n";
1587 print "\t{C_$arch} ", $d->{deps}->[0],
1588 " -o {Targ} {COptions_$arch}\n\n";
1591 select STDOUT; close OUT;
1594 if (defined $makefiles{'lcc'}) {
1596 $dirpfx = &dirpfx($makefiles{'lcc'}, "\\");
1599 open OUT, ">$makefiles{'lcc'}"; select OUT;
1601 "# Makefile for $project_name under lcc.\n".
1602 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1603 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1604 # lcc command line option is -D not /D
1605 ($_ = $help) =~ s/=\/D/=-D/gs;
1609 "# If you rename this file to `Makefile', you should change this line,\n".
1610 "# so that the .rsp files still depend on the correct makefile.\n".
1611 "MAKEFILE = Makefile.lcc\n".
1613 "# C compilation flags\n".
1614 "CFLAGS = -D_WINDOWS " .
1615 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
1618 "# Get include directory for resource compiler\n".
1620 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
1622 foreach $p (&prognames("G:C")) {
1623 ($prog, $type) = split ",", $p;
1624 $objstr = &objects($p, "X.obj", "X.res", undef);
1625 print &splitline("$prog.exe: " . $objstr ), "\n";
1626 $subsystemtype = undef;
1627 if ($type eq "G") { $subsystemtype = "-subsystem windows"; }
1628 my $libss = "shell32.lib wsock32.lib ws2_32.lib winspool.lib winmm.lib imm32.lib";
1629 print &splitline("\tlcclnk $subsystemtype -o $prog.exe $objstr $libss");
1633 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\")) {
1634 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
1636 if ($d->{obj} =~ /\.res$/) {
1637 print &splitline("\tlrc \$(FWHACK) \$(RCFL) -r \$*.rc",69)."\n";
1639 $deflist = join "", map { " -D$_" } @{$d->{defs}};
1640 print &splitline("\tlcc -O -p6 \$(COMPAT) \$(FWHACK) \$(CFLAGS)".
1641 " \$(XFLAGS)$deflist ".$d->{deps}->[0]." -o \$\@",69)."\n";
1645 print $makefile_extra{'lcc'} || "";
1651 select STDOUT; close OUT;
1654 if (defined $makefiles{'nestedvm'}) {
1655 $mftyp = 'nestedvm';
1656 $dirpfx = &dirpfx($makefiles{'nestedvm'}, "/");
1658 ##-- NestedVM makefile
1659 open OUT, ">$makefiles{'nestedvm'}"; select OUT;
1661 "# Makefile for $project_name under NestedVM.\n".
1662 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1663 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1664 # gcc command line option is -D not /D
1665 ($_ = $help) =~ s/=\/D/=-D/gs;
1669 "# This path points at the nestedvm root directory\n".
1670 "NESTEDVM = /opt/nestedvm\n".
1671 "# You can define this path to point at your tools if you need to\n".
1672 "TOOLPATH = \$(NESTEDVM)/upstream/install/bin\n".
1673 "CC = \$(TOOLPATH)/mips-unknown-elf-gcc\n".
1675 &splitline("CFLAGS = -O2 -Wall -Werror -DSLOW_SYSTEM -g " .
1676 (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
1678 print &splitline("all:" . join "", map { " $_.jar" } &progrealnames("X"));
1680 foreach $p (&prognames("X")) {
1681 ($prog, $type) = split ",", $p;
1682 $objstr = &objects($p, "X.o", undef, undef);
1683 $objstr =~ s/gtk\.o/nestedvm\.o/g;
1684 print &splitline($prog . ".mips: " . $objstr), "\n";
1685 $libstr = &objects($p, undef, undef, "-lX");
1686 print &splitline("\t\$(CC) \$(${type}LDFLAGS) -o \$@ " .
1687 $objstr . " $libstr -lm", 69), "\n\n";
1689 foreach $d (&deps("X.o", undef, $dirpfx, "/")) {
1691 $ddeps= join " ", @{$d->{deps}};
1692 $oobjs =~ s/gtk/nestedvm/g;
1693 $ddeps =~ s/gtk/nestedvm/g;
1694 print &splitline(sprintf("%s: %s", $oobjs, $ddeps)),
1696 $deflist = join "", map { " -D$_" } @{$d->{defs}};
1697 print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist" .
1698 " -c \$< -o \$\@\n";
1701 print $makefile_extra{'nestedvm'} || "";
1703 "\trm -rf *.o *.mips *.class *.html *.jar org applet.manifest\n";
1704 select STDOUT; close OUT;
1707 if (defined $makefiles{'osx'}) {
1709 $dirpfx = &dirpfx($makefiles{'osx'}, "/");
1710 @osxarchs = ('i386');
1712 ##-- Mac OS X makefile
1713 open OUT, ">$makefiles{'osx'}"; select OUT;
1715 "# Makefile for $project_name under Mac OS X.\n".
1716 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1717 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1718 # gcc command line option is -D not /D
1719 ($_ = $help) =~ s/=\/D/=-D/gs;
1722 "CC = \$(TOOLPATH)gcc\n".
1723 "LIPO = \$(TOOLPATH)lipo\n".
1725 &splitline("CFLAGS = -O2 -Wall -Werror -g " .
1726 (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
1727 "LDFLAGS = -framework Cocoa\n".
1728 &splitline("all:" . join "", map { " $_" } &progrealnames("MX:U")) .
1730 print $makefile_extra{'osx'} || "";
1732 ".SUFFIXES: .o .c .m\n".
1735 foreach $p (&prognames("MX")) {
1736 ($prog, $type) = split ",", $p;
1737 $icon = &special($p, ".icns");
1738 $infoplist = &special($p, "info.plist");
1739 print "${prog}.app:\n\tmkdir -p \$\@\n";
1740 print "${prog}.app/Contents: ${prog}.app\n\tmkdir -p \$\@\n";
1741 print "${prog}.app/Contents/MacOS: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1742 $targets = "${prog}.app/Contents/MacOS/$prog";
1743 if (defined $icon) {
1744 print "${prog}.app/Contents/Resources: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1745 print "${prog}.app/Contents/Resources/${prog}.icns: ${prog}.app/Contents/Resources $icon\n\tcp $icon \$\@\n";
1746 $targets .= " ${prog}.app/Contents/Resources/${prog}.icns";
1748 if (defined $infoplist) {
1749 print "${prog}.app/Contents/Info.plist: ${prog}.app/Contents/Resources $infoplist\n\tcp $infoplist \$\@\n";
1750 $targets .= " ${prog}.app/Contents/Info.plist";
1752 $targets .= " \$(${prog}_extra)";
1753 print &splitline("${prog}: $targets", 69) . "\n\n";
1754 $libstr = &objects($p, undef, undef, "-lX");
1756 foreach $arch (@osxarchs) {
1757 $objstr = &objects($p, "X.${arch}.o", undef, undef);
1758 print &splitline("${prog}.${arch}.bin: " . $objstr), "\n";
1759 print &splitline("\t\$(CC) -arch ${arch} -mmacosx-version-min=10.4 \$(LDFLAGS) -o \$@ " .
1760 $objstr . " $libstr", 69), "\n\n";
1761 $archbins .= " ${prog}.${arch}.bin";
1763 print &splitline("${prog}.app/Contents/MacOS/$prog: ".
1764 "${prog}.app/Contents/MacOS" . $archbins), "\n";
1765 print &splitline("\t\$(LIPO) -create $archbins -output \$@", 69), "\n\n";
1767 foreach $p (&prognames("U")) {
1768 ($prog, $type) = split ",", $p;
1769 $libstr = &objects($p, undef, undef, "-lX");
1771 foreach $arch (@osxarchs) {
1772 $objstr = &objects($p, "X.${arch}.o", undef, undef);
1773 print &splitline("${prog}.${arch}: " . $objstr), "\n";
1774 print &splitline("\t\$(CC) -arch ${arch} -mmacosx-version-min=10.4 \$(ULDFLAGS) -o \$@ " .
1775 $objstr . " $libstr", 69), "\n\n";
1776 $archbins .= " ${prog}.${arch}";
1778 print &splitline("${prog}:" . $archbins), "\n";
1779 print &splitline("\t\$(LIPO) -create $archbins -output \$@", 69), "\n\n";
1781 foreach $arch (@osxarchs) {
1782 foreach $d (&deps("X.${arch}.o", undef, $dirpfx, "/")) {
1783 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
1785 $deflist = join "", map { " -D$_" } @{$d->{defs}};
1786 if ($d->{deps}->[0] =~ /\.m$/) {
1787 print "\t\$(CC) -arch $arch -mmacosx-version-min=10.4 -x objective-c \$(COMPAT) \$(FWHACK) \$(CFLAGS)".
1788 " \$(XFLAGS)$deflist -c \$< -o \$\@\n";
1790 print "\t\$(CC) -arch $arch -mmacosx-version-min=10.4 \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist" .
1791 " -c \$< -o \$\@\n";
1796 "\trm -f *.o *.dmg". (join "", map { my $a=$_; (" $a", map { " ${a}.$_" } @osxarchs) } &progrealnames("U")) . "\n".
1798 select STDOUT; close OUT;
1801 if (defined $makefiles{'gnustep'}) {
1803 $dirpfx = &dirpfx($makefiles{'gnustep'}, "/");
1805 ##-- GNUstep makefile (use with 'gs_make -f Makefile.gnustep')
1807 # This is a pretty evil way to do things. In an ideal world, I'd
1808 # use the approved GNUstep makefile mechanism which just defines a
1809 # variable or two saying what source files go into what binary and
1810 # then includes application.make. Unfortunately, that has the
1811 # automake-ish limitation that it doesn't let you choose different
1812 # command lines for each object, so I can't arrange for all those
1813 # files with -DTHIS and -DTHAT to Just Work.
1815 # A simple if ugly fix would be to have mkfiles.pl construct a
1816 # directory full of stub C files of the form '#define thing',
1817 # '#include "real_source_file"', and then reference those in this
1818 # makefile. That would also make it easy to build a proper
1819 # automake makefile.
1820 open OUT, ">$makefiles{'gnustep'}"; select OUT;
1822 "# Makefile for $project_name under GNUstep.\n".
1823 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1824 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1825 # gcc command line option is -D not /D
1826 ($_ = $help) =~ s/=\/D/=-D/gs;
1830 "include \$(GNUSTEP_MAKEFILES)/common.make\n".
1831 "include \$(GNUSTEP_MAKEFILES)/rules.make\n".
1832 "include \$(GNUSTEP_MAKEFILES)/Instance/rules.make\n".
1834 &splitline("all::" . join "", map { " $_" } &progrealnames("MX:U")) .
1836 print $makefile_extra{'gnustep'} || "";
1838 ".SUFFIXES: .o .c .m\n".
1841 foreach $p (&prognames("MX")) {
1842 ($prog, $type) = split ",", $p;
1843 $icon = &special($p, ".icns");
1844 $infoplist = &special($p, "info.plist");
1845 print "${prog}.app:\n\tmkdir -p \$\@\n";
1846 $targets = "${prog}.app ${prog}.app/$prog";
1847 if (defined $icon) {
1848 print "${prog}.app/Resources: ${prog}.app\n\tmkdir -p \$\@\n";
1849 print "${prog}.app/Resources/${prog}.icns: ${prog}.app/Resources $icon\n\tcp $icon \$\@\n";
1850 $targets .= " ${prog}.app/Resources/${prog}.icns";
1852 if (defined $infoplist) {
1853 print "${prog}.app/Info.plist: ${prog}.app $infoplist\n\tcp $infoplist \$\@\n";
1854 $targets .= " ${prog}.app/Info.plist";
1856 $targets .= " \$(${prog}_extra)";
1857 print &splitline("${prog}: $targets", 69) . "\n\n";
1858 $libstr = &objects($p, undef, undef, "-lX");
1859 $objstr = &objects($p, "X.o", undef, undef);
1860 print &splitline("${prog}.app/$prog: " . $objstr), "\n";
1861 print &splitline("\t\$(CC) \$(ALL_LDFLAGS) -o \$@ " . $objstr . " \$(ALL_LIB_DIRS) $libstr \$(ALL_LIBS)", 69), "\n\n";
1863 foreach $p (&prognames("U")) {
1864 ($prog, $type) = split ",", $p;
1865 $libstr = &objects($p, undef, undef, "-lX");
1866 $objstr = &objects($p, "X.o", undef, undef);
1867 print &splitline("${prog}: " . $objstr), "\n";
1868 print &splitline("\t\$(CC) \$(ULDFLAGS) -o \$@ " . $objstr . " $libstr", 69), "\n\n";
1870 foreach $d (&deps("X.o", undef, $dirpfx, "/")) {
1871 print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
1873 $deflist = join "", map { " -D$_" } @{$d->{defs}};
1874 if ($d->{deps}->[0] =~ /\.m$/) {
1875 print "\t\$(CC) -DGNUSTEP \$(ALL_OBJCFLAGS) \$(COMPAT) \$(FWHACK) \$(OBJCFLAGS)".
1876 " \$(XFLAGS)$deflist -c \$< -o \$\@\n";
1878 print "\t\$(CC) \$(ALL_CFLAGS) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist" .
1879 " -c \$< -o \$\@\n";
1882 print "\nclean::\n".
1883 "\trm -f *.o ". (join " ", &progrealnames("U")) . "\n".
1885 select STDOUT; close OUT;
1888 if (defined $makefiles{'emcc'}) {
1890 $dirpfx = &dirpfx($makefiles{'emcc'}, "/");
1892 ##-- Makefile for building Javascript puzzles via Emscripten
1894 open OUT, ">$makefiles{'emcc'}"; select OUT;
1896 "# Makefile for $project_name using Emscripten. Requires GNU make.\n".
1897 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1898 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1899 # emcc command line option is -D not /D
1900 ($_ = $help) =~ s/=\/D/=-D/gs;
1904 "# This can be set on the command line to point at the emcc command,\n".
1905 "# if it is not on your PATH.\n".
1908 &splitline("CFLAGS = -DSLOW_SYSTEM " .
1909 (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
1911 $output_js_files = join "", map { " \$(OUTPREFIX)$_.js" } &progrealnames("X");
1912 print &splitline("all:" . $output_js_files);
1914 foreach $p (&prognames("X")) {
1915 ($prog, $type) = split ",", $p;
1916 $objstr = &objects($p, "X.o", undef, undef);
1917 $objstr =~ s/gtk\.o/emcc\.o/g;
1918 print &splitline("\$(OUTPREFIX)" . $prog . ".js: " . $objstr . " emccpre.js emcclib.js emccx.json"), "\n";
1919 print "\t\$(EMCC) -o \$(OUTPREFIX)".$prog.".js ".
1922 "--pre-js emccpre.js ".
1923 "--js-library emcclib.js ".
1924 "-s EXPORTED_FUNCTIONS=\"`sed 's://.*::' emccx.json | tr -d ' \\n'`\" " . $objstr . "\n\n";
1926 foreach $d (&deps("X.o", undef, $dirpfx, "/")) {
1928 $ddeps= join " ", @{$d->{deps}};
1929 $oobjs =~ s/gtk/emcc/g;
1930 $ddeps =~ s/gtk/emcc/g;
1931 print &splitline(sprintf("%s: %s", $oobjs, $ddeps)),
1933 $deflist = join "", map { " -D$_" } @{$d->{defs}};
1934 print "\t\$(EMCC) \$(CFLAGS) \$(XFLAGS)$deflist" .
1935 " -c \$< -o \$\@\n";
1938 print $makefile_extra{'emcc'} || "";
1940 "\trm -rf *.o $output_js_files\n";
1941 select STDOUT; close OUT;
1944 # All done, so do the Unix postprocessing if asked to.
1948 system "./mkauto.sh";
1949 die "mkfiles.pl: mkauto.sh returned $?\n" if $? > 0;
1950 system "./configure", @confargs;
1951 die "mkfiles.pl: configure returned $?\n" if $? > 0;