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.
23 if ($#ARGV >= 0 and ($ARGV[0] eq "-u" or $ARGV[0] eq "-U")) {
24 # Convenience for Unix users: -u means that after we finish what
25 # we're doing here, we also run mkauto.sh and then 'configure' in
26 # the Unix subdirectory. So it's a one-stop shop for regenerating
27 # the actual end-product Unix makefile.
29 # Arguments supplied after -u go to configure.
31 # -U is identical, but runs 'configure' at the _top_ level, for
32 # people who habitually do that.
33 $do_unix = ($ARGV[0] eq "-U" ?
2 : 1);
38 open IN
, "Recipe" or do {
39 # We want to deal correctly with being run from one of the
40 # subdirs in the source tree. So if we can't find Recipe here,
43 open IN
, "Recipe" or die "unable to open Recipe file\n";
46 # HACK: One of the source files in `charset' is auto-generated by
47 # sbcsgen.pl. We need to generate that _now_, before attempting
48 # dependency analysis.
49 eval 'chdir "charset"; require "sbcsgen.pl"; chdir ".."';
53 $divert = undef; # ref to scalar in which text is currently being put
54 $help = ""; # list of newline-free lines of help text
55 $project_name = "project"; # this is a good enough default
56 %makefiles = (); # maps makefile types to output makefile pathnames
57 %makefile_extra = (); # maps makefile types to extra Makefile text
58 %programs = (); # maps prog name + type letter to listref of objects/resources
59 %groups = (); # maps group name to listref of objects/resources
65 # If we're gathering help text, keep doing so.
66 if (defined $divert) {
67 if ((defined $_[0]) && $_[0] eq "!end") {
74 # Skip comments and blank lines.
75 next if /^\s*#/ or scalar @_ == 0;
77 if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = \
$help; next; }
78 if ($_[0] eq "!end") { $divert = undef; next; }
79 if ($_[0] eq "!name") { $project_name = $_[1]; next; }
80 if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; }
81 if ($_[0] eq "!makefile" and &mfval
($_[1])) { $makefiles{$_[1]}=$_[2]; next;}
82 if ($_[0] eq "!specialobj" and &mfval
($_[1])) { $specialobj{$_[1]}->{$_[2]} = 1; next;}
83 if ($_[0] eq "!cflags" and &mfval
($_[1])) {
84 ($rest = $_) =~ s/^\s*\S+\s+\S+\s+\S+\s*//; # find rest of input line
85 $rest = 1 if $rest eq "";
86 $cflags{$_[1]}->{$_[2]} = $rest;
89 if ($_[0] eq "!forceobj") { $forceobj{$_[1]} = 1; next; }
90 if ($_[0] eq "!begin") {
92 $sect = $_[2] ?
$_[2] : "end";
93 $divert = \
($makefile_extra{$_[1]}->{$sect});
100 # If we're gathering help/verbatim text, keep doing so.
101 if (defined $divert) { ${$divert} .= "$_\n"; next; }
102 # Ignore blank lines.
103 next if scalar @_ == 0;
105 # Now we have an ordinary line. See if it's an = line, a : line
110 $listref = $lastlistref;
112 die "$.: unexpected + line\n" if !defined $lastlistref;
113 } elsif ($_[1] eq "=") {
114 $groups{$_[0]} = [] if !defined $groups{$_[0]};
115 $listref = $groups{$_[0]};
117 shift @objs; # eat the group name
118 } elsif ($_[1] eq ":") {
121 shift @objs; # eat the program name
123 die "$.: unrecognised line type\n";
125 shift @objs; # eat the +, the = or the :
127 while (scalar @objs > 0) {
130 foreach $j (@
{$groups{$i}}) { unshift @objs, $j; }
131 } elsif (($i eq "[G]" or $i eq "[C]" or $i eq "[M]" or
132 $i eq "[X]" or $i eq "[U]" or $i eq "[MX]") and defined $prog) {
133 $type = substr($i,1,(length $i)-2);
138 if ($prog and $type) {
139 die "multiple program entries for $prog [$type]\n"
140 if defined $programs{$prog . "," . $type};
141 $programs{$prog . "," . $type} = $listref;
143 $lastlistref = $listref;
148 # Now retrieve the complete list of objects and resource files, and
149 # construct dependency data for them. While we're here, expand the
150 # object list for each program, and complain if its type isn't set.
151 @prognames = sort keys %programs;
154 foreach $i (@prognames) {
155 ($prog, $type) = split ",", $i;
156 # Strip duplicate object names.
158 @list = grep { $status = ($prev ne $_); $prev=$_; $status }
159 sort @
{$programs{$i}};
160 $programs{$i} = [@list];
162 # Dependencies for "x" start with "x.c" or "x.m" (depending on
164 # Dependencies for "x.res" start with "x.rc".
165 # Dependencies for "x.rsrc" start with "x.r".
166 # Both types of file are pushed on the list of files to scan.
167 # Libraries (.lib) don't have dependencies at all.
168 if ($j =~ /^(.*)\.res$/) {
170 $depends{$j} = [$file];
171 push @scanlist, $file;
172 } elsif ($j =~ /^(.*)\.rsrc$/) {
174 $depends{$j} = [$file];
175 push @scanlist, $file;
176 } elsif ($j !~ /\./) {
178 $file = "$j.m" unless &findfile
($file);
179 $depends{$j} = [$file];
180 push @scanlist, $file;
185 # Scan each file on @scanlist and find further inclusions.
186 # Inclusions are given by lines of the form `#include "otherfile"'
187 # (system headers are automatically ignored by this because they'll
188 # be given in angle brackets). Files included by this method are
189 # added back on to @scanlist to be scanned in turn (if not already
192 # Resource scripts (.rc) can also include a file by means of:
193 # - a line # ending `ICON "filename"';
194 # - a line ending `RT_MANIFEST "filename"'.
195 # Files included by this method are not added to @scanlist because
196 # they can never include further files.
198 # In this pass we write out a hash %further which maps a source
199 # file name into a listref containing further source file names.
202 %allsourcefiles = (); # this is wanted by some makefiles
203 while (scalar @scanlist > 0) {
204 $file = shift @scanlist;
205 next if defined $further{$file}; # skip if we've already done it
206 $further{$file} = [];
207 $dirfile = &findfile
($file);
208 $allsourcefiles{$dirfile} = 1;
209 open IN
, "$dirfile" or die "unable to open source file $file\n";
212 /^\s*#include\s+\"([^\"]+)\"/ and do {
213 push @
{$further{$file}}, $1;
217 /(RT_MANIFEST|ICON)\s+\"([^\"]+)\"\s*$/ and do {
218 push @
{$further{$file}}, $2;
225 # Now we're ready to generate the final dependencies section. For
226 # each key in %depends, we must expand the dependencies list by
227 # iteratively adding entries from %further.
228 foreach $i (keys %depends) {
230 @scanlist = @
{$depends{$i}};
231 foreach $i (@scanlist) { $dep{$i} = 1; }
232 while (scalar @scanlist > 0) {
233 $file = shift @scanlist;
234 foreach $j (@
{$further{$file}}) {
237 push @
{$depends{$i}}, $j;
242 # printf "%s: %s\n", $i, join ' ',@{$depends{$i}};
245 # Validation of input.
249 # Returns true if the argument is a known makefile type. Otherwise,
250 # prints a warning and returns false;
251 if (grep { $type eq $_ }
252 ("vc","vcproj","cygwin","borland","lcc","devcppproj","gtk","unix",
256 warn "$.:unknown makefile type '$type'\n";
260 # Utility routines while writing out the Makefiles.
264 return (defined $x) ?
$x : "";
268 my ($path) = shift @_;
269 my ($sep) = shift @_;
273 while (($i = index $path, $sep) >= 0 ||
274 ($j = index $path, "/") >= 0) {
275 if ($i >= 0 and ($j < 0 or $i < $j)) {
276 $path = substr $path, ($i + length $sep);
278 $path = substr $path, ($j + 1);
290 unless (defined $findfilecache{$name}) {
292 foreach $dir (@srcdirs) {
293 if (-f
"$dir$name") {
296 $outdir =~ s/^\.\///;
299 die "multiple instances of source file $name\n" if $i > 1;
300 $findfilecache{$name} = (defined $outdir ?
$outdir . $name : undef);
302 return $findfilecache{$name};
306 my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_;
309 ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ?
$_ : "" } ($otmpl, $rtmpl, $ltmpl);
311 foreach $i (@
{$programs{$prog}}) {
313 if ($i =~ /^(.*)\.(res|rsrc)/) {
315 ($x = $rtmpl) =~ s/X/$y/;
316 } elsif ($i =~ /^(.*)\.lib/) {
318 ($x = $ltmpl) =~ s/X/$y/;
319 } elsif ($i !~ /\./) {
320 ($x = $otmpl) =~ s/X/$i/;
322 push @ret, $x if $x ne "";
324 return join " ", @ret;
328 my ($prog, $suffix) = @_;
331 ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ?
$_ : "" } ($otmpl, $rtmpl, $ltmpl);
333 foreach $i (@
{$programs{$prog}}) {
334 if (substr($i, (length $i) - (length $suffix)) eq $suffix) {
338 return (scalar @ret) ?
(join " ", @ret) : undef;
342 my ($line, $width, $splitchar) = @_;
345 $len = (defined $width ?
$width : 76);
346 $splitchar = (defined $splitchar ?
$splitchar : '\\');
347 while (length $line > $len) {
348 $line =~ /^(.{0,$len})\s(.*)$/ or $line =~ /^(.{$len,}?\s(.*)$/;
350 $result .= " ${splitchar}\n\t\t" if $2 ne '';
354 return $result . $line;
358 my ($otmpl, $rtmpl, $prefix, $dirsep, $mftyp, $depchar, $splitchar) = @_;
364 foreach $i (sort keys %depends) {
365 next if $specialobj{$mftyp}->{$i};
366 if ($i =~ /^(.*)\.(res|rsrc)/) {
367 next if !defined $rtmpl;
369 ($x = $rtmpl) =~ s/X/$y/;
371 ($x = $otmpl) =~ s/X/$i/;
373 @deps = @
{$depends{$i}};
379 push @ret, {obj
=> $x, obj_orig
=> $i, deps
=> [@deps]};
386 my ($n, $prog, $type);
389 foreach $n (@prognames) {
390 ($prog, $type) = split ",", $n;
391 push @ret, $n if index(":$types:", ":$type:") >= 0;
398 my ($n, $prog, $type);
401 foreach $n (@prognames) {
402 ($prog, $type) = split ",", $n;
403 push @ret, $prog if index(":$types:", ":$type:") >= 0;
409 my ($types,$suffix) = @_;
411 # assume that all UNIX programs have a man page
412 if($suffix eq "1" && $types =~ /:X:/) {
413 return map("$_.1", &progrealnames
($types));
420 # Now we're ready to output the actual Makefiles.
422 if (defined $makefiles{'cygwin'}) {
423 $dirpfx = &dirpfx
($makefiles{'cygwin'}, "/");
426 open OUT
, ">$makefiles{'cygwin'}"; select OUT
;
428 "# Makefile for $project_name under cygwin.\n".
429 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
430 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
431 # gcc command line option is -D not /D
432 ($_ = $help) =~ s/([=" ])\/D/$1-D
/gs
;
436 "# You can define this path to point at your tools if you need to\n".
437 "# TOOLPATH = c:\\cygwin\\bin\\ # or similar, if you're running Windows\n".
438 "# TOOLPATH = /pkg/mingw32msvc/i386-mingw32msvc/bin/\n".
439 "CC = \$(TOOLPATH)gcc\n".
440 "RC = \$(TOOLPATH)windres\n".
441 "# Uncomment the following two lines to compile under Winelib\n".
444 "# You may also need to tell windres where to find include files:\n".
445 "# RCINC = --include-dir c:\\cygwin\\include\\\n".
447 &splitline
("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
448 " -D_NO_OLDNAMES -DNO_MULTIMON -DNO_HTMLHELP " .
449 (join " ", map {"-I$dirpfx$_"} @srcdirs)) .
451 "LDFLAGS = -mno-cygwin -s\n".
452 &splitline
("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1".
453 " --define WINVER=0x0400")."\n".
455 $makefile_extra{'cygwin'}->{'vars'} .
459 print &splitline
("all:" . join "", map { " $_.exe" } &progrealnames
("G:C"));
461 foreach $p (&prognames
("G:C")) {
462 ($prog, $type) = split ",", $p;
463 $objstr = &objects
($p, "X.o", "X.res.o", undef);
464 print &splitline
($prog . ".exe: " . $objstr), "\n";
465 my $mw = $type eq "G" ?
" -mwindows" : "";
466 $libstr = &objects
($p, undef, undef, "-lX");
467 print &splitline
("\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " .
468 "-Wl,-Map,$prog.map " .
469 $objstr . " $libstr", 69), "\n\n";
471 foreach $d (&deps
("X.o", "X.res.o", $dirpfx, "/", "cygwin")) {
472 if ($forceobj{$d->{obj_orig
}}) {
473 printf ("%s: FORCE\n", $d->{obj
});
475 print &splitline
(sprintf("%s: %s", $d->{obj
},
476 join " ", @
{$d->{deps
}})), "\n";
478 if ($d->{obj
} =~ /\.res\.o$/) {
479 print "\t\$(RC) \$(RCFL) \$(RCFLAGS) ".$d->{deps
}->[0]." ".$d->{obj
}."\n\n";
481 print "\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c ".$d->{deps
}->[0]."\n\n";
485 print $makefile_extra{'cygwin'}->{'end'};
487 "\trm -f *.o *.exe *.res.o *.map\n".
490 select STDOUT
; close OUT
;
494 ##-- Borland makefile
495 if (defined $makefiles{'borland'}) {
496 $dirpfx = &dirpfx
($makefiles{'borland'}, "\\");
498 %stdlibs = ( # Borland provides many Win32 API libraries intrinsically
510 open OUT
, ">$makefiles{'borland'}"; select OUT
;
512 "# Makefile for $project_name under Borland C.\n".
513 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
514 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
515 # bcc32 command line option is -D not /D
516 ($_ = $help) =~ s/([=" ])\/D/$1-D
/gs
;
520 "# If you rename this file to `Makefile', you should change this line,\n".
521 "# so that the .rsp files still depend on the correct makefile.\n".
522 "MAKEFILE = Makefile.bor\n".
524 "# C compilation flags\n".
525 "CFLAGS = -D_WINDOWS -DWINVER=0x0500\n".
526 "# Resource compilation flags\n".
527 "RCFLAGS = -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401\n".
529 "# Get include directory for resource compiler\n".
531 "BCB = \$(MAKEDIR)\\..\n".
534 $makefile_extra{'borland'}->{'vars'} .
537 &splitline
("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT)".
538 " \$(CFLAGS) \$(XFLAGS) ".
539 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
540 " /c \$*.c",69)."\n".
542 &splitline
("\tbrcc32 \$(RCFL) -i \$(BCB)\\include -r".
543 " \$(RCFLAGS) \$*.rc",69)."\n".
545 print &splitline
("all:" . join "", map { " $_.exe" } &progrealnames
("G:C"));
547 foreach $p (&prognames
("G:C")) {
548 ($prog, $type) = split ",", $p;
549 $objstr = &objects
($p, "X.obj", "X.res", undef);
550 print &splitline
("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
551 my $ap = ($type eq "G") ?
"-aa" : "-ap";
552 print "\tilink32 $ap -Gn -L\$(BCB)\\lib \@$prog.rsp\n\n";
554 foreach $p (&prognames
("G:C")) {
555 ($prog, $type) = split ",", $p;
556 print $prog, ".rsp: \$(MAKEFILE)\n";
557 $objstr = &objects
($p, "X.obj", undef, undef);
558 @objlist = split " ", $objstr;
560 foreach $i (@objlist) {
561 if (length($objlines[$#objlines] . " $i") > 50) {
564 $objlines[$#objlines] .= " $i";
566 $c0w = ($type eq "G") ?
"c0w32" : "c0x32";
567 print "\techo $c0w + > $prog.rsp\n";
568 for ($i=0; $i<=$#objlines; $i++) {
569 $plus = ($i < $#objlines ?
" +" : "");
570 print "\techo$objlines[$i]$plus >> $prog.rsp\n";
572 print "\techo $prog.exe >> $prog.rsp\n";
573 $objstr = &objects
($p, "X.obj", "X.res", undef);
574 @libs = split " ", &objects
($p, undef, undef, "X");
575 @libs = grep { !$stdlibs{$_} } @libs;
576 unshift @libs, "cw32", "import32";
577 $libstr = join ' ', @libs;
578 print "\techo nul,$libstr, >> $prog.rsp\n";
579 print "\techo " . &objects
($p, undef, "X.res", undef) . " >> $prog.rsp\n";
582 foreach $d (&deps
("X.obj", "X.res", $dirpfx, "\\", "borland")) {
583 if ($forceobj{$d->{obj_orig
}}) {
584 printf("%s: FORCE\n", $d->{obj
});
586 print &splitline
(sprintf("%s: %s", $d->{obj
},
587 join " ", @
{$d->{deps
}})), "\n";
591 print $makefile_extra{'borland'}->{'end'};
602 "\t-del *.\$\$\$\$\$\$\n".
605 "\t-rem dummy command\n";
606 select STDOUT
; close OUT
;
609 if (defined $makefiles{'vc'}) {
610 $dirpfx = &dirpfx
($makefiles{'vc'}, "\\");
612 ##-- Visual C++ makefile
613 open OUT
, ">$makefiles{'vc'}"; select OUT
;
615 "# Makefile for $project_name under Visual C.\n".
616 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
617 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
621 "# If you rename this file to `Makefile', you should change this line,\n".
622 "# so that the .rsp files still depend on the correct makefile.\n".
623 "MAKEFILE = Makefile.vc\n".
625 "# C compilation flags\n".
626 "CFLAGS = /nologo /W3 /O1 " .
627 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
628 " /D_WINDOWS /D_WIN32_WINDOWS=0x500 /DWINVER=0x500\n".
629 "LFLAGS = /incremental:no /fixed\n".
630 "RCFLAGS = -DWIN32 -D_WIN32 -DWINVER=0x0400\n".
632 $makefile_extra{'vc'}->{'vars'} .
635 print &splitline
("all:" . join "", map { " $_.exe" } &progrealnames
("G:C"));
637 foreach $p (&prognames
("G:C")) {
638 ($prog, $type) = split ",", $p;
639 $objstr = &objects
($p, "X.obj", "X.res", undef);
640 print &splitline
("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
641 print "\tlink \$(LFLAGS) \$(XLFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n";
643 foreach $p (&prognames
("G:C")) {
644 ($prog, $type) = split ",", $p;
645 print $prog, ".rsp: \$(MAKEFILE)\n";
646 $objstr = &objects
($p, "X.obj", "X.res", "X.lib");
647 @objlist = split " ", $objstr;
649 foreach $i (@objlist) {
650 if (length($objlines[$#objlines] . " $i") > 50) {
653 $objlines[$#objlines] .= " $i";
655 $subsys = ($type eq "G") ?
"windows" : "console";
656 print "\techo /nologo /subsystem:$subsys > $prog.rsp\n";
657 for ($i=0; $i<=$#objlines; $i++) {
658 print "\techo$objlines[$i] >> $prog.rsp\n";
662 foreach $d (&deps
("X.obj", "X.res", $dirpfx, "\\", "vc")) {
663 $extradeps = $forceobj{$d->{obj_orig
}} ?
["*.c","*.h","*.rc"] : [];
664 print &splitline
(sprintf("%s: %s", $d->{obj
},
665 join " ", @
$extradeps, @
{$d->{deps
}})), "\n";
666 if ($d->{obj
} =~ /.obj$/) {
667 print "\tcl \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c ".$d->{deps
}->[0],"\n\n";
669 print "\trc \$(RCFL) -r \$(RCFLAGS) ".$d->{deps
}->[0],"\n\n";
673 print $makefile_extra{'vc'}->{'end'};
674 print "\nclean: tidy\n".
691 "\t-del debug.log\n";
692 select STDOUT
; close OUT
;
695 if (defined $makefiles{'vcproj'}) {
696 $dirpfx = &dirpfx
($makefiles{'vcproj'}, "\\");
698 ##-- MSVC 6 Workspace and projects
700 # Note: All files created in this section are written in binary
701 # mode, because although MSVC's command-line make can deal with
702 # LF-only line endings, MSVC project files really _need_ to be
703 # CRLF. Hence, in order for mkfiles.pl to generate usable project
704 # files even when run from Unix, I make sure all files are binary
705 # and explicitly write the CRLFs.
707 # Create directories if necessary
708 mkdir $makefiles{'vcproj'}
709 if(! -d
$makefiles{'vcproj'});
710 chdir $makefiles{'vcproj'};
711 @deps = &deps
("X.obj", "X.res", $dirpfx, "\\", "vcproj");
712 %all_object_deps = map {$_->{obj
} => $_->{deps
}} @deps;
713 # Create the project files
714 # Get names of all Windows projects (GUI and console)
715 my @prognames = &prognames
("G:C");
716 foreach $progname (@prognames) {
717 create_vc_project
(\
%all_object_deps, $progname);
719 # Create the workspace file
720 open OUT
, ">$project_name.dsw"; binmode OUT
; select OUT
;
722 "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n".
723 "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n".
725 "###############################################################################\r\n".
728 foreach $progname (@prognames) {
729 ($windows_project, $type) = split ",", $progname;
730 print "Project: \"$windows_project\"=\".\\$windows_project\\$windows_project.dsp\" - Package Owner=<4>\r\n";
742 "###############################################################################\r\n".
754 "###############################################################################\r\n".
756 select STDOUT
; close OUT
;
759 sub create_vc_project
{
760 my ($all_object_deps, $progname) = @_;
761 # Construct program's dependency info
766 %resource_files = ();
767 @object_files = split " ", &objects
($progname, "X.obj", "X.res", "X.lib");
768 foreach $object_file (@object_files) {
769 next if defined $seen_objects{$object_file};
770 $seen_objects{$object_file} = 1;
771 if($object_file =~ /\.lib$/io) {
772 $lib_files{$object_file} = 1;
775 $object_deps = $all_object_deps{$object_file};
776 foreach $object_dep (@
$object_deps) {
777 if($object_dep =~ /\.c$/io) {
778 $source_files{$object_dep} = 1;
781 if($object_dep =~ /\.h$/io) {
782 $header_files{$object_dep} = 1;
785 if($object_dep =~ /\.(rc|ico)$/io) {
786 $resource_files{$object_dep} = 1;
791 $libs = join " ", sort keys %lib_files;
792 @source_files = sort keys %source_files;
793 @header_files = sort keys %header_files;
794 @resources = sort keys %resource_files;
795 ($windows_project, $type) = split ",", $progname;
796 mkdir $windows_project
797 if(! -d
$windows_project);
798 chdir $windows_project;
799 $subsys = ($type eq "G") ?
"windows" : "console";
800 open OUT
, ">$windows_project.dsp"; binmode OUT
; select OUT
;
802 "# Microsoft Developer Studio Project File - Name=\"$windows_project\" - Package Owner=<4>\r\n".
803 "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n".
804 "# ** DO NOT EDIT **\r\n".
806 "# TARGTYPE \"Win32 (x86) Application\" 0x0101\r\n".
808 "CFG=$windows_project - Win32 Debug\r\n".
809 "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n".
810 "!MESSAGE use the Export Makefile command and run\r\n".
812 "!MESSAGE NMAKE /f \"$windows_project.mak\".\r\n".
814 "!MESSAGE You can specify a configuration when running NMAKE\r\n".
815 "!MESSAGE by defining the macro CFG on the command line. For example:\r\n".
817 "!MESSAGE NMAKE /f \"$windows_project.mak\" CFG=\"$windows_project - Win32 Debug\"\r\n".
819 "!MESSAGE Possible choices for configuration are:\r\n".
821 "!MESSAGE \"$windows_project - Win32 Release\" (based on \"Win32 (x86) Application\")\r\n".
822 "!MESSAGE \"$windows_project - Win32 Debug\" (based on \"Win32 (x86) Application\")\r\n".
825 "# Begin Project\r\n".
826 "# PROP AllowPerConfigDependencies 0\r\n".
827 "# PROP Scc_ProjName \"\"\r\n".
828 "# PROP Scc_LocalPath \"\"\r\n".
833 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
835 "# PROP BASE Use_MFC 0\r\n".
836 "# PROP BASE Use_Debug_Libraries 0\r\n".
837 "# PROP BASE Output_Dir \"Release\"\r\n".
838 "# PROP BASE Intermediate_Dir \"Release\"\r\n".
839 "# PROP BASE Target_Dir \"\"\r\n".
840 "# PROP Use_MFC 0\r\n".
841 "# PROP Use_Debug_Libraries 0\r\n".
842 "# PROP Output_Dir \"Release\"\r\n".
843 "# PROP Intermediate_Dir \"Release\"\r\n".
844 "# PROP Ignore_Export_Lib 0\r\n".
845 "# PROP Target_Dir \"\"\r\n".
846 "# ADD BASE CPP /nologo /W3 /GX /O2 ".
847 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
848 " /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
849 "# ADD CPP /nologo /W3 /GX /O2 ".
850 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
851 " /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
852 "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
853 "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
854 "# ADD BASE RSC /l 0x809 /d \"NDEBUG\"\r\n".
855 "# ADD RSC /l 0x809 /d \"NDEBUG\"\r\n".
856 "BSC32=bscmake.exe\r\n".
857 "# ADD BASE BSC32 /nologo\r\n".
858 "# ADD BSC32 /nologo\r\n".
859 "LINK32=link.exe\r\n".
860 "# 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".
861 "# ADD LINK32 $libs /nologo /subsystem:$subsys /machine:I386\r\n".
862 "# SUBTRACT LINK32 /pdb:none\r\n".
864 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
866 "# PROP BASE Use_MFC 0\r\n".
867 "# PROP BASE Use_Debug_Libraries 1\r\n".
868 "# PROP BASE Output_Dir \"Debug\"\r\n".
869 "# PROP BASE Intermediate_Dir \"Debug\"\r\n".
870 "# PROP BASE Target_Dir \"\"\r\n".
871 "# PROP Use_MFC 0\r\n".
872 "# PROP Use_Debug_Libraries 1\r\n".
873 "# PROP Output_Dir \"Debug\"\r\n".
874 "# PROP Intermediate_Dir \"Debug\"\r\n".
875 "# PROP Ignore_Export_Lib 0\r\n".
876 "# PROP Target_Dir \"\"\r\n".
877 "# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od ".
878 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
879 " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
880 "# ADD CPP /nologo /W3 /Gm /GX /ZI /Od ".
881 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
882 " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
883 "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
884 "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
885 "# ADD BASE RSC /l 0x809 /d \"_DEBUG\"\r\n".
886 "# ADD RSC /l 0x809 /d \"_DEBUG\"\r\n".
887 "BSC32=bscmake.exe\r\n".
888 "# ADD BASE BSC32 /nologo\r\n".
889 "# ADD BSC32 /nologo\r\n".
890 "LINK32=link.exe\r\n".
891 "# 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".
892 "# ADD LINK32 $libs /nologo /subsystem:$subsys /debug /machine:I386 /pdbtype:sept\r\n".
893 "# SUBTRACT LINK32 /pdb:none\r\n".
897 "# Begin Target\r\n".
899 "# Name \"$windows_project - Win32 Release\"\r\n".
900 "# Name \"$windows_project - Win32 Debug\"\r\n".
901 "# Begin Group \"Source Files\"\r\n".
903 "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
904 foreach $source_file (@source_files) {
906 "# Begin Source File\r\n".
908 "SOURCE=..\\..\\$source_file\r\n";
909 if($source_file =~ /ssh\.c/io) {
910 # Disable 'Edit and continue' as Visual Studio can't handle the macros
913 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
915 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
922 print "# End Source File\r\n";
926 "# Begin Group \"Header Files\"\r\n".
928 "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
929 foreach $header_file (@header_files) {
931 "# Begin Source File\r\n".
933 "SOURCE=..\\..\\$header_file\r\n".
934 "# End Source File\r\n";
938 "# Begin Group \"Resource Files\"\r\n".
940 "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
941 foreach $resource_file (@resources) {
943 "# Begin Source File\r\n".
945 "SOURCE=..\\..\\$resource_file\r\n".
946 "# End Source File\r\n";
952 select STDOUT
; close OUT
;
957 if (defined $makefiles{'gtk'}) {
958 $dirpfx = &dirpfx
($makefiles{'gtk'}, "/");
960 ##-- X/GTK/Unix makefile
961 open OUT
, ">$makefiles{'gtk'}"; select OUT
;
963 "# Makefile for $project_name under X/GTK and Unix.\n".
964 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
965 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
966 # gcc command line option is -D not /D
967 ($_ = $help) =~ s/([=" ])\/D/$1-D
/gs
;
971 "# You can define this path to point at your tools if you need to\n".
972 "# TOOLPATH = /opt/gcc/bin\n".
973 "CC = \$(TOOLPATH)cc\n".
974 "# If necessary set the path to krb5-config here\n".
975 "KRB5CONFIG=krb5-config\n".
976 "# You can manually set this to `gtk-config' or `pkg-config gtk+-1.2'\n".
977 "# (depending on what works on your system) if you want to enforce\n".
978 "# building with GTK 1.2, or you can set it to `pkg-config gtk+-2.0 x11'\n".
979 "# if you want to enforce 2.0. The default is to try 2.0 and fall back\n".
980 "# to 1.2 if it isn't found.\n".
981 "GTK_CONFIG = sh -c 'pkg-config gtk+-2.0 x11 \$\$0 2>/dev/null || gtk-config \$\$0'\n".
983 "-include Makefile.local\n".
985 "unexport CFLAGS # work around a weird issue with krb5-config\n".
987 &splitline
("CFLAGS = -O2 -Wall -Werror -g " .
988 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
989 " \$(shell \$(GTK_CONFIG) --cflags)").
990 " -D _FILE_OFFSET_BITS=64\n".
991 "XLDFLAGS = \$(LDFLAGS) \$(shell \$(GTK_CONFIG) --libs)\n".
992 "ULDFLAGS = \$(LDFLAGS)\n".
993 "ifeq (,\$(findstring NO_GSSAPI,\$(COMPAT)))\n".
994 "ifeq (,\$(findstring STATIC_GSSAPI,\$(COMPAT)))\n".
998 "CFLAGS+= -DNO_LIBDL \$(shell \$(KRB5CONFIG) --cflags gssapi)\n".
999 "XLDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
1000 "ULDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
1003 "INSTALL=install\n".
1004 "INSTALL_PROGRAM=\$(INSTALL)\n".
1005 "INSTALL_DATA=\$(INSTALL)\n".
1006 "prefix=/usr/local\n".
1007 "exec_prefix=\$(prefix)\n".
1008 "bindir=\$(exec_prefix)/bin\n".
1009 "mandir=\$(prefix)/man\n".
1010 "man1dir=\$(mandir)/man1\n".
1012 &def
($makefile_extra{'gtk'}->{'vars'}) .
1017 print &splitline
("all:" . join "", map { " $_" } &progrealnames
("X:U"));
1019 foreach $p (&prognames
("X:U")) {
1020 ($prog, $type) = split ",", $p;
1021 $objstr = &objects
($p, "X.o", undef, undef);
1022 print &splitline
($prog . ": " . $objstr), "\n";
1023 $libstr = &objects
($p, undef, undef, "-lX");
1024 print &splitline
("\t\$(CC) -o \$@ " .
1025 $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
1027 foreach $d (&deps
("X.o", undef, $dirpfx, "/", "gtk")) {
1028 if ($forceobj{$d->{obj_orig
}}) {
1029 printf("%s: FORCE\n", $d->{obj
});
1031 print &splitline
(sprintf("%s: %s", $d->{obj
},
1032 join " ", @
{$d->{deps
}})), "\n";
1034 print &splitline
("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
1037 print $makefile_extra{'gtk'}->{'end'};
1039 "\trm -f *.o". (join "", map { " $_" } &progrealnames
("X:U")) . "\n";
1041 select STDOUT
; close OUT
;
1044 if (defined $makefiles{'unix'}) {
1045 $dirpfx = &dirpfx
($makefiles{'unix'}, "/");
1047 ##-- GTK-free pure-Unix makefile for non-GUI apps only
1048 open OUT
, ">$makefiles{'unix'}"; select OUT
;
1050 "# Makefile for $project_name under Unix.\n".
1051 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1052 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1053 # gcc command line option is -D not /D
1054 ($_ = $help) =~ s/([=" ])\/D/$1-D
/gs
;
1058 "# You can define this path to point at your tools if you need to\n".
1059 "# TOOLPATH = /opt/gcc/bin\n".
1060 "CC = \$(TOOLPATH)cc\n".
1062 "-include Makefile.local\n".
1064 "unexport CFLAGS # work around a weird issue with krb5-config\n".
1066 &splitline
("CFLAGS = -O2 -Wall -Werror -g " .
1067 (join " ", map {"-I$dirpfx$_"} @srcdirs)).
1068 " -D _FILE_OFFSET_BITS=64\n".
1069 "ULDFLAGS = \$(LDFLAGS)\n".
1070 "INSTALL=install\n".
1071 "INSTALL_PROGRAM=\$(INSTALL)\n".
1072 "INSTALL_DATA=\$(INSTALL)\n".
1073 "prefix=/usr/local\n".
1074 "exec_prefix=\$(prefix)\n".
1075 "bindir=\$(exec_prefix)/bin\n".
1076 "mandir=\$(prefix)/man\n".
1077 "man1dir=\$(mandir)/man1\n".
1079 &def
($makefile_extra{'unix'}->{'vars'}) .
1084 print &splitline
("all:" . join "", map { " $_" } &progrealnames
("U"));
1086 foreach $p (&prognames
("U")) {
1087 ($prog, $type) = split ",", $p;
1088 $objstr = &objects
($p, "X.o", undef, undef);
1089 print &splitline
($prog . ": " . $objstr), "\n";
1090 $libstr = &objects
($p, undef, undef, "-lX");
1091 print &splitline
("\t\$(CC) -o \$@ " .
1092 $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
1094 foreach $d (&deps
("X.o", undef, $dirpfx, "/", "unix")) {
1095 if ($forceobj{$d->{obj_orig
}}) {
1096 printf("%s: FORCE\n", $d->{obj
});
1098 print &splitline
(sprintf("%s: %s", $d->{obj
},
1099 join " ", @
{$d->{deps
}})), "\n";
1101 print &splitline
("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
1104 print &def
($makefile_extra{'unix'}->{'end'});
1106 "\trm -f *.o". (join "", map { " $_" } &progrealnames
("U")) . "\n";
1108 select STDOUT
; close OUT
;
1111 if (defined $makefiles{'am'}) {
1112 $dirpfx = "\$(srcdir)/" . &dirpfx($makefiles{'am'}, "/");
1114 ##-- Unix/autoconf Makefile.am
1115 open OUT
, ">$makefiles{'am'}"; select OUT
;
1117 "# Makefile.am for $project_name under Unix with Autoconf/Automake.\n".
1118 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1119 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n\n";
1121 # Complete list of source and header files. Not used by the
1122 # auto-generated parts of this makefile, but Recipe might like to
1123 # have it available as a variable so that mandatory-rebuild things
1124 # (version.o) can conveniently be made to depend on it.
1125 @sources = ("allsources", "=",
1126 map {"${dirpfx}$_"} sort keys %allsourcefiles);
1127 print &splitline
(join " ", @sources), "\n\n";
1129 @cliprogs = ("bin_PROGRAMS", "=");
1130 foreach $p (&prognames
("U")) {
1131 ($prog, $type) = split ",", $p;
1132 push @cliprogs, $prog;
1134 @allprogs = @cliprogs;
1135 foreach $p (&prognames
("X")) {
1136 ($prog, $type) = split ",", $p;
1137 push @allprogs, $prog;
1139 print "if HAVE_GTK\n";
1140 print &splitline
(join " ", @allprogs), "\n";
1142 print &splitline
(join " ", @cliprogs), "\n";
1146 foreach $d (&deps
("X", undef, $dirpfx, "/", "am")) {
1147 $objtosrc{$d->{obj
}} = $d->{deps
}->[0];
1150 @amcflags = ("\$(COMPAT)", "\$(XFLAGS)", map {"-I$dirpfx$_"} @srcdirs);
1151 print "if HAVE_GTK\n";
1152 print &splitline
(join " ", "AM_CFLAGS", "=",
1153 "\$(GTK_CFLAGS)", @amcflags), "\n";
1155 print &splitline
(join " ", "AM_CFLAGS", "=", @amcflags), "\n";
1158 %amspeciallibs = ();
1159 foreach $obj (sort { $a cmp $b } keys %{$cflags{'am'}}) {
1160 print "lib${obj}_a_SOURCES = ", $objtosrc{$obj}, "\n";
1161 print &splitline
(join " ", "lib${obj}_a_CFLAGS", "=", @amcflags,
1162 $cflags{'am'}->{$obj}), "\n";
1163 $amspeciallibs{$obj} = "lib${obj}.a";
1165 print &splitline
(join " ", "noinst_LIBRARIES", "=",
1166 sort { $a cmp $b } values %amspeciallibs), "\n\n";
1168 foreach $p (&prognames
("X:U")) {
1169 ($prog, $type) = split ",", $p;
1170 print "if HAVE_GTK\n" if $type eq "X";
1171 @progsources = ("${prog}_SOURCES", "=");
1174 $objstr = &objects
($p, "X", undef, undef);
1175 foreach $obj (split / /,$objstr) {
1176 if ($amspeciallibs{$obj}) {
1177 push @ldadd, $amspeciallibs{$obj};
1179 $sourcefiles{$objtosrc{$obj}} = 1;
1182 push @progsources, sort { $a cmp $b } keys %sourcefiles;
1183 print &splitline
(join " ", @progsources), "\n";
1185 push @ldadd, "\$(GTK_LIBS)";
1188 print &splitline
(join " ", "${prog}_LDADD", "=", @ldadd), "\n";
1190 print "endif\n" if $type eq "X";
1193 print $makefile_extra{'am'}->{'end'};
1194 select STDOUT
; close OUT
;
1197 if (defined $makefiles{'lcc'}) {
1198 $dirpfx = &dirpfx
($makefiles{'lcc'}, "\\");
1201 open OUT
, ">$makefiles{'lcc'}"; select OUT
;
1203 "# Makefile for $project_name under lcc.\n".
1204 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1205 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1206 # lcc command line option is -D not /D
1207 ($_ = $help) =~ s/([=" ])\/D/$1-D
/gs
;
1211 "# If you rename this file to `Makefile', you should change this line,\n".
1212 "# so that the .rsp files still depend on the correct makefile.\n".
1213 "MAKEFILE = Makefile.lcc\n".
1215 "# C compilation flags\n".
1216 "CFLAGS = -D_WINDOWS " .
1217 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
1219 "# Resource compilation flags\n".
1222 "# Get include directory for resource compiler\n".
1224 $makefile_extra{'lcc'}->{'vars'} .
1226 print &splitline
("all:" . join "", map { " $_.exe" } &progrealnames
("G:C"));
1228 foreach $p (&prognames
("G:C")) {
1229 ($prog, $type) = split ",", $p;
1230 $objstr = &objects
($p, "X.obj", "X.res", undef);
1231 print &splitline
("$prog.exe: " . $objstr ), "\n";
1232 $subsystemtype = '';
1233 if ($type eq "G") { $subsystemtype = "-subsystem windows"; }
1234 my $libss = "shell32.lib wsock32.lib ws2_32.lib winspool.lib winmm.lib imm32.lib";
1235 print &splitline
("\tlcclnk $subsystemtype -o $prog.exe $objstr $libss");
1239 foreach $d (&deps
("X.obj", "X.res", $dirpfx, "\\", "lcc")) {
1240 if ($forceobj{$d->{obj_orig
}}) {
1241 printf("%s: FORCE\n", $d->{obj
});
1243 print &splitline
(sprintf("%s: %s", $d->{obj
},
1244 join " ", @
{$d->{deps
}})), "\n";
1246 if ($d->{obj
} =~ /\.obj$/) {
1247 print &splitline
("\tlcc -O -p6 \$(COMPAT)".
1248 " \$(CFLAGS) \$(XFLAGS) ".$d->{deps
}->[0],69)."\n";
1250 print &splitline
("\tlrc \$(RCFL) -r \$(RCFLAGS) ".
1251 $d->{deps
}->[0],69)."\n";
1255 print $makefile_extra{'lcc'}->{'end'};
1263 select STDOUT
; close OUT
;
1266 if (defined $makefiles{'osx'}) {
1267 $dirpfx = &dirpfx
($makefiles{'osx'}, "/");
1269 ##-- Mac OS X makefile
1270 open OUT
, ">$makefiles{'osx'}"; select OUT
;
1272 "# Makefile for $project_name under Mac OS X.\n".
1273 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1274 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1275 # gcc command line option is -D not /D
1276 ($_ = $help) =~ s/([=" ])\/D/$1-D
/gs
;
1279 "CC = \$(TOOLPATH)gcc\n".
1281 &splitline
("CFLAGS = -O2 -Wall -Werror -g " .
1282 (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
1283 "MLDFLAGS = -framework Cocoa\n".
1286 $makefile_extra{'osx'}->{'vars'} .
1288 &splitline
("all:" . join "", map { " $_" } &progrealnames
("MX:U")) .
1290 foreach $p (&prognames
("MX")) {
1291 ($prog, $type) = split ",", $p;
1292 $objstr = &objects
($p, "X.o", undef, undef);
1293 $icon = &special
($p, ".icns");
1294 $infoplist = &special
($p, "info.plist");
1295 print "${prog}.app:\n\tmkdir -p \$\@\n";
1296 print "${prog}.app/Contents: ${prog}.app\n\tmkdir -p \$\@\n";
1297 print "${prog}.app/Contents/MacOS: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1298 $targets = "${prog}.app/Contents/MacOS/$prog";
1299 if (defined $icon) {
1300 print "${prog}.app/Contents/Resources: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1301 print "${prog}.app/Contents/Resources/${prog}.icns: ${prog}.app/Contents/Resources $icon\n\tcp $icon \$\@\n";
1302 $targets .= " ${prog}.app/Contents/Resources/${prog}.icns";
1304 if (defined $infoplist) {
1305 print "${prog}.app/Contents/Info.plist: ${prog}.app/Contents/Resources $infoplist\n\tcp $infoplist \$\@\n";
1306 $targets .= " ${prog}.app/Contents/Info.plist";
1308 $targets .= " \$(${prog}_extra)";
1309 print &splitline
("${prog}: $targets", 69) . "\n\n";
1310 print &splitline
("${prog}.app/Contents/MacOS/$prog: ".
1311 "${prog}.app/Contents/MacOS " . $objstr), "\n";
1312 $libstr = &objects
($p, undef, undef, "-lX");
1313 print &splitline
("\t\$(CC) \$(MLDFLAGS) -o \$@ " .
1314 $objstr . " $libstr", 69), "\n\n";
1316 foreach $p (&prognames
("U")) {
1317 ($prog, $type) = split ",", $p;
1318 $objstr = &objects
($p, "X.o", undef, undef);
1319 print &splitline
($prog . ": " . $objstr), "\n";
1320 $libstr = &objects
($p, undef, undef, "-lX");
1321 print &splitline
("\t\$(CC) \$(ULDFLAGS) -o \$@ " .
1322 $objstr . " $libstr", 69), "\n\n";
1324 foreach $d (&deps
("X.o", undef, $dirpfx, "/", "osx")) {
1325 if ($forceobj{$d->{obj_orig
}}) {
1326 printf("%s: FORCE\n", $d->{obj
});
1328 print &splitline
(sprintf("%s: %s", $d->{obj
},
1329 join " ", @
{$d->{deps
}})), "\n";
1331 $firstdep = $d->{deps
}->[0];
1332 if ($firstdep =~ /\.c$/) {
1333 print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
1334 } elsif ($firstdep =~ /\.m$/) {
1335 print "\t\$(CC) -x objective-c \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
1338 print "\n".&def
($makefile_extra{'osx'}->{'end'});
1340 "\trm -f *.o *.dmg". (join "", map { " $_" } &progrealnames
("U")) . "\n".
1344 select STDOUT
; close OUT
;
1347 if (defined $makefiles{'devcppproj'}) {
1348 $dirpfx = &dirpfx
($makefiles{'devcppproj'}, "\\");
1351 ##-- Dev-C++ 5 projects
1353 # Note: All files created in this section are written in binary
1354 # mode to prevent any posibility of misinterpreted line endings.
1355 # I don't know if Dev-C++ is as touchy as MSVC with LF-only line
1356 # endings. But however, CRLF line endings are the common way on
1357 # Win32 machines where Dev-C++ is running.
1358 # Hence, in order for mkfiles.pl to generate CRLF project files
1359 # even when run from Unix, I make sure all files are binary and
1360 # explicitly write the CRLFs.
1362 # Create directories if necessary
1363 mkdir $makefiles{'devcppproj'}
1364 if(! -d
$makefiles{'devcppproj'});
1365 chdir $makefiles{'devcppproj'};
1366 @deps = &deps
("X.obj", "X.res", $dirpfx, "\\", "devcppproj");
1367 %all_object_deps = map {$_->{obj
} => $_->{deps
}} @deps;
1368 # Make dir names FAT/NTFS compatible
1369 my @srcdirs = @srcdirs;
1370 for ($i=0; $i<@srcdirs; $i++) {
1371 $srcdirs[$i] =~ s/\//\\/g
;
1372 $srcdirs[$i] =~ s/\\$//;
1374 # Create the project files
1375 # Get names of all Windows projects (GUI and console)
1376 my @prognames = &prognames
("G:C");
1377 foreach $progname (@prognames) {
1378 create_devcpp_project
(\
%all_object_deps, $progname);
1383 sub create_devcpp_project
{
1384 my ($all_object_deps, $progname) = @_;
1385 # Construct program's dependency info (Taken from 'vcproj', seems to work right here, too.)
1390 %resource_files = ();
1391 @object_files = split " ", &objects
($progname, "X.obj", "X.res", "X.lib");
1392 foreach $object_file (@object_files) {
1393 next if defined $seen_objects{$object_file};
1394 $seen_objects{$object_file} = 1;
1395 if($object_file =~ /\.lib$/io) {
1396 $lib_files{$object_file} = 1;
1399 $object_deps = $all_object_deps{$object_file};
1400 foreach $object_dep (@
$object_deps) {
1401 if($object_dep =~ /\.c$/io) {
1402 $source_files{$object_dep} = 1;
1405 if($object_dep =~ /\.h$/io) {
1406 $header_files{$object_dep} = 1;
1409 if($object_dep =~ /\.(rc|ico)$/io) {
1410 $resource_files{$object_dep} = 1;
1415 $libs = join " ", sort keys %lib_files;
1416 @source_files = sort keys %source_files;
1417 @header_files = sort keys %header_files;
1418 @resources = sort keys %resource_files;
1419 ($windows_project, $type) = split ",", $progname;
1420 mkdir $windows_project
1421 if(! -d
$windows_project);
1422 chdir $windows_project;
1424 $subsys = ($type eq "G") ?
"0" : "1"; # 0 = Win32 GUI, 1 = Win32 Console
1425 open OUT
, ">$windows_project.dev"; binmode OUT
; select OUT
;
1427 "# DEV-C++ 5 Project File - $windows_project.dev\r\n".
1428 "# ** DO NOT EDIT **\r\n".
1430 # No difference between DEBUG and RELEASE here as in 'vcproj', because
1431 # Dev-C++ does not support mutiple compilation profiles in one single project.
1432 # (At least I can say this for Dev-C++ 5 Beta)
1434 "FileName=$windows_project.dev\r\n".
1435 "Name=$windows_project\r\n".
1439 # Multimon is disabled here, as Dev-C++ (Version 5 Beta) does not have multimon.h
1440 "Compiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
1441 "CppCompiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
1442 "Includes=" . (join ";", map {"..\\..\\$dirpfx$_"} @srcdirs) . "\r\n".
1443 "Linker=-ladvapi32 -lcomctl32 -lcomdlg32 -lgdi32 -limm32 -lshell32 -luser32 -lwinmm -lwinspool_\@\@_\r\n".
1445 "UnitCount=" . (@source_files + @header_files + @resources) . "\r\n".
1446 "Folders=\"Header Files\",\"Resource Files\",\"Source Files\"\r\n".
1448 "PrivateResource=${windows_project}_private.rc\r\n".
1449 "ResourceIncludes=..\\..\\..\\WINDOWS\r\n".
1450 "MakeIncludes=\r\n".
1451 "Icon=\r\n". # It's ok to leave this blank.
1453 "ObjectOutput=\r\n".
1454 "OverrideOutput=0\r\n".
1455 "OverrideOutputName=$windows_project.exe\r\n".
1456 "HostApplication=\r\n".
1458 "UseCustomMakefile=0\r\n".
1459 "CustomMakefile=\r\n".
1460 "IncludeVersionInfo=0\r\n".
1461 "SupportXPThemes=0\r\n".
1462 "CompilerSet=0\r\n".
1463 "CompilerSettings=0000000000000000000000\r\n".
1466 foreach $source_file (@source_files) {
1468 "[Unit$unit_count]\r\n".
1469 "FileName=..\\..\\$source_file\r\n".
1470 "Folder=Source Files\r\n".
1474 "Priority=1000\r\n".
1475 "OverrideBuildCmd=0\r\n".
1480 foreach $header_file (@header_files) {
1482 "[Unit$unit_count]\r\n".
1483 "FileName=..\\..\\$header_file\r\n".
1484 "Folder=Header Files\r\n".
1486 "CompileCpp=1\r\n". # Dev-C++ want's to compile all header files with both compilers C and C++. It does not hurt.
1488 "Priority=1000\r\n".
1489 "OverrideBuildCmd=0\r\n".
1494 foreach $resource_file (@resources) {
1495 if ($resource_file =~ /.*\.(ico|cur|bmp|dlg|rc2|rct|bin|rgs|gif|jpg|jpeg|jpe)/io) { # Default filter as in 'vcproj'
1496 $Compile = "0"; # Don't compile images and other binary resource files
1500 $CompileCpp = "1"; # Dev-C++ want's to compile all .rc files with both compilers C and C++. It does not hurt.
1503 "[Unit$unit_count]\r\n".
1504 "FileName=..\\..\\$resource_file\r\n".
1505 "Folder=Resource Files\r\n".
1506 "Compile=$Compile\r\n".
1507 "CompileCpp=$CompileCpp\r\n".
1509 "Priority=1000\r\n".
1510 "OverrideBuildCmd=0\r\n".
1515 #Note: By default, [VersionInfo] is not used.
1517 "[VersionInfo]\r\n".
1522 "LanguageID=1033\r\n".
1523 "CharsetID=1252\r\n".
1525 "FileVersion=0.1\r\n".
1526 "FileDescription=\r\n".
1527 "InternalName=\r\n".
1528 "LegalCopyright=\r\n".
1529 "LegalTrademarks=\r\n".
1530 "OriginalFilename=$windows_project.exe\r\n".
1531 "ProductName=$windows_project\r\n".
1532 "ProductVersion=0.1\r\n".
1533 "AutoIncBuildNr=0\r\n";
1534 select STDOUT
; close OUT
;
1539 # All done, so do the Unix postprocessing if asked to.
1543 system "./mkauto.sh";
1544 die "mkfiles.pl: mkauto.sh returned $?\n" if $?
> 0;
1545 if ($do_unix == 1) {
1546 chdir ($targetdir = dirname
($makefiles{"am"}))
1547 or die "$targetdir: chdir: $!\n";
1549 system "./configure", @confargs;
1550 die "mkfiles.pl: configure returned $?\n" if $?
> 0;