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 # FIXME: no attempt made to handle !forceobj in the project files.
21 open IN, "Recipe" or do {
22 # We want to deal correctly with being run from one of the
23 # subdirs in the source tree. So if we can't find Recipe here,
26 open IN, "Recipe" or die "unable to open Recipe file\n";
29 # HACK: One of the source files in `charset' is auto-generated by
30 # sbcsgen.pl. We need to generate that _now_, before attempting
31 # dependency analysis.
32 eval 'chdir "charset"; require "sbcsgen.pl"; chdir ".."';
36 $divert = undef; # ref to scalar in which text is currently being put
37 $help = ""; # list of newline-free lines of help text
38 $project_name = "project"; # this is a good enough default
39 %makefiles = (); # maps makefile types to output makefile pathnames
40 %makefile_extra = (); # maps makefile types to extra Makefile text
41 %programs = (); # maps prog name + type letter to listref of objects/resources
42 %groups = (); # maps group name to listref of objects/resources
45 # Skip comments (unless the comments belong, for example because
46 # they're part of a diversion).
47 next if /^\s*#/ and !defined $divert;
51 if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = \$help; next; }
52 if ($_[0] eq "!end") { $divert = undef; next; }
53 if ($_[0] eq "!name") { $project_name = $_[1]; next; }
54 if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; }
55 if ($_[0] eq "!makefile" and &mfval($_[1])) { $makefiles{$_[1]}=$_[2]; next;}
56 if ($_[0] eq "!specialobj" and &mfval($_[1])) { $specialobj{$_[1]}->{$_[2]} = 1; next;}
57 if ($_[0] eq "!forceobj") { $forceobj{$_[1]} = 1; next; }
58 if ($_[0] eq "!begin") {
60 $sect = $_[2] ? $_[2] : "end";
61 $divert = \($makefile_extra{$_[1]}->{$sect});
67 # If we're gathering help/verbatim text, keep doing so.
68 if (defined $divert) { ${$divert} .= "$_\n"; next; }
70 next if scalar @_ == 0;
72 # Now we have an ordinary line. See if it's an = line, a : line
77 $listref = $lastlistref;
79 die "$.: unexpected + line\n" if !defined $lastlistref;
80 } elsif ($_[1] eq "=") {
81 $groups{$_[0]} = [] if !defined $groups{$_[0]};
82 $listref = $groups{$_[0]};
84 shift @objs; # eat the group name
85 } elsif ($_[1] eq ":") {
88 shift @objs; # eat the program name
90 die "$.: unrecognised line type\n";
92 shift @objs; # eat the +, the = or the :
94 while (scalar @objs > 0) {
97 foreach $j (@{$groups{$i}}) { unshift @objs, $j; }
98 } elsif (($i eq "[G]" or $i eq "[C]" or $i eq "[M]" or
99 $i eq "[X]" or $i eq "[U]" or $i eq "[MX]") and defined $prog) {
100 $type = substr($i,1,(length $i)-2);
105 if ($prog and $type) {
106 die "multiple program entries for $prog [$type]\n"
107 if defined $programs{$prog . "," . $type};
108 $programs{$prog . "," . $type} = $listref;
110 $lastlistref = $listref;
115 # Now retrieve the complete list of objects and resource files, and
116 # construct dependency data for them. While we're here, expand the
117 # object list for each program, and complain if its type isn't set.
118 @prognames = sort keys %programs;
121 foreach $i (@prognames) {
122 ($prog, $type) = split ",", $i;
123 # Strip duplicate object names.
125 @list = grep { $status = ($prev ne $_); $prev=$_; $status }
126 sort @{$programs{$i}};
127 $programs{$i} = [@list];
129 # Dependencies for "x" start with "x.c" or "x.m" (depending on
131 # Dependencies for "x.res" start with "x.rc".
132 # Dependencies for "x.rsrc" start with "x.r".
133 # Both types of file are pushed on the list of files to scan.
134 # Libraries (.lib) don't have dependencies at all.
135 if ($j =~ /^(.*)\.res$/) {
137 $depends{$j} = [$file];
138 push @scanlist, $file;
139 } elsif ($j =~ /^(.*)\.rsrc$/) {
141 $depends{$j} = [$file];
142 push @scanlist, $file;
143 } elsif ($j !~ /\./) {
145 $file = "$j.m" unless &findfile($file);
146 $depends{$j} = [$file];
147 push @scanlist, $file;
152 # Scan each file on @scanlist and find further inclusions.
153 # Inclusions are given by lines of the form `#include "otherfile"'
154 # (system headers are automatically ignored by this because they'll
155 # be given in angle brackets). Files included by this method are
156 # added back on to @scanlist to be scanned in turn (if not already
159 # Resource scripts (.rc) can also include a file by means of:
160 # - a line # ending `ICON "filename"';
161 # - a line ending `RT_MANIFEST "filename"'.
162 # Files included by this method are not added to @scanlist because
163 # they can never include further files.
165 # In this pass we write out a hash %further which maps a source
166 # file name into a listref containing further source file names.
169 while (scalar @scanlist > 0) {
170 $file = shift @scanlist;
171 next if defined $further{$file}; # skip if we've already done it
172 $resource = ($file =~ /\.rc$/ ? 1 : 0);
173 $further{$file} = [];
174 $dirfile = &findfile($file);
175 open IN, "$dirfile" or die "unable to open source file $file\n";
178 /^\s*#include\s+\"([^\"]+)\"/ and do {
179 push @{$further{$file}}, $1;
183 /(RT_MANIFEST|ICON)\s+\"([^\"]+)\"\s*$/ and do {
184 push @{$further{$file}}, $2;
191 # Now we're ready to generate the final dependencies section. For
192 # each key in %depends, we must expand the dependencies list by
193 # iteratively adding entries from %further.
194 foreach $i (keys %depends) {
196 @scanlist = @{$depends{$i}};
197 foreach $i (@scanlist) { $dep{$i} = 1; }
198 while (scalar @scanlist > 0) {
199 $file = shift @scanlist;
200 foreach $j (@{$further{$file}}) {
203 push @{$depends{$i}}, $j;
208 # printf "%s: %s\n", $i, join ' ',@{$depends{$i}};
211 # Validation of input.
215 # Returns true if the argument is a known makefile type. Otherwise,
216 # prints a warning and returns false;
217 if (grep { $type eq $_ }
218 ("vc","vcproj","cygwin","borland","lcc","devcppproj","gtk","unix",
219 "ac","mpw","osx",)) {
222 warn "$.:unknown makefile type '$type'\n";
226 # Utility routines while writing out the Makefiles.
229 my ($path) = shift @_;
230 my ($sep) = shift @_;
233 while (($i = index $path, $sep) >= 0 ||
234 ($j = index $path, "/") >= 0) {
235 if ($i >= 0 and ($j < 0 or $i < $j)) {
236 $path = substr $path, ($i + length $sep);
238 $path = substr $path, ($j + 1);
250 unless (defined $findfilecache{$name}) {
252 foreach $dir (@srcdirs) {
253 $outdir = $dir, $i++ if -f "$dir$name";
256 die "multiple instances of source file $name\n" if $i > 1;
257 $findfilecache{$name} = (defined $outdir ? $outdir . $name : undef);
259 return $findfilecache{$name};
263 my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_;
267 foreach $i (@{$programs{$prog}}) {
269 if ($i =~ /^(.*)\.(res|rsrc)/) {
271 ($x = $rtmpl) =~ s/X/$y/;
272 } elsif ($i =~ /^(.*)\.lib/) {
274 ($x = $ltmpl) =~ s/X/$y/;
275 } elsif ($i !~ /\./) {
276 ($x = $otmpl) =~ s/X/$i/;
278 push @ret, $x if $x ne "";
280 return join " ", @ret;
284 my ($prog, $suffix) = @_;
288 foreach $i (@{$programs{$prog}}) {
289 if (substr($i, (length $i) - (length $suffix)) eq $suffix) {
293 return (scalar @ret) ? (join " ", @ret) : undef;
297 my ($line, $width, $splitchar) = @_;
299 $len = (defined $width ? $width : 76);
300 $splitchar = (defined $splitchar ? $splitchar : '\\');
301 while (length $line > $len) {
302 $line =~ /^(.{0,$len})\s(.*)$/ or $line =~ /^(.{$len,}?\s(.*)$/;
304 $result .= " ${splitchar}\n\t\t" if $2 ne '';
308 return $result . $line;
312 my ($otmpl, $rtmpl, $prefix, $dirsep, $mftyp, $depchar, $splitchar) = @_;
317 foreach $i (sort keys %depends) {
318 next if $specialobj{$mftyp}->{$i};
319 if ($i =~ /^(.*)\.(res|rsrc)/) {
320 next if !defined $rtmpl;
322 ($x = $rtmpl) =~ s/X/$y/;
324 ($x = $otmpl) =~ s/X/$i/;
326 @deps = @{$depends{$i}};
332 push @ret, {obj => $x, obj_orig => $i, deps => [@deps]};
339 my ($n, $prog, $type);
342 foreach $n (@prognames) {
343 ($prog, $type) = split ",", $n;
344 push @ret, $n if index(":$types:", ":$type:") >= 0;
351 my ($n, $prog, $type);
354 foreach $n (@prognames) {
355 ($prog, $type) = split ",", $n;
356 push @ret, $prog if index(":$types:", ":$type:") >= 0;
362 my ($types,$suffix) = @_;
364 # assume that all UNIX programs have a man page
365 if($suffix eq "1" && $types =~ /:X:/) {
366 return map("$_.1", &progrealnames($types));
371 # Now we're ready to output the actual Makefiles.
373 if (defined $makefiles{'cygwin'}) {
374 $dirpfx = &dirpfx($makefiles{'cygwin'}, "/");
377 open OUT, ">$makefiles{'cygwin'}"; select OUT;
379 "# Makefile for $project_name under cygwin.\n".
380 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
381 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
382 # gcc command line option is -D not /D
383 ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
387 "# You can define this path to point at your tools if you need to\n".
388 "# TOOLPATH = c:\\cygwin\\bin\\ # or similar, if you're running Windows\n".
389 "# TOOLPATH = /pkg/mingw32msvc/i386-mingw32msvc/bin/\n".
390 "CC = \$(TOOLPATH)gcc\n".
391 "RC = \$(TOOLPATH)windres\n".
392 "# Uncomment the following two lines to compile under Winelib\n".
395 "# You may also need to tell windres where to find include files:\n".
396 "# RCINC = --include-dir c:\\cygwin\\include\\\n".
398 &splitline("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
399 " -D_NO_OLDNAMES -DNO_MULTIMON -DNO_HTMLHELP " .
400 (join " ", map {"-I$dirpfx$_"} @srcdirs)) .
402 "LDFLAGS = -mno-cygwin -s\n".
403 &splitline("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1".
404 " --define WINVER=0x0400")."\n".
406 $makefile_extra{'cygwin'}->{'vars'} .
410 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
412 foreach $p (&prognames("G:C")) {
413 ($prog, $type) = split ",", $p;
414 $objstr = &objects($p, "X.o", "X.res.o", undef);
415 print &splitline($prog . ".exe: " . $objstr), "\n";
416 my $mw = $type eq "G" ? " -mwindows" : "";
417 $libstr = &objects($p, undef, undef, "-lX");
418 print &splitline("\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " .
419 "-Wl,-Map,$prog.map " .
420 $objstr . " $libstr", 69), "\n\n";
422 foreach $d (&deps("X.o", "X.res.o", $dirpfx, "/", "cygwin")) {
423 if ($forceobj{$d->{obj_orig}}) {
424 printf ("%s: FORCE\n", $d->{obj});
426 print &splitline(sprintf("%s: %s", $d->{obj},
427 join " ", @{$d->{deps}})), "\n";
429 if ($d->{obj} =~ /\.res\.o$/) {
430 print "\t\$(RC) \$(RCFL) \$(RCFLAGS) ".$d->{deps}->[0]." ".$d->{obj}."\n\n";
432 print "\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c ".$d->{deps}->[0]."\n\n";
436 print $makefile_extra{'cygwin'}->{'end'};
438 "\trm -f *.o *.exe *.res.o *.map\n".
441 select STDOUT; close OUT;
445 ##-- Borland makefile
446 if (defined $makefiles{'borland'}) {
447 $dirpfx = &dirpfx($makefiles{'borland'}, "\\");
449 %stdlibs = ( # Borland provides many Win32 API libraries intrinsically
461 open OUT, ">$makefiles{'borland'}"; select OUT;
463 "# Makefile for $project_name under Borland C.\n".
464 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
465 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
466 # bcc32 command line option is -D not /D
467 ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
471 "# If you rename this file to `Makefile', you should change this line,\n".
472 "# so that the .rsp files still depend on the correct makefile.\n".
473 "MAKEFILE = Makefile.bor\n".
475 "# C compilation flags\n".
476 "CFLAGS = -D_WINDOWS -DWINVER=0x0500\n".
477 "# Resource compilation flags\n".
478 "RCFLAGS = -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401\n".
480 "# Get include directory for resource compiler\n".
482 "BCB = \$(MAKEDIR)\\..\n".
485 $makefile_extra{'borland'}->{'vars'} .
488 &splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT)".
489 " \$(CFLAGS) \$(XFLAGS) ".
490 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
491 " /c \$*.c",69)."\n".
493 &splitline("\tbrcc32 \$(RCFL) -i \$(BCB)\\include -r".
494 " \$(RCFLAGS) \$*.rc",69)."\n".
496 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
498 foreach $p (&prognames("G:C")) {
499 ($prog, $type) = split ",", $p;
500 $objstr = &objects($p, "X.obj", "X.res", undef);
501 print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
502 my $ap = ($type eq "G") ? "-aa" : "-ap";
503 print "\tilink32 $ap -Gn -L\$(BCB)\\lib \@$prog.rsp\n\n";
505 foreach $p (&prognames("G:C")) {
506 ($prog, $type) = split ",", $p;
507 print $prog, ".rsp: \$(MAKEFILE)\n";
508 $objstr = &objects($p, "X.obj", undef, undef);
509 @objlist = split " ", $objstr;
511 foreach $i (@objlist) {
512 if (length($objlines[$#objlines] . " $i") > 50) {
515 $objlines[$#objlines] .= " $i";
517 $c0w = ($type eq "G") ? "c0w32" : "c0x32";
518 print "\techo $c0w + > $prog.rsp\n";
519 for ($i=0; $i<=$#objlines; $i++) {
520 $plus = ($i < $#objlines ? " +" : "");
521 print "\techo$objlines[$i]$plus >> $prog.rsp\n";
523 print "\techo $prog.exe >> $prog.rsp\n";
524 $objstr = &objects($p, "X.obj", "X.res", undef);
525 @libs = split " ", &objects($p, undef, undef, "X");
526 @libs = grep { !$stdlibs{$_} } @libs;
527 unshift @libs, "cw32", "import32";
528 $libstr = join ' ', @libs;
529 print "\techo nul,$libstr, >> $prog.rsp\n";
530 print "\techo " . &objects($p, undef, "X.res", undef) . " >> $prog.rsp\n";
533 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "borland")) {
534 if ($forceobj{$d->{obj_orig}}) {
535 printf("%s: FORCE\n", $d->{obj});
537 print &splitline(sprintf("%s: %s", $d->{obj},
538 join " ", @{$d->{deps}})), "\n";
542 print $makefile_extra{'borland'}->{'end'};
553 "\t-del *.\$\$\$\$\$\$\n".
556 "\t-rem dummy command\n";
557 select STDOUT; close OUT;
560 if (defined $makefiles{'vc'}) {
561 $dirpfx = &dirpfx($makefiles{'vc'}, "\\");
563 ##-- Visual C++ makefile
564 open OUT, ">$makefiles{'vc'}"; select OUT;
566 "# Makefile for $project_name under Visual C.\n".
567 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
568 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
572 "# If you rename this file to `Makefile', you should change this line,\n".
573 "# so that the .rsp files still depend on the correct makefile.\n".
574 "MAKEFILE = Makefile.vc\n".
576 "# C compilation flags\n".
577 "CFLAGS = /nologo /W3 /O1 " .
578 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
579 " /D_WINDOWS /D_WIN32_WINDOWS=0x500 /DWINVER=0x500\n".
580 "LFLAGS = /incremental:no /fixed\n".
581 "RCFLAGS = -DWIN32 -D_WIN32 -DWINVER=0x0400\n".
583 $makefile_extra{'vc'}->{'vars'} .
586 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
588 foreach $p (&prognames("G:C")) {
589 ($prog, $type) = split ",", $p;
590 $objstr = &objects($p, "X.obj", "X.res", undef);
591 print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
592 print "\tlink \$(LFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n";
594 foreach $p (&prognames("G:C")) {
595 ($prog, $type) = split ",", $p;
596 print $prog, ".rsp: \$(MAKEFILE)\n";
597 $objstr = &objects($p, "X.obj", "X.res", "X.lib");
598 @objlist = split " ", $objstr;
600 foreach $i (@objlist) {
601 if (length($objlines[$#objlines] . " $i") > 50) {
604 $objlines[$#objlines] .= " $i";
606 $subsys = ($type eq "G") ? "windows" : "console";
607 print "\techo /nologo /subsystem:$subsys > $prog.rsp\n";
608 for ($i=0; $i<=$#objlines; $i++) {
609 print "\techo$objlines[$i] >> $prog.rsp\n";
613 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "vc")) {
614 $extradeps = $forceobj{$d->{obj_orig}} ? ["*.c","*.h","*.rc"] : [];
615 print &splitline(sprintf("%s: %s", $d->{obj},
616 join " ", @$extradeps, @{$d->{deps}})), "\n";
617 if ($d->{obj} =~ /.obj$/) {
618 print "\tcl \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c ".$d->{deps}->[0],"\n\n";
620 print "\trc \$(RCFL) -r \$(RCFLAGS) ".$d->{deps}->[0],"\n\n";
624 print $makefile_extra{'vc'}->{'end'};
625 print "\nclean: tidy\n".
642 "\t-del debug.log\n";
643 select STDOUT; close OUT;
646 if (defined $makefiles{'vcproj'}) {
647 $dirpfx = &dirpfx($makefiles{'vcproj'}, "\\");
651 ##-- MSVC 6 Workspace and projects
653 # Note: All files created in this section are written in binary
654 # mode, because although MSVC's command-line make can deal with
655 # LF-only line endings, MSVC project files really _need_ to be
656 # CRLF. Hence, in order for mkfiles.pl to generate usable project
657 # files even when run from Unix, I make sure all files are binary
658 # and explicitly write the CRLFs.
660 # Create directories if necessary
661 mkdir $makefiles{'vcproj'}
662 if(! -d $makefiles{'vcproj'});
663 chdir $makefiles{'vcproj'};
664 @deps = &deps("X.obj", "X.res", $dirpfx, "\\", "vcproj");
665 %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;
666 # Create the project files
667 # Get names of all Windows projects (GUI and console)
668 my @prognames = &prognames("G:C");
669 foreach $progname (@prognames) {
670 create_vc_project(\%all_object_deps, $progname);
672 # Create the workspace file
673 open OUT, ">$project_name.dsw"; binmode OUT; select OUT;
675 "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n".
676 "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n".
678 "###############################################################################\r\n".
681 foreach $progname (@prognames) {
682 ($windows_project, $type) = split ",", $progname;
683 print "Project: \"$windows_project\"=\".\\$windows_project\\$windows_project.dsp\" - Package Owner=<4>\r\n";
695 "###############################################################################\r\n".
707 "###############################################################################\r\n".
709 select STDOUT; close OUT;
712 sub create_vc_project {
713 my ($all_object_deps, $progname) = @_;
714 # Construct program's dependency info
719 %resource_files = ();
720 @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");
721 foreach $object_file (@object_files) {
722 next if defined $seen_objects{$object_file};
723 $seen_objects{$object_file} = 1;
724 if($object_file =~ /\.lib$/io) {
725 $lib_files{$object_file} = 1;
728 $object_deps = $all_object_deps{$object_file};
729 foreach $object_dep (@$object_deps) {
730 if($object_dep =~ /\.c$/io) {
731 $source_files{$object_dep} = 1;
734 if($object_dep =~ /\.h$/io) {
735 $header_files{$object_dep} = 1;
738 if($object_dep =~ /\.(rc|ico)$/io) {
739 $resource_files{$object_dep} = 1;
744 $libs = join " ", sort keys %lib_files;
745 @source_files = sort keys %source_files;
746 @header_files = sort keys %header_files;
747 @resources = sort keys %resource_files;
748 ($windows_project, $type) = split ",", $progname;
749 mkdir $windows_project
750 if(! -d $windows_project);
751 chdir $windows_project;
752 $subsys = ($type eq "G") ? "windows" : "console";
753 open OUT, ">$windows_project.dsp"; binmode OUT; select OUT;
755 "# Microsoft Developer Studio Project File - Name=\"$windows_project\" - Package Owner=<4>\r\n".
756 "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n".
757 "# ** DO NOT EDIT **\r\n".
759 "# TARGTYPE \"Win32 (x86) Application\" 0x0101\r\n".
761 "CFG=$windows_project - Win32 Debug\r\n".
762 "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n".
763 "!MESSAGE use the Export Makefile command and run\r\n".
765 "!MESSAGE NMAKE /f \"$windows_project.mak\".\r\n".
767 "!MESSAGE You can specify a configuration when running NMAKE\r\n".
768 "!MESSAGE by defining the macro CFG on the command line. For example:\r\n".
770 "!MESSAGE NMAKE /f \"$windows_project.mak\" CFG=\"$windows_project - Win32 Debug\"\r\n".
772 "!MESSAGE Possible choices for configuration are:\r\n".
774 "!MESSAGE \"$windows_project - Win32 Release\" (based on \"Win32 (x86) Application\")\r\n".
775 "!MESSAGE \"$windows_project - Win32 Debug\" (based on \"Win32 (x86) Application\")\r\n".
778 "# Begin Project\r\n".
779 "# PROP AllowPerConfigDependencies 0\r\n".
780 "# PROP Scc_ProjName \"\"\r\n".
781 "# PROP Scc_LocalPath \"\"\r\n".
786 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
788 "# PROP BASE Use_MFC 0\r\n".
789 "# PROP BASE Use_Debug_Libraries 0\r\n".
790 "# PROP BASE Output_Dir \"Release\"\r\n".
791 "# PROP BASE Intermediate_Dir \"Release\"\r\n".
792 "# PROP BASE Target_Dir \"\"\r\n".
793 "# PROP Use_MFC 0\r\n".
794 "# PROP Use_Debug_Libraries 0\r\n".
795 "# PROP Output_Dir \"Release\"\r\n".
796 "# PROP Intermediate_Dir \"Release\"\r\n".
797 "# PROP Ignore_Export_Lib 0\r\n".
798 "# PROP Target_Dir \"\"\r\n".
799 "# ADD BASE CPP /nologo /W3 /GX /O2 ".
800 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
801 " /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
802 "# ADD CPP /nologo /W3 /GX /O2 ".
803 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
804 " /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
805 "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
806 "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
807 "# ADD BASE RSC /l 0x809 /d \"NDEBUG\"\r\n".
808 "# ADD RSC /l 0x809 /d \"NDEBUG\"\r\n".
809 "BSC32=bscmake.exe\r\n".
810 "# ADD BASE BSC32 /nologo\r\n".
811 "# ADD BSC32 /nologo\r\n".
812 "LINK32=link.exe\r\n".
813 "# 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".
814 "# ADD LINK32 $libs /nologo /subsystem:$subsys /machine:I386\r\n".
815 "# SUBTRACT LINK32 /pdb:none\r\n".
817 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
819 "# PROP BASE Use_MFC 0\r\n".
820 "# PROP BASE Use_Debug_Libraries 1\r\n".
821 "# PROP BASE Output_Dir \"Debug\"\r\n".
822 "# PROP BASE Intermediate_Dir \"Debug\"\r\n".
823 "# PROP BASE Target_Dir \"\"\r\n".
824 "# PROP Use_MFC 0\r\n".
825 "# PROP Use_Debug_Libraries 1\r\n".
826 "# PROP Output_Dir \"Debug\"\r\n".
827 "# PROP Intermediate_Dir \"Debug\"\r\n".
828 "# PROP Ignore_Export_Lib 0\r\n".
829 "# PROP Target_Dir \"\"\r\n".
830 "# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od ".
831 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
832 " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
833 "# ADD CPP /nologo /W3 /Gm /GX /ZI /Od ".
834 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
835 " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
836 "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
837 "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
838 "# ADD BASE RSC /l 0x809 /d \"_DEBUG\"\r\n".
839 "# ADD RSC /l 0x809 /d \"_DEBUG\"\r\n".
840 "BSC32=bscmake.exe\r\n".
841 "# ADD BASE BSC32 /nologo\r\n".
842 "# ADD BSC32 /nologo\r\n".
843 "LINK32=link.exe\r\n".
844 "# 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".
845 "# ADD LINK32 $libs /nologo /subsystem:$subsys /debug /machine:I386 /pdbtype:sept\r\n".
846 "# SUBTRACT LINK32 /pdb:none\r\n".
850 "# Begin Target\r\n".
852 "# Name \"$windows_project - Win32 Release\"\r\n".
853 "# Name \"$windows_project - Win32 Debug\"\r\n".
854 "# Begin Group \"Source Files\"\r\n".
856 "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
857 foreach $source_file (@source_files) {
859 "# Begin Source File\r\n".
861 "SOURCE=..\\..\\$source_file\r\n";
862 if($source_file =~ /ssh\.c/io) {
863 # Disable 'Edit and continue' as Visual Studio can't handle the macros
866 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
868 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
875 print "# End Source File\r\n";
879 "# Begin Group \"Header Files\"\r\n".
881 "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
882 foreach $header_file (@header_files) {
884 "# Begin Source File\r\n".
886 "SOURCE=..\\..\\$header_file\r\n".
887 "# End Source File\r\n";
891 "# Begin Group \"Resource Files\"\r\n".
893 "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
894 foreach $resource_file (@resources) {
896 "# Begin Source File\r\n".
898 "SOURCE=..\\..\\$resource_file\r\n".
899 "# End Source File\r\n";
905 select STDOUT; close OUT;
910 if (defined $makefiles{'gtk'}) {
911 $dirpfx = &dirpfx($makefiles{'gtk'}, "/");
913 ##-- X/GTK/Unix makefile
914 open OUT, ">$makefiles{'gtk'}"; select OUT;
916 "# Makefile for $project_name under X/GTK and Unix.\n".
917 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
918 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
919 # gcc command line option is -D not /D
920 ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
924 "# You can define this path to point at your tools if you need to\n".
925 "# TOOLPATH = /opt/gcc/bin\n".
926 "CC = \$(TOOLPATH)cc\n".
927 "# If necessary set the path to krb5-config here\n".
928 "KRB5CONFIG=krb5-config\n".
929 "# You can manually set this to `gtk-config' or `pkg-config gtk+-1.2'\n".
930 "# (depending on what works on your system) if you want to enforce\n".
931 "# building with GTK 1.2, or you can set it to `pkg-config gtk+-2.0'\n".
932 "# if you want to enforce 2.0. The default is to try 2.0 and fall back\n".
933 "# to 1.2 if it isn't found.\n".
934 "GTK_CONFIG = sh -c 'pkg-config gtk+-2.0 \$\$0 2>/dev/null || gtk-config \$\$0'\n".
936 "-include Makefile.local\n".
938 "unexport CFLAGS # work around a weird issue with krb5-config\n".
940 &splitline("CFLAGS = -O2 -Wall -Werror -g " .
941 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
942 " \$(shell \$(GTK_CONFIG) --cflags)").
943 " -D _FILE_OFFSET_BITS=64\n".
944 "XLDFLAGS = \$(LDFLAGS) \$(shell \$(GTK_CONFIG) --libs)\n".
945 "ULDFLAGS = \$(LDFLAGS)\n".
946 "ifeq (,\$(findstring NO_GSSAPI,\$(COMPAT)))\n".
947 "CFLAGS+= \$(shell \$(KRB5CONFIG) --cflags gssapi)\n".
948 "XLDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
949 "ULDFLAGS = \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
952 "INSTALL_PROGRAM=\$(INSTALL)\n".
953 "INSTALL_DATA=\$(INSTALL)\n".
954 "prefix=/usr/local\n".
955 "exec_prefix=\$(prefix)\n".
956 "bindir=\$(exec_prefix)/bin\n".
957 "mandir=\$(prefix)/man\n".
958 "man1dir=\$(mandir)/man1\n".
960 $makefile_extra{'gtk'}->{'vars'} .
965 print &splitline("all:" . join "", map { " $_" } &progrealnames("X:U"));
967 foreach $p (&prognames("X:U")) {
968 ($prog, $type) = split ",", $p;
969 $objstr = &objects($p, "X.o", undef, undef);
970 print &splitline($prog . ": " . $objstr), "\n";
971 $libstr = &objects($p, undef, undef, "-lX");
972 print &splitline("\t\$(CC)" . $mw . " -o \$@ " .
973 $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
975 foreach $d (&deps("X.o", undef, $dirpfx, "/", "gtk")) {
976 if ($forceobj{$d->{obj_orig}}) {
977 printf("%s: FORCE\n", $d->{obj});
979 print &splitline(sprintf("%s: %s", $d->{obj},
980 join " ", @{$d->{deps}})), "\n";
982 print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
985 print $makefile_extra{'gtk'}->{'end'};
987 "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:U")) . "\n";
989 select STDOUT; close OUT;
992 if (defined $makefiles{'unix'}) {
993 $dirpfx = &dirpfx($makefiles{'unix'}, "/");
995 ##-- GTK-free pure-Unix makefile for non-GUI apps only
996 open OUT, ">$makefiles{'unix'}"; select OUT;
998 "# Makefile for $project_name under Unix.\n".
999 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1000 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1001 # gcc command line option is -D not /D
1002 ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
1006 "# You can define this path to point at your tools if you need to\n".
1007 "# TOOLPATH = /opt/gcc/bin\n".
1008 "CC = \$(TOOLPATH)cc\n".
1009 "# If necessary set the path to krb5-config here\n".
1010 "KRB5CONFIG=krb5-config\n".
1012 "-include Makefile.local\n".
1014 "unexport CFLAGS # work around a weird issue with krb5-config\n".
1016 &splitline("CFLAGS = -O2 -Wall -Werror -g " .
1017 (join " ", map {"-I$dirpfx$_"} @srcdirs)).
1018 " -D _FILE_OFFSET_BITS=64\n".
1019 "ULDFLAGS = \$(LDFLAGS)\n".
1020 "ifeq (,\$(findstring NO_GSSAPI,\$(COMPAT)))\n".
1021 "CFLAGS+= \$(shell \$(KRB5CONFIG) --cflags gssapi)\n".
1022 "ULDFLAGS = \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
1024 "INSTALL=install\n".
1025 "INSTALL_PROGRAM=\$(INSTALL)\n".
1026 "INSTALL_DATA=\$(INSTALL)\n".
1027 "prefix=/usr/local\n".
1028 "exec_prefix=\$(prefix)\n".
1029 "bindir=\$(exec_prefix)/bin\n".
1030 "mandir=\$(prefix)/man\n".
1031 "man1dir=\$(mandir)/man1\n".
1033 $makefile_extra{'unix'}->{'vars'} .
1038 print &splitline("all:" . join "", map { " $_" } &progrealnames("U"));
1040 foreach $p (&prognames("U")) {
1041 ($prog, $type) = split ",", $p;
1042 $objstr = &objects($p, "X.o", undef, undef);
1043 print &splitline($prog . ": " . $objstr), "\n";
1044 $libstr = &objects($p, undef, undef, "-lX");
1045 print &splitline("\t\$(CC)" . $mw . " -o \$@ " .
1046 $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
1048 foreach $d (&deps("X.o", undef, $dirpfx, "/", "unix")) {
1049 if ($forceobj{$d->{obj_orig}}) {
1050 printf("%s: FORCE\n", $d->{obj});
1052 print &splitline(sprintf("%s: %s", $d->{obj},
1053 join " ", @{$d->{deps}})), "\n";
1055 print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
1058 print $makefile_extra{'unix'}->{'end'};
1060 "\trm -f *.o". (join "", map { " $_" } &progrealnames("U")) . "\n";
1062 select STDOUT; close OUT;
1065 if (defined $makefiles{'ac'}) {
1066 $dirpfx = &dirpfx($makefiles{'ac'}, "/");
1068 ##-- Unix/autoconf makefile
1069 open OUT, ">$makefiles{'ac'}"; select OUT;
1071 "# Makefile.in for $project_name under Unix with Autoconf.\n".
1072 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1073 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1074 # gcc command line option is -D not /D
1075 ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
1081 &splitline("CFLAGS = \@CFLAGS\@ \@CPPFLAGS\@ \@DEFS\@ \@GTK_CFLAGS\@ " .
1082 (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
1083 "XLDFLAGS = \@LDFLAGS\@ \@LIBS\@ \@GTK_LIBS\@\n".
1084 "ULDFLAGS = \@LDFLAGS\@ \@LIBS\@\n".
1085 "INSTALL=\@INSTALL\@\n".
1086 "INSTALL_PROGRAM=\$(INSTALL)\n".
1087 "INSTALL_DATA=\$(INSTALL)\n".
1088 "prefix=\@prefix\@\n".
1089 "exec_prefix=\@exec_prefix\@\n".
1090 "bindir=\@bindir\@\n".
1091 "datarootdir=\@datarootdir\@\n".
1092 "mandir=\@mandir\@\n".
1093 "man1dir=\$(mandir)/man1\n".
1095 $makefile_extra{'gtk'}->{'vars'} .
1100 "all: \@all_targets\@\n".
1101 &splitline("all-cli:" . join "", map { " $_" } &progrealnames("U"))."\n".
1102 &splitline("all-gtk:" . join "", map { " $_" } &progrealnames("X"))."\n";
1104 foreach $p (&prognames("X:U")) {
1105 ($prog, $type) = split ",", $p;
1106 $objstr = &objects($p, "X.o", undef, undef);
1107 print &splitline($prog . ": " . $objstr), "\n";
1108 $libstr = &objects($p, undef, undef, "-lX");
1109 print &splitline("\t\$(CC)" . $mw . " -o \$@ " .
1110 $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
1112 foreach $d (&deps("X.o", undef, $dirpfx, "/", "gtk")) {
1113 if ($forceobj{$d->{obj_orig}}) {
1114 printf("%s: FORCE\n", $d->{obj});
1116 print &splitline(sprintf("%s: %s", $d->{obj},
1117 join " ", @{$d->{deps}})), "\n";
1119 print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
1122 print $makefile_extra{'gtk'}->{'end'};
1124 "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:U")) . "\n";
1125 print "\ndistclean: clean\n".
1126 "\t". &splitline("rm -f config.status config.cache config.log ".
1127 "configure.lineno config.status.lineno Makefile") . "\n";
1129 select STDOUT; close OUT;
1132 if (defined $makefiles{'mpw'}) {
1134 open OUT, ">$makefiles{'mpw'}"; select OUT;
1136 "# Makefile for $project_name under MPW.\n#\n".
1137 "# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1138 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1139 # MPW command line option is -d not /D (FIXME further massaging?)
1140 ($_ = $help) =~ s/([=" ])\/D/\1-d /gs;
1143 "ROptions = `Echo \"{VER}\" | StreamEdit -e \"1,\$ replace /=(\xc5)\xa81\xb0/ 'STR=\xb6\xb6\xb6\xb6\xb6\"' \xa81 '\xb6\xb6\xb6\xb6\xb6\"'\"`".
1148 "C_Carbon = {PPCC}\n".
1150 "# -w 35 disables \"unused parameter\" warnings\n".
1151 "COptions = -i : -i :: -i ::charset -w 35 -w err -proto strict -ansi on \xb6\n".
1153 "COptions_68K = {COptions} -model far -opt time\n".
1154 "# Enabling \"-opt space\" for CFM-68K gives me undefined references to\n".
1155 "# _\$LDIVT and _\$LMODT.\n".
1156 "COptions_CFM68K = {COptions} -model cfmSeg -opt time\n".
1157 "COptions_PPC = {COptions} -opt size -traceback\n".
1158 "COptions_Carbon = {COptions} -opt size -traceback -d TARGET_API_MAC_CARBON\n".
1160 "Link_68K = ILink\n".
1161 "Link_CFM68K = ILink\n".
1162 "Link_PPC = PPCLink\n".
1163 "Link_Carbon = PPCLink\n".
1165 "LinkOptions = -c 'pTTY'\n".
1166 "LinkOptions_68K = {LinkOptions} -br 68k -model far -compact\n".
1167 "LinkOptions_CFM68K = {LinkOptions} -br 020 -model cfmseg -compact\n".
1168 "LinkOptions_PPC = {LinkOptions}\n".
1169 "LinkOptions_Carbon = -m __appstart -w {LinkOptions}\n".
1171 "Libs_68K = \"{CLibraries}StdCLib.far.o\" \xb6\n".
1172 " \"{Libraries}MacRuntime.o\" \xb6\n".
1173 " \"{Libraries}MathLib.far.o\" \xb6\n".
1174 " \"{Libraries}IntEnv.far.o\" \xb6\n".
1175 " \"{Libraries}Interface.o\" \xb6\n".
1176 " \"{Libraries}Navigation.far.o\" \xb6\n".
1177 " \"{Libraries}OpenTransport.o\" \xb6\n".
1178 " \"{Libraries}OpenTransportApp.o\" \xb6\n".
1179 " \"{Libraries}OpenTptInet.o\" \xb6\n".
1180 " \"{Libraries}UnicodeConverterLib.far.o\"\n".
1182 "Libs_CFM = \"{SharedLibraries}InterfaceLib\" \xb6\n".
1183 " \"{SharedLibraries}StdCLib\" \xb6\n".
1184 " \"{SharedLibraries}AppearanceLib\" \xb6\n".
1185 " -weaklib AppearanceLib \xb6\n".
1186 " \"{SharedLibraries}NavigationLib\" \xb6\n".
1187 " -weaklib NavigationLib \xb6\n".
1188 " \"{SharedLibraries}TextCommon\" \xb6\n".
1189 " -weaklib TextCommon \xb6\n".
1190 " \"{SharedLibraries}UnicodeConverter\" \xb6\n".
1191 " -weaklib UnicodeConverter\n".
1193 "Libs_CFM68K = {Libs_CFM} \xb6\n".
1194 " \"{CFM68KLibraries}NuMacRuntime.o\"\n".
1196 "Libs_PPC = {Libs_CFM} \xb6\n".
1197 " \"{SharedLibraries}ControlsLib\" \xb6\n".
1198 " -weaklib ControlsLib \xb6\n".
1199 " \"{SharedLibraries}WindowsLib\" \xb6\n".
1200 " -weaklib WindowsLib \xb6\n".
1201 " \"{SharedLibraries}OpenTransportLib\" \xb6\n".
1202 " -weaklib OTClientLib \xb6\n".
1203 " -weaklib OTClientUtilLib \xb6\n".
1204 " \"{SharedLibraries}OpenTptInternetLib\" \xb6\n".
1205 " -weaklib OTInetClientLib \xb6\n".
1206 " \"{PPCLibraries}StdCRuntime.o\" \xb6\n".
1207 " \"{PPCLibraries}PPCCRuntime.o\" \xb6\n".
1208 " \"{PPCLibraries}CarbonAccessors.o\" \xb6\n".
1209 " \"{PPCLibraries}OpenTransportAppPPC.o\" \xb6\n".
1210 " \"{PPCLibraries}OpenTptInetPPC.o\"\n".
1212 "Libs_Carbon = \"{PPCLibraries}CarbonStdCLib.o\" \xb6\n".
1213 " \"{PPCLibraries}StdCRuntime.o\" \xb6\n".
1214 " \"{PPCLibraries}PPCCRuntime.o\" \xb6\n".
1215 " \"{SharedLibraries}CarbonLib\" \xb6\n".
1216 " \"{SharedLibraries}StdCLib\"\n".
1218 print &splitline("all \xc4 " . join(" ", &progrealnames("M")), undef, "\xb6");
1220 foreach $p (&prognames("M")) {
1221 ($prog, $type) = split ",", $p;
1223 print &splitline("$prog \xc4 $prog.68k $prog.ppc $prog.carbon",
1224 undef, "\xb6"), "\n\n";
1226 $rsrc = &objects($p, "", "X.rsrc", undef);
1228 foreach $arch (qw(68K CFM68K PPC Carbon)) {
1229 $objstr = &objects($p, "X.\L$arch\E.o", "", undef);
1230 print &splitline("$prog.\L$arch\E \xc4 $objstr $rsrc", undef, "\xb6");
1232 print &splitline("\tDuplicate -y $rsrc {Targ}", 69, "\xb6"), "\n";
1233 print &splitline("\t{Link_$arch} -o {Targ} -fragname $prog " .
1234 "{LinkOptions_$arch} " .
1235 $objstr . " {Libs_$arch}", 69, "\xb6"), "\n";
1236 print &splitline("\tSetFile -a BMi {Targ}", 69, "\xb6"), "\n\n";
1240 foreach $d (&deps("", "X.rsrc", "::", ":", "mpw")) {
1241 next unless $d->{obj};
1242 print &splitline(sprintf("%s \xc4 %s", $d->{obj}, join " ", @{$d->{deps}}),
1243 undef, "\xb6"), "\n";
1244 print "\tRez ", $d->{deps}->[0], " -o {Targ} {ROptions}\n\n";
1246 foreach $arch (qw(68K CFM68K)) {
1247 foreach $d (&deps("X.\L$arch\E.o", "", "::", ":", "mpw")) {
1248 next unless $d->{obj};
1249 print &splitline(sprintf("%s \xc4 %s", $d->{obj},
1250 join " ", @{$d->{deps}}),
1251 undef, "\xb6"), "\n";
1252 print "\t{C_$arch} ", $d->{deps}->[0],
1253 " -o {Targ} {COptions_$arch}\n\n";
1256 foreach $arch (qw(PPC Carbon)) {
1257 foreach $d (&deps("X.\L$arch\E.o", "", "::", ":", "mpw")) {
1258 next unless $d->{obj};
1259 print &splitline(sprintf("%s \xc4 %s", $d->{obj},
1260 join " ", @{$d->{deps}}),
1261 undef, "\xb6"), "\n";
1262 # The odd stuff here seems to stop afpd getting confused.
1263 print "\techo -n > {Targ}\n";
1264 print "\tsetfile -t XCOF {Targ}\n";
1265 print "\t{C_$arch} ", $d->{deps}->[0],
1266 " -o {Targ} {COptions_$arch}\n\n";
1269 select STDOUT; close OUT;
1272 if (defined $makefiles{'lcc'}) {
1273 $dirpfx = &dirpfx($makefiles{'lcc'}, "\\");
1276 open OUT, ">$makefiles{'lcc'}"; select OUT;
1278 "# Makefile for $project_name under lcc.\n".
1279 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1280 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1281 # lcc command line option is -D not /D
1282 ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
1286 "# If you rename this file to `Makefile', you should change this line,\n".
1287 "# so that the .rsp files still depend on the correct makefile.\n".
1288 "MAKEFILE = Makefile.lcc\n".
1290 "# C compilation flags\n".
1291 "CFLAGS = -D_WINDOWS " .
1292 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
1294 "# Resource compilation flags\n".
1297 "# Get include directory for resource compiler\n".
1299 $makefile_extra{'lcc'}->{'vars'} .
1301 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
1303 foreach $p (&prognames("G:C")) {
1304 ($prog, $type) = split ",", $p;
1305 $objstr = &objects($p, "X.obj", "X.res", undef);
1306 print &splitline("$prog.exe: " . $objstr ), "\n";
1307 $subsystemtype = undef;
1308 if ($type eq "G") { $subsystemtype = "-subsystem windows"; }
1309 my $libss = "shell32.lib wsock32.lib ws2_32.lib winspool.lib winmm.lib imm32.lib";
1310 print &splitline("\tlcclnk $subsystemtype -o $prog.exe $objstr $libss");
1314 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "lcc")) {
1315 if ($forceobj{$d->{obj_orig}}) {
1316 printf("%s: FORCE\n", $d->{obj});
1318 print &splitline(sprintf("%s: %s", $d->{obj},
1319 join " ", @{$d->{deps}})), "\n";
1321 if ($d->{obj} =~ /\.obj$/) {
1322 print &splitline("\tlcc -O -p6 \$(COMPAT)".
1323 " \$(CFLAGS) \$(XFLAGS) ".$d->{deps}->[0],69)."\n";
1325 print &splitline("\tlrc \$(RCFL) -r \$(RCFLAGS) ".
1326 $d->{deps}->[0],69)."\n";
1330 print $makefile_extra{'lcc'}->{'end'};
1338 select STDOUT; close OUT;
1341 if (defined $makefiles{'osx'}) {
1342 $dirpfx = &dirpfx($makefiles{'osx'}, "/");
1344 ##-- Mac OS X makefile
1345 open OUT, ">$makefiles{'osx'}"; select OUT;
1347 "# Makefile for $project_name under Mac OS X.\n".
1348 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1349 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1350 # gcc command line option is -D not /D
1351 ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
1354 "CC = \$(TOOLPATH)gcc\n".
1356 &splitline("CFLAGS = -O2 -Wall -Werror -g " .
1357 (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
1358 "MLDFLAGS = -framework Cocoa\n".
1361 $makefile_extra{'osx'}->{'vars'} .
1363 &splitline("all:" . join "", map { " $_" } &progrealnames("MX:U")) .
1365 foreach $p (&prognames("MX")) {
1366 ($prog, $type) = split ",", $p;
1367 $objstr = &objects($p, "X.o", undef, undef);
1368 $icon = &special($p, ".icns");
1369 $infoplist = &special($p, "info.plist");
1370 print "${prog}.app:\n\tmkdir -p \$\@\n";
1371 print "${prog}.app/Contents: ${prog}.app\n\tmkdir -p \$\@\n";
1372 print "${prog}.app/Contents/MacOS: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1373 $targets = "${prog}.app/Contents/MacOS/$prog";
1374 if (defined $icon) {
1375 print "${prog}.app/Contents/Resources: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1376 print "${prog}.app/Contents/Resources/${prog}.icns: ${prog}.app/Contents/Resources $icon\n\tcp $icon \$\@\n";
1377 $targets .= " ${prog}.app/Contents/Resources/${prog}.icns";
1379 if (defined $infoplist) {
1380 print "${prog}.app/Contents/Info.plist: ${prog}.app/Contents/Resources $infoplist\n\tcp $infoplist \$\@\n";
1381 $targets .= " ${prog}.app/Contents/Info.plist";
1383 $targets .= " \$(${prog}_extra)";
1384 print &splitline("${prog}: $targets", 69) . "\n\n";
1385 print &splitline("${prog}.app/Contents/MacOS/$prog: ".
1386 "${prog}.app/Contents/MacOS " . $objstr), "\n";
1387 $libstr = &objects($p, undef, undef, "-lX");
1388 print &splitline("\t\$(CC)" . $mw . " \$(MLDFLAGS) -o \$@ " .
1389 $objstr . " $libstr", 69), "\n\n";
1391 foreach $p (&prognames("U")) {
1392 ($prog, $type) = split ",", $p;
1393 $objstr = &objects($p, "X.o", undef, undef);
1394 print &splitline($prog . ": " . $objstr), "\n";
1395 $libstr = &objects($p, undef, undef, "-lX");
1396 print &splitline("\t\$(CC)" . $mw . " \$(ULDFLAGS) -o \$@ " .
1397 $objstr . " $libstr", 69), "\n\n";
1399 foreach $d (&deps("X.o", undef, $dirpfx, "/")) {
1400 if ($forceobj{$d->{obj_orig}}) {
1401 printf("%s: FORCE\n", $d->{obj});
1403 print &splitline(sprintf("%s: %s", $d->{obj},
1404 join " ", @{$d->{deps}})), "\n";
1406 $firstdep = $d->{deps}->[0];
1407 if ($firstdep =~ /\.c$/) {
1408 print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
1409 } elsif ($firstdep =~ /\.m$/) {
1410 print "\t\$(CC) -x objective-c \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
1413 print "\n".$makefile_extra{'osx'}->{'end'};
1415 "\trm -f *.o *.dmg". (join "", map { " $_" } &progrealnames("U")) . "\n".
1419 select STDOUT; close OUT;
1422 if (defined $makefiles{'devcppproj'}) {
1423 $dirpfx = &dirpfx($makefiles{'devcppproj'}, "\\");
1426 ##-- Dev-C++ 5 projects
1428 # Note: All files created in this section are written in binary
1429 # mode to prevent any posibility of misinterpreted line endings.
1430 # I don't know if Dev-C++ is as touchy as MSVC with LF-only line
1431 # endings. But however, CRLF line endings are the common way on
1432 # Win32 machines where Dev-C++ is running.
1433 # Hence, in order for mkfiles.pl to generate CRLF project files
1434 # even when run from Unix, I make sure all files are binary and
1435 # explicitly write the CRLFs.
1437 # Create directories if necessary
1438 mkdir $makefiles{'devcppproj'}
1439 if(! -d $makefiles{'devcppproj'});
1440 chdir $makefiles{'devcppproj'};
1441 @deps = &deps("X.obj", "X.res", $dirpfx, "\\", "devcppproj");
1442 %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;
1443 # Make dir names FAT/NTFS compatible
1444 my @srcdirs = @srcdirs;
1445 for ($i=0; $i<@srcdirs; $i++) {
1446 $srcdirs[$i] =~ s/\//\\/g;
1447 $srcdirs[$i] =~ s/\\$//;
1449 # Create the project files
1450 # Get names of all Windows projects (GUI and console)
1451 my @prognames = &prognames("G:C");
1452 foreach $progname (@prognames) {
1453 create_devcpp_project(\%all_object_deps, $progname);
1456 sub create_devcpp_project {
1457 my ($all_object_deps, $progname) = @_;
1458 # Construct program's dependency info (Taken from 'vcproj', seems to work right here, too.)
1463 %resource_files = ();
1464 @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");
1465 foreach $object_file (@object_files) {
1466 next if defined $seen_objects{$object_file};
1467 $seen_objects{$object_file} = 1;
1468 if($object_file =~ /\.lib$/io) {
1469 $lib_files{$object_file} = 1;
1472 $object_deps = $all_object_deps{$object_file};
1473 foreach $object_dep (@$object_deps) {
1474 if($object_dep =~ /\.c$/io) {
1475 $source_files{$object_dep} = 1;
1478 if($object_dep =~ /\.h$/io) {
1479 $header_files{$object_dep} = 1;
1482 if($object_dep =~ /\.(rc|ico)$/io) {
1483 $resource_files{$object_dep} = 1;
1488 $libs = join " ", sort keys %lib_files;
1489 @source_files = sort keys %source_files;
1490 @header_files = sort keys %header_files;
1491 @resources = sort keys %resource_files;
1492 ($windows_project, $type) = split ",", $progname;
1493 mkdir $windows_project
1494 if(! -d $windows_project);
1495 chdir $windows_project;
1497 $subsys = ($type eq "G") ? "0" : "1"; # 0 = Win32 GUI, 1 = Win32 Console
1498 open OUT, ">$windows_project.dev"; binmode OUT; select OUT;
1500 "# DEV-C++ 5 Project File - $windows_project.dev\r\n".
1501 "# ** DO NOT EDIT **\r\n".
1503 # No difference between DEBUG and RELEASE here as in 'vcproj', because
1504 # Dev-C++ does not support mutiple compilation profiles in one single project.
1505 # (At least I can say this for Dev-C++ 5 Beta)
1507 "FileName=$windows_project.dev\r\n".
1508 "Name=$windows_project\r\n".
1512 # Multimon is disabled here, as Dev-C++ (Version 5 Beta) does not have multimon.h
1513 "Compiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
1514 "CppCompiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
1515 "Includes=" . (join ";", map {"..\\..\\$dirpfx$_"} @srcdirs) . "\r\n".
1516 "Linker=-ladvapi32 -lcomctl32 -lcomdlg32 -lgdi32 -limm32 -lshell32 -luser32 -lwinmm -lwinspool_\@\@_\r\n".
1518 "UnitCount=" . (@source_files + @header_files + @resources) . "\r\n".
1519 "Folders=\"Header Files\",\"Resource Files\",\"Source Files\"\r\n".
1521 "PrivateResource=${windows_project}_private.rc\r\n".
1522 "ResourceIncludes=..\\..\\..\\WINDOWS\r\n".
1523 "MakeIncludes=\r\n".
1524 "Icon=\r\n". # It's ok to leave this blank.
1526 "ObjectOutput=\r\n".
1527 "OverrideOutput=0\r\n".
1528 "OverrideOutputName=$windows_project.exe\r\n".
1529 "HostApplication=\r\n".
1531 "UseCustomMakefile=0\r\n".
1532 "CustomMakefile=\r\n".
1533 "IncludeVersionInfo=0\r\n".
1534 "SupportXPThemes=0\r\n".
1535 "CompilerSet=0\r\n".
1536 "CompilerSettings=0000000000000000000000\r\n".
1539 foreach $source_file (@source_files) {
1541 "[Unit$unit_count]\r\n".
1542 "FileName=..\\..\\$source_file\r\n".
1543 "Folder=Source Files\r\n".
1547 "Priority=1000\r\n".
1548 "OverrideBuildCmd=0\r\n".
1553 foreach $header_file (@header_files) {
1555 "[Unit$unit_count]\r\n".
1556 "FileName=..\\..\\$header_file\r\n".
1557 "Folder=Header Files\r\n".
1559 "CompileCpp=1\r\n". # Dev-C++ want's to compile all header files with both compilers C and C++. It does not hurt.
1561 "Priority=1000\r\n".
1562 "OverrideBuildCmd=0\r\n".
1567 foreach $resource_file (@resources) {
1568 if ($resource_file =~ /.*\.(ico|cur|bmp|dlg|rc2|rct|bin|rgs|gif|jpg|jpeg|jpe)/io) { # Default filter as in 'vcproj'
1569 $Compile = "0"; # Don't compile images and other binary resource files
1573 $CompileCpp = "1"; # Dev-C++ want's to compile all .rc files with both compilers C and C++. It does not hurt.
1576 "[Unit$unit_count]\r\n".
1577 "FileName=..\\..\\$resource_file\r\n".
1578 "Folder=Resource Files\r\n".
1579 "Compile=$Compile\r\n".
1580 "CompileCpp=$CompileCpp\r\n".
1582 "Priority=1000\r\n".
1583 "OverrideBuildCmd=0\r\n".
1588 #Note: By default, [VersionInfo] is not used.
1590 "[VersionInfo]\r\n".
1595 "LanguageID=1033\r\n".
1596 "CharsetID=1252\r\n".
1598 "FileVersion=0.1\r\n".
1599 "FileDescription=\r\n".
1600 "InternalName=\r\n".
1601 "LegalCopyright=\r\n".
1602 "LegalTrademarks=\r\n".
1603 "OriginalFilename=$windows_project.exe\r\n".
1604 "ProductName=$windows_project\r\n".
1605 "ProductVersion=0.1\r\n".
1606 "AutoIncBuildNr=0\r\n";
1607 select STDOUT; close OUT;