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.
22 open IN
, "Recipe" or do {
23 # We want to deal correctly with being run from one of the
24 # subdirs in the source tree. So if we can't find Recipe here,
27 open IN
, "Recipe" or die "unable to open Recipe file\n";
30 # HACK: One of the source files in `charset' is auto-generated by
31 # sbcsgen.pl. We need to generate that _now_, before attempting
32 # dependency analysis.
33 eval 'chdir "charset"; require "sbcsgen.pl"; chdir ".."';
37 $divert = undef; # ref to scalar in which text is currently being put
38 $help = ""; # list of newline-free lines of help text
39 $project_name = "project"; # this is a good enough default
40 %makefiles = (); # maps makefile types to output makefile pathnames
41 %makefile_extra = (); # maps makefile types to extra Makefile text
42 %programs = (); # maps prog name + type letter to listref of objects/resources
43 %groups = (); # maps group name to listref of objects/resources
49 # If we're gathering help text, keep doing so.
50 if (defined $divert) {
51 if ((defined $_[0]) && $_[0] eq "!end") {
58 # Skip comments and blank lines.
59 next if /^\s*#/ or scalar @_ == 0;
61 if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = \
$help; next; }
62 if ($_[0] eq "!end") { $divert = undef; next; }
63 if ($_[0] eq "!name") { $project_name = $_[1]; next; }
64 if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; }
65 if ($_[0] eq "!makefile" and &mfval
($_[1])) { $makefiles{$_[1]}=$_[2]; next;}
66 if ($_[0] eq "!specialobj" and &mfval
($_[1])) { $specialobj{$_[1]}->{$_[2]} = 1; next;}
67 if ($_[0] eq "!cflags" and &mfval
($_[1])) {
68 ($rest = $_) =~ s/^\s*\S+\s+\S+\s+\S+\s*//; # find rest of input line
69 $rest = 1 if $rest eq "";
70 $cflags{$_[1]}->{$_[2]} = $rest;
73 if ($_[0] eq "!forceobj") { $forceobj{$_[1]} = 1; next; }
74 if ($_[0] eq "!begin") {
76 $sect = $_[2] ?
$_[2] : "end";
77 $divert = \
($makefile_extra{$_[1]}->{$sect});
84 # If we're gathering help/verbatim text, keep doing so.
85 if (defined $divert) { ${$divert} .= "$_\n"; next; }
87 next if scalar @_ == 0;
89 # Now we have an ordinary line. See if it's an = line, a : line
94 $listref = $lastlistref;
96 die "$.: unexpected + line\n" if !defined $lastlistref;
97 } elsif ($_[1] eq "=") {
98 $groups{$_[0]} = [] if !defined $groups{$_[0]};
99 $listref = $groups{$_[0]};
101 shift @objs; # eat the group name
102 } elsif ($_[1] eq ":") {
105 shift @objs; # eat the program name
107 die "$.: unrecognised line type\n";
109 shift @objs; # eat the +, the = or the :
111 while (scalar @objs > 0) {
114 foreach $j (@
{$groups{$i}}) { unshift @objs, $j; }
115 } elsif (($i eq "[G]" or $i eq "[C]" or $i eq "[M]" or
116 $i eq "[X]" or $i eq "[U]" or $i eq "[MX]") and defined $prog) {
117 $type = substr($i,1,(length $i)-2);
122 if ($prog and $type) {
123 die "multiple program entries for $prog [$type]\n"
124 if defined $programs{$prog . "," . $type};
125 $programs{$prog . "," . $type} = $listref;
127 $lastlistref = $listref;
132 # Now retrieve the complete list of objects and resource files, and
133 # construct dependency data for them. While we're here, expand the
134 # object list for each program, and complain if its type isn't set.
135 @prognames = sort keys %programs;
138 foreach $i (@prognames) {
139 ($prog, $type) = split ",", $i;
140 # Strip duplicate object names.
142 @list = grep { $status = ($prev ne $_); $prev=$_; $status }
143 sort @
{$programs{$i}};
144 $programs{$i} = [@list];
146 # Dependencies for "x" start with "x.c" or "x.m" (depending on
148 # Dependencies for "x.res" start with "x.rc".
149 # Dependencies for "x.rsrc" start with "x.r".
150 # Both types of file are pushed on the list of files to scan.
151 # Libraries (.lib) don't have dependencies at all.
152 if ($j =~ /^(.*)\.res$/) {
154 $depends{$j} = [$file];
155 push @scanlist, $file;
156 } elsif ($j =~ /^(.*)\.rsrc$/) {
158 $depends{$j} = [$file];
159 push @scanlist, $file;
160 } elsif ($j !~ /\./) {
162 $file = "$j.m" unless &findfile
($file);
163 $depends{$j} = [$file];
164 push @scanlist, $file;
169 # Scan each file on @scanlist and find further inclusions.
170 # Inclusions are given by lines of the form `#include "otherfile"'
171 # (system headers are automatically ignored by this because they'll
172 # be given in angle brackets). Files included by this method are
173 # added back on to @scanlist to be scanned in turn (if not already
176 # Resource scripts (.rc) can also include a file by means of:
177 # - a line # ending `ICON "filename"';
178 # - a line ending `RT_MANIFEST "filename"'.
179 # Files included by this method are not added to @scanlist because
180 # they can never include further files.
182 # In this pass we write out a hash %further which maps a source
183 # file name into a listref containing further source file names.
186 %allsourcefiles = (); # this is wanted by some makefiles
187 while (scalar @scanlist > 0) {
188 $file = shift @scanlist;
189 next if defined $further{$file}; # skip if we've already done it
190 $further{$file} = [];
191 $dirfile = &findfile
($file);
192 $allsourcefiles{$dirfile} = 1;
193 open IN
, "$dirfile" or die "unable to open source file $file\n";
196 /^\s*#include\s+\"([^\"]+)\"/ and do {
197 push @
{$further{$file}}, $1;
201 /(RT_MANIFEST|ICON)\s+\"([^\"]+)\"\s*$/ and do {
202 push @
{$further{$file}}, $2;
209 # Now we're ready to generate the final dependencies section. For
210 # each key in %depends, we must expand the dependencies list by
211 # iteratively adding entries from %further.
212 foreach $i (keys %depends) {
214 @scanlist = @
{$depends{$i}};
215 foreach $i (@scanlist) { $dep{$i} = 1; }
216 while (scalar @scanlist > 0) {
217 $file = shift @scanlist;
218 foreach $j (@
{$further{$file}}) {
221 push @
{$depends{$i}}, $j;
226 # printf "%s: %s\n", $i, join ' ',@{$depends{$i}};
229 # Validation of input.
233 # Returns true if the argument is a known makefile type. Otherwise,
234 # prints a warning and returns false;
235 if (grep { $type eq $_ }
236 ("vc","vcproj","cygwin","borland","lcc","devcppproj","gtk","unix",
240 warn "$.:unknown makefile type '$type'\n";
244 # Utility routines while writing out the Makefiles.
248 return (defined $x) ?
$x : "";
252 my ($path) = shift @_;
253 my ($sep) = shift @_;
257 while (($i = index $path, $sep) >= 0 ||
258 ($j = index $path, "/") >= 0) {
259 if ($i >= 0 and ($j < 0 or $i < $j)) {
260 $path = substr $path, ($i + length $sep);
262 $path = substr $path, ($j + 1);
274 unless (defined $findfilecache{$name}) {
276 foreach $dir (@srcdirs) {
277 if (-f
"$dir$name") {
280 $outdir =~ s/^\.\///;
283 die "multiple instances of source file $name\n" if $i > 1;
284 $findfilecache{$name} = (defined $outdir ?
$outdir . $name : undef);
286 return $findfilecache{$name};
290 my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_;
293 ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ?
$_ : "" } ($otmpl, $rtmpl, $ltmpl);
295 foreach $i (@
{$programs{$prog}}) {
297 if ($i =~ /^(.*)\.(res|rsrc)/) {
299 ($x = $rtmpl) =~ s/X/$y/;
300 } elsif ($i =~ /^(.*)\.lib/) {
302 ($x = $ltmpl) =~ s/X/$y/;
303 } elsif ($i !~ /\./) {
304 ($x = $otmpl) =~ s/X/$i/;
306 push @ret, $x if $x ne "";
308 return join " ", @ret;
312 my ($prog, $suffix) = @_;
315 ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ?
$_ : "" } ($otmpl, $rtmpl, $ltmpl);
317 foreach $i (@
{$programs{$prog}}) {
318 if (substr($i, (length $i) - (length $suffix)) eq $suffix) {
322 return (scalar @ret) ?
(join " ", @ret) : undef;
326 my ($line, $width, $splitchar) = @_;
329 $len = (defined $width ?
$width : 76);
330 $splitchar = (defined $splitchar ?
$splitchar : '\\');
331 while (length $line > $len) {
332 $line =~ /^(.{0,$len})\s(.*)$/ or $line =~ /^(.{$len,}?\s(.*)$/;
334 $result .= " ${splitchar}\n\t\t" if $2 ne '';
338 return $result . $line;
342 my ($otmpl, $rtmpl, $prefix, $dirsep, $mftyp, $depchar, $splitchar) = @_;
348 foreach $i (sort keys %depends) {
349 next if $specialobj{$mftyp}->{$i};
350 if ($i =~ /^(.*)\.(res|rsrc)/) {
351 next if !defined $rtmpl;
353 ($x = $rtmpl) =~ s/X/$y/;
355 ($x = $otmpl) =~ s/X/$i/;
357 @deps = @
{$depends{$i}};
363 push @ret, {obj
=> $x, obj_orig
=> $i, deps
=> [@deps]};
370 my ($n, $prog, $type);
373 foreach $n (@prognames) {
374 ($prog, $type) = split ",", $n;
375 push @ret, $n if index(":$types:", ":$type:") >= 0;
382 my ($n, $prog, $type);
385 foreach $n (@prognames) {
386 ($prog, $type) = split ",", $n;
387 push @ret, $prog if index(":$types:", ":$type:") >= 0;
393 my ($types,$suffix) = @_;
395 # assume that all UNIX programs have a man page
396 if($suffix eq "1" && $types =~ /:X:/) {
397 return map("$_.1", &progrealnames
($types));
402 # Now we're ready to output the actual Makefiles.
404 if (defined $makefiles{'cygwin'}) {
405 $dirpfx = &dirpfx
($makefiles{'cygwin'}, "/");
408 open OUT
, ">$makefiles{'cygwin'}"; select OUT
;
410 "# Makefile for $project_name under cygwin.\n".
411 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
412 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
413 # gcc command line option is -D not /D
414 ($_ = $help) =~ s/([=" ])\/D/$1-D
/gs
;
418 "# You can define this path to point at your tools if you need to\n".
419 "# TOOLPATH = c:\\cygwin\\bin\\ # or similar, if you're running Windows\n".
420 "# TOOLPATH = /pkg/mingw32msvc/i386-mingw32msvc/bin/\n".
421 "CC = \$(TOOLPATH)gcc\n".
422 "RC = \$(TOOLPATH)windres\n".
423 "# Uncomment the following two lines to compile under Winelib\n".
426 "# You may also need to tell windres where to find include files:\n".
427 "# RCINC = --include-dir c:\\cygwin\\include\\\n".
429 &splitline
("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
430 " -D_NO_OLDNAMES -DNO_MULTIMON -DNO_HTMLHELP " .
431 (join " ", map {"-I$dirpfx$_"} @srcdirs)) .
433 "LDFLAGS = -mno-cygwin -s\n".
434 &splitline
("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1".
435 " --define WINVER=0x0400")."\n".
437 $makefile_extra{'cygwin'}->{'vars'} .
441 print &splitline
("all:" . join "", map { " $_.exe" } &progrealnames
("G:C"));
443 foreach $p (&prognames
("G:C")) {
444 ($prog, $type) = split ",", $p;
445 $objstr = &objects
($p, "X.o", "X.res.o", undef);
446 print &splitline
($prog . ".exe: " . $objstr), "\n";
447 my $mw = $type eq "G" ?
" -mwindows" : "";
448 $libstr = &objects
($p, undef, undef, "-lX");
449 print &splitline
("\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " .
450 "-Wl,-Map,$prog.map " .
451 $objstr . " $libstr", 69), "\n\n";
453 foreach $d (&deps
("X.o", "X.res.o", $dirpfx, "/", "cygwin")) {
454 if ($forceobj{$d->{obj_orig
}}) {
455 printf ("%s: FORCE\n", $d->{obj
});
457 print &splitline
(sprintf("%s: %s", $d->{obj
},
458 join " ", @
{$d->{deps
}})), "\n";
460 if ($d->{obj
} =~ /\.res\.o$/) {
461 print "\t\$(RC) \$(RCFL) \$(RCFLAGS) ".$d->{deps
}->[0]." ".$d->{obj
}."\n\n";
463 print "\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c ".$d->{deps
}->[0]."\n\n";
467 print $makefile_extra{'cygwin'}->{'end'};
469 "\trm -f *.o *.exe *.res.o *.map\n".
472 select STDOUT
; close OUT
;
476 ##-- Borland makefile
477 if (defined $makefiles{'borland'}) {
478 $dirpfx = &dirpfx
($makefiles{'borland'}, "\\");
480 %stdlibs = ( # Borland provides many Win32 API libraries intrinsically
492 open OUT
, ">$makefiles{'borland'}"; select OUT
;
494 "# Makefile for $project_name under Borland C.\n".
495 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
496 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
497 # bcc32 command line option is -D not /D
498 ($_ = $help) =~ s/([=" ])\/D/$1-D
/gs
;
502 "# If you rename this file to `Makefile', you should change this line,\n".
503 "# so that the .rsp files still depend on the correct makefile.\n".
504 "MAKEFILE = Makefile.bor\n".
506 "# C compilation flags\n".
507 "CFLAGS = -D_WINDOWS -DWINVER=0x0500\n".
508 "# Resource compilation flags\n".
509 "RCFLAGS = -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401\n".
511 "# Get include directory for resource compiler\n".
513 "BCB = \$(MAKEDIR)\\..\n".
516 $makefile_extra{'borland'}->{'vars'} .
519 &splitline
("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT)".
520 " \$(CFLAGS) \$(XFLAGS) ".
521 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
522 " /c \$*.c",69)."\n".
524 &splitline
("\tbrcc32 \$(RCFL) -i \$(BCB)\\include -r".
525 " \$(RCFLAGS) \$*.rc",69)."\n".
527 print &splitline
("all:" . join "", map { " $_.exe" } &progrealnames
("G:C"));
529 foreach $p (&prognames
("G:C")) {
530 ($prog, $type) = split ",", $p;
531 $objstr = &objects
($p, "X.obj", "X.res", undef);
532 print &splitline
("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
533 my $ap = ($type eq "G") ?
"-aa" : "-ap";
534 print "\tilink32 $ap -Gn -L\$(BCB)\\lib \@$prog.rsp\n\n";
536 foreach $p (&prognames
("G:C")) {
537 ($prog, $type) = split ",", $p;
538 print $prog, ".rsp: \$(MAKEFILE)\n";
539 $objstr = &objects
($p, "X.obj", undef, undef);
540 @objlist = split " ", $objstr;
542 foreach $i (@objlist) {
543 if (length($objlines[$#objlines] . " $i") > 50) {
546 $objlines[$#objlines] .= " $i";
548 $c0w = ($type eq "G") ?
"c0w32" : "c0x32";
549 print "\techo $c0w + > $prog.rsp\n";
550 for ($i=0; $i<=$#objlines; $i++) {
551 $plus = ($i < $#objlines ?
" +" : "");
552 print "\techo$objlines[$i]$plus >> $prog.rsp\n";
554 print "\techo $prog.exe >> $prog.rsp\n";
555 $objstr = &objects
($p, "X.obj", "X.res", undef);
556 @libs = split " ", &objects
($p, undef, undef, "X");
557 @libs = grep { !$stdlibs{$_} } @libs;
558 unshift @libs, "cw32", "import32";
559 $libstr = join ' ', @libs;
560 print "\techo nul,$libstr, >> $prog.rsp\n";
561 print "\techo " . &objects
($p, undef, "X.res", undef) . " >> $prog.rsp\n";
564 foreach $d (&deps
("X.obj", "X.res", $dirpfx, "\\", "borland")) {
565 if ($forceobj{$d->{obj_orig
}}) {
566 printf("%s: FORCE\n", $d->{obj
});
568 print &splitline
(sprintf("%s: %s", $d->{obj
},
569 join " ", @
{$d->{deps
}})), "\n";
573 print $makefile_extra{'borland'}->{'end'};
584 "\t-del *.\$\$\$\$\$\$\n".
587 "\t-rem dummy command\n";
588 select STDOUT
; close OUT
;
591 if (defined $makefiles{'vc'}) {
592 $dirpfx = &dirpfx
($makefiles{'vc'}, "\\");
594 ##-- Visual C++ makefile
595 open OUT
, ">$makefiles{'vc'}"; select OUT
;
597 "# Makefile for $project_name under Visual C.\n".
598 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
599 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
603 "# If you rename this file to `Makefile', you should change this line,\n".
604 "# so that the .rsp files still depend on the correct makefile.\n".
605 "MAKEFILE = Makefile.vc\n".
607 "# C compilation flags\n".
608 "CFLAGS = /nologo /W3 /O1 " .
609 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
610 " /D_WINDOWS /D_WIN32_WINDOWS=0x500 /DWINVER=0x500\n".
611 "LFLAGS = /incremental:no /fixed\n".
612 "RCFLAGS = -DWIN32 -D_WIN32 -DWINVER=0x0400\n".
614 $makefile_extra{'vc'}->{'vars'} .
617 print &splitline
("all:" . join "", map { " $_.exe" } &progrealnames
("G:C"));
619 foreach $p (&prognames
("G:C")) {
620 ($prog, $type) = split ",", $p;
621 $objstr = &objects
($p, "X.obj", "X.res", undef);
622 print &splitline
("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
623 print "\tlink \$(LFLAGS) \$(XLFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n";
625 foreach $p (&prognames
("G:C")) {
626 ($prog, $type) = split ",", $p;
627 print $prog, ".rsp: \$(MAKEFILE)\n";
628 $objstr = &objects
($p, "X.obj", "X.res", "X.lib");
629 @objlist = split " ", $objstr;
631 foreach $i (@objlist) {
632 if (length($objlines[$#objlines] . " $i") > 50) {
635 $objlines[$#objlines] .= " $i";
637 $subsys = ($type eq "G") ?
"windows" : "console";
638 print "\techo /nologo /subsystem:$subsys > $prog.rsp\n";
639 for ($i=0; $i<=$#objlines; $i++) {
640 print "\techo$objlines[$i] >> $prog.rsp\n";
644 foreach $d (&deps
("X.obj", "X.res", $dirpfx, "\\", "vc")) {
645 $extradeps = $forceobj{$d->{obj_orig
}} ?
["*.c","*.h","*.rc"] : [];
646 print &splitline
(sprintf("%s: %s", $d->{obj
},
647 join " ", @
$extradeps, @
{$d->{deps
}})), "\n";
648 if ($d->{obj
} =~ /.obj$/) {
649 print "\tcl \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c ".$d->{deps
}->[0],"\n\n";
651 print "\trc \$(RCFL) -r \$(RCFLAGS) ".$d->{deps
}->[0],"\n\n";
655 print $makefile_extra{'vc'}->{'end'};
656 print "\nclean: tidy\n".
673 "\t-del debug.log\n";
674 select STDOUT
; close OUT
;
677 if (defined $makefiles{'vcproj'}) {
678 $dirpfx = &dirpfx
($makefiles{'vcproj'}, "\\");
682 ##-- MSVC 6 Workspace and projects
684 # Note: All files created in this section are written in binary
685 # mode, because although MSVC's command-line make can deal with
686 # LF-only line endings, MSVC project files really _need_ to be
687 # CRLF. Hence, in order for mkfiles.pl to generate usable project
688 # files even when run from Unix, I make sure all files are binary
689 # and explicitly write the CRLFs.
691 # Create directories if necessary
692 mkdir $makefiles{'vcproj'}
693 if(! -d
$makefiles{'vcproj'});
694 chdir $makefiles{'vcproj'};
695 @deps = &deps
("X.obj", "X.res", $dirpfx, "\\", "vcproj");
696 %all_object_deps = map {$_->{obj
} => $_->{deps
}} @deps;
697 # Create the project files
698 # Get names of all Windows projects (GUI and console)
699 my @prognames = &prognames
("G:C");
700 foreach $progname (@prognames) {
701 create_vc_project
(\
%all_object_deps, $progname);
703 # Create the workspace file
704 open OUT
, ">$project_name.dsw"; binmode OUT
; select OUT
;
706 "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n".
707 "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n".
709 "###############################################################################\r\n".
712 foreach $progname (@prognames) {
713 ($windows_project, $type) = split ",", $progname;
714 print "Project: \"$windows_project\"=\".\\$windows_project\\$windows_project.dsp\" - Package Owner=<4>\r\n";
726 "###############################################################################\r\n".
738 "###############################################################################\r\n".
740 select STDOUT
; close OUT
;
743 sub create_vc_project
{
744 my ($all_object_deps, $progname) = @_;
745 # Construct program's dependency info
750 %resource_files = ();
751 @object_files = split " ", &objects
($progname, "X.obj", "X.res", "X.lib");
752 foreach $object_file (@object_files) {
753 next if defined $seen_objects{$object_file};
754 $seen_objects{$object_file} = 1;
755 if($object_file =~ /\.lib$/io) {
756 $lib_files{$object_file} = 1;
759 $object_deps = $all_object_deps{$object_file};
760 foreach $object_dep (@
$object_deps) {
761 if($object_dep =~ /\.c$/io) {
762 $source_files{$object_dep} = 1;
765 if($object_dep =~ /\.h$/io) {
766 $header_files{$object_dep} = 1;
769 if($object_dep =~ /\.(rc|ico)$/io) {
770 $resource_files{$object_dep} = 1;
775 $libs = join " ", sort keys %lib_files;
776 @source_files = sort keys %source_files;
777 @header_files = sort keys %header_files;
778 @resources = sort keys %resource_files;
779 ($windows_project, $type) = split ",", $progname;
780 mkdir $windows_project
781 if(! -d
$windows_project);
782 chdir $windows_project;
783 $subsys = ($type eq "G") ?
"windows" : "console";
784 open OUT
, ">$windows_project.dsp"; binmode OUT
; select OUT
;
786 "# Microsoft Developer Studio Project File - Name=\"$windows_project\" - Package Owner=<4>\r\n".
787 "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n".
788 "# ** DO NOT EDIT **\r\n".
790 "# TARGTYPE \"Win32 (x86) Application\" 0x0101\r\n".
792 "CFG=$windows_project - Win32 Debug\r\n".
793 "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n".
794 "!MESSAGE use the Export Makefile command and run\r\n".
796 "!MESSAGE NMAKE /f \"$windows_project.mak\".\r\n".
798 "!MESSAGE You can specify a configuration when running NMAKE\r\n".
799 "!MESSAGE by defining the macro CFG on the command line. For example:\r\n".
801 "!MESSAGE NMAKE /f \"$windows_project.mak\" CFG=\"$windows_project - Win32 Debug\"\r\n".
803 "!MESSAGE Possible choices for configuration are:\r\n".
805 "!MESSAGE \"$windows_project - Win32 Release\" (based on \"Win32 (x86) Application\")\r\n".
806 "!MESSAGE \"$windows_project - Win32 Debug\" (based on \"Win32 (x86) Application\")\r\n".
809 "# Begin Project\r\n".
810 "# PROP AllowPerConfigDependencies 0\r\n".
811 "# PROP Scc_ProjName \"\"\r\n".
812 "# PROP Scc_LocalPath \"\"\r\n".
817 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
819 "# PROP BASE Use_MFC 0\r\n".
820 "# PROP BASE Use_Debug_Libraries 0\r\n".
821 "# PROP BASE Output_Dir \"Release\"\r\n".
822 "# PROP BASE Intermediate_Dir \"Release\"\r\n".
823 "# PROP BASE Target_Dir \"\"\r\n".
824 "# PROP Use_MFC 0\r\n".
825 "# PROP Use_Debug_Libraries 0\r\n".
826 "# PROP Output_Dir \"Release\"\r\n".
827 "# PROP Intermediate_Dir \"Release\"\r\n".
828 "# PROP Ignore_Export_Lib 0\r\n".
829 "# PROP Target_Dir \"\"\r\n".
830 "# ADD BASE CPP /nologo /W3 /GX /O2 ".
831 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
832 " /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
833 "# ADD CPP /nologo /W3 /GX /O2 ".
834 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
835 " /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
836 "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
837 "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
838 "# ADD BASE RSC /l 0x809 /d \"NDEBUG\"\r\n".
839 "# ADD RSC /l 0x809 /d \"NDEBUG\"\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 /machine:I386\r\n".
845 "# ADD LINK32 $libs /nologo /subsystem:$subsys /machine:I386\r\n".
846 "# SUBTRACT LINK32 /pdb:none\r\n".
848 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
850 "# PROP BASE Use_MFC 0\r\n".
851 "# PROP BASE Use_Debug_Libraries 1\r\n".
852 "# PROP BASE Output_Dir \"Debug\"\r\n".
853 "# PROP BASE Intermediate_Dir \"Debug\"\r\n".
854 "# PROP BASE Target_Dir \"\"\r\n".
855 "# PROP Use_MFC 0\r\n".
856 "# PROP Use_Debug_Libraries 1\r\n".
857 "# PROP Output_Dir \"Debug\"\r\n".
858 "# PROP Intermediate_Dir \"Debug\"\r\n".
859 "# PROP Ignore_Export_Lib 0\r\n".
860 "# PROP Target_Dir \"\"\r\n".
861 "# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od ".
862 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
863 " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
864 "# ADD CPP /nologo /W3 /Gm /GX /ZI /Od ".
865 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
866 " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
867 "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
868 "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
869 "# ADD BASE RSC /l 0x809 /d \"_DEBUG\"\r\n".
870 "# ADD RSC /l 0x809 /d \"_DEBUG\"\r\n".
871 "BSC32=bscmake.exe\r\n".
872 "# ADD BASE BSC32 /nologo\r\n".
873 "# ADD BSC32 /nologo\r\n".
874 "LINK32=link.exe\r\n".
875 "# 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".
876 "# ADD LINK32 $libs /nologo /subsystem:$subsys /debug /machine:I386 /pdbtype:sept\r\n".
877 "# SUBTRACT LINK32 /pdb:none\r\n".
881 "# Begin Target\r\n".
883 "# Name \"$windows_project - Win32 Release\"\r\n".
884 "# Name \"$windows_project - Win32 Debug\"\r\n".
885 "# Begin Group \"Source Files\"\r\n".
887 "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
888 foreach $source_file (@source_files) {
890 "# Begin Source File\r\n".
892 "SOURCE=..\\..\\$source_file\r\n";
893 if($source_file =~ /ssh\.c/io) {
894 # Disable 'Edit and continue' as Visual Studio can't handle the macros
897 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
899 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
906 print "# End Source File\r\n";
910 "# Begin Group \"Header Files\"\r\n".
912 "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
913 foreach $header_file (@header_files) {
915 "# Begin Source File\r\n".
917 "SOURCE=..\\..\\$header_file\r\n".
918 "# End Source File\r\n";
922 "# Begin Group \"Resource Files\"\r\n".
924 "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
925 foreach $resource_file (@resources) {
927 "# Begin Source File\r\n".
929 "SOURCE=..\\..\\$resource_file\r\n".
930 "# End Source File\r\n";
936 select STDOUT
; close OUT
;
941 if (defined $makefiles{'gtk'}) {
942 $dirpfx = &dirpfx
($makefiles{'gtk'}, "/");
944 ##-- X/GTK/Unix makefile
945 open OUT
, ">$makefiles{'gtk'}"; select OUT
;
947 "# Makefile for $project_name under X/GTK and Unix.\n".
948 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
949 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
950 # gcc command line option is -D not /D
951 ($_ = $help) =~ s/([=" ])\/D/$1-D
/gs
;
955 "# You can define this path to point at your tools if you need to\n".
956 "# TOOLPATH = /opt/gcc/bin\n".
957 "CC = \$(TOOLPATH)cc\n".
958 "# If necessary set the path to krb5-config here\n".
959 "KRB5CONFIG=krb5-config\n".
960 "# You can manually set this to `gtk-config' or `pkg-config gtk+-1.2'\n".
961 "# (depending on what works on your system) if you want to enforce\n".
962 "# building with GTK 1.2, or you can set it to `pkg-config gtk+-2.0 x11'\n".
963 "# if you want to enforce 2.0. The default is to try 2.0 and fall back\n".
964 "# to 1.2 if it isn't found.\n".
965 "GTK_CONFIG = sh -c 'pkg-config gtk+-2.0 x11 \$\$0 2>/dev/null || gtk-config \$\$0'\n".
967 "-include Makefile.local\n".
969 "unexport CFLAGS # work around a weird issue with krb5-config\n".
971 &splitline
("CFLAGS = -O2 -Wall -Werror -g " .
972 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
973 " \$(shell \$(GTK_CONFIG) --cflags)").
974 " -D _FILE_OFFSET_BITS=64\n".
975 "XLDFLAGS = \$(LDFLAGS) \$(shell \$(GTK_CONFIG) --libs)\n".
976 "ULDFLAGS = \$(LDFLAGS)\n".
977 "ifeq (,\$(findstring NO_GSSAPI,\$(COMPAT)))\n".
978 "ifeq (,\$(findstring STATIC_GSSAPI,\$(COMPAT)))\n".
982 "CFLAGS+= -DNO_LIBDL \$(shell \$(KRB5CONFIG) --cflags gssapi)\n".
983 "XLDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
984 "ULDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
988 "INSTALL_PROGRAM=\$(INSTALL)\n".
989 "INSTALL_DATA=\$(INSTALL)\n".
990 "prefix=/usr/local\n".
991 "exec_prefix=\$(prefix)\n".
992 "bindir=\$(exec_prefix)/bin\n".
993 "mandir=\$(prefix)/man\n".
994 "man1dir=\$(mandir)/man1\n".
996 &def
($makefile_extra{'gtk'}->{'vars'}) .
1001 print &splitline
("all:" . join "", map { " $_" } &progrealnames
("X:U"));
1003 foreach $p (&prognames
("X:U")) {
1004 ($prog, $type) = split ",", $p;
1005 $objstr = &objects
($p, "X.o", undef, undef);
1006 print &splitline
($prog . ": " . $objstr), "\n";
1007 $libstr = &objects
($p, undef, undef, "-lX");
1008 print &splitline
("\t\$(CC) -o \$@ " .
1009 $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
1011 foreach $d (&deps
("X.o", undef, $dirpfx, "/", "gtk")) {
1012 if ($forceobj{$d->{obj_orig
}}) {
1013 printf("%s: FORCE\n", $d->{obj
});
1015 print &splitline
(sprintf("%s: %s", $d->{obj
},
1016 join " ", @
{$d->{deps
}})), "\n";
1018 print &splitline
("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
1021 print $makefile_extra{'gtk'}->{'end'};
1023 "\trm -f *.o". (join "", map { " $_" } &progrealnames
("X:U")) . "\n";
1025 select STDOUT
; close OUT
;
1028 if (defined $makefiles{'unix'}) {
1029 $dirpfx = &dirpfx
($makefiles{'unix'}, "/");
1031 ##-- GTK-free pure-Unix makefile for non-GUI apps only
1032 open OUT
, ">$makefiles{'unix'}"; select OUT
;
1034 "# Makefile for $project_name under Unix.\n".
1035 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1036 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1037 # gcc command line option is -D not /D
1038 ($_ = $help) =~ s/([=" ])\/D/$1-D
/gs
;
1042 "# You can define this path to point at your tools if you need to\n".
1043 "# TOOLPATH = /opt/gcc/bin\n".
1044 "CC = \$(TOOLPATH)cc\n".
1046 "-include Makefile.local\n".
1048 "unexport CFLAGS # work around a weird issue with krb5-config\n".
1050 &splitline
("CFLAGS = -O2 -Wall -Werror -g " .
1051 (join " ", map {"-I$dirpfx$_"} @srcdirs)).
1052 " -D _FILE_OFFSET_BITS=64\n".
1053 "ULDFLAGS = \$(LDFLAGS)\n".
1054 "INSTALL=install\n".
1055 "INSTALL_PROGRAM=\$(INSTALL)\n".
1056 "INSTALL_DATA=\$(INSTALL)\n".
1057 "prefix=/usr/local\n".
1058 "exec_prefix=\$(prefix)\n".
1059 "bindir=\$(exec_prefix)/bin\n".
1060 "mandir=\$(prefix)/man\n".
1061 "man1dir=\$(mandir)/man1\n".
1063 &def
($makefile_extra{'unix'}->{'vars'}) .
1068 print &splitline
("all:" . join "", map { " $_" } &progrealnames
("U"));
1070 foreach $p (&prognames
("U")) {
1071 ($prog, $type) = split ",", $p;
1072 $objstr = &objects
($p, "X.o", undef, undef);
1073 print &splitline
($prog . ": " . $objstr), "\n";
1074 $libstr = &objects
($p, undef, undef, "-lX");
1075 print &splitline
("\t\$(CC) -o \$@ " .
1076 $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
1078 foreach $d (&deps
("X.o", undef, $dirpfx, "/", "unix")) {
1079 if ($forceobj{$d->{obj_orig
}}) {
1080 printf("%s: FORCE\n", $d->{obj
});
1082 print &splitline
(sprintf("%s: %s", $d->{obj
},
1083 join " ", @
{$d->{deps
}})), "\n";
1085 print &splitline
("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
1088 print &def
($makefile_extra{'unix'}->{'end'});
1090 "\trm -f *.o". (join "", map { " $_" } &progrealnames
("U")) . "\n";
1092 select STDOUT
; close OUT
;
1095 if (defined $makefiles{'am'}) {
1096 $dirpfx = "\$(srcdir)/" . &dirpfx($makefiles{'am'}, "/");
1098 ##-- Unix/autoconf Makefile.am
1099 open OUT
, ">$makefiles{'am'}"; select OUT
;
1101 "# Makefile.am for $project_name under Unix with Autoconf/Automake.\n".
1102 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1103 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n\n";
1105 # Complete list of source and header files. Not used by the
1106 # auto-generated parts of this makefile, but Recipe might like to
1107 # have it available as a variable so that mandatory-rebuild things
1108 # (version.o) can conveniently be made to depend on it.
1109 @sources = ("allsources", "=",
1110 map {"${dirpfx}$_"} sort keys %allsourcefiles);
1111 print &splitline
(join " ", @sources), "\n\n";
1113 @cliprogs = ("bin_PROGRAMS", "=");
1114 foreach $p (&prognames
("U")) {
1115 ($prog, $type) = split ",", $p;
1116 push @cliprogs, $prog;
1118 @allprogs = @cliprogs;
1119 foreach $p (&prognames
("X")) {
1120 ($prog, $type) = split ",", $p;
1121 push @allprogs, $prog;
1123 print "if HAVE_GTK\n";
1124 print &splitline
(join " ", @allprogs), "\n";
1126 print &splitline
(join " ", @cliprogs), "\n";
1130 foreach $d (&deps
("X", undef, $dirpfx, "/", "am")) {
1131 $objtosrc{$d->{obj
}} = $d->{deps
}->[0];
1134 @amcflags = ("\$(COMPAT)", "\$(XFLAGS)", map {"-I$dirpfx$_"} @srcdirs);
1135 print "if HAVE_GTK\n";
1136 print &splitline
(join " ", "AM_CFLAGS", "=",
1137 "\$(GTK_CFLAGS)", @amcflags), "\n";
1139 print &splitline
(join " ", "AM_CFLAGS", "=", @amcflags), "\n";
1142 %amspeciallibs = ();
1143 foreach $obj (sort { $a cmp $b } keys %{$cflags{'am'}}) {
1144 print "lib${obj}_a_SOURCES = ", $objtosrc{$obj}, "\n";
1145 print &splitline
(join " ", "lib${obj}_a_CFLAGS", "=", @amcflags,
1146 $cflags{'am'}->{$obj}), "\n";
1147 $amspeciallibs{$obj} = "lib${obj}.a";
1149 print &splitline
(join " ", "noinst_LIBRARIES", "=",
1150 sort { $a cmp $b } values %amspeciallibs), "\n\n";
1152 foreach $p (&prognames
("X:U")) {
1153 ($prog, $type) = split ",", $p;
1154 print "if HAVE_GTK\n" if $type eq "X";
1155 @progsources = ("${prog}_SOURCES", "=");
1158 $objstr = &objects
($p, "X", undef, undef);
1159 foreach $obj (split / /,$objstr) {
1160 if ($amspeciallibs{$obj}) {
1161 push @ldadd, $amspeciallibs{$obj};
1163 $sourcefiles{$objtosrc{$obj}} = 1;
1166 push @progsources, sort { $a cmp $b } keys %sourcefiles;
1167 print &splitline
(join " ", @progsources), "\n";
1169 push @ldadd, "\$(GTK_LIBS)";
1172 print &splitline
(join " ", "${prog}_LDADD", "=", @ldadd), "\n";
1174 print "endif\n" if $type eq "X";
1177 print $makefile_extra{'am'}->{'end'};
1178 select STDOUT
; close OUT
;
1181 if (defined $makefiles{'lcc'}) {
1182 $dirpfx = &dirpfx
($makefiles{'lcc'}, "\\");
1185 open OUT
, ">$makefiles{'lcc'}"; select OUT
;
1187 "# Makefile for $project_name under lcc.\n".
1188 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1189 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1190 # lcc command line option is -D not /D
1191 ($_ = $help) =~ s/([=" ])\/D/$1-D
/gs
;
1195 "# If you rename this file to `Makefile', you should change this line,\n".
1196 "# so that the .rsp files still depend on the correct makefile.\n".
1197 "MAKEFILE = Makefile.lcc\n".
1199 "# C compilation flags\n".
1200 "CFLAGS = -D_WINDOWS " .
1201 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
1203 "# Resource compilation flags\n".
1206 "# Get include directory for resource compiler\n".
1208 $makefile_extra{'lcc'}->{'vars'} .
1210 print &splitline
("all:" . join "", map { " $_.exe" } &progrealnames
("G:C"));
1212 foreach $p (&prognames
("G:C")) {
1213 ($prog, $type) = split ",", $p;
1214 $objstr = &objects
($p, "X.obj", "X.res", undef);
1215 print &splitline
("$prog.exe: " . $objstr ), "\n";
1216 $subsystemtype = '';
1217 if ($type eq "G") { $subsystemtype = "-subsystem windows"; }
1218 my $libss = "shell32.lib wsock32.lib ws2_32.lib winspool.lib winmm.lib imm32.lib";
1219 print &splitline
("\tlcclnk $subsystemtype -o $prog.exe $objstr $libss");
1223 foreach $d (&deps
("X.obj", "X.res", $dirpfx, "\\", "lcc")) {
1224 if ($forceobj{$d->{obj_orig
}}) {
1225 printf("%s: FORCE\n", $d->{obj
});
1227 print &splitline
(sprintf("%s: %s", $d->{obj
},
1228 join " ", @
{$d->{deps
}})), "\n";
1230 if ($d->{obj
} =~ /\.obj$/) {
1231 print &splitline
("\tlcc -O -p6 \$(COMPAT)".
1232 " \$(CFLAGS) \$(XFLAGS) ".$d->{deps
}->[0],69)."\n";
1234 print &splitline
("\tlrc \$(RCFL) -r \$(RCFLAGS) ".
1235 $d->{deps
}->[0],69)."\n";
1239 print $makefile_extra{'lcc'}->{'end'};
1247 select STDOUT
; close OUT
;
1250 if (defined $makefiles{'osx'}) {
1251 $dirpfx = &dirpfx
($makefiles{'osx'}, "/");
1253 ##-- Mac OS X makefile
1254 open OUT
, ">$makefiles{'osx'}"; select OUT
;
1256 "# Makefile for $project_name under Mac OS X.\n".
1257 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1258 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1259 # gcc command line option is -D not /D
1260 ($_ = $help) =~ s/([=" ])\/D/$1-D
/gs
;
1263 "CC = \$(TOOLPATH)gcc\n".
1265 &splitline
("CFLAGS = -O2 -Wall -Werror -g " .
1266 (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
1267 "MLDFLAGS = -framework Cocoa\n".
1270 $makefile_extra{'osx'}->{'vars'} .
1272 &splitline
("all:" . join "", map { " $_" } &progrealnames
("MX:U")) .
1274 foreach $p (&prognames
("MX")) {
1275 ($prog, $type) = split ",", $p;
1276 $objstr = &objects
($p, "X.o", undef, undef);
1277 $icon = &special
($p, ".icns");
1278 $infoplist = &special
($p, "info.plist");
1279 print "${prog}.app:\n\tmkdir -p \$\@\n";
1280 print "${prog}.app/Contents: ${prog}.app\n\tmkdir -p \$\@\n";
1281 print "${prog}.app/Contents/MacOS: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1282 $targets = "${prog}.app/Contents/MacOS/$prog";
1283 if (defined $icon) {
1284 print "${prog}.app/Contents/Resources: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1285 print "${prog}.app/Contents/Resources/${prog}.icns: ${prog}.app/Contents/Resources $icon\n\tcp $icon \$\@\n";
1286 $targets .= " ${prog}.app/Contents/Resources/${prog}.icns";
1288 if (defined $infoplist) {
1289 print "${prog}.app/Contents/Info.plist: ${prog}.app/Contents/Resources $infoplist\n\tcp $infoplist \$\@\n";
1290 $targets .= " ${prog}.app/Contents/Info.plist";
1292 $targets .= " \$(${prog}_extra)";
1293 print &splitline
("${prog}: $targets", 69) . "\n\n";
1294 print &splitline
("${prog}.app/Contents/MacOS/$prog: ".
1295 "${prog}.app/Contents/MacOS " . $objstr), "\n";
1296 $libstr = &objects
($p, undef, undef, "-lX");
1297 print &splitline
("\t\$(CC) \$(MLDFLAGS) -o \$@ " .
1298 $objstr . " $libstr", 69), "\n\n";
1300 foreach $p (&prognames
("U")) {
1301 ($prog, $type) = split ",", $p;
1302 $objstr = &objects
($p, "X.o", undef, undef);
1303 print &splitline
($prog . ": " . $objstr), "\n";
1304 $libstr = &objects
($p, undef, undef, "-lX");
1305 print &splitline
("\t\$(CC) \$(ULDFLAGS) -o \$@ " .
1306 $objstr . " $libstr", 69), "\n\n";
1308 foreach $d (&deps
("X.o", undef, $dirpfx, "/", "osx")) {
1309 if ($forceobj{$d->{obj_orig
}}) {
1310 printf("%s: FORCE\n", $d->{obj
});
1312 print &splitline
(sprintf("%s: %s", $d->{obj
},
1313 join " ", @
{$d->{deps
}})), "\n";
1315 $firstdep = $d->{deps
}->[0];
1316 if ($firstdep =~ /\.c$/) {
1317 print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
1318 } elsif ($firstdep =~ /\.m$/) {
1319 print "\t\$(CC) -x objective-c \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
1322 print "\n".&def
($makefile_extra{'osx'}->{'end'});
1324 "\trm -f *.o *.dmg". (join "", map { " $_" } &progrealnames
("U")) . "\n".
1328 select STDOUT
; close OUT
;
1331 if (defined $makefiles{'devcppproj'}) {
1332 $dirpfx = &dirpfx
($makefiles{'devcppproj'}, "\\");
1335 ##-- Dev-C++ 5 projects
1337 # Note: All files created in this section are written in binary
1338 # mode to prevent any posibility of misinterpreted line endings.
1339 # I don't know if Dev-C++ is as touchy as MSVC with LF-only line
1340 # endings. But however, CRLF line endings are the common way on
1341 # Win32 machines where Dev-C++ is running.
1342 # Hence, in order for mkfiles.pl to generate CRLF project files
1343 # even when run from Unix, I make sure all files are binary and
1344 # explicitly write the CRLFs.
1346 # Create directories if necessary
1347 mkdir $makefiles{'devcppproj'}
1348 if(! -d
$makefiles{'devcppproj'});
1349 chdir $makefiles{'devcppproj'};
1350 @deps = &deps
("X.obj", "X.res", $dirpfx, "\\", "devcppproj");
1351 %all_object_deps = map {$_->{obj
} => $_->{deps
}} @deps;
1352 # Make dir names FAT/NTFS compatible
1353 my @srcdirs = @srcdirs;
1354 for ($i=0; $i<@srcdirs; $i++) {
1355 $srcdirs[$i] =~ s/\//\\/g
;
1356 $srcdirs[$i] =~ s/\\$//;
1358 # Create the project files
1359 # Get names of all Windows projects (GUI and console)
1360 my @prognames = &prognames
("G:C");
1361 foreach $progname (@prognames) {
1362 create_devcpp_project
(\
%all_object_deps, $progname);
1365 sub create_devcpp_project
{
1366 my ($all_object_deps, $progname) = @_;
1367 # Construct program's dependency info (Taken from 'vcproj', seems to work right here, too.)
1372 %resource_files = ();
1373 @object_files = split " ", &objects
($progname, "X.obj", "X.res", "X.lib");
1374 foreach $object_file (@object_files) {
1375 next if defined $seen_objects{$object_file};
1376 $seen_objects{$object_file} = 1;
1377 if($object_file =~ /\.lib$/io) {
1378 $lib_files{$object_file} = 1;
1381 $object_deps = $all_object_deps{$object_file};
1382 foreach $object_dep (@
$object_deps) {
1383 if($object_dep =~ /\.c$/io) {
1384 $source_files{$object_dep} = 1;
1387 if($object_dep =~ /\.h$/io) {
1388 $header_files{$object_dep} = 1;
1391 if($object_dep =~ /\.(rc|ico)$/io) {
1392 $resource_files{$object_dep} = 1;
1397 $libs = join " ", sort keys %lib_files;
1398 @source_files = sort keys %source_files;
1399 @header_files = sort keys %header_files;
1400 @resources = sort keys %resource_files;
1401 ($windows_project, $type) = split ",", $progname;
1402 mkdir $windows_project
1403 if(! -d
$windows_project);
1404 chdir $windows_project;
1406 $subsys = ($type eq "G") ?
"0" : "1"; # 0 = Win32 GUI, 1 = Win32 Console
1407 open OUT
, ">$windows_project.dev"; binmode OUT
; select OUT
;
1409 "# DEV-C++ 5 Project File - $windows_project.dev\r\n".
1410 "# ** DO NOT EDIT **\r\n".
1412 # No difference between DEBUG and RELEASE here as in 'vcproj', because
1413 # Dev-C++ does not support mutiple compilation profiles in one single project.
1414 # (At least I can say this for Dev-C++ 5 Beta)
1416 "FileName=$windows_project.dev\r\n".
1417 "Name=$windows_project\r\n".
1421 # Multimon is disabled here, as Dev-C++ (Version 5 Beta) does not have multimon.h
1422 "Compiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
1423 "CppCompiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
1424 "Includes=" . (join ";", map {"..\\..\\$dirpfx$_"} @srcdirs) . "\r\n".
1425 "Linker=-ladvapi32 -lcomctl32 -lcomdlg32 -lgdi32 -limm32 -lshell32 -luser32 -lwinmm -lwinspool_\@\@_\r\n".
1427 "UnitCount=" . (@source_files + @header_files + @resources) . "\r\n".
1428 "Folders=\"Header Files\",\"Resource Files\",\"Source Files\"\r\n".
1430 "PrivateResource=${windows_project}_private.rc\r\n".
1431 "ResourceIncludes=..\\..\\..\\WINDOWS\r\n".
1432 "MakeIncludes=\r\n".
1433 "Icon=\r\n". # It's ok to leave this blank.
1435 "ObjectOutput=\r\n".
1436 "OverrideOutput=0\r\n".
1437 "OverrideOutputName=$windows_project.exe\r\n".
1438 "HostApplication=\r\n".
1440 "UseCustomMakefile=0\r\n".
1441 "CustomMakefile=\r\n".
1442 "IncludeVersionInfo=0\r\n".
1443 "SupportXPThemes=0\r\n".
1444 "CompilerSet=0\r\n".
1445 "CompilerSettings=0000000000000000000000\r\n".
1448 foreach $source_file (@source_files) {
1450 "[Unit$unit_count]\r\n".
1451 "FileName=..\\..\\$source_file\r\n".
1452 "Folder=Source Files\r\n".
1456 "Priority=1000\r\n".
1457 "OverrideBuildCmd=0\r\n".
1462 foreach $header_file (@header_files) {
1464 "[Unit$unit_count]\r\n".
1465 "FileName=..\\..\\$header_file\r\n".
1466 "Folder=Header Files\r\n".
1468 "CompileCpp=1\r\n". # Dev-C++ want's to compile all header files with both compilers C and C++. It does not hurt.
1470 "Priority=1000\r\n".
1471 "OverrideBuildCmd=0\r\n".
1476 foreach $resource_file (@resources) {
1477 if ($resource_file =~ /.*\.(ico|cur|bmp|dlg|rc2|rct|bin|rgs|gif|jpg|jpeg|jpe)/io) { # Default filter as in 'vcproj'
1478 $Compile = "0"; # Don't compile images and other binary resource files
1482 $CompileCpp = "1"; # Dev-C++ want's to compile all .rc files with both compilers C and C++. It does not hurt.
1485 "[Unit$unit_count]\r\n".
1486 "FileName=..\\..\\$resource_file\r\n".
1487 "Folder=Resource Files\r\n".
1488 "Compile=$Compile\r\n".
1489 "CompileCpp=$CompileCpp\r\n".
1491 "Priority=1000\r\n".
1492 "OverrideBuildCmd=0\r\n".
1497 #Note: By default, [VersionInfo] is not used.
1499 "[VersionInfo]\r\n".
1504 "LanguageID=1033\r\n".
1505 "CharsetID=1252\r\n".
1507 "FileVersion=0.1\r\n".
1508 "FileDescription=\r\n".
1509 "InternalName=\r\n".
1510 "LegalCopyright=\r\n".
1511 "LegalTrademarks=\r\n".
1512 "OriginalFilename=$windows_project.exe\r\n".
1513 "ProductName=$windows_project\r\n".
1514 "ProductVersion=0.1\r\n".
1515 "AutoIncBuildNr=0\r\n";
1516 select STDOUT
; close OUT
;