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","ac","mpw",
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(.*)$/;
303 $result .= $1 . " ${splitchar}\n\t\t";
307 return $result . $line;
311 my ($otmpl, $rtmpl, $prefix, $dirsep, $mftyp, $depchar, $splitchar) = @_;
316 foreach $i (sort keys %depends) {
317 next if $specialobj{$mftyp}->{$i};
318 if ($i =~ /^(.*)\.(res|rsrc)/) {
319 next if !defined $rtmpl;
321 ($x = $rtmpl) =~ s/X/$y/;
323 ($x = $otmpl) =~ s/X/$i/;
325 @deps = @{$depends{$i}};
331 push @ret, {obj => $x, obj_orig => $i, deps => [@deps]};
338 my ($n, $prog, $type);
341 foreach $n (@prognames) {
342 ($prog, $type) = split ",", $n;
343 push @ret, $n if index(":$types:", ":$type:") >= 0;
350 my ($n, $prog, $type);
353 foreach $n (@prognames) {
354 ($prog, $type) = split ",", $n;
355 push @ret, $prog if index(":$types:", ":$type:") >= 0;
361 my ($types,$suffix) = @_;
363 # assume that all UNIX programs have a man page
364 if($suffix eq "1" && $types =~ /:X:/) {
365 return map("$_.1", &progrealnames($types));
370 # Now we're ready to output the actual Makefiles.
372 if (defined $makefiles{'cygwin'}) {
373 $dirpfx = &dirpfx($makefiles{'cygwin'}, "/");
376 open OUT, ">$makefiles{'cygwin'}"; select OUT;
378 "# Makefile for $project_name under cygwin.\n".
379 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
380 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
381 # gcc command line option is -D not /D
382 ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
386 "# You can define this path to point at your tools if you need to\n".
387 "# TOOLPATH = c:\\cygwin\\bin\\ # or similar, if you're running Windows\n".
388 "# TOOLPATH = /pkg/mingw32msvc/i386-mingw32msvc/bin/\n".
389 "CC = \$(TOOLPATH)gcc\n".
390 "RC = \$(TOOLPATH)windres\n".
391 "# Uncomment the following two lines to compile under Winelib\n".
394 "# You may also need to tell windres where to find include files:\n".
395 "# RCINC = --include-dir c:\\cygwin\\include\\\n".
397 &splitline("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
398 " -D_NO_OLDNAMES -DNO_MULTIMON " .
399 (join " ", map {"-I$dirpfx$_"} @srcdirs)) .
401 "LDFLAGS = -mno-cygwin -s\n".
402 &splitline("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1".
403 " --define WINVER=0x0400")."\n".
405 $makefile_extra{'cygwin'}->{'vars'} .
409 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
411 foreach $p (&prognames("G:C")) {
412 ($prog, $type) = split ",", $p;
413 $objstr = &objects($p, "X.o", "X.res.o", undef);
414 print &splitline($prog . ".exe: " . $objstr), "\n";
415 my $mw = $type eq "G" ? " -mwindows" : "";
416 $libstr = &objects($p, undef, undef, "-lX");
417 print &splitline("\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " .
418 "-Wl,-Map,$prog.map " .
419 $objstr . " $libstr", 69), "\n\n";
421 foreach $d (&deps("X.o", "X.res.o", $dirpfx, "/", "cygwin")) {
422 if ($forceobj{$d->{obj_orig}}) {
423 printf ("%s: FORCE\n", $d->{obj});
425 print &splitline(sprintf("%s: %s", $d->{obj},
426 join " ", @{$d->{deps}})), "\n";
428 if ($d->{obj} =~ /\.res\.o$/) {
429 print "\t\$(RC) \$(RCFL) \$(RCFLAGS) ".$d->{deps}->[0]." ".$d->{obj}."\n\n";
431 print "\t\$(CC) \$(COMPAT) \$(XFLAGS) \$(CFLAGS) -c ".$d->{deps}->[0]."\n\n";
435 print $makefile_extra{'cygwin'}->{'end'};
437 "\trm -f *.o *.exe *.res.o *.map\n".
440 select STDOUT; close OUT;
444 ##-- Borland makefile
445 if (defined $makefiles{'borland'}) {
446 $dirpfx = &dirpfx($makefiles{'borland'}, "\\");
448 %stdlibs = ( # Borland provides many Win32 API libraries intrinsically
460 open OUT, ">$makefiles{'borland'}"; select OUT;
462 "# Makefile for $project_name under Borland C.\n".
463 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
464 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
465 # bcc32 command line option is -D not /D
466 ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
470 "# If you rename this file to `Makefile', you should change this line,\n".
471 "# so that the .rsp files still depend on the correct makefile.\n".
472 "MAKEFILE = Makefile.bor\n".
474 "# C compilation flags\n".
475 "CFLAGS = -D_WINDOWS -DWINVER=0x0401\n".
476 "# Resource compilation flags\n".
477 "RCFLAGS = -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401\n".
479 "# Get include directory for resource compiler\n".
481 "BCB = \$(MAKEDIR)\\..\n".
484 $makefile_extra{'borland'}->{'vars'} .
487 &splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT)".
488 " \$(XFLAGS) \$(CFLAGS) ".
489 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
490 " /c \$*.c",69)."\n".
492 &splitline("\tbrcc32 \$(RCFL) -i \$(BCB)\\include -r".
493 " \$(RCFLAGS) \$*.rc",69)."\n".
495 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
497 foreach $p (&prognames("G:C")) {
498 ($prog, $type) = split ",", $p;
499 $objstr = &objects($p, "X.obj", "X.res", undef);
500 print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
501 my $ap = ($type eq "G") ? "-aa" : "-ap";
502 print "\tilink32 $ap -Gn -L\$(BCB)\\lib \@$prog.rsp\n\n";
504 foreach $p (&prognames("G:C")) {
505 ($prog, $type) = split ",", $p;
506 print $prog, ".rsp: \$(MAKEFILE)\n";
507 $objstr = &objects($p, "X.obj", undef, undef);
508 @objlist = split " ", $objstr;
510 foreach $i (@objlist) {
511 if (length($objlines[$#objlines] . " $i") > 50) {
514 $objlines[$#objlines] .= " $i";
516 $c0w = ($type eq "G") ? "c0w32" : "c0x32";
517 print "\techo $c0w + > $prog.rsp\n";
518 for ($i=0; $i<=$#objlines; $i++) {
519 $plus = ($i < $#objlines ? " +" : "");
520 print "\techo$objlines[$i]$plus >> $prog.rsp\n";
522 print "\techo $prog.exe >> $prog.rsp\n";
523 $objstr = &objects($p, "X.obj", "X.res", undef);
524 @libs = split " ", &objects($p, undef, undef, "X");
525 @libs = grep { !$stdlibs{$_} } @libs;
526 unshift @libs, "cw32", "import32";
527 $libstr = join ' ', @libs;
528 print "\techo nul,$libstr, >> $prog.rsp\n";
529 print "\techo " . &objects($p, undef, "X.res", undef) . " >> $prog.rsp\n";
532 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "borland")) {
533 if ($forceobj{$d->{obj_orig}}) {
534 printf("%s: FORCE\n", $d->{obj});
536 print &splitline(sprintf("%s: %s", $d->{obj},
537 join " ", @{$d->{deps}})), "\n";
541 print $makefile_extra{'borland'}->{'end'};
552 "\t-del *.\$\$\$\$\$\$\n".
555 "\t-rem dummy command\n";
556 select STDOUT; close OUT;
559 if (defined $makefiles{'vc'}) {
560 $dirpfx = &dirpfx($makefiles{'vc'}, "\\");
562 ##-- Visual C++ makefile
563 open OUT, ">$makefiles{'vc'}"; select OUT;
565 "# Makefile for $project_name under Visual C.\n".
566 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
567 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
571 "# If you rename this file to `Makefile', you should change this line,\n".
572 "# so that the .rsp files still depend on the correct makefile.\n".
573 "MAKEFILE = Makefile.vc\n".
575 "# C compilation flags\n".
576 "CFLAGS = /nologo /W3 /O1 " .
577 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
578 " /D_WINDOWS /D_WIN32_WINDOWS=0x401 /DWINVER=0x401\n".
579 "LFLAGS = /incremental:no /fixed\n".
580 "RCFLAGS = -DWIN32 -D_WIN32 -DWINVER=0x0400\n".
582 $makefile_extra{'vc'}->{'vars'} .
585 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
587 foreach $p (&prognames("G:C")) {
588 ($prog, $type) = split ",", $p;
589 $objstr = &objects($p, "X.obj", "X.res", undef);
590 print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
591 print "\tlink \$(LFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n";
593 foreach $p (&prognames("G:C")) {
594 ($prog, $type) = split ",", $p;
595 print $prog, ".rsp: \$(MAKEFILE)\n";
596 $objstr = &objects($p, "X.obj", "X.res", "X.lib");
597 @objlist = split " ", $objstr;
599 foreach $i (@objlist) {
600 if (length($objlines[$#objlines] . " $i") > 50) {
603 $objlines[$#objlines] .= " $i";
605 $subsys = ($type eq "G") ? "windows" : "console";
606 print "\techo /nologo /subsystem:$subsys > $prog.rsp\n";
607 for ($i=0; $i<=$#objlines; $i++) {
608 print "\techo$objlines[$i] >> $prog.rsp\n";
612 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "vc")) {
613 $extradeps = $forceobj{$d->{obj_orig}} ? ["*.c","*.h","*.rc"] : [];
614 print &splitline(sprintf("%s: %s", $d->{obj},
615 join " ", @$extradeps, @{$d->{deps}})), "\n";
616 if ($d->{obj} =~ /.obj$/) {
617 print "\tcl \$(COMPAT) \$(XFLAGS) \$(CFLAGS) /c ".$d->{deps}->[0],"\n\n";
619 print "\trc \$(RCFL) -r \$(RCFLAGS) ".$d->{deps}->[0],"\n\n";
623 print $makefile_extra{'vc'}->{'end'};
624 print "\nclean: tidy\n".
641 "\t-del debug.log\n";
642 select STDOUT; close OUT;
645 if (defined $makefiles{'vcproj'}) {
646 $dirpfx = &dirpfx($makefiles{'vcproj'}, "\\");
650 ##-- MSVC 6 Workspace and projects
652 # Note: All files created in this section are written in binary
653 # mode, because although MSVC's command-line make can deal with
654 # LF-only line endings, MSVC project files really _need_ to be
655 # CRLF. Hence, in order for mkfiles.pl to generate usable project
656 # files even when run from Unix, I make sure all files are binary
657 # and explicitly write the CRLFs.
659 # Create directories if necessary
660 mkdir $makefiles{'vcproj'}
661 if(! -d $makefiles{'vcproj'});
662 chdir $makefiles{'vcproj'};
663 @deps = &deps("X.obj", "X.res", $dirpfx, "\\", "vcproj");
664 %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;
665 # Create the project files
666 # Get names of all Windows projects (GUI and console)
667 my @prognames = &prognames("G:C");
668 foreach $progname (@prognames) {
669 create_vc_project(\%all_object_deps, $progname);
671 # Create the workspace file
672 open OUT, ">$project_name.dsw"; binmode OUT; select OUT;
674 "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n".
675 "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n".
677 "###############################################################################\r\n".
680 foreach $progname (@prognames) {
681 ($windows_project, $type) = split ",", $progname;
682 print "Project: \"$windows_project\"=\".\\$windows_project\\$windows_project.dsp\" - Package Owner=<4>\r\n";
694 "###############################################################################\r\n".
706 "###############################################################################\r\n".
708 select STDOUT; close OUT;
711 sub create_vc_project {
712 my ($all_object_deps, $progname) = @_;
713 # Construct program's dependency info
718 %resource_files = ();
719 @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");
720 foreach $object_file (@object_files) {
721 next if defined $seen_objects{$object_file};
722 $seen_objects{$object_file} = 1;
723 if($object_file =~ /\.lib$/io) {
724 $lib_files{$object_file} = 1;
727 $object_deps = $all_object_deps{$object_file};
728 foreach $object_dep (@$object_deps) {
729 if($object_dep =~ /\.c$/io) {
730 $source_files{$object_dep} = 1;
733 if($object_dep =~ /\.h$/io) {
734 $header_files{$object_dep} = 1;
737 if($object_dep =~ /\.(rc|ico)$/io) {
738 $resource_files{$object_dep} = 1;
743 $libs = join " ", sort keys %lib_files;
744 @source_files = sort keys %source_files;
745 @header_files = sort keys %header_files;
746 @resources = sort keys %resource_files;
747 ($windows_project, $type) = split ",", $progname;
748 mkdir $windows_project
749 if(! -d $windows_project);
750 chdir $windows_project;
751 $subsys = ($type eq "G") ? "windows" : "console";
752 open OUT, ">$windows_project.dsp"; binmode OUT; select OUT;
754 "# Microsoft Developer Studio Project File - Name=\"$windows_project\" - Package Owner=<4>\r\n".
755 "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n".
756 "# ** DO NOT EDIT **\r\n".
758 "# TARGTYPE \"Win32 (x86) Application\" 0x0101\r\n".
760 "CFG=$windows_project - Win32 Debug\r\n".
761 "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n".
762 "!MESSAGE use the Export Makefile command and run\r\n".
764 "!MESSAGE NMAKE /f \"$windows_project.mak\".\r\n".
766 "!MESSAGE You can specify a configuration when running NMAKE\r\n".
767 "!MESSAGE by defining the macro CFG on the command line. For example:\r\n".
769 "!MESSAGE NMAKE /f \"$windows_project.mak\" CFG=\"$windows_project - Win32 Debug\"\r\n".
771 "!MESSAGE Possible choices for configuration are:\r\n".
773 "!MESSAGE \"$windows_project - Win32 Release\" (based on \"Win32 (x86) Application\")\r\n".
774 "!MESSAGE \"$windows_project - Win32 Debug\" (based on \"Win32 (x86) Application\")\r\n".
777 "# Begin Project\r\n".
778 "# PROP AllowPerConfigDependencies 0\r\n".
779 "# PROP Scc_ProjName \"\"\r\n".
780 "# PROP Scc_LocalPath \"\"\r\n".
785 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
787 "# PROP BASE Use_MFC 0\r\n".
788 "# PROP BASE Use_Debug_Libraries 0\r\n".
789 "# PROP BASE Output_Dir \"Release\"\r\n".
790 "# PROP BASE Intermediate_Dir \"Release\"\r\n".
791 "# PROP BASE Target_Dir \"\"\r\n".
792 "# PROP Use_MFC 0\r\n".
793 "# PROP Use_Debug_Libraries 0\r\n".
794 "# PROP Output_Dir \"Release\"\r\n".
795 "# PROP Intermediate_Dir \"Release\"\r\n".
796 "# PROP Ignore_Export_Lib 0\r\n".
797 "# PROP Target_Dir \"\"\r\n".
798 "# ADD BASE CPP /nologo /W3 /GX /O2 ".
799 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
800 " /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
801 "# ADD CPP /nologo /W3 /GX /O2 ".
802 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
803 " /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
804 "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
805 "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
806 "# ADD BASE RSC /l 0x809 /d \"NDEBUG\"\r\n".
807 "# ADD RSC /l 0x809 /d \"NDEBUG\"\r\n".
808 "BSC32=bscmake.exe\r\n".
809 "# ADD BASE BSC32 /nologo\r\n".
810 "# ADD BSC32 /nologo\r\n".
811 "LINK32=link.exe\r\n".
812 "# 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".
813 "# ADD LINK32 $libs /nologo /subsystem:$subsys /machine:I386\r\n".
814 "# SUBTRACT LINK32 /pdb:none\r\n".
816 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
818 "# PROP BASE Use_MFC 0\r\n".
819 "# PROP BASE Use_Debug_Libraries 1\r\n".
820 "# PROP BASE Output_Dir \"Debug\"\r\n".
821 "# PROP BASE Intermediate_Dir \"Debug\"\r\n".
822 "# PROP BASE Target_Dir \"\"\r\n".
823 "# PROP Use_MFC 0\r\n".
824 "# PROP Use_Debug_Libraries 1\r\n".
825 "# PROP Output_Dir \"Debug\"\r\n".
826 "# PROP Intermediate_Dir \"Debug\"\r\n".
827 "# PROP Ignore_Export_Lib 0\r\n".
828 "# PROP Target_Dir \"\"\r\n".
829 "# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od ".
830 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
831 " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
832 "# ADD CPP /nologo /W3 /Gm /GX /ZI /Od ".
833 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
834 " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
835 "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
836 "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
837 "# ADD BASE RSC /l 0x809 /d \"_DEBUG\"\r\n".
838 "# ADD RSC /l 0x809 /d \"_DEBUG\"\r\n".
839 "BSC32=bscmake.exe\r\n".
840 "# ADD BASE BSC32 /nologo\r\n".
841 "# ADD BSC32 /nologo\r\n".
842 "LINK32=link.exe\r\n".
843 "# 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".
844 "# ADD LINK32 $libs /nologo /subsystem:$subsys /debug /machine:I386 /pdbtype:sept\r\n".
845 "# SUBTRACT LINK32 /pdb:none\r\n".
849 "# Begin Target\r\n".
851 "# Name \"$windows_project - Win32 Release\"\r\n".
852 "# Name \"$windows_project - Win32 Debug\"\r\n".
853 "# Begin Group \"Source Files\"\r\n".
855 "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
856 foreach $source_file (@source_files) {
858 "# Begin Source File\r\n".
860 "SOURCE=..\\..\\$source_file\r\n";
861 if($source_file =~ /ssh\.c/io) {
862 # Disable 'Edit and continue' as Visual Studio can't handle the macros
865 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
867 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
874 print "# End Source File\r\n";
878 "# Begin Group \"Header Files\"\r\n".
880 "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
881 foreach $header_file (@header_files) {
883 "# Begin Source File\r\n".
885 "SOURCE=..\\..\\$header_file\r\n".
886 "# End Source File\r\n";
890 "# Begin Group \"Resource Files\"\r\n".
892 "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
893 foreach $resource_file (@resources) {
895 "# Begin Source File\r\n".
897 "SOURCE=..\\..\\$resource_file\r\n".
898 "# End Source File\r\n";
904 select STDOUT; close OUT;
909 if (defined $makefiles{'gtk'}) {
910 $dirpfx = &dirpfx($makefiles{'gtk'}, "/");
912 ##-- X/GTK/Unix makefile
913 open OUT, ">$makefiles{'gtk'}"; select OUT;
915 "# Makefile for $project_name under X/GTK and Unix.\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";
918 # gcc command line option is -D not /D
919 ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
923 "# You can define this path to point at your tools if you need to\n".
924 "# TOOLPATH = /opt/gcc/bin\n".
925 "CC = \$(TOOLPATH)cc\n".
927 &splitline("CFLAGS = -O2 -Wall -Werror -g " .
928 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
929 " `gtk-config --cflags`")."\n".
930 "XLDFLAGS = `gtk-config --libs`\n".
933 "INSTALL_PROGRAM=\$(INSTALL)\n",
934 "INSTALL_DATA=\$(INSTALL)\n",
935 "prefix=/usr/local\n",
936 "exec_prefix=\$(prefix)\n",
937 "bindir=\$(exec_prefix)/bin\n",
938 "mandir=\$(prefix)/man\n",
939 "man1dir=\$(mandir)/man1\n",
941 $makefile_extra{'gtk'}->{'vars'} .
946 print &splitline("all:" . join "", map { " $_" } &progrealnames("X:U"));
948 foreach $p (&prognames("X:U")) {
949 ($prog, $type) = split ",", $p;
950 $objstr = &objects($p, "X.o", undef, undef);
951 print &splitline($prog . ": " . $objstr), "\n";
952 $libstr = &objects($p, undef, undef, "-lX");
953 print &splitline("\t\$(CC)" . $mw . " \$(${type}LDFLAGS) -o \$@ " .
954 $objstr . " $libstr", 69), "\n\n";
956 foreach $d (&deps("X.o", undef, $dirpfx, "/", "gtk")) {
957 if ($forceobj{$d->{obj_orig}}) {
958 printf("%s: FORCE\n", $d->{obj});
960 print &splitline(sprintf("%s: %s", $d->{obj},
961 join " ", @{$d->{deps}})), "\n";
963 print &splitline("\t\$(CC) \$(COMPAT) \$(XFLAGS) \$(CFLAGS) -c $d->{deps}->[0]\n");
966 print $makefile_extra{'gtk'}->{'end'};
968 "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:U")) . "\n";
970 select STDOUT; close OUT;
973 if (defined $makefiles{'ac'}) {
974 $dirpfx = &dirpfx($makefiles{'ac'}, "/");
976 ##-- Unix/autoconf makefile
977 open OUT, ">$makefiles{'ac'}"; select OUT;
979 "# Makefile.in for $project_name under Unix with Autoconf.\n".
980 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
981 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
982 # gcc command line option is -D not /D
983 ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
989 &splitline("CFLAGS = \@CFLAGS\@ \@CPPFLAGS\@ \@DEFS\@ \@GTK_CFLAGS\@ " .
990 (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
991 "XLDFLAGS = \@LDFLAGS\@ \@LIBS\@ \@GTK_LIBS\@\n".
992 "ULDFLAGS = \@LDFLAGS\@ \@LIBS\@\n".
993 "INSTALL=\@INSTALL\@\n",
994 "INSTALL_PROGRAM=\$(INSTALL)\n",
995 "INSTALL_DATA=\$(INSTALL)\n",
996 "prefix=\@prefix\@\n",
997 "exec_prefix=\@exec_prefix\@\n",
998 "bindir=\@bindir\@\n",
999 "mandir=\@mandir\@\n",
1000 "man1dir=\$(mandir)/man1\n",
1002 $makefile_extra{'gtk'}->{'vars'} .
1007 "all: \@all_targets\@\n".
1008 &splitline("all-cli:" . join "", map { " $_" } &progrealnames("U"))."\n".
1009 &splitline("all-gtk:" . join "", map { " $_" } &progrealnames("X"))."\n";
1011 foreach $p (&prognames("X:U")) {
1012 ($prog, $type) = split ",", $p;
1013 $objstr = &objects($p, "X.o", undef, undef);
1014 print &splitline($prog . ": " . $objstr), "\n";
1015 $libstr = &objects($p, undef, undef, "-lX");
1016 print &splitline("\t\$(CC)" . $mw . " \$(${type}LDFLAGS) -o \$@ " .
1017 $objstr . " $libstr", 69), "\n\n";
1019 foreach $d (&deps("X.o", undef, $dirpfx, "/", "gtk")) {
1020 if ($forceobj{$d->{obj_orig}}) {
1021 printf("%s: FORCE\n", $d->{obj});
1023 print &splitline(sprintf("%s: %s", $d->{obj},
1024 join " ", @{$d->{deps}})), "\n";
1026 print &splitline("\t\$(CC) \$(COMPAT) \$(XFLAGS) \$(CFLAGS) -c $d->{deps}->[0]\n");
1029 print $makefile_extra{'gtk'}->{'end'};
1031 "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:U")) . "\n";
1033 select STDOUT; close OUT;
1036 if (defined $makefiles{'mpw'}) {
1038 open OUT, ">$makefiles{'mpw'}"; select OUT;
1040 "# Makefile for $project_name under MPW.\n#\n".
1041 "# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1042 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1043 # MPW command line option is -d not /D (FIXME further massaging?)
1044 ($_ = $help) =~ s/([=" ])\/D/\1-d /gs;
1047 "ROptions = `Echo \"{VER}\" | StreamEdit -e \"1,\$ replace /=(\xc5)\xa81\xb0/ 'STR=\xb6\xb6\xb6\xb6\xb6\"' \xa81 '\xb6\xb6\xb6\xb6\xb6\"'\"`".
1052 "C_Carbon = {PPCC}\n".
1054 "# -w 35 disables \"unused parameter\" warnings\n".
1055 "COptions = -i : -i :: -i ::charset -w 35 -w err -proto strict -ansi on \xb6\n".
1057 "COptions_68K = {COptions} -model far -opt time\n".
1058 "# Enabling \"-opt space\" for CFM-68K gives me undefined references to\n".
1059 "# _\$LDIVT and _\$LMODT.\n".
1060 "COptions_CFM68K = {COptions} -model cfmSeg -opt time\n".
1061 "COptions_PPC = {COptions} -opt size -traceback\n".
1062 "COptions_Carbon = {COptions} -opt size -traceback -d TARGET_API_MAC_CARBON\n".
1064 "Link_68K = ILink\n".
1065 "Link_CFM68K = ILink\n".
1066 "Link_PPC = PPCLink\n".
1067 "Link_Carbon = PPCLink\n".
1069 "LinkOptions = -c 'pTTY'\n".
1070 "LinkOptions_68K = {LinkOptions} -br 68k -model far -compact\n".
1071 "LinkOptions_CFM68K = {LinkOptions} -br 020 -model cfmseg -compact\n".
1072 "LinkOptions_PPC = {LinkOptions}\n".
1073 "LinkOptions_Carbon = -m __appstart -w {LinkOptions}\n".
1075 "Libs_68K = \"{CLibraries}StdCLib.far.o\" \xb6\n".
1076 " \"{Libraries}MacRuntime.o\" \xb6\n".
1077 " \"{Libraries}MathLib.far.o\" \xb6\n".
1078 " \"{Libraries}IntEnv.far.o\" \xb6\n".
1079 " \"{Libraries}Interface.o\" \xb6\n".
1080 " \"{Libraries}Navigation.far.o\" \xb6\n".
1081 " \"{Libraries}OpenTransport.o\" \xb6\n".
1082 " \"{Libraries}OpenTransportApp.o\" \xb6\n".
1083 " \"{Libraries}OpenTptInet.o\" \xb6\n".
1084 " \"{Libraries}UnicodeConverterLib.far.o\"\n".
1086 "Libs_CFM = \"{SharedLibraries}InterfaceLib\" \xb6\n".
1087 " \"{SharedLibraries}StdCLib\" \xb6\n".
1088 " \"{SharedLibraries}AppearanceLib\" \xb6\n".
1089 " -weaklib AppearanceLib \xb6\n".
1090 " \"{SharedLibraries}NavigationLib\" \xb6\n".
1091 " -weaklib NavigationLib \xb6\n".
1092 " \"{SharedLibraries}TextCommon\" \xb6\n".
1093 " -weaklib TextCommon \xb6\n".
1094 " \"{SharedLibraries}UnicodeConverter\" \xb6\n".
1095 " -weaklib UnicodeConverter\n".
1097 "Libs_CFM68K = {Libs_CFM} \xb6\n".
1098 " \"{CFM68KLibraries}NuMacRuntime.o\"\n".
1100 "Libs_PPC = {Libs_CFM} \xb6\n".
1101 " \"{SharedLibraries}ControlsLib\" \xb6\n".
1102 " -weaklib ControlsLib \xb6\n".
1103 " \"{SharedLibraries}WindowsLib\" \xb6\n".
1104 " -weaklib WindowsLib \xb6\n".
1105 " \"{SharedLibraries}OpenTransportLib\" \xb6\n".
1106 " -weaklib OTClientLib \xb6\n".
1107 " -weaklib OTClientUtilLib \xb6\n".
1108 " \"{SharedLibraries}OpenTptInternetLib\" \xb6\n".
1109 " -weaklib OTInetClientLib \xb6\n".
1110 " \"{PPCLibraries}StdCRuntime.o\" \xb6\n".
1111 " \"{PPCLibraries}PPCCRuntime.o\" \xb6\n".
1112 " \"{PPCLibraries}CarbonAccessors.o\" \xb6\n".
1113 " \"{PPCLibraries}OpenTransportAppPPC.o\" \xb6\n".
1114 " \"{PPCLibraries}OpenTptInetPPC.o\"\n".
1116 "Libs_Carbon = \"{PPCLibraries}CarbonStdCLib.o\" \xb6\n".
1117 " \"{PPCLibraries}StdCRuntime.o\" \xb6\n".
1118 " \"{PPCLibraries}PPCCRuntime.o\" \xb6\n".
1119 " \"{SharedLibraries}CarbonLib\" \xb6\n".
1120 " \"{SharedLibraries}StdCLib\"\n".
1122 print &splitline("all \xc4 " . join(" ", &progrealnames("M")), undef, "\xb6");
1124 foreach $p (&prognames("M")) {
1125 ($prog, $type) = split ",", $p;
1127 print &splitline("$prog \xc4 $prog.68k $prog.ppc $prog.carbon",
1128 undef, "\xb6"), "\n\n";
1130 $rsrc = &objects($p, "", "X.rsrc", undef);
1132 foreach $arch (qw(68K CFM68K PPC Carbon)) {
1133 $objstr = &objects($p, "X.\L$arch\E.o", "", undef);
1134 print &splitline("$prog.\L$arch\E \xc4 $objstr $rsrc", undef, "\xb6");
1136 print &splitline("\tDuplicate -y $rsrc {Targ}", 69, "\xb6"), "\n";
1137 print &splitline("\t{Link_$arch} -o {Targ} -fragname $prog " .
1138 "{LinkOptions_$arch} " .
1139 $objstr . " {Libs_$arch}", 69, "\xb6"), "\n";
1140 print &splitline("\tSetFile -a BMi {Targ}", 69, "\xb6"), "\n\n";
1144 foreach $d (&deps("", "X.rsrc", "::", ":", "mpw")) {
1145 next unless $d->{obj};
1146 print &splitline(sprintf("%s \xc4 %s", $d->{obj}, join " ", @{$d->{deps}}),
1147 undef, "\xb6"), "\n";
1148 print "\tRez ", $d->{deps}->[0], " -o {Targ} {ROptions}\n\n";
1150 foreach $arch (qw(68K CFM68K)) {
1151 foreach $d (&deps("X.\L$arch\E.o", "", "::", ":", "mpw")) {
1152 next unless $d->{obj};
1153 print &splitline(sprintf("%s \xc4 %s", $d->{obj},
1154 join " ", @{$d->{deps}}),
1155 undef, "\xb6"), "\n";
1156 print "\t{C_$arch} ", $d->{deps}->[0],
1157 " -o {Targ} {COptions_$arch}\n\n";
1160 foreach $arch (qw(PPC Carbon)) {
1161 foreach $d (&deps("X.\L$arch\E.o", "", "::", ":", "mpw")) {
1162 next unless $d->{obj};
1163 print &splitline(sprintf("%s \xc4 %s", $d->{obj},
1164 join " ", @{$d->{deps}}),
1165 undef, "\xb6"), "\n";
1166 # The odd stuff here seems to stop afpd getting confused.
1167 print "\techo -n > {Targ}\n";
1168 print "\tsetfile -t XCOF {Targ}\n";
1169 print "\t{C_$arch} ", $d->{deps}->[0],
1170 " -o {Targ} {COptions_$arch}\n\n";
1173 select STDOUT; close OUT;
1176 if (defined $makefiles{'lcc'}) {
1177 $dirpfx = &dirpfx($makefiles{'lcc'}, "\\");
1180 open OUT, ">$makefiles{'lcc'}"; select OUT;
1182 "# Makefile for $project_name under lcc.\n".
1183 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1184 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1185 # lcc command line option is -D not /D
1186 ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
1190 "# If you rename this file to `Makefile', you should change this line,\n".
1191 "# so that the .rsp files still depend on the correct makefile.\n".
1192 "MAKEFILE = Makefile.lcc\n".
1194 "# C compilation flags\n".
1195 "CFLAGS = -D_WINDOWS " .
1196 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
1198 "# Resource compilation flags\n".
1201 "# Get include directory for resource compiler\n".
1203 $makefile_extra{'lcc'}->{'vars'} .
1205 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
1207 foreach $p (&prognames("G:C")) {
1208 ($prog, $type) = split ",", $p;
1209 $objstr = &objects($p, "X.obj", "X.res", undef);
1210 print &splitline("$prog.exe: " . $objstr ), "\n";
1211 $subsystemtype = undef;
1212 if ($type eq "G") { $subsystemtype = "-subsystem windows"; }
1213 my $libss = "shell32.lib wsock32.lib ws2_32.lib winspool.lib winmm.lib imm32.lib";
1214 print &splitline("\tlcclnk $subsystemtype -o $prog.exe $objstr $libss");
1218 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "lcc")) {
1219 if ($forceobj{$d->{obj_orig}}) {
1220 printf("%s: FORCE\n", $d->{obj});
1222 print &splitline(sprintf("%s: %s", $d->{obj},
1223 join " ", @{$d->{deps}})), "\n";
1225 if ($d->{obj} =~ /\.obj$/) {
1226 print &splitline("\tlcc -O -p6 \$(COMPAT)".
1227 " \$(XFLAGS) \$(CFLAGS) ".$d->{deps}->[0],69)."\n";
1229 print &splitline("\tlrc \$(RCFL) -r \$(RCFLAGS) ".
1230 $d->{deps}->[0],69)."\n";
1234 print $makefile_extra{'lcc'}->{'end'};
1242 select STDOUT; close OUT;
1245 if (defined $makefiles{'osx'}) {
1246 $dirpfx = &dirpfx($makefiles{'osx'}, "/");
1248 ##-- Mac OS X makefile
1249 open OUT, ">$makefiles{'osx'}"; select OUT;
1251 "# Makefile for $project_name under Mac OS X.\n".
1252 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1253 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1254 # gcc command line option is -D not /D
1255 ($_ = $help) =~ s/([=" ])\/D/\1-D/gs;
1258 "CC = \$(TOOLPATH)gcc\n".
1260 &splitline("CFLAGS = -O2 -Wall -Werror -g " .
1261 (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
1262 "MLDFLAGS = -framework Cocoa\n".
1265 $makefile_extra{'osx'}->{'vars'} .
1267 &splitline("all:" . join "", map { " $_" } &progrealnames("MX:U")) .
1269 foreach $p (&prognames("MX")) {
1270 ($prog, $type) = split ",", $p;
1271 $objstr = &objects($p, "X.o", undef, undef);
1272 $icon = &special($p, ".icns");
1273 $infoplist = &special($p, "info.plist");
1274 print "${prog}.app:\n\tmkdir -p \$\@\n";
1275 print "${prog}.app/Contents: ${prog}.app\n\tmkdir -p \$\@\n";
1276 print "${prog}.app/Contents/MacOS: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1277 $targets = "${prog}.app/Contents/MacOS/$prog";
1278 if (defined $icon) {
1279 print "${prog}.app/Contents/Resources: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1280 print "${prog}.app/Contents/Resources/${prog}.icns: ${prog}.app/Contents/Resources $icon\n\tcp $icon \$\@\n";
1281 $targets .= " ${prog}.app/Contents/Resources/${prog}.icns";
1283 if (defined $infoplist) {
1284 print "${prog}.app/Contents/Info.plist: ${prog}.app/Contents/Resources $infoplist\n\tcp $infoplist \$\@\n";
1285 $targets .= " ${prog}.app/Contents/Info.plist";
1287 $targets .= " \$(${prog}_extra)";
1288 print &splitline("${prog}: $targets", 69) . "\n\n";
1289 print &splitline("${prog}.app/Contents/MacOS/$prog: ".
1290 "${prog}.app/Contents/MacOS " . $objstr), "\n";
1291 $libstr = &objects($p, undef, undef, "-lX");
1292 print &splitline("\t\$(CC)" . $mw . " \$(MLDFLAGS) -o \$@ " .
1293 $objstr . " $libstr", 69), "\n\n";
1295 foreach $p (&prognames("U")) {
1296 ($prog, $type) = split ",", $p;
1297 $objstr = &objects($p, "X.o", undef, undef);
1298 print &splitline($prog . ": " . $objstr), "\n";
1299 $libstr = &objects($p, undef, undef, "-lX");
1300 print &splitline("\t\$(CC)" . $mw . " \$(ULDFLAGS) -o \$@ " .
1301 $objstr . " $libstr", 69), "\n\n";
1303 foreach $d (&deps("X.o", undef, $dirpfx, "/")) {
1304 if ($forceobj{$d->{obj_orig}}) {
1305 printf("%s: FORCE\n", $d->{obj});
1307 print &splitline(sprintf("%s: %s", $d->{obj},
1308 join " ", @{$d->{deps}})), "\n";
1310 $firstdep = $d->{deps}->[0];
1311 if ($firstdep =~ /\.c$/) {
1312 print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) -c \$<\n";
1313 } elsif ($firstdep =~ /\.m$/) {
1314 print "\t\$(CC) -x objective-c \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) -c \$<\n";
1317 print "\n".$makefile_extra{'osx'}->{'end'};
1319 "\trm -f *.o *.dmg". (join "", map { " $_" } &progrealnames("U")) . "\n".
1323 select STDOUT; close OUT;
1326 if (defined $makefiles{'devcppproj'}) {
1327 $dirpfx = &dirpfx($makefiles{'devcppproj'}, "\\");
1330 ##-- Dev-C++ 5 projects
1332 # Note: All files created in this section are written in binary
1333 # mode to prevent any posibility of misinterpreted line endings.
1334 # I don't know if Dev-C++ is as touchy as MSVC with LF-only line
1335 # endings. But however, CRLF line endings are the common way on
1336 # Win32 machines where Dev-C++ is running.
1337 # Hence, in order for mkfiles.pl to generate CRLF project files
1338 # even when run from Unix, I make sure all files are binary and
1339 # explicitly write the CRLFs.
1341 # Create directories if necessary
1342 mkdir $makefiles{'devcppproj'}
1343 if(! -d $makefiles{'devcppproj'});
1344 chdir $makefiles{'devcppproj'};
1345 @deps = &deps("X.obj", "X.res", $dirpfx, "\\", "devcppproj");
1346 %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;
1347 # Make dir names FAT/NTFS compatible
1348 my @srcdirs = @srcdirs;
1349 for ($i=0; $i<@srcdirs; $i++) {
1350 $srcdirs[$i] =~ s/\//\\/g;
1351 $srcdirs[$i] =~ s/\\$//;
1353 # Create the project files
1354 # Get names of all Windows projects (GUI and console)
1355 my @prognames = &prognames("G:C");
1356 foreach $progname (@prognames) {
1357 create_devcpp_project(\%all_object_deps, $progname);
1360 sub create_devcpp_project {
1361 my ($all_object_deps, $progname) = @_;
1362 # Construct program's dependency info (Taken from 'vcproj', seems to work right here, too.)
1367 %resource_files = ();
1368 @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");
1369 foreach $object_file (@object_files) {
1370 next if defined $seen_objects{$object_file};
1371 $seen_objects{$object_file} = 1;
1372 if($object_file =~ /\.lib$/io) {
1373 $lib_files{$object_file} = 1;
1376 $object_deps = $all_object_deps{$object_file};
1377 foreach $object_dep (@$object_deps) {
1378 if($object_dep =~ /\.c$/io) {
1379 $source_files{$object_dep} = 1;
1382 if($object_dep =~ /\.h$/io) {
1383 $header_files{$object_dep} = 1;
1386 if($object_dep =~ /\.(rc|ico)$/io) {
1387 $resource_files{$object_dep} = 1;
1392 $libs = join " ", sort keys %lib_files;
1393 @source_files = sort keys %source_files;
1394 @header_files = sort keys %header_files;
1395 @resources = sort keys %resource_files;
1396 ($windows_project, $type) = split ",", $progname;
1397 mkdir $windows_project
1398 if(! -d $windows_project);
1399 chdir $windows_project;
1401 $subsys = ($type eq "G") ? "0" : "1"; # 0 = Win32 GUI, 1 = Win32 Console
1402 open OUT, ">$windows_project.dev"; binmode OUT; select OUT;
1404 "# DEV-C++ 5 Project File - $windows_project.dev\r\n".
1405 "# ** DO NOT EDIT **\r\n".
1407 # No difference between DEBUG and RELEASE here as in 'vcproj', because
1408 # Dev-C++ does not support mutiple compilation profiles in one single project.
1409 # (At least I can say this for Dev-C++ 5 Beta)
1411 "FileName=$windows_project.dev\r\n".
1412 "Name=$windows_project\r\n".
1416 # Multimon is disabled here, as Dev-C++ (Version 5 Beta) does not have multimon.h
1417 "Compiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
1418 "CppCompiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
1419 "Includes=" . (join ";", map {"..\\..\\$dirpfx$_"} @srcdirs) . "\r\n".
1420 "Linker=-ladvapi32 -lcomctl32 -lcomdlg32 -lgdi32 -limm32 -lshell32 -luser32 -lwinmm -lwinspool_\@\@_\r\n".
1422 "UnitCount=" . (@source_files + @header_files + @resources) . "\r\n".
1423 "Folders=\"Header Files\",\"Resource Files\",\"Source Files\"\r\n".
1425 "PrivateResource=${windows_project}_private.rc\r\n".
1426 "ResourceIncludes=..\\..\\..\\WINDOWS\r\n".
1427 "MakeIncludes=\r\n".
1428 "Icon=\r\n". # It's ok to leave this blank.
1430 "ObjectOutput=\r\n".
1431 "OverrideOutput=0\r\n".
1432 "OverrideOutputName=$windows_project.exe\r\n".
1433 "HostApplication=\r\n".
1435 "UseCustomMakefile=0\r\n".
1436 "CustomMakefile=\r\n".
1437 "IncludeVersionInfo=0\r\n".
1438 "SupportXPThemes=0\r\n".
1439 "CompilerSet=0\r\n".
1440 "CompilerSettings=0000000000000000000000\r\n".
1443 foreach $source_file (@source_files) {
1445 "[Unit$unit_count]\r\n".
1446 "FileName=..\\..\\$source_file\r\n".
1447 "Folder=Source Files\r\n".
1451 "Priority=1000\r\n".
1452 "OverrideBuildCmd=0\r\n".
1457 foreach $header_file (@header_files) {
1459 "[Unit$unit_count]\r\n".
1460 "FileName=..\\..\\$header_file\r\n".
1461 "Folder=Header Files\r\n".
1463 "CompileCpp=1\r\n". # Dev-C++ want's to compile all header files with both compilers C and C++. It does not hurt.
1465 "Priority=1000\r\n".
1466 "OverrideBuildCmd=0\r\n".
1471 foreach $resource_file (@resources) {
1472 if ($resource_file =~ /.*\.(ico|cur|bmp|dlg|rc2|rct|bin|rgs|gif|jpg|jpeg|jpe)/io) { # Default filter as in 'vcproj'
1473 $Compile = "0"; # Don't compile images and other binary resource files
1477 $CompileCpp = "1"; # Dev-C++ want's to compile all .rc files with both compilers C and C++. It does not hurt.
1480 "[Unit$unit_count]\r\n".
1481 "FileName=..\\..\\$resource_file\r\n".
1482 "Folder=Resource Files\r\n".
1483 "Compile=$Compile\r\n".
1484 "CompileCpp=$CompileCpp\r\n".
1486 "Priority=1000\r\n".
1487 "OverrideBuildCmd=0\r\n".
1492 #Note: By default, [VersionInfo] is not used.
1494 "[VersionInfo]\r\n".
1499 "LanguageID=1033\r\n".
1500 "CharsetID=1252\r\n".
1502 "FileVersion=0.1\r\n".
1503 "FileDescription=\r\n".
1504 "InternalName=\r\n".
1505 "LegalCopyright=\r\n".
1506 "LegalTrademarks=\r\n".
1507 "OriginalFilename=$windows_project.exe\r\n".
1508 "ProductName=$windows_project\r\n".
1509 "ProductVersion=0.1\r\n".
1510 "AutoIncBuildNr=0\r\n";
1511 select STDOUT; close OUT;