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") {
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.
35 open IN
, "Recipe" or do {
36 # We want to deal correctly with being run from one of the
37 # subdirs in the source tree. So if we can't find Recipe here,
40 open IN
, "Recipe" or die "unable to open Recipe file\n";
43 # HACK: One of the source files in `charset' is auto-generated by
44 # sbcsgen.pl. We need to generate that _now_, before attempting
45 # dependency analysis.
46 eval 'chdir "charset"; require "sbcsgen.pl"; chdir ".."';
50 $divert = undef; # ref to scalar in which text is currently being put
51 $help = ""; # list of newline-free lines of help text
52 $project_name = "project"; # this is a good enough default
53 %makefiles = (); # maps makefile types to output makefile pathnames
54 %makefile_extra = (); # maps makefile types to extra Makefile text
55 %programs = (); # maps prog name + type letter to listref of objects/resources
56 %groups = (); # maps group name to listref of objects/resources
62 # If we're gathering help text, keep doing so.
63 if (defined $divert) {
64 if ((defined $_[0]) && $_[0] eq "!end") {
71 # Skip comments and blank lines.
72 next if /^\s*#/ or scalar @_ == 0;
74 if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = \
$help; next; }
75 if ($_[0] eq "!end") { $divert = undef; next; }
76 if ($_[0] eq "!name") { $project_name = $_[1]; next; }
77 if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; }
78 if ($_[0] eq "!makefile" and &mfval
($_[1])) { $makefiles{$_[1]}=$_[2]; next;}
79 if ($_[0] eq "!specialobj" and &mfval
($_[1])) { $specialobj{$_[1]}->{$_[2]} = 1; next;}
80 if ($_[0] eq "!cflags" and &mfval
($_[1])) {
81 ($rest = $_) =~ s/^\s*\S+\s+\S+\s+\S+\s*//; # find rest of input line
82 $rest = 1 if $rest eq "";
83 $cflags{$_[1]}->{$_[2]} = $rest;
86 if ($_[0] eq "!forceobj") { $forceobj{$_[1]} = 1; next; }
87 if ($_[0] eq "!begin") {
89 $sect = $_[2] ?
$_[2] : "end";
90 $divert = \
($makefile_extra{$_[1]}->{$sect});
97 # If we're gathering help/verbatim text, keep doing so.
98 if (defined $divert) { ${$divert} .= "$_\n"; next; }
100 next if scalar @_ == 0;
102 # Now we have an ordinary line. See if it's an = line, a : line
107 $listref = $lastlistref;
109 die "$.: unexpected + line\n" if !defined $lastlistref;
110 } elsif ($_[1] eq "=") {
111 $groups{$_[0]} = [] if !defined $groups{$_[0]};
112 $listref = $groups{$_[0]};
114 shift @objs; # eat the group name
115 } elsif ($_[1] eq ":") {
118 shift @objs; # eat the program name
120 die "$.: unrecognised line type\n";
122 shift @objs; # eat the +, the = or the :
124 while (scalar @objs > 0) {
127 foreach $j (@
{$groups{$i}}) { unshift @objs, $j; }
128 } elsif (($i eq "[G]" or $i eq "[C]" or $i eq "[M]" or
129 $i eq "[X]" or $i eq "[U]" or $i eq "[MX]") and defined $prog) {
130 $type = substr($i,1,(length $i)-2);
135 if ($prog and $type) {
136 die "multiple program entries for $prog [$type]\n"
137 if defined $programs{$prog . "," . $type};
138 $programs{$prog . "," . $type} = $listref;
140 $lastlistref = $listref;
145 # Now retrieve the complete list of objects and resource files, and
146 # construct dependency data for them. While we're here, expand the
147 # object list for each program, and complain if its type isn't set.
148 @prognames = sort keys %programs;
151 foreach $i (@prognames) {
152 ($prog, $type) = split ",", $i;
153 # Strip duplicate object names.
155 @list = grep { $status = ($prev ne $_); $prev=$_; $status }
156 sort @
{$programs{$i}};
157 $programs{$i} = [@list];
159 # Dependencies for "x" start with "x.c" or "x.m" (depending on
161 # Dependencies for "x.res" start with "x.rc".
162 # Dependencies for "x.rsrc" start with "x.r".
163 # Both types of file are pushed on the list of files to scan.
164 # Libraries (.lib) don't have dependencies at all.
165 if ($j =~ /^(.*)\.res$/) {
167 $depends{$j} = [$file];
168 push @scanlist, $file;
169 } elsif ($j =~ /^(.*)\.rsrc$/) {
171 $depends{$j} = [$file];
172 push @scanlist, $file;
173 } elsif ($j !~ /\./) {
175 $file = "$j.m" unless &findfile
($file);
176 $depends{$j} = [$file];
177 push @scanlist, $file;
182 # Scan each file on @scanlist and find further inclusions.
183 # Inclusions are given by lines of the form `#include "otherfile"'
184 # (system headers are automatically ignored by this because they'll
185 # be given in angle brackets). Files included by this method are
186 # added back on to @scanlist to be scanned in turn (if not already
189 # Resource scripts (.rc) can also include a file by means of:
190 # - a line # ending `ICON "filename"';
191 # - a line ending `RT_MANIFEST "filename"'.
192 # Files included by this method are not added to @scanlist because
193 # they can never include further files.
195 # In this pass we write out a hash %further which maps a source
196 # file name into a listref containing further source file names.
199 %allsourcefiles = (); # this is wanted by some makefiles
200 while (scalar @scanlist > 0) {
201 $file = shift @scanlist;
202 next if defined $further{$file}; # skip if we've already done it
203 $further{$file} = [];
204 $dirfile = &findfile
($file);
205 $allsourcefiles{$dirfile} = 1;
206 open IN
, "$dirfile" or die "unable to open source file $file\n";
209 /^\s*#include\s+\"([^\"]+)\"/ and do {
210 push @
{$further{$file}}, $1;
214 /(RT_MANIFEST|ICON)\s+\"([^\"]+)\"\s*$/ and do {
215 push @
{$further{$file}}, $2;
222 # Now we're ready to generate the final dependencies section. For
223 # each key in %depends, we must expand the dependencies list by
224 # iteratively adding entries from %further.
225 foreach $i (keys %depends) {
227 @scanlist = @
{$depends{$i}};
228 foreach $i (@scanlist) { $dep{$i} = 1; }
229 while (scalar @scanlist > 0) {
230 $file = shift @scanlist;
231 foreach $j (@
{$further{$file}}) {
234 push @
{$depends{$i}}, $j;
239 # printf "%s: %s\n", $i, join ' ',@{$depends{$i}};
242 # Validation of input.
246 # Returns true if the argument is a known makefile type. Otherwise,
247 # prints a warning and returns false;
248 if (grep { $type eq $_ }
249 ("vc","vcproj","cygwin","borland","lcc","devcppproj","gtk","unix",
253 warn "$.:unknown makefile type '$type'\n";
257 # Utility routines while writing out the Makefiles.
261 return (defined $x) ?
$x : "";
265 my ($path) = shift @_;
266 my ($sep) = shift @_;
270 while (($i = index $path, $sep) >= 0 ||
271 ($j = index $path, "/") >= 0) {
272 if ($i >= 0 and ($j < 0 or $i < $j)) {
273 $path = substr $path, ($i + length $sep);
275 $path = substr $path, ($j + 1);
287 unless (defined $findfilecache{$name}) {
289 foreach $dir (@srcdirs) {
290 if (-f
"$dir$name") {
293 $outdir =~ s/^\.\///;
296 die "multiple instances of source file $name\n" if $i > 1;
297 $findfilecache{$name} = (defined $outdir ?
$outdir . $name : undef);
299 return $findfilecache{$name};
303 my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_;
306 ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ?
$_ : "" } ($otmpl, $rtmpl, $ltmpl);
308 foreach $i (@
{$programs{$prog}}) {
310 if ($i =~ /^(.*)\.(res|rsrc)/) {
312 ($x = $rtmpl) =~ s/X/$y/;
313 } elsif ($i =~ /^(.*)\.lib/) {
315 ($x = $ltmpl) =~ s/X/$y/;
316 } elsif ($i !~ /\./) {
317 ($x = $otmpl) =~ s/X/$i/;
319 push @ret, $x if $x ne "";
321 return join " ", @ret;
325 my ($prog, $suffix) = @_;
328 ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ?
$_ : "" } ($otmpl, $rtmpl, $ltmpl);
330 foreach $i (@
{$programs{$prog}}) {
331 if (substr($i, (length $i) - (length $suffix)) eq $suffix) {
335 return (scalar @ret) ?
(join " ", @ret) : undef;
339 my ($line, $width, $splitchar) = @_;
342 $len = (defined $width ?
$width : 76);
343 $splitchar = (defined $splitchar ?
$splitchar : '\\');
344 while (length $line > $len) {
345 $line =~ /^(.{0,$len})\s(.*)$/ or $line =~ /^(.{$len,}?\s(.*)$/;
347 $result .= " ${splitchar}\n\t\t" if $2 ne '';
351 return $result . $line;
355 my ($otmpl, $rtmpl, $prefix, $dirsep, $mftyp, $depchar, $splitchar) = @_;
361 foreach $i (sort keys %depends) {
362 next if $specialobj{$mftyp}->{$i};
363 if ($i =~ /^(.*)\.(res|rsrc)/) {
364 next if !defined $rtmpl;
366 ($x = $rtmpl) =~ s/X/$y/;
368 ($x = $otmpl) =~ s/X/$i/;
370 @deps = @
{$depends{$i}};
376 push @ret, {obj
=> $x, obj_orig
=> $i, deps
=> [@deps]};
383 my ($n, $prog, $type);
386 foreach $n (@prognames) {
387 ($prog, $type) = split ",", $n;
388 push @ret, $n if index(":$types:", ":$type:") >= 0;
395 my ($n, $prog, $type);
398 foreach $n (@prognames) {
399 ($prog, $type) = split ",", $n;
400 push @ret, $prog if index(":$types:", ":$type:") >= 0;
406 my ($types,$suffix) = @_;
408 # assume that all UNIX programs have a man page
409 if($suffix eq "1" && $types =~ /:X:/) {
410 return map("$_.1", &progrealnames
($types));
417 # Now we're ready to output the actual Makefiles.
419 if (defined $makefiles{'cygwin'}) {
420 $dirpfx = &dirpfx
($makefiles{'cygwin'}, "/");
423 open OUT
, ">$makefiles{'cygwin'}"; select OUT
;
425 "# Makefile for $project_name under cygwin.\n".
426 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
427 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
428 # gcc command line option is -D not /D
429 ($_ = $help) =~ s/([=" ])\/D/$1-D
/gs
;
433 "# You can define this path to point at your tools if you need to\n".
434 "# TOOLPATH = c:\\cygwin\\bin\\ # or similar, if you're running Windows\n".
435 "# TOOLPATH = /pkg/mingw32msvc/i386-mingw32msvc/bin/\n".
436 "CC = \$(TOOLPATH)gcc\n".
437 "RC = \$(TOOLPATH)windres\n".
438 "# Uncomment the following two lines to compile under Winelib\n".
441 "# You may also need to tell windres where to find include files:\n".
442 "# RCINC = --include-dir c:\\cygwin\\include\\\n".
444 &splitline
("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
445 " -D_NO_OLDNAMES -DNO_MULTIMON -DNO_HTMLHELP " .
446 (join " ", map {"-I$dirpfx$_"} @srcdirs)) .
448 "LDFLAGS = -mno-cygwin -s\n".
449 &splitline
("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1".
450 " --define WINVER=0x0400")."\n".
452 $makefile_extra{'cygwin'}->{'vars'} .
456 print &splitline
("all:" . join "", map { " $_.exe" } &progrealnames
("G:C"));
458 foreach $p (&prognames
("G:C")) {
459 ($prog, $type) = split ",", $p;
460 $objstr = &objects
($p, "X.o", "X.res.o", undef);
461 print &splitline
($prog . ".exe: " . $objstr), "\n";
462 my $mw = $type eq "G" ?
" -mwindows" : "";
463 $libstr = &objects
($p, undef, undef, "-lX");
464 print &splitline
("\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " .
465 "-Wl,-Map,$prog.map " .
466 $objstr . " $libstr", 69), "\n\n";
468 foreach $d (&deps
("X.o", "X.res.o", $dirpfx, "/", "cygwin")) {
469 if ($forceobj{$d->{obj_orig
}}) {
470 printf ("%s: FORCE\n", $d->{obj
});
472 print &splitline
(sprintf("%s: %s", $d->{obj
},
473 join " ", @
{$d->{deps
}})), "\n";
475 if ($d->{obj
} =~ /\.res\.o$/) {
476 print "\t\$(RC) \$(RCFL) \$(RCFLAGS) ".$d->{deps
}->[0]." ".$d->{obj
}."\n\n";
478 print "\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c ".$d->{deps
}->[0]."\n\n";
482 print $makefile_extra{'cygwin'}->{'end'};
484 "\trm -f *.o *.exe *.res.o *.map\n".
487 select STDOUT
; close OUT
;
491 ##-- Borland makefile
492 if (defined $makefiles{'borland'}) {
493 $dirpfx = &dirpfx
($makefiles{'borland'}, "\\");
495 %stdlibs = ( # Borland provides many Win32 API libraries intrinsically
507 open OUT
, ">$makefiles{'borland'}"; select OUT
;
509 "# Makefile for $project_name under Borland C.\n".
510 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
511 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
512 # bcc32 command line option is -D not /D
513 ($_ = $help) =~ s/([=" ])\/D/$1-D
/gs
;
517 "# If you rename this file to `Makefile', you should change this line,\n".
518 "# so that the .rsp files still depend on the correct makefile.\n".
519 "MAKEFILE = Makefile.bor\n".
521 "# C compilation flags\n".
522 "CFLAGS = -D_WINDOWS -DWINVER=0x0500\n".
523 "# Resource compilation flags\n".
524 "RCFLAGS = -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401\n".
526 "# Get include directory for resource compiler\n".
528 "BCB = \$(MAKEDIR)\\..\n".
531 $makefile_extra{'borland'}->{'vars'} .
534 &splitline
("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT)".
535 " \$(CFLAGS) \$(XFLAGS) ".
536 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
537 " /c \$*.c",69)."\n".
539 &splitline
("\tbrcc32 \$(RCFL) -i \$(BCB)\\include -r".
540 " \$(RCFLAGS) \$*.rc",69)."\n".
542 print &splitline
("all:" . join "", map { " $_.exe" } &progrealnames
("G:C"));
544 foreach $p (&prognames
("G:C")) {
545 ($prog, $type) = split ",", $p;
546 $objstr = &objects
($p, "X.obj", "X.res", undef);
547 print &splitline
("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
548 my $ap = ($type eq "G") ?
"-aa" : "-ap";
549 print "\tilink32 $ap -Gn -L\$(BCB)\\lib \@$prog.rsp\n\n";
551 foreach $p (&prognames
("G:C")) {
552 ($prog, $type) = split ",", $p;
553 print $prog, ".rsp: \$(MAKEFILE)\n";
554 $objstr = &objects
($p, "X.obj", undef, undef);
555 @objlist = split " ", $objstr;
557 foreach $i (@objlist) {
558 if (length($objlines[$#objlines] . " $i") > 50) {
561 $objlines[$#objlines] .= " $i";
563 $c0w = ($type eq "G") ?
"c0w32" : "c0x32";
564 print "\techo $c0w + > $prog.rsp\n";
565 for ($i=0; $i<=$#objlines; $i++) {
566 $plus = ($i < $#objlines ?
" +" : "");
567 print "\techo$objlines[$i]$plus >> $prog.rsp\n";
569 print "\techo $prog.exe >> $prog.rsp\n";
570 $objstr = &objects
($p, "X.obj", "X.res", undef);
571 @libs = split " ", &objects
($p, undef, undef, "X");
572 @libs = grep { !$stdlibs{$_} } @libs;
573 unshift @libs, "cw32", "import32";
574 $libstr = join ' ', @libs;
575 print "\techo nul,$libstr, >> $prog.rsp\n";
576 print "\techo " . &objects
($p, undef, "X.res", undef) . " >> $prog.rsp\n";
579 foreach $d (&deps
("X.obj", "X.res", $dirpfx, "\\", "borland")) {
580 if ($forceobj{$d->{obj_orig
}}) {
581 printf("%s: FORCE\n", $d->{obj
});
583 print &splitline
(sprintf("%s: %s", $d->{obj
},
584 join " ", @
{$d->{deps
}})), "\n";
588 print $makefile_extra{'borland'}->{'end'};
599 "\t-del *.\$\$\$\$\$\$\n".
602 "\t-rem dummy command\n";
603 select STDOUT
; close OUT
;
606 if (defined $makefiles{'vc'}) {
607 $dirpfx = &dirpfx
($makefiles{'vc'}, "\\");
609 ##-- Visual C++ makefile
610 open OUT
, ">$makefiles{'vc'}"; select OUT
;
612 "# Makefile for $project_name under Visual C.\n".
613 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
614 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
618 "# If you rename this file to `Makefile', you should change this line,\n".
619 "# so that the .rsp files still depend on the correct makefile.\n".
620 "MAKEFILE = Makefile.vc\n".
622 "# C compilation flags\n".
623 "CFLAGS = /nologo /W3 /O1 " .
624 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
625 " /D_WINDOWS /D_WIN32_WINDOWS=0x500 /DWINVER=0x500\n".
626 "LFLAGS = /incremental:no /fixed\n".
627 "RCFLAGS = -DWIN32 -D_WIN32 -DWINVER=0x0400\n".
629 $makefile_extra{'vc'}->{'vars'} .
632 print &splitline
("all:" . join "", map { " $_.exe" } &progrealnames
("G:C"));
634 foreach $p (&prognames
("G:C")) {
635 ($prog, $type) = split ",", $p;
636 $objstr = &objects
($p, "X.obj", "X.res", undef);
637 print &splitline
("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
638 print "\tlink \$(LFLAGS) \$(XLFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n";
640 foreach $p (&prognames
("G:C")) {
641 ($prog, $type) = split ",", $p;
642 print $prog, ".rsp: \$(MAKEFILE)\n";
643 $objstr = &objects
($p, "X.obj", "X.res", "X.lib");
644 @objlist = split " ", $objstr;
646 foreach $i (@objlist) {
647 if (length($objlines[$#objlines] . " $i") > 50) {
650 $objlines[$#objlines] .= " $i";
652 $subsys = ($type eq "G") ?
"windows" : "console";
653 print "\techo /nologo /subsystem:$subsys > $prog.rsp\n";
654 for ($i=0; $i<=$#objlines; $i++) {
655 print "\techo$objlines[$i] >> $prog.rsp\n";
659 foreach $d (&deps
("X.obj", "X.res", $dirpfx, "\\", "vc")) {
660 $extradeps = $forceobj{$d->{obj_orig
}} ?
["*.c","*.h","*.rc"] : [];
661 print &splitline
(sprintf("%s: %s", $d->{obj
},
662 join " ", @
$extradeps, @
{$d->{deps
}})), "\n";
663 if ($d->{obj
} =~ /.obj$/) {
664 print "\tcl \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c ".$d->{deps
}->[0],"\n\n";
666 print "\trc \$(RCFL) -r \$(RCFLAGS) ".$d->{deps
}->[0],"\n\n";
670 print $makefile_extra{'vc'}->{'end'};
671 print "\nclean: tidy\n".
688 "\t-del debug.log\n";
689 select STDOUT
; close OUT
;
692 if (defined $makefiles{'vcproj'}) {
693 $dirpfx = &dirpfx
($makefiles{'vcproj'}, "\\");
695 ##-- MSVC 6 Workspace and projects
697 # Note: All files created in this section are written in binary
698 # mode, because although MSVC's command-line make can deal with
699 # LF-only line endings, MSVC project files really _need_ to be
700 # CRLF. Hence, in order for mkfiles.pl to generate usable project
701 # files even when run from Unix, I make sure all files are binary
702 # and explicitly write the CRLFs.
704 # Create directories if necessary
705 mkdir $makefiles{'vcproj'}
706 if(! -d
$makefiles{'vcproj'});
707 chdir $makefiles{'vcproj'};
708 @deps = &deps
("X.obj", "X.res", $dirpfx, "\\", "vcproj");
709 %all_object_deps = map {$_->{obj
} => $_->{deps
}} @deps;
710 # Create the project files
711 # Get names of all Windows projects (GUI and console)
712 my @prognames = &prognames
("G:C");
713 foreach $progname (@prognames) {
714 create_vc_project
(\
%all_object_deps, $progname);
716 # Create the workspace file
717 open OUT
, ">$project_name.dsw"; binmode OUT
; select OUT
;
719 "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n".
720 "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n".
722 "###############################################################################\r\n".
725 foreach $progname (@prognames) {
726 ($windows_project, $type) = split ",", $progname;
727 print "Project: \"$windows_project\"=\".\\$windows_project\\$windows_project.dsp\" - Package Owner=<4>\r\n";
739 "###############################################################################\r\n".
751 "###############################################################################\r\n".
753 select STDOUT
; close OUT
;
756 sub create_vc_project
{
757 my ($all_object_deps, $progname) = @_;
758 # Construct program's dependency info
763 %resource_files = ();
764 @object_files = split " ", &objects
($progname, "X.obj", "X.res", "X.lib");
765 foreach $object_file (@object_files) {
766 next if defined $seen_objects{$object_file};
767 $seen_objects{$object_file} = 1;
768 if($object_file =~ /\.lib$/io) {
769 $lib_files{$object_file} = 1;
772 $object_deps = $all_object_deps{$object_file};
773 foreach $object_dep (@
$object_deps) {
774 if($object_dep =~ /\.c$/io) {
775 $source_files{$object_dep} = 1;
778 if($object_dep =~ /\.h$/io) {
779 $header_files{$object_dep} = 1;
782 if($object_dep =~ /\.(rc|ico)$/io) {
783 $resource_files{$object_dep} = 1;
788 $libs = join " ", sort keys %lib_files;
789 @source_files = sort keys %source_files;
790 @header_files = sort keys %header_files;
791 @resources = sort keys %resource_files;
792 ($windows_project, $type) = split ",", $progname;
793 mkdir $windows_project
794 if(! -d
$windows_project);
795 chdir $windows_project;
796 $subsys = ($type eq "G") ?
"windows" : "console";
797 open OUT
, ">$windows_project.dsp"; binmode OUT
; select OUT
;
799 "# Microsoft Developer Studio Project File - Name=\"$windows_project\" - Package Owner=<4>\r\n".
800 "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n".
801 "# ** DO NOT EDIT **\r\n".
803 "# TARGTYPE \"Win32 (x86) Application\" 0x0101\r\n".
805 "CFG=$windows_project - Win32 Debug\r\n".
806 "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n".
807 "!MESSAGE use the Export Makefile command and run\r\n".
809 "!MESSAGE NMAKE /f \"$windows_project.mak\".\r\n".
811 "!MESSAGE You can specify a configuration when running NMAKE\r\n".
812 "!MESSAGE by defining the macro CFG on the command line. For example:\r\n".
814 "!MESSAGE NMAKE /f \"$windows_project.mak\" CFG=\"$windows_project - Win32 Debug\"\r\n".
816 "!MESSAGE Possible choices for configuration are:\r\n".
818 "!MESSAGE \"$windows_project - Win32 Release\" (based on \"Win32 (x86) Application\")\r\n".
819 "!MESSAGE \"$windows_project - Win32 Debug\" (based on \"Win32 (x86) Application\")\r\n".
822 "# Begin Project\r\n".
823 "# PROP AllowPerConfigDependencies 0\r\n".
824 "# PROP Scc_ProjName \"\"\r\n".
825 "# PROP Scc_LocalPath \"\"\r\n".
830 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
832 "# PROP BASE Use_MFC 0\r\n".
833 "# PROP BASE Use_Debug_Libraries 0\r\n".
834 "# PROP BASE Output_Dir \"Release\"\r\n".
835 "# PROP BASE Intermediate_Dir \"Release\"\r\n".
836 "# PROP BASE Target_Dir \"\"\r\n".
837 "# PROP Use_MFC 0\r\n".
838 "# PROP Use_Debug_Libraries 0\r\n".
839 "# PROP Output_Dir \"Release\"\r\n".
840 "# PROP Intermediate_Dir \"Release\"\r\n".
841 "# PROP Ignore_Export_Lib 0\r\n".
842 "# PROP Target_Dir \"\"\r\n".
843 "# ADD BASE CPP /nologo /W3 /GX /O2 ".
844 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
845 " /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
846 "# ADD 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 BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
850 "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
851 "# ADD BASE RSC /l 0x809 /d \"NDEBUG\"\r\n".
852 "# ADD RSC /l 0x809 /d \"NDEBUG\"\r\n".
853 "BSC32=bscmake.exe\r\n".
854 "# ADD BASE BSC32 /nologo\r\n".
855 "# ADD BSC32 /nologo\r\n".
856 "LINK32=link.exe\r\n".
857 "# 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".
858 "# ADD LINK32 $libs /nologo /subsystem:$subsys /machine:I386\r\n".
859 "# SUBTRACT LINK32 /pdb:none\r\n".
861 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
863 "# PROP BASE Use_MFC 0\r\n".
864 "# PROP BASE Use_Debug_Libraries 1\r\n".
865 "# PROP BASE Output_Dir \"Debug\"\r\n".
866 "# PROP BASE Intermediate_Dir \"Debug\"\r\n".
867 "# PROP BASE Target_Dir \"\"\r\n".
868 "# PROP Use_MFC 0\r\n".
869 "# PROP Use_Debug_Libraries 1\r\n".
870 "# PROP Output_Dir \"Debug\"\r\n".
871 "# PROP Intermediate_Dir \"Debug\"\r\n".
872 "# PROP Ignore_Export_Lib 0\r\n".
873 "# PROP Target_Dir \"\"\r\n".
874 "# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od ".
875 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
876 " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
877 "# ADD 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 BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
881 "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
882 "# ADD BASE RSC /l 0x809 /d \"_DEBUG\"\r\n".
883 "# ADD RSC /l 0x809 /d \"_DEBUG\"\r\n".
884 "BSC32=bscmake.exe\r\n".
885 "# ADD BASE BSC32 /nologo\r\n".
886 "# ADD BSC32 /nologo\r\n".
887 "LINK32=link.exe\r\n".
888 "# 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".
889 "# ADD LINK32 $libs /nologo /subsystem:$subsys /debug /machine:I386 /pdbtype:sept\r\n".
890 "# SUBTRACT LINK32 /pdb:none\r\n".
894 "# Begin Target\r\n".
896 "# Name \"$windows_project - Win32 Release\"\r\n".
897 "# Name \"$windows_project - Win32 Debug\"\r\n".
898 "# Begin Group \"Source Files\"\r\n".
900 "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
901 foreach $source_file (@source_files) {
903 "# Begin Source File\r\n".
905 "SOURCE=..\\..\\$source_file\r\n";
906 if($source_file =~ /ssh\.c/io) {
907 # Disable 'Edit and continue' as Visual Studio can't handle the macros
910 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
912 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
919 print "# End Source File\r\n";
923 "# Begin Group \"Header Files\"\r\n".
925 "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
926 foreach $header_file (@header_files) {
928 "# Begin Source File\r\n".
930 "SOURCE=..\\..\\$header_file\r\n".
931 "# End Source File\r\n";
935 "# Begin Group \"Resource Files\"\r\n".
937 "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
938 foreach $resource_file (@resources) {
940 "# Begin Source File\r\n".
942 "SOURCE=..\\..\\$resource_file\r\n".
943 "# End Source File\r\n";
949 select STDOUT
; close OUT
;
954 if (defined $makefiles{'gtk'}) {
955 $dirpfx = &dirpfx
($makefiles{'gtk'}, "/");
957 ##-- X/GTK/Unix makefile
958 open OUT
, ">$makefiles{'gtk'}"; select OUT
;
960 "# Makefile for $project_name under X/GTK and Unix.\n".
961 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
962 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
963 # gcc command line option is -D not /D
964 ($_ = $help) =~ s/([=" ])\/D/$1-D
/gs
;
968 "# You can define this path to point at your tools if you need to\n".
969 "# TOOLPATH = /opt/gcc/bin\n".
970 "CC = \$(TOOLPATH)cc\n".
971 "# If necessary set the path to krb5-config here\n".
972 "KRB5CONFIG=krb5-config\n".
973 "# You can manually set this to `gtk-config' or `pkg-config gtk+-1.2'\n".
974 "# (depending on what works on your system) if you want to enforce\n".
975 "# building with GTK 1.2, or you can set it to `pkg-config gtk+-2.0 x11'\n".
976 "# if you want to enforce 2.0. The default is to try 2.0 and fall back\n".
977 "# to 1.2 if it isn't found.\n".
978 "GTK_CONFIG = sh -c 'pkg-config gtk+-2.0 x11 \$\$0 2>/dev/null || gtk-config \$\$0'\n".
980 "-include Makefile.local\n".
982 "unexport CFLAGS # work around a weird issue with krb5-config\n".
984 &splitline
("CFLAGS = -O2 -Wall -Werror -g " .
985 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
986 " \$(shell \$(GTK_CONFIG) --cflags)").
987 " -D _FILE_OFFSET_BITS=64\n".
988 "XLDFLAGS = \$(LDFLAGS) \$(shell \$(GTK_CONFIG) --libs)\n".
989 "ULDFLAGS = \$(LDFLAGS)\n".
990 "ifeq (,\$(findstring NO_GSSAPI,\$(COMPAT)))\n".
991 "ifeq (,\$(findstring STATIC_GSSAPI,\$(COMPAT)))\n".
995 "CFLAGS+= -DNO_LIBDL \$(shell \$(KRB5CONFIG) --cflags gssapi)\n".
996 "XLDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
997 "ULDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
1000 "INSTALL=install\n".
1001 "INSTALL_PROGRAM=\$(INSTALL)\n".
1002 "INSTALL_DATA=\$(INSTALL)\n".
1003 "prefix=/usr/local\n".
1004 "exec_prefix=\$(prefix)\n".
1005 "bindir=\$(exec_prefix)/bin\n".
1006 "mandir=\$(prefix)/man\n".
1007 "man1dir=\$(mandir)/man1\n".
1009 &def
($makefile_extra{'gtk'}->{'vars'}) .
1014 print &splitline
("all:" . join "", map { " $_" } &progrealnames
("X:U"));
1016 foreach $p (&prognames
("X:U")) {
1017 ($prog, $type) = split ",", $p;
1018 $objstr = &objects
($p, "X.o", undef, undef);
1019 print &splitline
($prog . ": " . $objstr), "\n";
1020 $libstr = &objects
($p, undef, undef, "-lX");
1021 print &splitline
("\t\$(CC) -o \$@ " .
1022 $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
1024 foreach $d (&deps
("X.o", undef, $dirpfx, "/", "gtk")) {
1025 if ($forceobj{$d->{obj_orig
}}) {
1026 printf("%s: FORCE\n", $d->{obj
});
1028 print &splitline
(sprintf("%s: %s", $d->{obj
},
1029 join " ", @
{$d->{deps
}})), "\n";
1031 print &splitline
("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
1034 print $makefile_extra{'gtk'}->{'end'};
1036 "\trm -f *.o". (join "", map { " $_" } &progrealnames
("X:U")) . "\n";
1038 select STDOUT
; close OUT
;
1041 if (defined $makefiles{'unix'}) {
1042 $dirpfx = &dirpfx
($makefiles{'unix'}, "/");
1044 ##-- GTK-free pure-Unix makefile for non-GUI apps only
1045 open OUT
, ">$makefiles{'unix'}"; select OUT
;
1047 "# Makefile for $project_name under Unix.\n".
1048 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1049 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1050 # gcc command line option is -D not /D
1051 ($_ = $help) =~ s/([=" ])\/D/$1-D
/gs
;
1055 "# You can define this path to point at your tools if you need to\n".
1056 "# TOOLPATH = /opt/gcc/bin\n".
1057 "CC = \$(TOOLPATH)cc\n".
1059 "-include Makefile.local\n".
1061 "unexport CFLAGS # work around a weird issue with krb5-config\n".
1063 &splitline
("CFLAGS = -O2 -Wall -Werror -g " .
1064 (join " ", map {"-I$dirpfx$_"} @srcdirs)).
1065 " -D _FILE_OFFSET_BITS=64\n".
1066 "ULDFLAGS = \$(LDFLAGS)\n".
1067 "INSTALL=install\n".
1068 "INSTALL_PROGRAM=\$(INSTALL)\n".
1069 "INSTALL_DATA=\$(INSTALL)\n".
1070 "prefix=/usr/local\n".
1071 "exec_prefix=\$(prefix)\n".
1072 "bindir=\$(exec_prefix)/bin\n".
1073 "mandir=\$(prefix)/man\n".
1074 "man1dir=\$(mandir)/man1\n".
1076 &def
($makefile_extra{'unix'}->{'vars'}) .
1081 print &splitline
("all:" . join "", map { " $_" } &progrealnames
("U"));
1083 foreach $p (&prognames
("U")) {
1084 ($prog, $type) = split ",", $p;
1085 $objstr = &objects
($p, "X.o", undef, undef);
1086 print &splitline
($prog . ": " . $objstr), "\n";
1087 $libstr = &objects
($p, undef, undef, "-lX");
1088 print &splitline
("\t\$(CC) -o \$@ " .
1089 $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
1091 foreach $d (&deps
("X.o", undef, $dirpfx, "/", "unix")) {
1092 if ($forceobj{$d->{obj_orig
}}) {
1093 printf("%s: FORCE\n", $d->{obj
});
1095 print &splitline
(sprintf("%s: %s", $d->{obj
},
1096 join " ", @
{$d->{deps
}})), "\n";
1098 print &splitline
("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
1101 print &def
($makefile_extra{'unix'}->{'end'});
1103 "\trm -f *.o". (join "", map { " $_" } &progrealnames
("U")) . "\n";
1105 select STDOUT
; close OUT
;
1108 if (defined $makefiles{'am'}) {
1109 $dirpfx = "\$(srcdir)/" . &dirpfx($makefiles{'am'}, "/");
1111 ##-- Unix/autoconf Makefile.am
1112 open OUT
, ">$makefiles{'am'}"; select OUT
;
1114 "# Makefile.am for $project_name under Unix with Autoconf/Automake.\n".
1115 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1116 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n\n";
1118 # Complete list of source and header files. Not used by the
1119 # auto-generated parts of this makefile, but Recipe might like to
1120 # have it available as a variable so that mandatory-rebuild things
1121 # (version.o) can conveniently be made to depend on it.
1122 @sources = ("allsources", "=",
1123 map {"${dirpfx}$_"} sort keys %allsourcefiles);
1124 print &splitline
(join " ", @sources), "\n\n";
1126 @cliprogs = ("bin_PROGRAMS", "=");
1127 foreach $p (&prognames
("U")) {
1128 ($prog, $type) = split ",", $p;
1129 push @cliprogs, $prog;
1131 @allprogs = @cliprogs;
1132 foreach $p (&prognames
("X")) {
1133 ($prog, $type) = split ",", $p;
1134 push @allprogs, $prog;
1136 print "if HAVE_GTK\n";
1137 print &splitline
(join " ", @allprogs), "\n";
1139 print &splitline
(join " ", @cliprogs), "\n";
1143 foreach $d (&deps
("X", undef, $dirpfx, "/", "am")) {
1144 $objtosrc{$d->{obj
}} = $d->{deps
}->[0];
1147 @amcflags = ("\$(COMPAT)", "\$(XFLAGS)", map {"-I$dirpfx$_"} @srcdirs);
1148 print "if HAVE_GTK\n";
1149 print &splitline
(join " ", "AM_CFLAGS", "=",
1150 "\$(GTK_CFLAGS)", @amcflags), "\n";
1152 print &splitline
(join " ", "AM_CFLAGS", "=", @amcflags), "\n";
1155 %amspeciallibs = ();
1156 foreach $obj (sort { $a cmp $b } keys %{$cflags{'am'}}) {
1157 print "lib${obj}_a_SOURCES = ", $objtosrc{$obj}, "\n";
1158 print &splitline
(join " ", "lib${obj}_a_CFLAGS", "=", @amcflags,
1159 $cflags{'am'}->{$obj}), "\n";
1160 $amspeciallibs{$obj} = "lib${obj}.a";
1162 print &splitline
(join " ", "noinst_LIBRARIES", "=",
1163 sort { $a cmp $b } values %amspeciallibs), "\n\n";
1165 foreach $p (&prognames
("X:U")) {
1166 ($prog, $type) = split ",", $p;
1167 print "if HAVE_GTK\n" if $type eq "X";
1168 @progsources = ("${prog}_SOURCES", "=");
1171 $objstr = &objects
($p, "X", undef, undef);
1172 foreach $obj (split / /,$objstr) {
1173 if ($amspeciallibs{$obj}) {
1174 push @ldadd, $amspeciallibs{$obj};
1176 $sourcefiles{$objtosrc{$obj}} = 1;
1179 push @progsources, sort { $a cmp $b } keys %sourcefiles;
1180 print &splitline
(join " ", @progsources), "\n";
1182 push @ldadd, "\$(GTK_LIBS)";
1185 print &splitline
(join " ", "${prog}_LDADD", "=", @ldadd), "\n";
1187 print "endif\n" if $type eq "X";
1190 print $makefile_extra{'am'}->{'end'};
1191 select STDOUT
; close OUT
;
1194 if (defined $makefiles{'lcc'}) {
1195 $dirpfx = &dirpfx
($makefiles{'lcc'}, "\\");
1198 open OUT
, ">$makefiles{'lcc'}"; select OUT
;
1200 "# Makefile for $project_name under lcc.\n".
1201 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1202 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1203 # lcc command line option is -D not /D
1204 ($_ = $help) =~ s/([=" ])\/D/$1-D
/gs
;
1208 "# If you rename this file to `Makefile', you should change this line,\n".
1209 "# so that the .rsp files still depend on the correct makefile.\n".
1210 "MAKEFILE = Makefile.lcc\n".
1212 "# C compilation flags\n".
1213 "CFLAGS = -D_WINDOWS " .
1214 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
1216 "# Resource compilation flags\n".
1219 "# Get include directory for resource compiler\n".
1221 $makefile_extra{'lcc'}->{'vars'} .
1223 print &splitline
("all:" . join "", map { " $_.exe" } &progrealnames
("G:C"));
1225 foreach $p (&prognames
("G:C")) {
1226 ($prog, $type) = split ",", $p;
1227 $objstr = &objects
($p, "X.obj", "X.res", undef);
1228 print &splitline
("$prog.exe: " . $objstr ), "\n";
1229 $subsystemtype = '';
1230 if ($type eq "G") { $subsystemtype = "-subsystem windows"; }
1231 my $libss = "shell32.lib wsock32.lib ws2_32.lib winspool.lib winmm.lib imm32.lib";
1232 print &splitline
("\tlcclnk $subsystemtype -o $prog.exe $objstr $libss");
1236 foreach $d (&deps
("X.obj", "X.res", $dirpfx, "\\", "lcc")) {
1237 if ($forceobj{$d->{obj_orig
}}) {
1238 printf("%s: FORCE\n", $d->{obj
});
1240 print &splitline
(sprintf("%s: %s", $d->{obj
},
1241 join " ", @
{$d->{deps
}})), "\n";
1243 if ($d->{obj
} =~ /\.obj$/) {
1244 print &splitline
("\tlcc -O -p6 \$(COMPAT)".
1245 " \$(CFLAGS) \$(XFLAGS) ".$d->{deps
}->[0],69)."\n";
1247 print &splitline
("\tlrc \$(RCFL) -r \$(RCFLAGS) ".
1248 $d->{deps
}->[0],69)."\n";
1252 print $makefile_extra{'lcc'}->{'end'};
1260 select STDOUT
; close OUT
;
1263 if (defined $makefiles{'osx'}) {
1264 $dirpfx = &dirpfx
($makefiles{'osx'}, "/");
1266 ##-- Mac OS X makefile
1267 open OUT
, ">$makefiles{'osx'}"; select OUT
;
1269 "# Makefile for $project_name under Mac OS X.\n".
1270 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1271 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1272 # gcc command line option is -D not /D
1273 ($_ = $help) =~ s/([=" ])\/D/$1-D
/gs
;
1276 "CC = \$(TOOLPATH)gcc\n".
1278 &splitline
("CFLAGS = -O2 -Wall -Werror -g " .
1279 (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
1280 "MLDFLAGS = -framework Cocoa\n".
1283 $makefile_extra{'osx'}->{'vars'} .
1285 &splitline
("all:" . join "", map { " $_" } &progrealnames
("MX:U")) .
1287 foreach $p (&prognames
("MX")) {
1288 ($prog, $type) = split ",", $p;
1289 $objstr = &objects
($p, "X.o", undef, undef);
1290 $icon = &special
($p, ".icns");
1291 $infoplist = &special
($p, "info.plist");
1292 print "${prog}.app:\n\tmkdir -p \$\@\n";
1293 print "${prog}.app/Contents: ${prog}.app\n\tmkdir -p \$\@\n";
1294 print "${prog}.app/Contents/MacOS: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1295 $targets = "${prog}.app/Contents/MacOS/$prog";
1296 if (defined $icon) {
1297 print "${prog}.app/Contents/Resources: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1298 print "${prog}.app/Contents/Resources/${prog}.icns: ${prog}.app/Contents/Resources $icon\n\tcp $icon \$\@\n";
1299 $targets .= " ${prog}.app/Contents/Resources/${prog}.icns";
1301 if (defined $infoplist) {
1302 print "${prog}.app/Contents/Info.plist: ${prog}.app/Contents/Resources $infoplist\n\tcp $infoplist \$\@\n";
1303 $targets .= " ${prog}.app/Contents/Info.plist";
1305 $targets .= " \$(${prog}_extra)";
1306 print &splitline
("${prog}: $targets", 69) . "\n\n";
1307 print &splitline
("${prog}.app/Contents/MacOS/$prog: ".
1308 "${prog}.app/Contents/MacOS " . $objstr), "\n";
1309 $libstr = &objects
($p, undef, undef, "-lX");
1310 print &splitline
("\t\$(CC) \$(MLDFLAGS) -o \$@ " .
1311 $objstr . " $libstr", 69), "\n\n";
1313 foreach $p (&prognames
("U")) {
1314 ($prog, $type) = split ",", $p;
1315 $objstr = &objects
($p, "X.o", undef, undef);
1316 print &splitline
($prog . ": " . $objstr), "\n";
1317 $libstr = &objects
($p, undef, undef, "-lX");
1318 print &splitline
("\t\$(CC) \$(ULDFLAGS) -o \$@ " .
1319 $objstr . " $libstr", 69), "\n\n";
1321 foreach $d (&deps
("X.o", undef, $dirpfx, "/", "osx")) {
1322 if ($forceobj{$d->{obj_orig
}}) {
1323 printf("%s: FORCE\n", $d->{obj
});
1325 print &splitline
(sprintf("%s: %s", $d->{obj
},
1326 join " ", @
{$d->{deps
}})), "\n";
1328 $firstdep = $d->{deps
}->[0];
1329 if ($firstdep =~ /\.c$/) {
1330 print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
1331 } elsif ($firstdep =~ /\.m$/) {
1332 print "\t\$(CC) -x objective-c \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
1335 print "\n".&def
($makefile_extra{'osx'}->{'end'});
1337 "\trm -f *.o *.dmg". (join "", map { " $_" } &progrealnames
("U")) . "\n".
1341 select STDOUT
; close OUT
;
1344 if (defined $makefiles{'devcppproj'}) {
1345 $dirpfx = &dirpfx
($makefiles{'devcppproj'}, "\\");
1348 ##-- Dev-C++ 5 projects
1350 # Note: All files created in this section are written in binary
1351 # mode to prevent any posibility of misinterpreted line endings.
1352 # I don't know if Dev-C++ is as touchy as MSVC with LF-only line
1353 # endings. But however, CRLF line endings are the common way on
1354 # Win32 machines where Dev-C++ is running.
1355 # Hence, in order for mkfiles.pl to generate CRLF project files
1356 # even when run from Unix, I make sure all files are binary and
1357 # explicitly write the CRLFs.
1359 # Create directories if necessary
1360 mkdir $makefiles{'devcppproj'}
1361 if(! -d
$makefiles{'devcppproj'});
1362 chdir $makefiles{'devcppproj'};
1363 @deps = &deps
("X.obj", "X.res", $dirpfx, "\\", "devcppproj");
1364 %all_object_deps = map {$_->{obj
} => $_->{deps
}} @deps;
1365 # Make dir names FAT/NTFS compatible
1366 my @srcdirs = @srcdirs;
1367 for ($i=0; $i<@srcdirs; $i++) {
1368 $srcdirs[$i] =~ s/\//\\/g
;
1369 $srcdirs[$i] =~ s/\\$//;
1371 # Create the project files
1372 # Get names of all Windows projects (GUI and console)
1373 my @prognames = &prognames
("G:C");
1374 foreach $progname (@prognames) {
1375 create_devcpp_project
(\
%all_object_deps, $progname);
1380 sub create_devcpp_project
{
1381 my ($all_object_deps, $progname) = @_;
1382 # Construct program's dependency info (Taken from 'vcproj', seems to work right here, too.)
1387 %resource_files = ();
1388 @object_files = split " ", &objects
($progname, "X.obj", "X.res", "X.lib");
1389 foreach $object_file (@object_files) {
1390 next if defined $seen_objects{$object_file};
1391 $seen_objects{$object_file} = 1;
1392 if($object_file =~ /\.lib$/io) {
1393 $lib_files{$object_file} = 1;
1396 $object_deps = $all_object_deps{$object_file};
1397 foreach $object_dep (@
$object_deps) {
1398 if($object_dep =~ /\.c$/io) {
1399 $source_files{$object_dep} = 1;
1402 if($object_dep =~ /\.h$/io) {
1403 $header_files{$object_dep} = 1;
1406 if($object_dep =~ /\.(rc|ico)$/io) {
1407 $resource_files{$object_dep} = 1;
1412 $libs = join " ", sort keys %lib_files;
1413 @source_files = sort keys %source_files;
1414 @header_files = sort keys %header_files;
1415 @resources = sort keys %resource_files;
1416 ($windows_project, $type) = split ",", $progname;
1417 mkdir $windows_project
1418 if(! -d
$windows_project);
1419 chdir $windows_project;
1421 $subsys = ($type eq "G") ?
"0" : "1"; # 0 = Win32 GUI, 1 = Win32 Console
1422 open OUT
, ">$windows_project.dev"; binmode OUT
; select OUT
;
1424 "# DEV-C++ 5 Project File - $windows_project.dev\r\n".
1425 "# ** DO NOT EDIT **\r\n".
1427 # No difference between DEBUG and RELEASE here as in 'vcproj', because
1428 # Dev-C++ does not support mutiple compilation profiles in one single project.
1429 # (At least I can say this for Dev-C++ 5 Beta)
1431 "FileName=$windows_project.dev\r\n".
1432 "Name=$windows_project\r\n".
1436 # Multimon is disabled here, as Dev-C++ (Version 5 Beta) does not have multimon.h
1437 "Compiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
1438 "CppCompiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
1439 "Includes=" . (join ";", map {"..\\..\\$dirpfx$_"} @srcdirs) . "\r\n".
1440 "Linker=-ladvapi32 -lcomctl32 -lcomdlg32 -lgdi32 -limm32 -lshell32 -luser32 -lwinmm -lwinspool_\@\@_\r\n".
1442 "UnitCount=" . (@source_files + @header_files + @resources) . "\r\n".
1443 "Folders=\"Header Files\",\"Resource Files\",\"Source Files\"\r\n".
1445 "PrivateResource=${windows_project}_private.rc\r\n".
1446 "ResourceIncludes=..\\..\\..\\WINDOWS\r\n".
1447 "MakeIncludes=\r\n".
1448 "Icon=\r\n". # It's ok to leave this blank.
1450 "ObjectOutput=\r\n".
1451 "OverrideOutput=0\r\n".
1452 "OverrideOutputName=$windows_project.exe\r\n".
1453 "HostApplication=\r\n".
1455 "UseCustomMakefile=0\r\n".
1456 "CustomMakefile=\r\n".
1457 "IncludeVersionInfo=0\r\n".
1458 "SupportXPThemes=0\r\n".
1459 "CompilerSet=0\r\n".
1460 "CompilerSettings=0000000000000000000000\r\n".
1463 foreach $source_file (@source_files) {
1465 "[Unit$unit_count]\r\n".
1466 "FileName=..\\..\\$source_file\r\n".
1467 "Folder=Source Files\r\n".
1471 "Priority=1000\r\n".
1472 "OverrideBuildCmd=0\r\n".
1477 foreach $header_file (@header_files) {
1479 "[Unit$unit_count]\r\n".
1480 "FileName=..\\..\\$header_file\r\n".
1481 "Folder=Header Files\r\n".
1483 "CompileCpp=1\r\n". # Dev-C++ want's to compile all header files with both compilers C and C++. It does not hurt.
1485 "Priority=1000\r\n".
1486 "OverrideBuildCmd=0\r\n".
1491 foreach $resource_file (@resources) {
1492 if ($resource_file =~ /.*\.(ico|cur|bmp|dlg|rc2|rct|bin|rgs|gif|jpg|jpeg|jpe)/io) { # Default filter as in 'vcproj'
1493 $Compile = "0"; # Don't compile images and other binary resource files
1497 $CompileCpp = "1"; # Dev-C++ want's to compile all .rc files with both compilers C and C++. It does not hurt.
1500 "[Unit$unit_count]\r\n".
1501 "FileName=..\\..\\$resource_file\r\n".
1502 "Folder=Resource Files\r\n".
1503 "Compile=$Compile\r\n".
1504 "CompileCpp=$CompileCpp\r\n".
1506 "Priority=1000\r\n".
1507 "OverrideBuildCmd=0\r\n".
1512 #Note: By default, [VersionInfo] is not used.
1514 "[VersionInfo]\r\n".
1519 "LanguageID=1033\r\n".
1520 "CharsetID=1252\r\n".
1522 "FileVersion=0.1\r\n".
1523 "FileDescription=\r\n".
1524 "InternalName=\r\n".
1525 "LegalCopyright=\r\n".
1526 "LegalTrademarks=\r\n".
1527 "OriginalFilename=$windows_project.exe\r\n".
1528 "ProductName=$windows_project\r\n".
1529 "ProductVersion=0.1\r\n".
1530 "AutoIncBuildNr=0\r\n";
1531 select STDOUT
; close OUT
;
1536 # All done, so do the Unix postprocessing if asked to.
1540 system "./mkauto.sh";
1541 die "mkfiles.pl: mkauto.sh returned $?\n" if $?
> 0;
1542 chdir ($targetdir = dirname
($makefiles{"am"}))
1543 or die "$targetdir: chdir: $!\n";
1544 system "./configure", @confargs;
1545 die "mkfiles.pl: configure returned $?\n" if $?
> 0;