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 use Digest::SHA qw(sha512_hex);
24 if ($#ARGV >= 0 and ($ARGV[0] eq "-u" or $ARGV[0] eq "-U")) {
25 # Convenience for Unix users: -u means that after we finish what
26 # we're doing here, we also run mkauto.sh and then 'configure' in
27 # the Unix subdirectory. So it's a one-stop shop for regenerating
28 # the actual end-product Unix makefile.
30 # Arguments supplied after -u go to configure.
32 # -U is identical, but runs 'configure' at the _top_ level, for
33 # people who habitually do that.
34 $do_unix = ($ARGV[0] eq "-U" ? 2 : 1);
39 open IN, "Recipe" or do {
40 # We want to deal correctly with being run from one of the
41 # subdirs in the source tree. So if we can't find Recipe here,
44 open IN, "Recipe" or die "unable to open Recipe file\n";
47 # HACK: One of the source files in `charset' is auto-generated by
48 # sbcsgen.pl. We need to generate that _now_, before attempting
49 # dependency analysis.
50 eval 'chdir "charset"; require "sbcsgen.pl"; chdir ".."; select STDOUT;';
54 $divert = undef; # ref to scalar in which text is currently being put
55 $help = ""; # list of newline-free lines of help text
56 $project_name = "project"; # this is a good enough default
57 %makefiles = (); # maps makefile types to output makefile pathnames
58 %makefile_extra = (); # maps makefile types to extra Makefile text
59 %programs = (); # maps prog name + type letter to listref of objects/resources
60 %groups = (); # maps group name to listref of objects/resources
66 # If we're gathering help text, keep doing so.
67 if (defined $divert) {
68 if ((defined $_[0]) && $_[0] eq "!end") {
75 # Skip comments and blank lines.
76 next if /^\s*#/ or scalar @_ == 0;
78 if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = \$help; next; }
79 if ($_[0] eq "!end") { $divert = undef; next; }
80 if ($_[0] eq "!name") { $project_name = $_[1]; next; }
81 if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; }
82 if ($_[0] eq "!makefile" and &mfval($_[1])) { $makefiles{$_[1]}=$_[2]; next;}
83 if ($_[0] eq "!specialobj" and &mfval($_[1])) { $specialobj{$_[1]}->{$_[2]} = 1; next;}
84 if ($_[0] eq "!cflags" and &mfval($_[1])) {
85 ($rest = $_) =~ s/^\s*\S+\s+\S+\s+\S+\s*//; # find rest of input line
86 $rest = 1 if $rest eq "";
87 $cflags{$_[1]}->{$_[2]} = $rest;
90 if ($_[0] eq "!forceobj") { $forceobj{$_[1]} = 1; next; }
91 if ($_[0] eq "!begin") {
92 if ($_[1] =~ /^>(.*)/) {
93 $divert = \$auxfiles{$1};
94 } elsif (&mfval($_[1])) {
95 $sect = $_[2] ? $_[2] : "end";
96 $divert = \($makefile_extra{$_[1]}->{$sect});
103 # If we're gathering help/verbatim text, keep doing so.
104 if (defined $divert) { ${$divert} .= "$_\n"; next; }
105 # Ignore blank lines.
106 next if scalar @_ == 0;
108 # Now we have an ordinary line. See if it's an = line, a : line
113 $listref = $lastlistref;
115 die "$.: unexpected + line\n" if !defined $lastlistref;
116 } elsif ($_[1] eq "=") {
117 $groups{$_[0]} = [] if !defined $groups{$_[0]};
118 $listref = $groups{$_[0]};
120 shift @objs; # eat the group name
121 } elsif ($_[1] eq ":") {
124 shift @objs; # eat the program name
126 die "$.: unrecognised line type\n";
128 shift @objs; # eat the +, the = or the :
130 while (scalar @objs > 0) {
133 foreach $j (@{$groups{$i}}) { unshift @objs, $j; }
134 } elsif (($i =~ /^\[([A-Z]*)\]$/) and defined $prog) {
135 $type = substr($i,1,(length $i)-2);
136 die "unrecognised program type for $prog [$type]\n"
137 if ! grep { $type eq $_ } qw(G C X U MX UT);
142 if ($prog and $type) {
143 die "multiple program entries for $prog [$type]\n"
144 if defined $programs{$prog . "," . $type};
145 $programs{$prog . "," . $type} = $listref;
147 $lastlistref = $listref;
152 foreach $aux (sort keys %auxfiles) {
154 print AUX $auxfiles{$aux};
158 # Now retrieve the complete list of objects and resource files, and
159 # construct dependency data for them. While we're here, expand the
160 # object list for each program, and complain if its type isn't set.
161 @prognames = sort keys %programs;
164 foreach $i (@prognames) {
165 ($prog, $type) = split ",", $i;
166 # Strip duplicate object names.
168 @list = grep { $status = ($prev ne $_); $prev=$_; $status }
169 sort @{$programs{$i}};
170 $programs{$i} = [@list];
172 # Dependencies for "x" start with "x.c" or "x.m" (depending on
174 # Dependencies for "x.res" start with "x.rc".
175 # Dependencies for "x.rsrc" start with "x.r".
176 # Both types of file are pushed on the list of files to scan.
177 # Libraries (.lib) don't have dependencies at all.
178 if ($j =~ /^(.*)\.res$/) {
180 $depends{$j} = [$file];
181 push @scanlist, $file;
182 } elsif ($j =~ /^(.*)\.rsrc$/) {
184 $depends{$j} = [$file];
185 push @scanlist, $file;
186 } elsif ($j !~ /\./) {
188 $file = "$j.m" unless &findfile($file);
189 $depends{$j} = [$file];
190 push @scanlist, $file;
195 # Scan each file on @scanlist and find further inclusions.
196 # Inclusions are given by lines of the form `#include "otherfile"'
197 # (system headers are automatically ignored by this because they'll
198 # be given in angle brackets). Files included by this method are
199 # added back on to @scanlist to be scanned in turn (if not already
202 # Resource scripts (.rc) can also include a file by means of:
203 # - a line # ending `ICON "filename"';
204 # - a line ending `RT_MANIFEST "filename"'.
205 # Files included by this method are not added to @scanlist because
206 # they can never include further files.
208 # In this pass we write out a hash %further which maps a source
209 # file name into a listref containing further source file names.
212 %allsourcefiles = (); # this is wanted by some makefiles
213 while (scalar @scanlist > 0) {
214 $file = shift @scanlist;
215 next if defined $further{$file}; # skip if we've already done it
216 $further{$file} = [];
217 $dirfile = &findfile($file);
218 $allsourcefiles{$dirfile} = 1;
219 open IN, "$dirfile" or die "unable to open source file $file\n";
222 /^\s*#include\s+\"([^\"]+)\"/ and do {
223 push @{$further{$file}}, $1;
227 /(RT_MANIFEST|ICON)\s+\"([^\"]+)\"\s*$/ and do {
228 push @{$further{$file}}, $2;
235 # Now we're ready to generate the final dependencies section. For
236 # each key in %depends, we must expand the dependencies list by
237 # iteratively adding entries from %further.
238 foreach $i (keys %depends) {
240 @scanlist = @{$depends{$i}};
241 foreach $i (@scanlist) { $dep{$i} = 1; }
242 while (scalar @scanlist > 0) {
243 $file = shift @scanlist;
244 foreach $j (@{$further{$file}}) {
247 push @{$depends{$i}}, $j;
252 # printf "%s: %s\n", $i, join ' ',@{$depends{$i}};
255 # Validation of input.
259 # Returns true if the argument is a known makefile type. Otherwise,
260 # prints a warning and returns false;
261 if (grep { $type eq $_ }
262 ("vc","vcproj","cygwin","borland","lcc","devcppproj","gtk","unix",
263 "am","osx","vstudio10","vstudio12")) {
266 warn "$.:unknown makefile type '$type'\n";
270 # Utility routines while writing out the Makefiles.
274 return (defined $x) ? $x : "";
278 my ($path) = shift @_;
279 my ($sep) = shift @_;
283 while (($i = index $path, $sep) >= 0 ||
284 ($j = index $path, "/") >= 0) {
285 if ($i >= 0 and ($j < 0 or $i < $j)) {
286 $path = substr $path, ($i + length $sep);
288 $path = substr $path, ($j + 1);
300 unless (defined $findfilecache{$name}) {
302 foreach $dir (@srcdirs) {
303 if (-f "$dir$name") {
306 $outdir =~ s/^\.\///;
309 die "multiple instances of source file $name\n" if $i > 1;
310 $findfilecache{$name} = (defined $outdir ? $outdir . $name : undef);
312 return $findfilecache{$name};
316 my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_;
319 ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ? $_ : "" } ($otmpl, $rtmpl, $ltmpl);
321 foreach $i (@{$programs{$prog}}) {
323 if ($i =~ /^(.*)\.(res|rsrc)/) {
325 ($x = $rtmpl) =~ s/X/$y/;
326 } elsif ($i =~ /^(.*)\.lib/) {
328 ($x = $ltmpl) =~ s/X/$y/;
329 } elsif ($i !~ /\./) {
330 ($x = $otmpl) =~ s/X/$i/;
332 push @ret, $x if $x ne "";
334 return join " ", @ret;
338 my ($prog, $suffix) = @_;
341 ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ? $_ : "" } ($otmpl, $rtmpl, $ltmpl);
343 foreach $i (@{$programs{$prog}}) {
344 if (substr($i, (length $i) - (length $suffix)) eq $suffix) {
348 return (scalar @ret) ? (join " ", @ret) : undef;
352 my ($line, $width, $splitchar) = @_;
355 $len = (defined $width ? $width : 76);
356 $splitchar = (defined $splitchar ? $splitchar : '\\');
357 while (length $line > $len) {
358 $line =~ /^(.{0,$len})\s(.*)$/ or $line =~ /^(.{$len,}?\s(.*)$/;
360 $result .= " ${splitchar}\n\t\t" if $2 ne '';
364 return $result . $line;
368 my ($otmpl, $rtmpl, $prefix, $dirsep, $mftyp, $depchar, $splitchar) = @_;
374 foreach $i (sort keys %depends) {
375 next if $specialobj{$mftyp}->{$i};
376 if ($i =~ /^(.*)\.(res|rsrc)/) {
377 next if !defined $rtmpl;
379 ($x = $rtmpl) =~ s/X/$y/;
381 ($x = $otmpl) =~ s/X/$i/;
383 @deps = @{$depends{$i}};
389 push @ret, {obj => $x, obj_orig => $i, deps => [@deps]};
396 my ($n, $prog, $type);
399 foreach $n (@prognames) {
400 ($prog, $type) = split ",", $n;
401 push @ret, $n if index(":$types:", ":$type:") >= 0;
408 my ($n, $prog, $type);
411 foreach $n (@prognames) {
412 ($prog, $type) = split ",", $n;
413 push @ret, $prog if index(":$types:", ":$type:") >= 0;
419 my ($types,$suffix) = @_;
421 # assume that all UNIX programs have a man page
422 if($suffix eq "1" && $types =~ /:X:/) {
423 return map("$_.1", &progrealnames($types));
430 # Now we're ready to output the actual Makefiles.
432 if (defined $makefiles{'cygwin'}) {
433 $dirpfx = &dirpfx($makefiles{'cygwin'}, "/");
436 open OUT, ">$makefiles{'cygwin'}"; select OUT;
438 "# Makefile for $project_name under Cygwin, MinGW, or Winelib.\n".
439 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
440 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
441 # gcc command line option is -D not /D
442 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
446 "# You can define this path to point at your tools if you need to\n".
447 "# TOOLPATH = c:\\cygwin\\bin\\ # or similar, if you're running Windows\n".
448 "# TOOLPATH = /pkg/mingw32msvc/i386-mingw32msvc/bin/\n".
449 "CC = \$(TOOLPATH)gcc\n".
450 "RC = \$(TOOLPATH)windres\n".
451 "# Uncomment the following two lines to compile under Winelib\n".
454 "# You may also need to tell windres where to find include files:\n".
455 "# RCINC = --include-dir c:\\cygwin\\include\\\n".
457 &splitline("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
458 " -D_NO_OLDNAMES -DNO_MULTIMON -DNO_HTMLHELP -DNO_SECUREZEROMEMORY " .
459 (join " ", map {"-I$dirpfx$_"} @srcdirs)) .
461 "LDFLAGS = -mno-cygwin -s\n".
462 &splitline("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1 ".
463 "--define WINVER=0x0400 ".(join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
465 &def($makefile_extra{'cygwin'}->{'vars'}) .
469 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
471 foreach $p (&prognames("G:C")) {
472 ($prog, $type) = split ",", $p;
473 $objstr = &objects($p, "X.o", "X.res.o", undef);
474 print &splitline($prog . ".exe: " . $objstr), "\n";
475 my $mw = $type eq "G" ? " -mwindows" : "";
476 $libstr = &objects($p, undef, undef, "-lX");
477 print &splitline("\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " .
478 "-Wl,-Map,$prog.map " .
479 $objstr . " $libstr", 69), "\n\n";
481 foreach $d (&deps("X.o", "X.res.o", $dirpfx, "/", "cygwin")) {
482 if ($forceobj{$d->{obj_orig}}) {
483 printf ("%s: FORCE\n", $d->{obj});
485 print &splitline(sprintf("%s: %s", $d->{obj},
486 join " ", @{$d->{deps}})), "\n";
488 if ($d->{obj} =~ /\.res\.o$/) {
489 print "\t\$(RC) \$(RCFL) \$(RCFLAGS) ".$d->{deps}->[0]." -o ".$d->{obj}."\n\n";
491 print "\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c ".$d->{deps}->[0]."\n\n";
495 print &def($makefile_extra{'cygwin'}->{'end'});
497 "\trm -f *.o *.exe *.res.o *.so *.map\n".
500 select STDOUT; close OUT;
504 ##-- Borland makefile
505 if (defined $makefiles{'borland'}) {
506 $dirpfx = &dirpfx($makefiles{'borland'}, "\\");
508 %stdlibs = ( # Borland provides many Win32 API libraries intrinsically
520 open OUT, ">$makefiles{'borland'}"; select OUT;
522 "# Makefile for $project_name under Borland C.\n".
523 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
524 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
525 # bcc32 command line option is -D not /D
526 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
530 "# If you rename this file to `Makefile', you should change this line,\n".
531 "# so that the .rsp files still depend on the correct makefile.\n".
532 "MAKEFILE = Makefile.bor\n".
534 "# C compilation flags\n".
535 "CFLAGS = -D_WINDOWS -DWINVER=0x0500\n".
536 "# Resource compilation flags\n".
537 "RCFLAGS = -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401\n".
539 "# Get include directory for resource compiler\n".
541 "BCB = \$(MAKEDIR)\\..\n".
544 &def($makefile_extra{'borland'}->{'vars'}) .
547 &splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT)".
548 " \$(CFLAGS) \$(XFLAGS) ".
549 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
550 " /c \$*.c",69)."\n".
552 &splitline("\tbrcc32 \$(RCFL) -i \$(BCB)\\include -r".
553 " \$(RCFLAGS) \$*.rc",69)."\n".
555 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
557 foreach $p (&prognames("G:C")) {
558 ($prog, $type) = split ",", $p;
559 $objstr = &objects($p, "X.obj", "X.res", undef);
560 print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
561 my $ap = ($type eq "G") ? "-aa" : "-ap";
562 print "\tilink32 $ap -Gn -L\$(BCB)\\lib \@$prog.rsp\n\n";
564 foreach $p (&prognames("G:C")) {
565 ($prog, $type) = split ",", $p;
566 print $prog, ".rsp: \$(MAKEFILE)\n";
567 $objstr = &objects($p, "X.obj", undef, undef);
568 @objlist = split " ", $objstr;
570 foreach $i (@objlist) {
571 if (length($objlines[$#objlines] . " $i") > 50) {
574 $objlines[$#objlines] .= " $i";
576 $c0w = ($type eq "G") ? "c0w32" : "c0x32";
577 print "\techo $c0w + > $prog.rsp\n";
578 for ($i=0; $i<=$#objlines; $i++) {
579 $plus = ($i < $#objlines ? " +" : "");
580 print "\techo$objlines[$i]$plus >> $prog.rsp\n";
582 print "\techo $prog.exe >> $prog.rsp\n";
583 $objstr = &objects($p, "X.obj", "X.res", undef);
584 @libs = split " ", &objects($p, undef, undef, "X");
585 @libs = grep { !$stdlibs{$_} } @libs;
586 unshift @libs, "cw32", "import32";
587 $libstr = join ' ', @libs;
588 print "\techo nul,$libstr, >> $prog.rsp\n";
589 print "\techo " . &objects($p, undef, "X.res", undef) . " >> $prog.rsp\n";
592 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "borland")) {
593 if ($forceobj{$d->{obj_orig}}) {
594 printf("%s: FORCE\n", $d->{obj});
596 print &splitline(sprintf("%s: %s", $d->{obj},
597 join " ", @{$d->{deps}})), "\n";
601 print &def($makefile_extra{'borland'}->{'end'});
612 "\t-del *.\$\$\$\$\$\$\n".
615 "\t-rem dummy command\n";
616 select STDOUT; close OUT;
619 if (defined $makefiles{'vc'}) {
620 $dirpfx = &dirpfx($makefiles{'vc'}, "\\");
622 ##-- Visual C++ makefile
623 open OUT, ">$makefiles{'vc'}"; select OUT;
625 "# Makefile for $project_name under Visual C.\n".
626 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
627 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
631 "# If you rename this file to `Makefile', you should change this line,\n".
632 "# so that the .rsp files still depend on the correct makefile.\n".
633 "MAKEFILE = Makefile.vc\n".
635 "# C compilation flags\n".
636 "CFLAGS = /nologo /W3 /O1 " .
637 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
638 " /D_WINDOWS /D_WIN32_WINDOWS=0x500 /DWINVER=0x500\n".
639 "LFLAGS = /incremental:no /fixed\n".
640 "RCFLAGS = ".(join " ", map {"-I$dirpfx$_"} @srcdirs).
641 " -DWIN32 -D_WIN32 -DWINVER=0x0400\n".
643 &def($makefile_extra{'vc'}->{'vars'}) .
646 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
648 foreach $p (&prognames("G:C")) {
649 ($prog, $type) = split ",", $p;
650 $objstr = &objects($p, "X.obj", "X.res", undef);
651 print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
652 print "\tlink \$(LFLAGS) \$(XLFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n";
654 foreach $p (&prognames("G:C")) {
655 ($prog, $type) = split ",", $p;
656 print $prog, ".rsp: \$(MAKEFILE)\n";
657 $objstr = &objects($p, "X.obj", "X.res", "X.lib");
658 @objlist = split " ", $objstr;
660 foreach $i (@objlist) {
661 if (length($objlines[$#objlines] . " $i") > 50) {
664 $objlines[$#objlines] .= " $i";
666 $subsys = ($type eq "G") ? "windows" : "console";
667 print "\techo /nologo /subsystem:$subsys > $prog.rsp\n";
668 for ($i=0; $i<=$#objlines; $i++) {
669 print "\techo$objlines[$i] >> $prog.rsp\n";
673 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "vc")) {
674 $extradeps = $forceobj{$d->{obj_orig}} ? ["*.c","*.h","*.rc"] : [];
675 print &splitline(sprintf("%s: %s", $d->{obj},
676 join " ", @$extradeps, @{$d->{deps}})), "\n";
677 if ($d->{obj} =~ /.obj$/) {
678 print "\tcl \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c ".$d->{deps}->[0],"\n\n";
680 print "\trc \$(RCFL) -r \$(RCFLAGS) ".$d->{deps}->[0],"\n\n";
684 print &def($makefile_extra{'vc'}->{'end'});
685 print "\nclean: tidy\n".
702 "\t-del debug.log\n";
703 select STDOUT; close OUT;
706 if (defined $makefiles{'vcproj'}) {
707 $dirpfx = &dirpfx($makefiles{'vcproj'}, "\\");
709 ##-- MSVC 6 Workspace and projects
711 # Note: All files created in this section are written in binary
712 # mode, because although MSVC's command-line make can deal with
713 # LF-only line endings, MSVC project files really _need_ to be
714 # CRLF. Hence, in order for mkfiles.pl to generate usable project
715 # files even when run from Unix, I make sure all files are binary
716 # and explicitly write the CRLFs.
718 # Create directories if necessary
719 mkdir $makefiles{'vcproj'}
720 if(! -d $makefiles{'vcproj'});
721 chdir $makefiles{'vcproj'};
722 @deps = &deps("X.obj", "X.res", $dirpfx, "\\", "vcproj");
723 %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;
724 # Create the project files
725 # Get names of all Windows projects (GUI and console)
726 my @prognames = &prognames("G:C");
727 foreach $progname (@prognames) {
728 create_vc_project(\%all_object_deps, $progname);
730 # Create the workspace file
731 open OUT, ">$project_name.dsw"; binmode OUT; select OUT;
733 "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n".
734 "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n".
736 "###############################################################################\r\n".
739 foreach $progname (@prognames) {
740 ($windows_project, $type) = split ",", $progname;
741 print "Project: \"$windows_project\"=\".\\$windows_project\\$windows_project.dsp\" - Package Owner=<4>\r\n";
753 "###############################################################################\r\n".
765 "###############################################################################\r\n".
767 select STDOUT; close OUT;
770 sub create_vc_project {
771 my ($all_object_deps, $progname) = @_;
772 # Construct program's dependency info
777 %resource_files = ();
778 @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");
779 foreach $object_file (@object_files) {
780 next if defined $seen_objects{$object_file};
781 $seen_objects{$object_file} = 1;
782 if($object_file =~ /\.lib$/io) {
783 $lib_files{$object_file} = 1;
786 $object_deps = $all_object_deps{$object_file};
787 foreach $object_dep (@$object_deps) {
788 if($object_dep =~ /\.c$/io) {
789 $source_files{$object_dep} = 1;
792 if($object_dep =~ /\.h$/io) {
793 $header_files{$object_dep} = 1;
796 if($object_dep =~ /\.(rc|ico)$/io) {
797 $resource_files{$object_dep} = 1;
802 $libs = join " ", sort keys %lib_files;
803 @source_files = sort keys %source_files;
804 @header_files = sort keys %header_files;
805 @resources = sort keys %resource_files;
806 ($windows_project, $type) = split ",", $progname;
807 mkdir $windows_project
808 if(! -d $windows_project);
809 chdir $windows_project;
810 $subsys = ($type eq "G") ? "windows" : "console";
811 open OUT, ">$windows_project.dsp"; binmode OUT; select OUT;
813 "# Microsoft Developer Studio Project File - Name=\"$windows_project\" - Package Owner=<4>\r\n".
814 "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n".
815 "# ** DO NOT EDIT **\r\n".
817 "# TARGTYPE \"Win32 (x86) Application\" 0x0101\r\n".
819 "CFG=$windows_project - Win32 Debug\r\n".
820 "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n".
821 "!MESSAGE use the Export Makefile command and run\r\n".
823 "!MESSAGE NMAKE /f \"$windows_project.mak\".\r\n".
825 "!MESSAGE You can specify a configuration when running NMAKE\r\n".
826 "!MESSAGE by defining the macro CFG on the command line. For example:\r\n".
828 "!MESSAGE NMAKE /f \"$windows_project.mak\" CFG=\"$windows_project - Win32 Debug\"\r\n".
830 "!MESSAGE Possible choices for configuration are:\r\n".
832 "!MESSAGE \"$windows_project - Win32 Release\" (based on \"Win32 (x86) Application\")\r\n".
833 "!MESSAGE \"$windows_project - Win32 Debug\" (based on \"Win32 (x86) Application\")\r\n".
836 "# Begin Project\r\n".
837 "# PROP AllowPerConfigDependencies 0\r\n".
838 "# PROP Scc_ProjName \"\"\r\n".
839 "# PROP Scc_LocalPath \"\"\r\n".
844 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
846 "# PROP BASE Use_MFC 0\r\n".
847 "# PROP BASE Use_Debug_Libraries 0\r\n".
848 "# PROP BASE Output_Dir \"Release\"\r\n".
849 "# PROP BASE Intermediate_Dir \"Release\"\r\n".
850 "# PROP BASE Target_Dir \"\"\r\n".
851 "# PROP Use_MFC 0\r\n".
852 "# PROP Use_Debug_Libraries 0\r\n".
853 "# PROP Output_Dir \"Release\"\r\n".
854 "# PROP Intermediate_Dir \"Release\"\r\n".
855 "# PROP Ignore_Export_Lib 0\r\n".
856 "# PROP Target_Dir \"\"\r\n".
857 "# ADD BASE CPP /nologo /W3 /GX /O2 ".
858 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
859 " /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
860 "# ADD CPP /nologo /W3 /GX /O2 ".
861 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
862 " /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
863 "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
864 "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
865 "# ADD BASE RSC /l 0x809 /d \"NDEBUG\"\r\n".
866 "# ADD RSC /l 0x809 /d \"NDEBUG\"\r\n".
867 "BSC32=bscmake.exe\r\n".
868 "# ADD BASE BSC32 /nologo\r\n".
869 "# ADD BSC32 /nologo\r\n".
870 "LINK32=link.exe\r\n".
871 "# 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".
872 "# ADD LINK32 $libs /nologo /subsystem:$subsys /machine:I386\r\n".
873 "# SUBTRACT LINK32 /pdb:none\r\n".
875 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
877 "# PROP BASE Use_MFC 0\r\n".
878 "# PROP BASE Use_Debug_Libraries 1\r\n".
879 "# PROP BASE Output_Dir \"Debug\"\r\n".
880 "# PROP BASE Intermediate_Dir \"Debug\"\r\n".
881 "# PROP BASE Target_Dir \"\"\r\n".
882 "# PROP Use_MFC 0\r\n".
883 "# PROP Use_Debug_Libraries 1\r\n".
884 "# PROP Output_Dir \"Debug\"\r\n".
885 "# PROP Intermediate_Dir \"Debug\"\r\n".
886 "# PROP Ignore_Export_Lib 0\r\n".
887 "# PROP Target_Dir \"\"\r\n".
888 "# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od ".
889 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
890 " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
891 "# ADD CPP /nologo /W3 /Gm /GX /ZI /Od ".
892 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
893 " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
894 "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
895 "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
896 "# ADD BASE RSC /l 0x809 /d \"_DEBUG\"\r\n".
897 "# ADD RSC /l 0x809 /d \"_DEBUG\"\r\n".
898 "BSC32=bscmake.exe\r\n".
899 "# ADD BASE BSC32 /nologo\r\n".
900 "# ADD BSC32 /nologo\r\n".
901 "LINK32=link.exe\r\n".
902 "# 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".
903 "# ADD LINK32 $libs /nologo /subsystem:$subsys /debug /machine:I386 /pdbtype:sept\r\n".
904 "# SUBTRACT LINK32 /pdb:none\r\n".
908 "# Begin Target\r\n".
910 "# Name \"$windows_project - Win32 Release\"\r\n".
911 "# Name \"$windows_project - Win32 Debug\"\r\n".
912 "# Begin Group \"Source Files\"\r\n".
914 "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
915 foreach $source_file (@source_files) {
917 "# Begin Source File\r\n".
919 "SOURCE=..\\..\\$source_file\r\n";
920 if($source_file =~ /ssh\.c/io) {
921 # Disable 'Edit and continue' as Visual Studio can't handle the macros
924 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
926 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
933 print "# End Source File\r\n";
937 "# Begin Group \"Header Files\"\r\n".
939 "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
940 foreach $header_file (@header_files) {
942 "# Begin Source File\r\n".
944 "SOURCE=..\\..\\$header_file\r\n".
945 "# End Source File\r\n";
949 "# Begin Group \"Resource Files\"\r\n".
951 "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
952 foreach $resource_file (@resources) {
954 "# Begin Source File\r\n".
956 "SOURCE=..\\..\\$resource_file\r\n".
957 "# End Source File\r\n";
963 select STDOUT; close OUT;
968 if (defined $makefiles{'vstudio10'} || defined $makefiles{'vstudio12'}) {
970 ##-- Visual Studio 2010+ Solution and Projects
972 if (defined $makefiles{'vstudio10'}) {
973 create_vs_solution('vstudio10', "2010", "11.00", "v100");
976 if (defined $makefiles{'vstudio12'}) {
977 create_vs_solution('vstudio12', "2012", "12.00", "v110");
980 sub create_vs_solution {
981 my ($makefilename, $name, $version, $toolsver) = @_;
983 $dirpfx = &dirpfx($makefiles{$makefilename}, "\\");
985 @deps = &deps("X.obj", "X.res", $dirpfx, "\\", $makefilename);
986 %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;
988 my @prognames = &prognames("G:C");
990 # Create the solution file.
991 mkdir $makefiles{$makefilename}
992 if(! -f $makefiles{$makefilename});
993 chdir $makefiles{$makefilename};
995 open OUT, ">$project_name.sln"; select OUT;
998 "Microsoft Visual Studio Solution File, Format Version $version\n" .
999 "# Visual Studio $name\n";
1002 foreach $progname (@prognames) {
1003 ($windows_project, $type) = split ",", $progname;
1005 $projguids{$windows_project} = $guid =
1006 &invent_guid("project:$progname");
1009 "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"$windows_project\", \"$windows_project\\$windows_project.vcxproj\", \"{$guid}\"\n" .
1015 " GlobalSection(SolutionConfigurationPlatforms) = preSolution\n" .
1016 " Debug|Win32 = Debug|Win32\n" .
1017 " Release|Win32 = Release|Win32\n" .
1018 " EndGlobalSection\n" .
1019 " GlobalSection(ProjectConfigurationPlatforms) = postSolution\n" ;
1021 foreach my $projguid (values %projguids) {
1023 " {$projguid}.Debug|Win32.ActiveCfg = Debug|Win32\n" .
1024 " {$projguid}.Debug|Win32.Build.0 = Debug|Win32\n" .
1025 " {$projguid}.Release|Win32.ActiveCfg = Release|Win32\n" .
1026 " {$projguid}.Release|Win32.Build.0 = Release|Win32\n";
1030 " EndGlobalSection\n" .
1031 " GlobalSection(SolutionProperties) = preSolution\n" .
1032 " HideSolutionNode = FALSE\n" .
1033 " EndGlobalSection\n" .
1036 select STDOUT; close OUT;
1038 foreach $progname (@prognames) {
1039 ($windows_project, $type) = split ",", $progname;
1040 create_vs_project(\%all_object_deps, $windows_project, $type, $projguids{$windows_project}, $toolsver);
1046 sub create_vs_project {
1047 my ($all_object_deps, $windows_project, $type, $projguid, $toolsver) = @_;
1049 # Break down the project's dependency information into the appropriate
1055 %resource_files = ();
1058 @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");
1059 foreach $object_file (@object_files) {
1060 next if defined $seen_objects{$object_file};
1061 $seen_objects{$object_file} = 1;
1063 if($object_file =~ /\.lib$/io) {
1064 $lib_files{$object_file} = 1;
1068 $object_deps = $all_object_deps{$object_file};
1069 foreach $object_dep (@$object_deps) {
1070 if($object_dep eq $object_deps->[0]) {
1071 if($object_dep =~ /\.c$/io) {
1072 $source_files{$object_dep} = 1;
1073 } elsif($object_dep =~ /\.rc$/io) {
1074 $resource_files{$object_dep} = 1;
1076 } elsif ($object_dep =~ /\.[ch]$/io) {
1077 $header_files{$object_dep} = 1;
1078 } elsif ($object_dep =~ /\.ico$/io) {
1079 $icon_files{$object_dep} = 1;
1084 $libs = join ";", sort keys %lib_files;
1085 @source_files = sort keys %source_files;
1086 @header_files = sort keys %header_files;
1087 @resources = sort keys %resource_files;
1088 @icons = sort keys %icon_files;
1089 $subsystem = ($type eq "G") ? "Windows" : "Console";
1091 mkdir $windows_project
1092 if(! -d $windows_project);
1093 chdir $windows_project;
1094 open OUT, ">$windows_project.vcxproj"; select OUT;
1095 open FILTERS, ">$windows_project.vcxproj.filters";
1097 # The bulk of the project file is just boilerplate stuff, so we
1098 # can mostly just dump it out here. Note, buried in the ClCompile
1099 # item definition, that we use a debug information format of
1100 # ProgramDatabase, which disables the edit-and-continue support
1101 # that breaks most of the project builds.
1103 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" .
1104 "<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n" .
1105 " <ItemGroup Label=\"ProjectConfigurations\">\n" .
1106 " <ProjectConfiguration Include=\"Debug|Win32\">\n" .
1107 " <Configuration>Debug</Configuration>\n" .
1108 " <Platform>Win32</Platform>\n" .
1109 " </ProjectConfiguration>\n" .
1110 " <ProjectConfiguration Include=\"Release|Win32\">\n" .
1111 " <Configuration>Release</Configuration>\n" .
1112 " <Platform>Win32</Platform>\n" .
1113 " </ProjectConfiguration>\n" .
1115 " <PropertyGroup Label=\"Globals\">\n" .
1116 " <SccProjectName />\n" .
1117 " <SccLocalPath />\n" .
1118 " <ProjectGuid>{$projguid}</ProjectGuid>\n" .
1119 " </PropertyGroup>\n" .
1120 " <Import Project=\"\$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n" .
1121 " <PropertyGroup Condition=\"'\$(Configuration)|\$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\n" .
1122 " <ConfigurationType>Application</ConfigurationType>\n" .
1123 " <UseOfMfc>false</UseOfMfc>\n" .
1124 " <CharacterSet>MultiByte</CharacterSet>\n" .
1125 " <PlatformToolset>$toolsver</PlatformToolset>\n" .
1126 " </PropertyGroup>\n" .
1127 " <PropertyGroup Condition=\"'\$(Configuration)|\$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\n" .
1128 " <ConfigurationType>Application</ConfigurationType>\n" .
1129 " <UseOfMfc>false</UseOfMfc>\n" .
1130 " <CharacterSet>MultiByte</CharacterSet>\n" .
1131 " <PlatformToolset>$toolsver</PlatformToolset>\n" .
1132 " </PropertyGroup>\n" .
1133 " <Import Project=\"\$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n" .
1134 " <ImportGroup Label=\"ExtensionTargets\">\n" .
1135 " </ImportGroup>\n" .
1136 " <ImportGroup Condition=\"'\$(Configuration)|\$(Platform)'=='Debug|Win32'\" Label=\"PropertySheets\">\n" .
1137 " <Import Project=\"\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props\" Condition=\"exists('\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n" .
1138 " </ImportGroup>\n" .
1139 " <ImportGroup Condition=\"'\$(Configuration)|\$(Platform)'=='Release|Win32'\" Label=\"PropertySheets\">\n" .
1140 " <Import Project=\"\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props\" Condition=\"exists('\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n" .
1141 " </ImportGroup>\n" .
1142 " <PropertyGroup Label=\"UserMacros\" />\n" .
1143 " <PropertyGroup Condition=\"'\$(Configuration)|\$(Platform)'=='Release|Win32'\">\n" .
1144 " <OutDir>.\\Release\\</OutDir>\n" .
1145 " <IntDir>.\\Release\\</IntDir>\n" .
1146 " <LinkIncremental>false</LinkIncremental>\n" .
1147 " </PropertyGroup>\n" .
1148 " <PropertyGroup Condition=\"'\$(Configuration)|\$(Platform)'=='Debug|Win32'\">\n" .
1149 " <OutDir>.\\Debug\\</OutDir>\n" .
1150 " <IntDir>.\\Debug\\</IntDir>\n" .
1151 " <LinkIncremental>true</LinkIncremental>\n" .
1152 " </PropertyGroup>\n" .
1153 " <ItemDefinitionGroup Condition=\"'\$(Configuration)|\$(Platform)'=='Release|Win32'\">\n" .
1155 " <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n" .
1156 " <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>\n" .
1157 " <StringPooling>true</StringPooling>\n" .
1158 " <FunctionLevelLinking>true</FunctionLevelLinking>\n" .
1159 " <Optimization>MaxSpeed</Optimization>\n" .
1160 " <SuppressStartupBanner>true</SuppressStartupBanner>\n" .
1161 " <WarningLevel>Level3</WarningLevel>\n" .
1162 " <AdditionalIncludeDirectories>" . (join ";", map {"..\\..\\$dirpfx$_"} @srcdirs) . ";%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n" .
1163 " <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;POSIX;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n" .
1164 " <AssemblerListingLocation>.\\Release\\</AssemblerListingLocation>\n" .
1165 " <PrecompiledHeaderOutputFile>.\\Release\\$windows_project.pch</PrecompiledHeaderOutputFile>\n" .
1166 " <ObjectFileName>.\\Release\\</ObjectFileName>\n" .
1167 " <ProgramDataBaseFileName>.\\Release\\</ProgramDataBaseFileName>\n" .
1170 " <SuppressStartupBanner>true</SuppressStartupBanner>\n" .
1171 " <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n" .
1172 " <TypeLibraryName>.\\Release\\$windows_project.tlb</TypeLibraryName>\n" .
1173 " <MkTypLibCompatible>true</MkTypLibCompatible>\n" .
1174 " <TargetEnvironment>Win32</TargetEnvironment>\n" .
1176 " <ResourceCompile>\n" .
1177 " <Culture>0x0809</Culture>\n" .
1178 " <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n" .
1179 " </ResourceCompile>\n" .
1181 " <SuppressStartupBanner>true</SuppressStartupBanner>\n" .
1182 " <OutputFile>.\\Release\\$windows_project.bsc</OutputFile>\n" .
1185 " <SuppressStartupBanner>true</SuppressStartupBanner>\n" .
1186 " <SubSystem>$subsystem</SubSystem>\n" .
1187 " <OutputFile>.\\Release\\$windows_project.exe</OutputFile>\n" .
1188 " <AdditionalDependencies>$libs;%(AdditionalDependencies)</AdditionalDependencies>\n" .
1190 " </ItemDefinitionGroup>\n" .
1191 " <ItemDefinitionGroup Condition=\"'\$(Configuration)|\$(Platform)'=='Debug|Win32'\">\n" .
1193 " <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n" .
1194 " <InlineFunctionExpansion>Default</InlineFunctionExpansion>\n" .
1195 " <FunctionLevelLinking>false</FunctionLevelLinking>\n" .
1196 " <Optimization>Disabled</Optimization>\n" .
1197 " <SuppressStartupBanner>true</SuppressStartupBanner>\n" .
1198 " <WarningLevel>Level3</WarningLevel>\n" .
1199 " <MinimalRebuild>true</MinimalRebuild>\n" .
1200 " <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n" .
1201 " <AdditionalIncludeDirectories>" . (join ";", map {"..\\..\\$dirpfx$_"} @srcdirs) . ";%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n" .
1202 " <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;POSIX;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n" .
1203 " <AssemblerListingLocation>.\\Debug\\</AssemblerListingLocation>\n" .
1204 " <PrecompiledHeaderOutputFile>.\\Debug\\$windows_project.pch</PrecompiledHeaderOutputFile>\n" .
1205 " <ObjectFileName>.\\Debug\\</ObjectFileName>\n" .
1206 " <ProgramDataBaseFileName>.\\Debug\\</ProgramDataBaseFileName>\n" .
1207 " <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n" .
1210 " <SuppressStartupBanner>true</SuppressStartupBanner>\n" .
1211 " <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n" .
1212 " <TypeLibraryName>.\\Debug\\$windows_project.tlb</TypeLibraryName>\n" .
1213 " <MkTypLibCompatible>true</MkTypLibCompatible>\n" .
1214 " <TargetEnvironment>Win32</TargetEnvironment>\n" .
1216 " <ResourceCompile>\n" .
1217 " <Culture>0x0809</Culture>\n" .
1218 " <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n" .
1219 " </ResourceCompile>\n" .
1221 " <SuppressStartupBanner>true</SuppressStartupBanner>\n" .
1222 " <OutputFile>.\\Debug\\$windows_project.bsc</OutputFile>\n" .
1225 " <SuppressStartupBanner>true</SuppressStartupBanner>\n" .
1226 " <GenerateDebugInformation>true</GenerateDebugInformation>\n" .
1227 " <SubSystem>$subsystem</SubSystem>\n" .
1228 " <OutputFile>\$(TargetPath)</OutputFile>\n" .
1229 " <AdditionalDependencies>$libs;%(AdditionalDependencies)</AdditionalDependencies>\n" .
1231 " </ItemDefinitionGroup>\n";
1233 # The VC++ projects don't have physical structure to them, instead
1234 # the files are organized by logical "filters" that are stored in
1235 # a separate file, so different users can organize things differently.
1236 # The filters file contains a copy of the ItemGroup elements from
1237 # the main project file that list the included items, but tack
1238 # on a filter name where needed.
1240 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" .
1241 "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n";
1243 print " <ItemGroup>\n";
1244 print FILTERS " <ItemGroup>\n";
1245 foreach $icon_file (@icons) {
1246 $icon_file =~ s/..\\windows\\//;
1247 print " <CustomBuild Include=\"..\\..\\$icon_file\" />\n";
1249 " <CustomBuild Include=\"..\\..\\$icon_file\">\n" .
1250 " <Filter>Resource Files</Filter>\n" .
1251 " </CustomBuild>\n";
1253 print FILTERS " </ItemGroup>\n";
1254 print " </ItemGroup>\n";
1256 print " <ItemGroup>\n";
1257 print FILTERS " <ItemGroup>\n";
1258 foreach $resource_file (@resources) {
1259 $resource_file =~ s/..\\windows\\//;
1261 " <ResourceCompile Include=\"..\\..\\$resource_file\">\n" .
1262 " <AdditionalIncludeDirectories Condition=\"'\$(Configuration)|\$(Platform)'=='Release|Win32'\">..\\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n" .
1263 " <AdditionalIncludeDirectories Condition=\"'\$(Configuration)|\$(Platform)'=='Debug|Win32'\">..\\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n" .
1264 " </ResourceCompile>\n";
1266 " <ResourceCompile Include=\"..\\..\\$resource_file\">\n" .
1267 " <Filter>Resource Files</Filter>\n" .
1268 " </ResourceCompile>\n";
1270 print FILTERS " </ItemGroup>\n";
1271 print " </ItemGroup>\n";
1273 print " <ItemGroup>\n";
1274 print FILTERS " <ItemGroup>\n";
1275 foreach $source_file (@source_files) {
1276 $source_file =~ s/..\\windows\\//;
1277 print " <ClCompile Include=\"..\\..\\$source_file\" />\n";
1279 " <ClCompile Include=\"..\\..\\$source_file\">\n" .
1280 " <Filter>Source Files</Filter>\n" .
1283 print FILTERS " </ItemGroup>\n";
1284 print " </ItemGroup>\n";
1286 print " <ItemGroup>\n";
1287 print FILTERS " <ItemGroup>\n";
1288 foreach $header_file (@header_files) {
1289 $header_file =~ s/..\\windows\\//;
1290 print " <ClInclude Include=\"..\\..\\$header_file\" />\n";
1292 " <ClInclude Include=\"..\\..\\$header_file\">\n" .
1293 " <Filter>Header Files</Filter>\n" .
1296 print FILTERS " </ItemGroup>\n";
1297 print " </ItemGroup>\n";
1300 " <Import Project=\"\$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n" .
1305 " <Filter Include=\"Source Files\">\n" .
1306 " <UniqueIdentifier>{" . &invent_guid("sources:$windows_project") . "}</UniqueIdentifier>\n" .
1308 " <Filter Include=\"Header Files\">\n" .
1309 " <UniqueIdentifier>{" . &invent_guid("headers:$windows_project") . "}</UniqueIdentifier>\n" .
1311 " <Filter Include=\"Resource Files\">\n" .
1312 " <UniqueIdentifier>{" . &invent_guid("resources:$windows_project") . "}</UniqueIdentifier>\n" .
1317 select STDOUT; close OUT; close FILTERS;
1322 if (defined $makefiles{'gtk'}) {
1323 $dirpfx = &dirpfx($makefiles{'gtk'}, "/");
1325 ##-- X/GTK/Unix makefile
1326 open OUT, ">$makefiles{'gtk'}"; select OUT;
1328 "# Makefile for $project_name under X/GTK and Unix.\n".
1329 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1330 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1331 # gcc command line option is -D not /D
1332 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
1336 "# You can define this path to point at your tools if you need to\n".
1337 "# TOOLPATH = /opt/gcc/bin\n".
1338 "CC = \$(TOOLPATH)cc\n".
1339 "# If necessary set the path to krb5-config here\n".
1340 "KRB5CONFIG=krb5-config\n".
1341 "# You can manually set this to `gtk-config' or `pkg-config gtk+-1.2'\n".
1342 "# (depending on what works on your system) if you want to enforce\n".
1343 "# building with GTK 1.2, or you can set it to `pkg-config gtk+-2.0 x11'\n".
1344 "# if you want to enforce 2.0. The default is to try 2.0 and fall back\n".
1345 "# to 1.2 if it isn't found.\n".
1346 "GTK_CONFIG = sh -c 'pkg-config gtk+-2.0 x11 \$\$0 2>/dev/null || gtk-config \$\$0'\n".
1348 "-include Makefile.local\n".
1350 "unexport CFLAGS # work around a weird issue with krb5-config\n".
1352 &splitline("CFLAGS = -O2 -Wall -Werror -g " .
1353 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
1354 " \$(shell \$(GTK_CONFIG) --cflags)").
1355 " -D _FILE_OFFSET_BITS=64\n".
1356 "XLDFLAGS = \$(LDFLAGS) \$(shell \$(GTK_CONFIG) --libs)\n".
1357 "ULDFLAGS = \$(LDFLAGS)\n".
1358 "ifeq (,\$(findstring NO_GSSAPI,\$(COMPAT)))\n".
1359 "ifeq (,\$(findstring STATIC_GSSAPI,\$(COMPAT)))\n".
1360 "XLDFLAGS+= -ldl\n".
1361 "ULDFLAGS+= -ldl\n".
1363 "CFLAGS+= -DNO_LIBDL \$(shell \$(KRB5CONFIG) --cflags gssapi)\n".
1364 "XLDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
1365 "ULDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
1368 "INSTALL=install\n".
1369 "INSTALL_PROGRAM=\$(INSTALL)\n".
1370 "INSTALL_DATA=\$(INSTALL)\n".
1371 "prefix=/usr/local\n".
1372 "exec_prefix=\$(prefix)\n".
1373 "bindir=\$(exec_prefix)/bin\n".
1374 "mandir=\$(prefix)/man\n".
1375 "man1dir=\$(mandir)/man1\n".
1377 &def($makefile_extra{'gtk'}->{'vars'}) .
1382 print &splitline("all:" . join "", map { " $_" } &progrealnames("X:U:UT"));
1384 foreach $p (&prognames("X:U:UT")) {
1385 ($prog, $type) = split ",", $p;
1386 $objstr = &objects($p, "X.o", undef, undef);
1387 print &splitline($prog . ": " . $objstr), "\n";
1388 $libstr = &objects($p, undef, undef, "-lX");
1389 print &splitline("\t\$(CC) -o \$@ " .
1390 $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
1392 foreach $d (&deps("X.o", undef, $dirpfx, "/", "gtk")) {
1393 if ($forceobj{$d->{obj_orig}}) {
1394 printf("%s: FORCE\n", $d->{obj});
1396 print &splitline(sprintf("%s: %s", $d->{obj},
1397 join " ", @{$d->{deps}})), "\n";
1399 print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
1402 print &def($makefile_extra{'gtk'}->{'end'});
1404 "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:U:UT")) . "\n";
1406 select STDOUT; close OUT;
1409 if (defined $makefiles{'unix'}) {
1410 $dirpfx = &dirpfx($makefiles{'unix'}, "/");
1412 ##-- GTK-free pure-Unix makefile for non-GUI apps only
1413 open OUT, ">$makefiles{'unix'}"; select OUT;
1415 "# Makefile for $project_name under Unix.\n".
1416 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1417 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1418 # gcc command line option is -D not /D
1419 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
1423 "# You can define this path to point at your tools if you need to\n".
1424 "# TOOLPATH = /opt/gcc/bin\n".
1425 "CC = \$(TOOLPATH)cc\n".
1427 "-include Makefile.local\n".
1429 "unexport CFLAGS # work around a weird issue with krb5-config\n".
1431 &splitline("CFLAGS = -O2 -Wall -Werror -g " .
1432 (join " ", map {"-I$dirpfx$_"} @srcdirs)).
1433 " -D _FILE_OFFSET_BITS=64\n".
1434 "ULDFLAGS = \$(LDFLAGS)\n".
1435 "INSTALL=install\n".
1436 "INSTALL_PROGRAM=\$(INSTALL)\n".
1437 "INSTALL_DATA=\$(INSTALL)\n".
1438 "prefix=/usr/local\n".
1439 "exec_prefix=\$(prefix)\n".
1440 "bindir=\$(exec_prefix)/bin\n".
1441 "mandir=\$(prefix)/man\n".
1442 "man1dir=\$(mandir)/man1\n".
1444 &def($makefile_extra{'unix'}->{'vars'}) .
1449 print &splitline("all:" . join "", map { " $_" } &progrealnames("U:UT"));
1451 foreach $p (&prognames("U:UT")) {
1452 ($prog, $type) = split ",", $p;
1453 $objstr = &objects($p, "X.o", undef, undef);
1454 print &splitline($prog . ": " . $objstr), "\n";
1455 $libstr = &objects($p, undef, undef, "-lX");
1456 print &splitline("\t\$(CC) -o \$@ " .
1457 $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
1459 foreach $d (&deps("X.o", undef, $dirpfx, "/", "unix")) {
1460 if ($forceobj{$d->{obj_orig}}) {
1461 printf("%s: FORCE\n", $d->{obj});
1463 print &splitline(sprintf("%s: %s", $d->{obj},
1464 join " ", @{$d->{deps}})), "\n";
1466 print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
1469 print &def($makefile_extra{'unix'}->{'end'});
1471 "\trm -f *.o". (join "", map { " $_" } &progrealnames("U:UT")) . "\n";
1473 select STDOUT; close OUT;
1476 if (defined $makefiles{'am'}) {
1477 die "Makefile.am in a subdirectory is not supported\n"
1478 if &dirpfx($makefiles{'am'}, "/") ne "";
1480 ##-- Unix/autoconf Makefile.am
1481 open OUT, ">$makefiles{'am'}"; select OUT;
1483 "# Makefile.am for $project_name under Unix with Autoconf/Automake.\n".
1484 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1485 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n\n";
1487 # 2014-02-22: as of automake-1.14 we begin to get complained at if
1488 # we don't use this option
1489 print "AUTOMAKE_OPTIONS = subdir-objects\n\n";
1491 # Complete list of source and header files. Not used by the
1492 # auto-generated parts of this makefile, but Recipe might like to
1493 # have it available as a variable so that mandatory-rebuild things
1494 # (version.o) can conveniently be made to depend on it.
1495 @sources = ("allsources", "=", sort keys %allsourcefiles);
1496 print &splitline(join " ", @sources), "\n\n";
1498 @cliprogs = ("bin_PROGRAMS", "=");
1499 foreach $p (&prognames("U")) {
1500 ($prog, $type) = split ",", $p;
1501 push @cliprogs, $prog;
1503 @allprogs = @cliprogs;
1504 foreach $p (&prognames("X")) {
1505 ($prog, $type) = split ",", $p;
1506 push @allprogs, $prog;
1508 print "if HAVE_GTK\n";
1509 print &splitline(join " ", @allprogs), "\n";
1511 print &splitline(join " ", @cliprogs), "\n";
1514 @noinstcliprogs = ("noinst_PROGRAMS", "=");
1515 foreach $p (&prognames("UT")) {
1516 ($prog, $type) = split ",", $p;
1517 push @noinstcliprogs, $prog;
1519 print &splitline(join " ", @noinstcliprogs), "\n";
1522 foreach $d (&deps("X", undef, "", "/", "am")) {
1523 $objtosrc{$d->{obj}} = $d->{deps}->[0];
1526 print &splitline(join " ", "AM_CPPFLAGS", "=",
1527 map {"-I\$(srcdir)/$_"} @srcdirs), "\n";
1529 @amcflags = ("\$(COMPAT)", "\$(XFLAGS)", "\$(WARNINGOPTS)");
1530 print "if HAVE_GTK\n";
1531 print &splitline(join " ", "AM_CFLAGS", "=",
1532 "\$(GTK_CFLAGS)", @amcflags), "\n";
1534 print &splitline(join " ", "AM_CFLAGS", "=", @amcflags), "\n";
1537 %amspeciallibs = ();
1538 foreach $obj (sort { $a cmp $b } keys %{$cflags{'am'}}) {
1539 print "lib${obj}_a_SOURCES = ", $objtosrc{$obj}, "\n";
1540 print &splitline(join " ", "lib${obj}_a_CFLAGS", "=", @amcflags,
1541 $cflags{'am'}->{$obj}), "\n";
1542 $amspeciallibs{$obj} = "lib${obj}.a";
1544 print &splitline(join " ", "noinst_LIBRARIES", "=",
1545 sort { $a cmp $b } values %amspeciallibs), "\n\n";
1547 foreach $p (&prognames("X:U:UT")) {
1548 ($prog, $type) = split ",", $p;
1549 print "if HAVE_GTK\n" if $type eq "X";
1550 @progsources = ("${prog}_SOURCES", "=");
1553 $objstr = &objects($p, "X", undef, undef);
1554 foreach $obj (split / /,$objstr) {
1555 if ($amspeciallibs{$obj}) {
1556 push @ldadd, $amspeciallibs{$obj};
1558 $sourcefiles{$objtosrc{$obj}} = 1;
1561 push @progsources, sort { $a cmp $b } keys %sourcefiles;
1562 print &splitline(join " ", @progsources), "\n";
1564 push @ldadd, "\$(GTK_LIBS)";
1567 print &splitline(join " ", "${prog}_LDADD", "=", @ldadd), "\n";
1569 print "endif\n" if $type eq "X";
1572 print &def($makefile_extra{'am'}->{'end'});
1573 select STDOUT; close OUT;
1576 if (defined $makefiles{'lcc'}) {
1577 $dirpfx = &dirpfx($makefiles{'lcc'}, "\\");
1580 open OUT, ">$makefiles{'lcc'}"; select OUT;
1582 "# Makefile for $project_name under lcc.\n".
1583 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1584 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1585 # lcc command line option is -D not /D
1586 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
1590 "# If you rename this file to `Makefile', you should change this line,\n".
1591 "# so that the .rsp files still depend on the correct makefile.\n".
1592 "MAKEFILE = Makefile.lcc\n".
1594 "# C compilation flags\n".
1595 "CFLAGS = -D_WINDOWS " .
1596 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
1598 "# Resource compilation flags\n".
1599 "RCFLAGS = ".(join " ", map {"-I$dirpfx$_"} @srcdirs)."\n".
1601 "# Get include directory for resource compiler\n".
1603 &def($makefile_extra{'lcc'}->{'vars'}) .
1605 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
1607 foreach $p (&prognames("G:C")) {
1608 ($prog, $type) = split ",", $p;
1609 $objstr = &objects($p, "X.obj", "X.res", undef);
1610 print &splitline("$prog.exe: " . $objstr ), "\n";
1611 $subsystemtype = '';
1612 if ($type eq "G") { $subsystemtype = "-subsystem windows"; }
1613 my $libss = "shell32.lib wsock32.lib ws2_32.lib winspool.lib winmm.lib imm32.lib";
1614 print &splitline("\tlcclnk $subsystemtype -o $prog.exe $objstr $libss");
1618 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "lcc")) {
1619 if ($forceobj{$d->{obj_orig}}) {
1620 printf("%s: FORCE\n", $d->{obj});
1622 print &splitline(sprintf("%s: %s", $d->{obj},
1623 join " ", @{$d->{deps}})), "\n";
1625 if ($d->{obj} =~ /\.obj$/) {
1626 print &splitline("\tlcc -O -p6 \$(COMPAT)".
1627 " \$(CFLAGS) \$(XFLAGS) ".$d->{deps}->[0],69)."\n";
1629 print &splitline("\tlrc \$(RCFL) -r \$(RCFLAGS) ".
1630 $d->{deps}->[0],69)."\n";
1634 print &def($makefile_extra{'lcc'}->{'end'});
1642 select STDOUT; close OUT;
1645 if (defined $makefiles{'osx'}) {
1646 $dirpfx = &dirpfx($makefiles{'osx'}, "/");
1648 ##-- Mac OS X makefile
1649 open OUT, ">$makefiles{'osx'}"; select OUT;
1651 "# Makefile for $project_name under Mac OS X.\n".
1652 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1653 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1654 # gcc command line option is -D not /D
1655 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
1658 "CC = \$(TOOLPATH)gcc\n".
1660 &splitline("CFLAGS = -O2 -Wall -Werror -g " .
1661 (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
1662 "MLDFLAGS = -framework Cocoa\n".
1665 &def($makefile_extra{'osx'}->{'vars'}) .
1667 &splitline("all:" . join "", map { " $_" } &progrealnames("MX:U:UT")) .
1669 foreach $p (&prognames("MX")) {
1670 ($prog, $type) = split ",", $p;
1671 $objstr = &objects($p, "X.o", undef, undef);
1672 $icon = &special($p, ".icns");
1673 $infoplist = &special($p, "info.plist");
1674 print "${prog}.app:\n\tmkdir -p \$\@\n";
1675 print "${prog}.app/Contents: ${prog}.app\n\tmkdir -p \$\@\n";
1676 print "${prog}.app/Contents/MacOS: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1677 $targets = "${prog}.app/Contents/MacOS/$prog";
1678 if (defined $icon) {
1679 print "${prog}.app/Contents/Resources: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1680 print "${prog}.app/Contents/Resources/${prog}.icns: ${prog}.app/Contents/Resources $icon\n\tcp $icon \$\@\n";
1681 $targets .= " ${prog}.app/Contents/Resources/${prog}.icns";
1683 if (defined $infoplist) {
1684 print "${prog}.app/Contents/Info.plist: ${prog}.app/Contents/Resources $infoplist\n\tcp $infoplist \$\@\n";
1685 $targets .= " ${prog}.app/Contents/Info.plist";
1687 $targets .= " \$(${prog}_extra)";
1688 print &splitline("${prog}: $targets", 69) . "\n\n";
1689 print &splitline("${prog}.app/Contents/MacOS/$prog: ".
1690 "${prog}.app/Contents/MacOS " . $objstr), "\n";
1691 $libstr = &objects($p, undef, undef, "-lX");
1692 print &splitline("\t\$(CC) \$(MLDFLAGS) -o \$@ " .
1693 $objstr . " $libstr", 69), "\n\n";
1695 foreach $p (&prognames("U:UT")) {
1696 ($prog, $type) = split ",", $p;
1697 $objstr = &objects($p, "X.o", undef, undef);
1698 print &splitline($prog . ": " . $objstr), "\n";
1699 $libstr = &objects($p, undef, undef, "-lX");
1700 print &splitline("\t\$(CC) \$(ULDFLAGS) -o \$@ " .
1701 $objstr . " $libstr", 69), "\n\n";
1703 foreach $d (&deps("X.o", undef, $dirpfx, "/", "osx")) {
1704 if ($forceobj{$d->{obj_orig}}) {
1705 printf("%s: FORCE\n", $d->{obj});
1707 print &splitline(sprintf("%s: %s", $d->{obj},
1708 join " ", @{$d->{deps}})), "\n";
1710 $firstdep = $d->{deps}->[0];
1711 if ($firstdep =~ /\.c$/) {
1712 print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
1713 } elsif ($firstdep =~ /\.m$/) {
1714 print "\t\$(CC) -x objective-c \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
1717 print "\n".&def($makefile_extra{'osx'}->{'end'});
1719 "\trm -f *.o *.dmg". (join "", map { " $_" } &progrealnames("U:UT")) . "\n".
1723 select STDOUT; close OUT;
1726 if (defined $makefiles{'devcppproj'}) {
1727 $dirpfx = &dirpfx($makefiles{'devcppproj'}, "\\");
1730 ##-- Dev-C++ 5 projects
1732 # Note: All files created in this section are written in binary
1733 # mode to prevent any posibility of misinterpreted line endings.
1734 # I don't know if Dev-C++ is as touchy as MSVC with LF-only line
1735 # endings. But however, CRLF line endings are the common way on
1736 # Win32 machines where Dev-C++ is running.
1737 # Hence, in order for mkfiles.pl to generate CRLF project files
1738 # even when run from Unix, I make sure all files are binary and
1739 # explicitly write the CRLFs.
1741 # Create directories if necessary
1742 mkdir $makefiles{'devcppproj'}
1743 if(! -d $makefiles{'devcppproj'});
1744 chdir $makefiles{'devcppproj'};
1745 @deps = &deps("X.obj", "X.res", $dirpfx, "\\", "devcppproj");
1746 %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;
1747 # Make dir names FAT/NTFS compatible
1748 my @srcdirs = @srcdirs;
1749 for ($i=0; $i<@srcdirs; $i++) {
1750 $srcdirs[$i] =~ s/\//\\/g;
1751 $srcdirs[$i] =~ s/\\$//;
1753 # Create the project files
1754 # Get names of all Windows projects (GUI and console)
1755 my @prognames = &prognames("G:C");
1756 foreach $progname (@prognames) {
1757 create_devcpp_project(\%all_object_deps, $progname);
1762 sub create_devcpp_project {
1763 my ($all_object_deps, $progname) = @_;
1764 # Construct program's dependency info (Taken from 'vcproj', seems to work right here, too.)
1769 %resource_files = ();
1770 @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");
1771 foreach $object_file (@object_files) {
1772 next if defined $seen_objects{$object_file};
1773 $seen_objects{$object_file} = 1;
1774 if($object_file =~ /\.lib$/io) {
1775 $lib_files{$object_file} = 1;
1778 $object_deps = $all_object_deps{$object_file};
1779 foreach $object_dep (@$object_deps) {
1780 if($object_dep =~ /\.c$/io) {
1781 $source_files{$object_dep} = 1;
1784 if($object_dep =~ /\.h$/io) {
1785 $header_files{$object_dep} = 1;
1788 if($object_dep =~ /\.(rc|ico)$/io) {
1789 $resource_files{$object_dep} = 1;
1794 $libs = join " ", sort keys %lib_files;
1795 @source_files = sort keys %source_files;
1796 @header_files = sort keys %header_files;
1797 @resources = sort keys %resource_files;
1798 ($windows_project, $type) = split ",", $progname;
1799 mkdir $windows_project
1800 if(! -d $windows_project);
1801 chdir $windows_project;
1803 $subsys = ($type eq "G") ? "0" : "1"; # 0 = Win32 GUI, 1 = Win32 Console
1804 open OUT, ">$windows_project.dev"; binmode OUT; select OUT;
1806 "# DEV-C++ 5 Project File - $windows_project.dev\r\n".
1807 "# ** DO NOT EDIT **\r\n".
1809 # No difference between DEBUG and RELEASE here as in 'vcproj', because
1810 # Dev-C++ does not support mutiple compilation profiles in one single project.
1811 # (At least I can say this for Dev-C++ 5 Beta)
1813 "FileName=$windows_project.dev\r\n".
1814 "Name=$windows_project\r\n".
1818 # Multimon is disabled here, as Dev-C++ (Version 5 Beta) does not have multimon.h
1819 "Compiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
1820 "CppCompiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
1821 "Includes=" . (join ";", map {"..\\..\\$dirpfx$_"} @srcdirs) . "\r\n".
1822 "Linker=-ladvapi32 -lcomctl32 -lcomdlg32 -lgdi32 -limm32 -lshell32 -luser32 -lwinmm -lwinspool_\@\@_\r\n".
1824 "UnitCount=" . (@source_files + @header_files + @resources) . "\r\n".
1825 "Folders=\"Header Files\",\"Resource Files\",\"Source Files\"\r\n".
1827 "PrivateResource=${windows_project}_private.rc\r\n".
1828 "ResourceIncludes=..\\..\\..\\WINDOWS\r\n".
1829 "MakeIncludes=\r\n".
1830 "Icon=\r\n". # It's ok to leave this blank.
1832 "ObjectOutput=\r\n".
1833 "OverrideOutput=0\r\n".
1834 "OverrideOutputName=$windows_project.exe\r\n".
1835 "HostApplication=\r\n".
1837 "UseCustomMakefile=0\r\n".
1838 "CustomMakefile=\r\n".
1839 "IncludeVersionInfo=0\r\n".
1840 "SupportXPThemes=0\r\n".
1841 "CompilerSet=0\r\n".
1842 "CompilerSettings=0000000000000000000000\r\n".
1845 foreach $source_file (@source_files) {
1847 "[Unit$unit_count]\r\n".
1848 "FileName=..\\..\\$source_file\r\n".
1849 "Folder=Source Files\r\n".
1853 "Priority=1000\r\n".
1854 "OverrideBuildCmd=0\r\n".
1859 foreach $header_file (@header_files) {
1861 "[Unit$unit_count]\r\n".
1862 "FileName=..\\..\\$header_file\r\n".
1863 "Folder=Header Files\r\n".
1865 "CompileCpp=1\r\n". # Dev-C++ want's to compile all header files with both compilers C and C++. It does not hurt.
1867 "Priority=1000\r\n".
1868 "OverrideBuildCmd=0\r\n".
1873 foreach $resource_file (@resources) {
1874 if ($resource_file =~ /.*\.(ico|cur|bmp|dlg|rc2|rct|bin|rgs|gif|jpg|jpeg|jpe)/io) { # Default filter as in 'vcproj'
1875 $Compile = "0"; # Don't compile images and other binary resource files
1879 $CompileCpp = "1"; # Dev-C++ want's to compile all .rc files with both compilers C and C++. It does not hurt.
1882 "[Unit$unit_count]\r\n".
1883 "FileName=..\\..\\$resource_file\r\n".
1884 "Folder=Resource Files\r\n".
1885 "Compile=$Compile\r\n".
1886 "CompileCpp=$CompileCpp\r\n".
1888 "Priority=1000\r\n".
1889 "OverrideBuildCmd=0\r\n".
1894 #Note: By default, [VersionInfo] is not used.
1896 "[VersionInfo]\r\n".
1901 "LanguageID=1033\r\n".
1902 "CharsetID=1252\r\n".
1904 "FileVersion=0.1\r\n".
1905 "FileDescription=\r\n".
1906 "InternalName=\r\n".
1907 "LegalCopyright=\r\n".
1908 "LegalTrademarks=\r\n".
1909 "OriginalFilename=$windows_project.exe\r\n".
1910 "ProductName=$windows_project\r\n".
1911 "ProductVersion=0.1\r\n".
1912 "AutoIncBuildNr=0\r\n";
1913 select STDOUT; close OUT;
1918 # All done, so do the Unix postprocessing if asked to.
1922 system "./mkauto.sh";
1923 die "mkfiles.pl: mkauto.sh returned $?\n" if $? > 0;
1924 if ($do_unix == 1) {
1925 chdir ($targetdir = "unix")
1926 or die "$targetdir: chdir: $!\n";
1928 system "./configure", @confargs;
1929 die "mkfiles.pl: configure returned $?\n" if $? > 0;
1932 sub invent_guid($) {
1935 # Invent a GUID for use in Visual Studio project files. We need
1936 # a few of these for every executable file we build.
1938 # In order to avoid having to use the non-core Perl module
1939 # Data::GUID, and also arrange for GUIDs to be stable, we generate
1940 # our GUIDs by hashing a pile of fixed (but originally randomly
1941 # generated) data with the filename for which we need an id.
1943 # Hashing _just_ the filenames would clearly be cheating (it's
1944 # quite conceivable that someone might hash the same string for
1945 # another reason and so generate a colliding GUID), but hashing a
1946 # whole SHA-512 data block of random gibberish as well should make
1947 # these GUIDs pseudo-random enough to not collide with anyone
1950 my $randdata = pack "N*",
1951 0xD4AB035F,0x76998BA0,0x2DCCB0BD,0x6D3FA320,0x53638051,0xFE312F35,
1952 0xDE1CECC0,0x784DF852,0x6C9F4589,0x54B7AC23,0x14E7A1C4,0xF9BF04DF,
1953 0x19C08B6D,0x3FB69EF1,0xB2DA9043,0xDB5362F3,0x25718DB6,0x733560DA,
1954 0xFEF871B0,0xFECF7A0C,0x67D19C95,0xB492E911,0xF5D562A3,0xFCE1D478,
1955 0x02C50434,0xF7326B7E,0x93D39872,0xCF0D0269,0x9EF24C0F,0x827689AD,
1956 0x88BD20BC,0x74EA6AFE,0x29223682,0xB9AB9287,0x7EA7CE4F,0xCF81B379,
1957 0x9AE4A954,0x81C7AD97,0x2FF2F031,0xC51DA3C2,0xD311CCE7,0x0A31EB8B,
1958 0x1AB04242,0xAF53B714,0xFC574D40,0x8CB4ED01,0x29FEB16F,0x4904D7ED,
1959 0xF5C5F5E1,0xF138A4C2,0xA9D881CE,0xCEA65187,0x4421BA97,0x0EE8428E,
1960 0x9556E384,0x6D0484C9,0x561BD84B,0xD9516A40,0x6B4FD33F,0xDDFFE4C8,
1961 0x3D5DF8A5,0xFE6B7D99,0x3443371B,0xF4E30A3E,0xE62B9FDA,0x6BAA75DB,
1962 0x9EF3C2C7,0x6815CA42,0xE6536076,0xF851E6E2,0x39D16E69,0xBCDF3BB6,
1963 0x50EFFA41,0x378CDF2A,0xB5EC0D0C,0x1E94C433,0xE818241A,0x2689EB1F,
1964 0xB649CEF9,0xD7344D46,0x59C1BB13,0x27511FDF,0x7DAD1768,0xB355E29E,
1965 0xDFAE550C,0x2433005B,0x09DE10B0,0xAA00BA6B,0xC144ED2D,0x8513D007,
1966 0xB0315232,0x7A10DAB6,0x1D97654E,0xF048214D,0xE3059E75,0x83C225D1,
1967 0xFC7AB177,0x83F2B553,0x79F7A0AF,0x1C94582C,0xF5E4AF4B,0xFB39C865,
1968 0x58ABEB27,0xAAB28058,0x52C15A89,0x0EBE9741,0x343F4D26,0xF941202A,
1969 0xA32FD32F,0xDCC055B8,0x64281BF3,0x468BD7BA,0x0CEE09D3,0xBB5FD2B6,
1970 0xA528D412,0xA6A6967E,0xEAAF5DAE,0xDE7B2FAE,0xCA36887B,0x0DE196EB,
1971 0x74B95EF0,0x9EB8B7C2,0x020BFC83,0x1445086F,0xBF4B61B2,0x89AFACEC,
1972 0x80A5CD69,0xC790F744,0x435A6998,0x8DE7AC48,0x32F31BC9,0x8F760D3D,
1973 0xF02A74CB,0xD7B47E20,0x9EC91035,0x70FDE74D,0x9B531362,0x9D81739A,
1974 0x59ADC2EB,0x511555B5,0xCA84B8D5,0x3EC325FF,0x2E442A4C,0x82AF30D9,
1975 0xBFD3EC87,0x90C59E07,0x1C6DC991,0x2D16B822,0x7EA44EB5,0x3A655A39,
1976 0xAB640886,0x09311821,0x777801D9,0x489DBE61,0xA1FFEC65,0x978B49B1,
1977 0x7DB700CD,0x263CF3D6,0xF977E89F,0xBA0B3D01,0x6C6CED19,0x1BE6F23A,
1978 0x19E0ED98,0x8E71A499,0x70BA3271,0x3FB7EE98,0xABA46848,0x2B797959,
1979 0x72C6DE59,0xE08B795C,0x02936C39,0x02185CCB,0xD6F3CE18,0xD0157A40,
1980 0x833DEC3F,0x319B00C4,0x97B59513,0x900B81FD,0x9A022379,0x16E44E1A,
1981 0x0C4CC540,0xCA98E7F9,0xF9431A26,0x290BCFAC,0x406B82C0,0xBC1C4585,
1982 0x55C54528,0x811EBB77,0xD4EDD4F3,0xA70DC02E,0x8AD5C0D1,0x28D64EF4,
1983 0xBEFF5C69,0x99852C4A,0xB4BBFF7B,0x069230AC,0xA3E141FA,0x4E99FB0E,
1984 0xBC154DAA,0x323C7F15,0x86E0247E,0x2EEA3054,0xC9CA1D32,0x8964A006,
1985 0xC93978AC,0xF9B2C159,0x03F2079E,0xB051D284,0x4A7EA9A9,0xF001DA1F,
1986 0xD47A0DAA,0xCF7B6B73,0xF18293B2,0x84303E34,0xF8BC76C4,0xAFBEE24F,
1987 0xB589CA80,0x77B5BF86,0x21B9FD5B,0x1A5071DF,0xA3863110,0x0E50CA61,
1988 0x939151A5,0xD2A59021,0x83A9CDCE,0xCEC69767,0xC906BB16,0x3EE1FF4D,
1989 0x1321EAE4,0x0BF940D6,0x52471E61,0x8A087056,0x66E54293,0xF84AAB9B,
1990 0x08835EF1,0x8F12B77A,0xD86935A5,0x200281D7,0xCD3C37C9,0x30ABEC05,
1991 0x7067E8A0,0x608C4838,0xC9F51CDE,0xA6D318DE,0x41C05B2A,0x694CCE0E,
1992 0xC7842451,0xA3194393,0xFBDC2C84,0xA6D2B577,0xC91E7924,0x01EDA708,
1993 0x22FBB61E,0x662F9B7B,0xDE3150C3,0x2397058C;
1994 my $digest = sha512_hex($name . "\0" . $randdata);
1995 return sprintf("%s-%s-%04x-%04x-%s",
1996 substr($digest,0,8),
1997 substr($digest,8,4),
1998 0x4000 | (0xFFF & hex(substr($digest,12,4))),
1999 0x8000 | (0x3FFF & hex(substr($digest,16,4))),
2000 substr($digest,20,12));