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, and licence.h is likewise generated by licence.pl. We
49 # need to generate those _now_, before attempting dependency analysis.
50 eval 'chdir "charset"; require "./sbcsgen.pl"; chdir ".."; select STDOUT;';
51 eval 'require "./licence.pl"; select STDOUT;';
55 $divert = undef; # ref to scalar in which text is currently being put
56 $help = ""; # list of newline-free lines of help text
57 $project_name = "project"; # this is a good enough default
58 %makefiles = (); # maps makefile types to output makefile pathnames
59 %makefile_extra = (); # maps makefile types to extra Makefile text
60 %programs = (); # maps prog name + type letter to listref of objects/resources
61 %groups = (); # maps group name to listref of objects/resources
67 # If we're gathering help text, keep doing so.
68 if (defined $divert) {
69 if ((defined $_[0]) && $_[0] eq "!end") {
76 # Skip comments and blank lines.
77 next if /^\s*#/ or scalar @_ == 0;
79 if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = \$help; next; }
80 if ($_[0] eq "!end") { $divert = undef; next; }
81 if ($_[0] eq "!name") { $project_name = $_[1]; next; }
82 if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; }
83 if ($_[0] eq "!makefile" and &mfval($_[1])) { $makefiles{$_[1]}=$_[2]; next;}
84 if ($_[0] eq "!specialobj" and &mfval($_[1])) { $specialobj{$_[1]}->{$_[2]} = 1; next;}
85 if ($_[0] eq "!cflags" and &mfval($_[1])) {
86 ($rest = $_) =~ s/^\s*\S+\s+\S+\s+\S+\s*//; # find rest of input line
88 # Make sure this file doesn't get lumped together with any
89 # other file's cflags.
92 # Give this file a specific set of cflags, but permit it to
93 # go together with other files using the same set.
96 $cflags{$_[1]}->{$_[2]} = $rest;
99 if ($_[0] eq "!forceobj") { $forceobj{$_[1]} = 1; next; }
100 if ($_[0] eq "!begin") {
101 if ($_[1] =~ /^>(.*)/) {
102 $divert = \$auxfiles{$1};
103 } elsif (&mfval($_[1])) {
104 $sect = $_[2] ? $_[2] : "end";
105 $divert = \($makefile_extra{$_[1]}->{$sect});
112 # If we're gathering help/verbatim text, keep doing so.
113 if (defined $divert) { ${$divert} .= "$_\n"; next; }
114 # Ignore blank lines.
115 next if scalar @_ == 0;
117 # Now we have an ordinary line. See if it's an = line, a : line
122 $listref = $lastlistref;
124 die "$.: unexpected + line\n" if !defined $lastlistref;
125 } elsif ($_[1] eq "=") {
126 $groups{$_[0]} = [] if !defined $groups{$_[0]};
127 $listref = $groups{$_[0]};
129 shift @objs; # eat the group name
130 } elsif ($_[1] eq ":") {
133 shift @objs; # eat the program name
135 die "$.: unrecognised line type\n";
137 shift @objs; # eat the +, the = or the :
139 while (scalar @objs > 0) {
142 foreach $j (@{$groups{$i}}) { unshift @objs, $j; }
143 } elsif (($i =~ /^\[([A-Z]*)\]$/) and defined $prog) {
144 $type = substr($i,1,(length $i)-2);
145 die "unrecognised program type for $prog [$type]\n"
146 if ! grep { $type eq $_ } qw(G C X U MX XT UT);
151 if ($prog and $type) {
152 die "multiple program entries for $prog [$type]\n"
153 if defined $programs{$prog . "," . $type};
154 $programs{$prog . "," . $type} = $listref;
156 $lastlistref = $listref;
161 foreach $aux (sort keys %auxfiles) {
163 print AUX $auxfiles{$aux};
167 # Now retrieve the complete list of objects and resource files, and
168 # construct dependency data for them. While we're here, expand the
169 # object list for each program, and complain if its type isn't set.
170 @prognames = sort keys %programs;
173 foreach $i (@prognames) {
174 ($prog, $type) = split ",", $i;
175 # Strip duplicate object names.
177 @list = grep { $status = ($prev ne $_); $prev=$_; $status }
178 sort @{$programs{$i}};
179 $programs{$i} = [@list];
181 # Dependencies for "x" start with "x.c" or "x.m" (depending on
183 # Dependencies for "x.res" start with "x.rc".
184 # Dependencies for "x.rsrc" start with "x.r".
185 # Both types of file are pushed on the list of files to scan.
186 # Libraries (.lib) don't have dependencies at all.
187 if ($j =~ /^(.*)\.res$/) {
189 $depends{$j} = [$file];
190 push @scanlist, $file;
191 } elsif ($j =~ /^(.*)\.rsrc$/) {
193 $depends{$j} = [$file];
194 push @scanlist, $file;
195 } elsif ($j !~ /\./) {
197 $file = "$j.m" unless &findfile($file);
198 $depends{$j} = [$file];
199 push @scanlist, $file;
204 # Scan each file on @scanlist and find further inclusions.
205 # Inclusions are given by lines of the form `#include "otherfile"'
206 # (system headers are automatically ignored by this because they'll
207 # be given in angle brackets). Files included by this method are
208 # added back on to @scanlist to be scanned in turn (if not already
211 # Resource scripts (.rc) can also include a file by means of:
212 # - a line # ending `ICON "filename"';
213 # - a line ending `RT_MANIFEST "filename"'.
214 # Files included by this method are not added to @scanlist because
215 # they can never include further files.
217 # In this pass we write out a hash %further which maps a source
218 # file name into a listref containing further source file names.
221 %allsourcefiles = (); # this is wanted by some makefiles
222 while (scalar @scanlist > 0) {
223 $file = shift @scanlist;
224 next if defined $further{$file}; # skip if we've already done it
225 $further{$file} = [];
226 $dirfile = &findfile($file);
227 $allsourcefiles{$dirfile} = 1;
228 open IN, "$dirfile" or die "unable to open source file $file\n";
231 /^\s*#include\s+\"([^\"]+)\"/ and do {
232 push @{$further{$file}}, $1;
236 /(RT_MANIFEST|ICON)\s+\"([^\"]+)\"\s*$/ and do {
237 push @{$further{$file}}, $2;
244 # Now we're ready to generate the final dependencies section. For
245 # each key in %depends, we must expand the dependencies list by
246 # iteratively adding entries from %further.
247 foreach $i (keys %depends) {
249 @scanlist = @{$depends{$i}};
250 foreach $i (@scanlist) { $dep{$i} = 1; }
251 while (scalar @scanlist > 0) {
252 $file = shift @scanlist;
253 foreach $j (@{$further{$file}}) {
256 push @{$depends{$i}}, $j;
261 # printf "%s: %s\n", $i, join ' ',@{$depends{$i}};
264 # Validation of input.
268 # Returns true if the argument is a known makefile type. Otherwise,
269 # prints a warning and returns false;
270 if (grep { $type eq $_ }
271 ("vc","vcproj","cygwin","borland","lcc","devcppproj","gtk","unix",
272 "am","osx","vstudio10","vstudio12")) {
275 warn "$.:unknown makefile type '$type'\n";
279 # Utility routines while writing out the Makefiles.
283 return (defined $x) ? $x : "";
287 my ($path) = shift @_;
288 my ($sep) = shift @_;
292 while (($i = index $path, $sep) >= 0 ||
293 ($j = index $path, "/") >= 0) {
294 if ($i >= 0 and ($j < 0 or $i < $j)) {
295 $path = substr $path, ($i + length $sep);
297 $path = substr $path, ($j + 1);
309 unless (defined $findfilecache{$name}) {
311 foreach $dir (@srcdirs) {
312 if (-f "$dir$name") {
315 $outdir =~ s/^\.\///;
318 die "multiple instances of source file $name\n" if $i > 1;
319 $findfilecache{$name} = (defined $outdir ? $outdir . $name : undef);
321 return $findfilecache{$name};
325 my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_;
328 ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ? $_ : "" } ($otmpl, $rtmpl, $ltmpl);
330 foreach $i (@{$programs{$prog}}) {
332 if ($i =~ /^(.*)\.(res|rsrc)/) {
334 ($x = $rtmpl) =~ s/X/$y/;
335 } elsif ($i =~ /^(.*)\.lib/) {
337 ($x = $ltmpl) =~ s/X/$y/;
338 } elsif ($i !~ /\./) {
339 ($x = $otmpl) =~ s/X/$i/;
341 push @ret, $x if $x ne "";
343 return join " ", @ret;
347 my ($prog, $suffix) = @_;
350 ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ? $_ : "" } ($otmpl, $rtmpl, $ltmpl);
352 foreach $i (@{$programs{$prog}}) {
353 if (substr($i, (length $i) - (length $suffix)) eq $suffix) {
357 return (scalar @ret) ? (join " ", @ret) : undef;
361 my ($line, $width, $splitchar) = @_;
364 $len = (defined $width ? $width : 76);
365 $splitchar = (defined $splitchar ? $splitchar : '\\');
366 while (length $line > $len) {
367 $line =~ /^(.{0,$len})\s(.*)$/ or $line =~ /^(.{$len,}?\s(.*)$/;
369 $result .= " ${splitchar}\n\t\t" if $2 ne '';
373 return $result . $line;
377 my ($otmpl, $rtmpl, $prefix, $dirsep, $mftyp, $depchar, $splitchar) = @_;
383 foreach $i (sort keys %depends) {
384 next if $specialobj{$mftyp}->{$i};
385 if ($i =~ /^(.*)\.(res|rsrc)/) {
386 next if !defined $rtmpl;
388 ($x = $rtmpl) =~ s/X/$y/;
390 ($x = $otmpl) =~ s/X/$i/;
392 @deps = @{$depends{$i}};
398 push @ret, {obj => $x, obj_orig => $i, deps => [@deps]};
405 my ($n, $prog, $type);
408 foreach $n (@prognames) {
409 ($prog, $type) = split ",", $n;
410 push @ret, $n if index(":$types:", ":$type:") >= 0;
417 my ($n, $prog, $type);
420 foreach $n (@prognames) {
421 ($prog, $type) = split ",", $n;
422 push @ret, $prog if index(":$types:", ":$type:") >= 0;
428 my ($types,$suffix) = @_;
430 # assume that all UNIX programs have a man page
431 if($suffix eq "1" && $types =~ /:X:/) {
432 return map("$_.1", &progrealnames($types));
439 # Now we're ready to output the actual Makefiles.
441 if (defined $makefiles{'cygwin'}) {
442 $dirpfx = &dirpfx($makefiles{'cygwin'}, "/");
444 ##-- MinGW/CygWin makefile (called 'cygwin' for historical reasons)
445 open OUT, ">$makefiles{'cygwin'}"; select OUT;
447 "# Makefile for $project_name under MinGW, Cygwin, or Winelib.\n".
448 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
449 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
450 # gcc command line option is -D not /D
451 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
455 "# You can define this path to point at your tools if you need to\n".
456 "# TOOLPATH = c:\\cygwin\\bin\\ # or similar, if you're running Windows\n".
457 "# TOOLPATH = /pkg/mingw32msvc/i386-mingw32msvc/bin/\n".
458 "# TOOLPATH = i686-w64-mingw32-\n".
459 "CC = \$(TOOLPATH)gcc\n".
460 "RC = \$(TOOLPATH)windres\n".
461 "# Uncomment the following two lines to compile under Winelib\n".
464 "# You may also need to tell windres where to find include files:\n".
465 "# RCINC = --include-dir c:\\cygwin\\include\\\n".
467 &splitline("CFLAGS = -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
469 (join " ", map {"-I$dirpfx$_"} @srcdirs)) .
472 &splitline("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1 ".
473 "--define WINVER=0x0400 ".(join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
475 &def($makefile_extra{'cygwin'}->{'vars'}) .
479 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
481 foreach $p (&prognames("G:C")) {
482 ($prog, $type) = split ",", $p;
483 $objstr = &objects($p, "X.o", "X.res.o", undef);
484 print &splitline($prog . ".exe: " . $objstr), "\n";
485 my $mw = $type eq "G" ? " -mwindows" : "";
486 $libstr = &objects($p, undef, undef, "-lX");
487 print &splitline("\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " .
488 "-Wl,-Map,$prog.map " .
489 $objstr . " $libstr", 69), "\n\n";
491 foreach $d (&deps("X.o", "X.res.o", $dirpfx, "/", "cygwin")) {
492 if ($forceobj{$d->{obj_orig}}) {
493 printf ("%s: FORCE\n", $d->{obj});
495 print &splitline(sprintf("%s: %s", $d->{obj},
496 join " ", @{$d->{deps}})), "\n";
498 if ($d->{obj} =~ /\.res\.o$/) {
499 print "\t\$(RC) \$(RCFL) \$(RCFLAGS) ".$d->{deps}->[0]." -o ".$d->{obj}."\n\n";
501 print "\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c ".$d->{deps}->[0]."\n\n";
505 print &def($makefile_extra{'cygwin'}->{'end'});
507 "\trm -f *.o *.exe *.res.o *.so *.map\n".
510 select STDOUT; close OUT;
514 ##-- Borland makefile
515 if (defined $makefiles{'borland'}) {
516 $dirpfx = &dirpfx($makefiles{'borland'}, "\\");
518 %stdlibs = ( # Borland provides many Win32 API libraries intrinsically
530 open OUT, ">$makefiles{'borland'}"; select OUT;
532 "# Makefile for $project_name under Borland C.\n".
533 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
534 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
535 # bcc32 command line option is -D not /D
536 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
540 "# If you rename this file to `Makefile', you should change this line,\n".
541 "# so that the .rsp files still depend on the correct makefile.\n".
542 "MAKEFILE = Makefile.bor\n".
544 "# C compilation flags\n".
545 "CFLAGS = -D_WINDOWS -DWINVER=0x0500\n".
546 "# Resource compilation flags\n".
547 "RCFLAGS = -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401\n".
549 "# Get include directory for resource compiler\n".
551 "BCB = \$(MAKEDIR)\\..\n".
554 &def($makefile_extra{'borland'}->{'vars'}) .
557 &splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT)".
558 " \$(CFLAGS) \$(XFLAGS) ".
559 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
560 " /c \$*.c",69)."\n".
562 &splitline("\tbrcc32 \$(RCFL) -i \$(BCB)\\include -r".
563 " \$(RCFLAGS) \$*.rc",69)."\n".
565 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
567 foreach $p (&prognames("G:C")) {
568 ($prog, $type) = split ",", $p;
569 $objstr = &objects($p, "X.obj", "X.res", undef);
570 print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
571 my $ap = ($type eq "G") ? "-aa" : "-ap";
572 print "\tilink32 $ap -Gn -L\$(BCB)\\lib \@$prog.rsp\n\n";
574 foreach $p (&prognames("G:C")) {
575 ($prog, $type) = split ",", $p;
576 print $prog, ".rsp: \$(MAKEFILE)\n";
577 $objstr = &objects($p, "X.obj", undef, undef);
578 @objlist = split " ", $objstr;
580 foreach $i (@objlist) {
581 if (length($objlines[$#objlines] . " $i") > 50) {
584 $objlines[$#objlines] .= " $i";
586 $c0w = ($type eq "G") ? "c0w32" : "c0x32";
587 print "\techo $c0w + > $prog.rsp\n";
588 for ($i=0; $i<=$#objlines; $i++) {
589 $plus = ($i < $#objlines ? " +" : "");
590 print "\techo$objlines[$i]$plus >> $prog.rsp\n";
592 print "\techo $prog.exe >> $prog.rsp\n";
593 $objstr = &objects($p, "X.obj", "X.res", undef);
594 @libs = split " ", &objects($p, undef, undef, "X");
595 @libs = grep { !$stdlibs{$_} } @libs;
596 unshift @libs, "cw32", "import32";
597 $libstr = join ' ', @libs;
598 print "\techo nul,$libstr, >> $prog.rsp\n";
599 print "\techo " . &objects($p, undef, "X.res", undef) . " >> $prog.rsp\n";
602 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "borland")) {
603 if ($forceobj{$d->{obj_orig}}) {
604 printf("%s: FORCE\n", $d->{obj});
606 print &splitline(sprintf("%s: %s", $d->{obj},
607 join " ", @{$d->{deps}})), "\n";
611 print &def($makefile_extra{'borland'}->{'end'});
622 "\t-del *.\$\$\$\$\$\$\n".
625 "\t-rem dummy command\n";
626 select STDOUT; close OUT;
629 if (defined $makefiles{'vc'}) {
630 $dirpfx = &dirpfx($makefiles{'vc'}, "\\");
632 ##-- Visual C++ makefile
633 open OUT, ">$makefiles{'vc'}"; select OUT;
635 "# Makefile for $project_name under Visual C.\n".
636 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
637 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
641 "# If you rename this file to `Makefile', you should change this line,\n".
642 "# so that the .rsp files still depend on the correct makefile.\n".
643 "MAKEFILE = Makefile.vc\n".
645 "# C compilation flags\n".
646 "CFLAGS = /nologo /W3 /O1 " .
647 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
648 " /D_WINDOWS /D_WIN32_WINDOWS=0x500 /DWINVER=0x500 /D_CRT_SECURE_NO_WARNINGS\n".
649 "LFLAGS = /incremental:no /dynamicbase /nxcompat\n".
650 "RCFLAGS = ".(join " ", map {"-I$dirpfx$_"} @srcdirs).
651 " -DWIN32 -D_WIN32 -DWINVER=0x0400\n".
653 &def($makefile_extra{'vc'}->{'vars'}) .
656 print &splitline("all:" . join "", map { " \$(BUILDDIR)$_.exe" } &progrealnames("G:C"));
658 foreach $p (&prognames("G:C")) {
659 ($prog, $type) = split ",", $p;
660 $objstr = &objects($p, "\$(BUILDDIR)X.obj", "\$(BUILDDIR)X.res", undef);
661 print &splitline("\$(BUILDDIR)$prog.exe: " . $objstr), "\n";
663 $objstr = &objects($p, "\$(BUILDDIR)X.obj", "\$(BUILDDIR)X.res", "X.lib");
664 $subsys = ($type eq "G") ? "windows" : "console";
665 $inlinefilename = "link_$prog";
666 print "\ttype <<$inlinefilename\n";
667 @objlist = split " ", $objstr;
669 foreach $i (@objlist) {
670 if (length($objlines[$#objlines] . " $i") > 72) {
673 $objlines[$#objlines] .= " $i";
675 for ($i=0; $i<=$#objlines; $i++) {
676 print "$objlines[$i]\n";
679 print "\tlink \$(LFLAGS) \$(XLFLAGS) -out:\$(BUILDDIR)$prog.exe -map:\$(BUILDDIR)$prog.map -nologo -subsystem:$subsys\$(SUBSYSVER) \@$inlinefilename\n\n";
681 foreach $d (&deps("\$(BUILDDIR)X.obj", "\$(BUILDDIR)X.res", $dirpfx, "\\", "vc")) {
682 $extradeps = $forceobj{$d->{obj_orig}} ? ["*.c","*.h","*.rc"] : [];
683 print &splitline(sprintf("%s: %s", $d->{obj},
684 join " ", @$extradeps, @{$d->{deps}})), "\n";
685 if ($d->{obj} =~ /.res$/) {
686 print "\trc /Fo@{[$d->{obj}]} \$(RCFL) -r \$(RCFLAGS) ".$d->{deps}->[0],"\n\n";
690 foreach $real_srcdir ("", @srcdirs) {
691 $srcdir = $real_srcdir;
694 $srcdir = $dirpfx . $srcdir;
695 $srcdir =~ s!\\\.\\!\\!;
696 $srcdir = "{$srcdir}";
698 # The double colon at the end of the line makes this a
699 # 'batch-mode inference rule', which means that nmake will
700 # aggregate multiple invocations of the rule and issue just
701 # one cl command with multiple source-file arguments. That
702 # noticeably speeds up builds, since starting up the cl
703 # process is a noticeable overhead and now has to be done far
705 print "${srcdir}.c.obj::\n\tcl /Fo\$(BUILDDIR) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c \$<\n\n";
707 print &def($makefile_extra{'vc'}->{'end'});
708 print "\nclean: tidy\n".
709 "\t-del \$(BUILDDIR)*.exe\n\n".
711 "\t-del \$(BUILDDIR)*.obj\n".
712 "\t-del \$(BUILDDIR)*.res\n".
713 "\t-del \$(BUILDDIR)*.pch\n".
714 "\t-del \$(BUILDDIR)*.aps\n".
715 "\t-del \$(BUILDDIR)*.ilk\n".
716 "\t-del \$(BUILDDIR)*.pdb\n".
717 "\t-del \$(BUILDDIR)*.rsp\n".
718 "\t-del \$(BUILDDIR)*.dsp\n".
719 "\t-del \$(BUILDDIR)*.dsw\n".
720 "\t-del \$(BUILDDIR)*.ncb\n".
721 "\t-del \$(BUILDDIR)*.opt\n".
722 "\t-del \$(BUILDDIR)*.plg\n".
723 "\t-del \$(BUILDDIR)*.map\n".
724 "\t-del \$(BUILDDIR)*.idb\n".
725 "\t-del \$(BUILDDIR)debug.log\n";
726 select STDOUT; close OUT;
729 if (defined $makefiles{'vcproj'}) {
730 $dirpfx = &dirpfx($makefiles{'vcproj'}, "\\");
732 ##-- MSVC 6 Workspace and projects
734 # Note: All files created in this section are written in binary
735 # mode, because although MSVC's command-line make can deal with
736 # LF-only line endings, MSVC project files really _need_ to be
737 # CRLF. Hence, in order for mkfiles.pl to generate usable project
738 # files even when run from Unix, I make sure all files are binary
739 # and explicitly write the CRLFs.
741 # Create directories if necessary
742 mkdir $makefiles{'vcproj'}
743 if(! -d $makefiles{'vcproj'});
744 chdir $makefiles{'vcproj'};
745 @deps = &deps("X.obj", "X.res", $dirpfx, "\\", "vcproj");
746 %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;
747 # Create the project files
748 # Get names of all Windows projects (GUI and console)
749 my @prognames = &prognames("G:C");
750 foreach $progname (@prognames) {
751 create_vc_project(\%all_object_deps, $progname);
753 # Create the workspace file
754 open OUT, ">$project_name.dsw"; binmode OUT; select OUT;
756 "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n".
757 "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n".
759 "###############################################################################\r\n".
762 foreach $progname (@prognames) {
763 ($windows_project, $type) = split ",", $progname;
764 print "Project: \"$windows_project\"=\".\\$windows_project\\$windows_project.dsp\" - Package Owner=<4>\r\n";
776 "###############################################################################\r\n".
788 "###############################################################################\r\n".
790 select STDOUT; close OUT;
793 sub create_vc_project {
794 my ($all_object_deps, $progname) = @_;
795 # Construct program's dependency info
800 %resource_files = ();
801 @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");
802 foreach $object_file (@object_files) {
803 next if defined $seen_objects{$object_file};
804 $seen_objects{$object_file} = 1;
805 if($object_file =~ /\.lib$/io) {
806 $lib_files{$object_file} = 1;
809 $object_deps = $all_object_deps{$object_file};
810 foreach $object_dep (@$object_deps) {
811 if($object_dep =~ /\.c$/io) {
812 $source_files{$object_dep} = 1;
815 if($object_dep =~ /\.h$/io) {
816 $header_files{$object_dep} = 1;
819 if($object_dep =~ /\.(rc|ico)$/io) {
820 $resource_files{$object_dep} = 1;
825 $libs = join " ", sort keys %lib_files;
826 @source_files = sort keys %source_files;
827 @header_files = sort keys %header_files;
828 @resources = sort keys %resource_files;
829 ($windows_project, $type) = split ",", $progname;
830 mkdir $windows_project
831 if(! -d $windows_project);
832 chdir $windows_project;
833 $subsys = ($type eq "G") ? "windows" : "console";
834 open OUT, ">$windows_project.dsp"; binmode OUT; select OUT;
836 "# Microsoft Developer Studio Project File - Name=\"$windows_project\" - Package Owner=<4>\r\n".
837 "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n".
838 "# ** DO NOT EDIT **\r\n".
840 "# TARGTYPE \"Win32 (x86) Application\" 0x0101\r\n".
842 "CFG=$windows_project - Win32 Debug\r\n".
843 "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n".
844 "!MESSAGE use the Export Makefile command and run\r\n".
846 "!MESSAGE NMAKE /f \"$windows_project.mak\".\r\n".
848 "!MESSAGE You can specify a configuration when running NMAKE\r\n".
849 "!MESSAGE by defining the macro CFG on the command line. For example:\r\n".
851 "!MESSAGE NMAKE /f \"$windows_project.mak\" CFG=\"$windows_project - Win32 Debug\"\r\n".
853 "!MESSAGE Possible choices for configuration are:\r\n".
855 "!MESSAGE \"$windows_project - Win32 Release\" (based on \"Win32 (x86) Application\")\r\n".
856 "!MESSAGE \"$windows_project - Win32 Debug\" (based on \"Win32 (x86) Application\")\r\n".
859 "# Begin Project\r\n".
860 "# PROP AllowPerConfigDependencies 0\r\n".
861 "# PROP Scc_ProjName \"\"\r\n".
862 "# PROP Scc_LocalPath \"\"\r\n".
867 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
869 "# PROP BASE Use_MFC 0\r\n".
870 "# PROP BASE Use_Debug_Libraries 0\r\n".
871 "# PROP BASE Output_Dir \"Release\"\r\n".
872 "# PROP BASE Intermediate_Dir \"Release\"\r\n".
873 "# PROP BASE Target_Dir \"\"\r\n".
874 "# PROP Use_MFC 0\r\n".
875 "# PROP Use_Debug_Libraries 0\r\n".
876 "# PROP Output_Dir \"Release\"\r\n".
877 "# PROP Intermediate_Dir \"Release\"\r\n".
878 "# PROP Ignore_Export_Lib 0\r\n".
879 "# PROP Target_Dir \"\"\r\n".
880 "# ADD BASE CPP /nologo /W3 /GX /O2 ".
881 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
882 " /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
883 "# ADD CPP /nologo /W3 /GX /O2 ".
884 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
885 " /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
886 "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
887 "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
888 "# ADD BASE RSC /l 0x809 /d \"NDEBUG\"\r\n".
889 "# ADD RSC /l 0x809 /d \"NDEBUG\"\r\n".
890 "BSC32=bscmake.exe\r\n".
891 "# ADD BASE BSC32 /nologo\r\n".
892 "# ADD BSC32 /nologo\r\n".
893 "LINK32=link.exe\r\n".
894 "# 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".
895 "# ADD LINK32 $libs /nologo /subsystem:$subsys /machine:I386\r\n".
896 "# SUBTRACT LINK32 /pdb:none\r\n".
898 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
900 "# PROP BASE Use_MFC 0\r\n".
901 "# PROP BASE Use_Debug_Libraries 1\r\n".
902 "# PROP BASE Output_Dir \"Debug\"\r\n".
903 "# PROP BASE Intermediate_Dir \"Debug\"\r\n".
904 "# PROP BASE Target_Dir \"\"\r\n".
905 "# PROP Use_MFC 0\r\n".
906 "# PROP Use_Debug_Libraries 1\r\n".
907 "# PROP Output_Dir \"Debug\"\r\n".
908 "# PROP Intermediate_Dir \"Debug\"\r\n".
909 "# PROP Ignore_Export_Lib 0\r\n".
910 "# PROP Target_Dir \"\"\r\n".
911 "# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od ".
912 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
913 " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
914 "# ADD CPP /nologo /W3 /Gm /GX /ZI /Od ".
915 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
916 " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
917 "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
918 "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
919 "# ADD BASE RSC /l 0x809 /d \"_DEBUG\"\r\n".
920 "# ADD RSC /l 0x809 /d \"_DEBUG\"\r\n".
921 "BSC32=bscmake.exe\r\n".
922 "# ADD BASE BSC32 /nologo\r\n".
923 "# ADD BSC32 /nologo\r\n".
924 "LINK32=link.exe\r\n".
925 "# 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".
926 "# ADD LINK32 $libs /nologo /subsystem:$subsys /debug /machine:I386 /pdbtype:sept\r\n".
927 "# SUBTRACT LINK32 /pdb:none\r\n".
931 "# Begin Target\r\n".
933 "# Name \"$windows_project - Win32 Release\"\r\n".
934 "# Name \"$windows_project - Win32 Debug\"\r\n".
935 "# Begin Group \"Source Files\"\r\n".
937 "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
938 foreach $source_file (@source_files) {
940 "# Begin Source File\r\n".
942 "SOURCE=..\\..\\$source_file\r\n";
943 if($source_file =~ /ssh\.c/io) {
944 # Disable 'Edit and continue' as Visual Studio can't handle the macros
947 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
949 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
956 print "# End Source File\r\n";
960 "# Begin Group \"Header Files\"\r\n".
962 "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
963 foreach $header_file (@header_files) {
965 "# Begin Source File\r\n".
967 "SOURCE=..\\..\\$header_file\r\n".
968 "# End Source File\r\n";
972 "# Begin Group \"Resource Files\"\r\n".
974 "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
975 foreach $resource_file (@resources) {
977 "# Begin Source File\r\n".
979 "SOURCE=..\\..\\$resource_file\r\n".
980 "# End Source File\r\n";
986 select STDOUT; close OUT;
991 if (defined $makefiles{'vstudio10'} || defined $makefiles{'vstudio12'}) {
993 ##-- Visual Studio 2010+ Solution and Projects
995 if (defined $makefiles{'vstudio10'}) {
996 create_vs_solution('vstudio10', "2010", "11.00", "v100");
999 if (defined $makefiles{'vstudio12'}) {
1000 create_vs_solution('vstudio12', "2012", "12.00", "v110");
1003 sub create_vs_solution {
1004 my ($makefilename, $name, $version, $toolsver) = @_;
1006 $dirpfx = &dirpfx($makefiles{$makefilename}, "\\");
1008 @deps = &deps("X.obj", "X.res", $dirpfx, "\\", $makefilename);
1009 %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;
1011 my @prognames = &prognames("G:C");
1013 # Create the solution file.
1014 mkdir $makefiles{$makefilename}
1015 if(! -f $makefiles{$makefilename});
1016 chdir $makefiles{$makefilename};
1018 open OUT, ">$project_name.sln"; select OUT;
1021 "Microsoft Visual Studio Solution File, Format Version $version\n" .
1022 "# Visual Studio $name\n";
1025 foreach $progname (@prognames) {
1026 ($windows_project, $type) = split ",", $progname;
1028 $projguids{$windows_project} = $guid =
1029 &invent_guid("project:$progname");
1032 "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"$windows_project\", \"$windows_project\\$windows_project.vcxproj\", \"{$guid}\"\n" .
1038 " GlobalSection(SolutionConfigurationPlatforms) = preSolution\n" .
1039 " Debug|Win32 = Debug|Win32\n" .
1040 " Release|Win32 = Release|Win32\n" .
1041 " EndGlobalSection\n" .
1042 " GlobalSection(ProjectConfigurationPlatforms) = postSolution\n" ;
1044 foreach my $projguid (values %projguids) {
1046 " {$projguid}.Debug|Win32.ActiveCfg = Debug|Win32\n" .
1047 " {$projguid}.Debug|Win32.Build.0 = Debug|Win32\n" .
1048 " {$projguid}.Release|Win32.ActiveCfg = Release|Win32\n" .
1049 " {$projguid}.Release|Win32.Build.0 = Release|Win32\n";
1053 " EndGlobalSection\n" .
1054 " GlobalSection(SolutionProperties) = preSolution\n" .
1055 " HideSolutionNode = FALSE\n" .
1056 " EndGlobalSection\n" .
1059 select STDOUT; close OUT;
1061 foreach $progname (@prognames) {
1062 ($windows_project, $type) = split ",", $progname;
1063 create_vs_project(\%all_object_deps, $windows_project, $type, $projguids{$windows_project}, $toolsver);
1069 sub create_vs_project {
1070 my ($all_object_deps, $windows_project, $type, $projguid, $toolsver) = @_;
1072 # Break down the project's dependency information into the appropriate
1078 %resource_files = ();
1081 @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");
1082 foreach $object_file (@object_files) {
1083 next if defined $seen_objects{$object_file};
1084 $seen_objects{$object_file} = 1;
1086 if($object_file =~ /\.lib$/io) {
1087 $lib_files{$object_file} = 1;
1091 $object_deps = $all_object_deps{$object_file};
1092 foreach $object_dep (@$object_deps) {
1093 if($object_dep eq $object_deps->[0]) {
1094 if($object_dep =~ /\.c$/io) {
1095 $source_files{$object_dep} = 1;
1096 } elsif($object_dep =~ /\.rc$/io) {
1097 $resource_files{$object_dep} = 1;
1099 } elsif ($object_dep =~ /\.[ch]$/io) {
1100 $header_files{$object_dep} = 1;
1101 } elsif ($object_dep =~ /\.ico$/io) {
1102 $icon_files{$object_dep} = 1;
1107 $libs = join ";", sort keys %lib_files;
1108 @source_files = sort keys %source_files;
1109 @header_files = sort keys %header_files;
1110 @resources = sort keys %resource_files;
1111 @icons = sort keys %icon_files;
1112 $subsystem = ($type eq "G") ? "Windows" : "Console";
1114 mkdir $windows_project
1115 if(! -d $windows_project);
1116 chdir $windows_project;
1117 open OUT, ">$windows_project.vcxproj"; select OUT;
1118 open FILTERS, ">$windows_project.vcxproj.filters";
1120 # The bulk of the project file is just boilerplate stuff, so we
1121 # can mostly just dump it out here. Note, buried in the ClCompile
1122 # item definition, that we use a debug information format of
1123 # ProgramDatabase, which disables the edit-and-continue support
1124 # that breaks most of the project builds.
1126 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" .
1127 "<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n" .
1128 " <ItemGroup Label=\"ProjectConfigurations\">\n" .
1129 " <ProjectConfiguration Include=\"Debug|Win32\">\n" .
1130 " <Configuration>Debug</Configuration>\n" .
1131 " <Platform>Win32</Platform>\n" .
1132 " </ProjectConfiguration>\n" .
1133 " <ProjectConfiguration Include=\"Release|Win32\">\n" .
1134 " <Configuration>Release</Configuration>\n" .
1135 " <Platform>Win32</Platform>\n" .
1136 " </ProjectConfiguration>\n" .
1138 " <PropertyGroup Label=\"Globals\">\n" .
1139 " <SccProjectName />\n" .
1140 " <SccLocalPath />\n" .
1141 " <ProjectGuid>{$projguid}</ProjectGuid>\n" .
1142 " </PropertyGroup>\n" .
1143 " <Import Project=\"\$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n" .
1144 " <PropertyGroup Condition=\"'\$(Configuration)|\$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\n" .
1145 " <ConfigurationType>Application</ConfigurationType>\n" .
1146 " <UseOfMfc>false</UseOfMfc>\n" .
1147 " <CharacterSet>MultiByte</CharacterSet>\n" .
1148 " <PlatformToolset>$toolsver</PlatformToolset>\n" .
1149 " </PropertyGroup>\n" .
1150 " <PropertyGroup Condition=\"'\$(Configuration)|\$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\n" .
1151 " <ConfigurationType>Application</ConfigurationType>\n" .
1152 " <UseOfMfc>false</UseOfMfc>\n" .
1153 " <CharacterSet>MultiByte</CharacterSet>\n" .
1154 " <PlatformToolset>$toolsver</PlatformToolset>\n" .
1155 " </PropertyGroup>\n" .
1156 " <Import Project=\"\$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n" .
1157 " <ImportGroup Label=\"ExtensionTargets\">\n" .
1158 " </ImportGroup>\n" .
1159 " <ImportGroup Condition=\"'\$(Configuration)|\$(Platform)'=='Debug|Win32'\" Label=\"PropertySheets\">\n" .
1160 " <Import Project=\"\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props\" Condition=\"exists('\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n" .
1161 " </ImportGroup>\n" .
1162 " <ImportGroup Condition=\"'\$(Configuration)|\$(Platform)'=='Release|Win32'\" Label=\"PropertySheets\">\n" .
1163 " <Import Project=\"\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props\" Condition=\"exists('\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n" .
1164 " </ImportGroup>\n" .
1165 " <PropertyGroup Label=\"UserMacros\" />\n" .
1166 " <PropertyGroup Condition=\"'\$(Configuration)|\$(Platform)'=='Release|Win32'\">\n" .
1167 " <OutDir>.\\Release\\</OutDir>\n" .
1168 " <IntDir>.\\Release\\</IntDir>\n" .
1169 " <LinkIncremental>false</LinkIncremental>\n" .
1170 " </PropertyGroup>\n" .
1171 " <PropertyGroup Condition=\"'\$(Configuration)|\$(Platform)'=='Debug|Win32'\">\n" .
1172 " <OutDir>.\\Debug\\</OutDir>\n" .
1173 " <IntDir>.\\Debug\\</IntDir>\n" .
1174 " <LinkIncremental>true</LinkIncremental>\n" .
1175 " </PropertyGroup>\n" .
1176 " <ItemDefinitionGroup Condition=\"'\$(Configuration)|\$(Platform)'=='Release|Win32'\">\n" .
1178 " <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n" .
1179 " <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>\n" .
1180 " <StringPooling>true</StringPooling>\n" .
1181 " <FunctionLevelLinking>true</FunctionLevelLinking>\n" .
1182 " <Optimization>MaxSpeed</Optimization>\n" .
1183 " <SuppressStartupBanner>true</SuppressStartupBanner>\n" .
1184 " <WarningLevel>Level3</WarningLevel>\n" .
1185 " <AdditionalIncludeDirectories>" . (join ";", map {"..\\..\\$dirpfx$_"} @srcdirs) . ";%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n" .
1186 " <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;POSIX;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n" .
1187 " <AssemblerListingLocation>.\\Release\\</AssemblerListingLocation>\n" .
1188 " <PrecompiledHeaderOutputFile>.\\Release\\$windows_project.pch</PrecompiledHeaderOutputFile>\n" .
1189 " <ObjectFileName>.\\Release\\</ObjectFileName>\n" .
1190 " <ProgramDataBaseFileName>.\\Release\\</ProgramDataBaseFileName>\n" .
1193 " <SuppressStartupBanner>true</SuppressStartupBanner>\n" .
1194 " <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n" .
1195 " <TypeLibraryName>.\\Release\\$windows_project.tlb</TypeLibraryName>\n" .
1196 " <MkTypLibCompatible>true</MkTypLibCompatible>\n" .
1197 " <TargetEnvironment>Win32</TargetEnvironment>\n" .
1199 " <ResourceCompile>\n" .
1200 " <Culture>0x0809</Culture>\n" .
1201 " <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n" .
1202 " </ResourceCompile>\n" .
1204 " <SuppressStartupBanner>true</SuppressStartupBanner>\n" .
1205 " <OutputFile>.\\Release\\$windows_project.bsc</OutputFile>\n" .
1208 " <SuppressStartupBanner>true</SuppressStartupBanner>\n" .
1209 " <SubSystem>$subsystem</SubSystem>\n" .
1210 " <OutputFile>.\\Release\\$windows_project.exe</OutputFile>\n" .
1211 " <AdditionalDependencies>$libs;%(AdditionalDependencies)</AdditionalDependencies>\n" .
1213 " </ItemDefinitionGroup>\n" .
1214 " <ItemDefinitionGroup Condition=\"'\$(Configuration)|\$(Platform)'=='Debug|Win32'\">\n" .
1216 " <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n" .
1217 " <InlineFunctionExpansion>Default</InlineFunctionExpansion>\n" .
1218 " <FunctionLevelLinking>false</FunctionLevelLinking>\n" .
1219 " <Optimization>Disabled</Optimization>\n" .
1220 " <SuppressStartupBanner>true</SuppressStartupBanner>\n" .
1221 " <WarningLevel>Level3</WarningLevel>\n" .
1222 " <MinimalRebuild>true</MinimalRebuild>\n" .
1223 " <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n" .
1224 " <AdditionalIncludeDirectories>" . (join ";", map {"..\\..\\$dirpfx$_"} @srcdirs) . ";%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n" .
1225 " <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;POSIX;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n" .
1226 " <AssemblerListingLocation>.\\Debug\\</AssemblerListingLocation>\n" .
1227 " <PrecompiledHeaderOutputFile>.\\Debug\\$windows_project.pch</PrecompiledHeaderOutputFile>\n" .
1228 " <ObjectFileName>.\\Debug\\</ObjectFileName>\n" .
1229 " <ProgramDataBaseFileName>.\\Debug\\</ProgramDataBaseFileName>\n" .
1230 " <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n" .
1233 " <SuppressStartupBanner>true</SuppressStartupBanner>\n" .
1234 " <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n" .
1235 " <TypeLibraryName>.\\Debug\\$windows_project.tlb</TypeLibraryName>\n" .
1236 " <MkTypLibCompatible>true</MkTypLibCompatible>\n" .
1237 " <TargetEnvironment>Win32</TargetEnvironment>\n" .
1239 " <ResourceCompile>\n" .
1240 " <Culture>0x0809</Culture>\n" .
1241 " <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n" .
1242 " </ResourceCompile>\n" .
1244 " <SuppressStartupBanner>true</SuppressStartupBanner>\n" .
1245 " <OutputFile>.\\Debug\\$windows_project.bsc</OutputFile>\n" .
1248 " <SuppressStartupBanner>true</SuppressStartupBanner>\n" .
1249 " <GenerateDebugInformation>true</GenerateDebugInformation>\n" .
1250 " <SubSystem>$subsystem</SubSystem>\n" .
1251 " <OutputFile>\$(TargetPath)</OutputFile>\n" .
1252 " <AdditionalDependencies>$libs;%(AdditionalDependencies)</AdditionalDependencies>\n" .
1254 " </ItemDefinitionGroup>\n";
1256 # The VC++ projects don't have physical structure to them, instead
1257 # the files are organized by logical "filters" that are stored in
1258 # a separate file, so different users can organize things differently.
1259 # The filters file contains a copy of the ItemGroup elements from
1260 # the main project file that list the included items, but tack
1261 # on a filter name where needed.
1263 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" .
1264 "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n";
1266 print " <ItemGroup>\n";
1267 print FILTERS " <ItemGroup>\n";
1268 foreach $icon_file (@icons) {
1269 $icon_file =~ s/..\\windows\\//;
1270 print " <CustomBuild Include=\"..\\..\\$icon_file\" />\n";
1272 " <CustomBuild Include=\"..\\..\\$icon_file\">\n" .
1273 " <Filter>Resource Files</Filter>\n" .
1274 " </CustomBuild>\n";
1276 print FILTERS " </ItemGroup>\n";
1277 print " </ItemGroup>\n";
1279 print " <ItemGroup>\n";
1280 print FILTERS " <ItemGroup>\n";
1281 foreach $resource_file (@resources) {
1282 $resource_file =~ s/..\\windows\\//;
1284 " <ResourceCompile Include=\"..\\..\\$resource_file\">\n" .
1285 " <AdditionalIncludeDirectories Condition=\"'\$(Configuration)|\$(Platform)'=='Release|Win32'\">..\\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n" .
1286 " <AdditionalIncludeDirectories Condition=\"'\$(Configuration)|\$(Platform)'=='Debug|Win32'\">..\\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n" .
1287 " </ResourceCompile>\n";
1289 " <ResourceCompile Include=\"..\\..\\$resource_file\">\n" .
1290 " <Filter>Resource Files</Filter>\n" .
1291 " </ResourceCompile>\n";
1293 print FILTERS " </ItemGroup>\n";
1294 print " </ItemGroup>\n";
1296 print " <ItemGroup>\n";
1297 print FILTERS " <ItemGroup>\n";
1298 foreach $source_file (@source_files) {
1299 $source_file =~ s/..\\windows\\//;
1300 print " <ClCompile Include=\"..\\..\\$source_file\" />\n";
1302 " <ClCompile Include=\"..\\..\\$source_file\">\n" .
1303 " <Filter>Source Files</Filter>\n" .
1306 print FILTERS " </ItemGroup>\n";
1307 print " </ItemGroup>\n";
1309 print " <ItemGroup>\n";
1310 print FILTERS " <ItemGroup>\n";
1311 foreach $header_file (@header_files) {
1312 $header_file =~ s/..\\windows\\//;
1313 print " <ClInclude Include=\"..\\..\\$header_file\" />\n";
1315 " <ClInclude Include=\"..\\..\\$header_file\">\n" .
1316 " <Filter>Header Files</Filter>\n" .
1319 print FILTERS " </ItemGroup>\n";
1320 print " </ItemGroup>\n";
1323 " <Import Project=\"\$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n" .
1328 " <Filter Include=\"Source Files\">\n" .
1329 " <UniqueIdentifier>{" . &invent_guid("sources:$windows_project") . "}</UniqueIdentifier>\n" .
1331 " <Filter Include=\"Header Files\">\n" .
1332 " <UniqueIdentifier>{" . &invent_guid("headers:$windows_project") . "}</UniqueIdentifier>\n" .
1334 " <Filter Include=\"Resource Files\">\n" .
1335 " <UniqueIdentifier>{" . &invent_guid("resources:$windows_project") . "}</UniqueIdentifier>\n" .
1340 select STDOUT; close OUT; close FILTERS;
1345 if (defined $makefiles{'gtk'}) {
1346 $dirpfx = &dirpfx($makefiles{'gtk'}, "/");
1348 ##-- X/GTK/Unix makefile
1349 open OUT, ">$makefiles{'gtk'}"; select OUT;
1351 "# Makefile for $project_name under X/GTK and Unix.\n".
1352 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1353 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1354 # gcc command line option is -D not /D
1355 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
1359 "# You can define this path to point at your tools if you need to\n".
1360 "# TOOLPATH = /opt/gcc/bin\n".
1361 "CC = \$(TOOLPATH)cc\n".
1362 "# If necessary set the path to krb5-config here\n".
1363 "KRB5CONFIG=krb5-config\n".
1364 "# You can manually set this to `gtk-config' or `pkg-config gtk+-1.2'\n".
1365 "# (depending on what works on your system) if you want to enforce\n".
1366 "# building with GTK 1.2, or you can set it to `pkg-config gtk+-2.0 x11'\n".
1367 "# if you want to enforce 2.0. The default is to try 2.0 and fall back\n".
1368 "# to 1.2 if it isn't found.\n".
1369 "GTK_CONFIG = sh -c 'pkg-config gtk+-3.0 x11 \$\$0 2>/dev/null || pkg-config gtk+-2.0 x11 \$\$0 2>/dev/null || gtk-config \$\$0'\n".
1371 "-include Makefile.local\n".
1373 "unexport CFLAGS # work around a weird issue with krb5-config\n".
1375 &splitline("CFLAGS = -O2 -Wall -Werror -g " .
1376 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
1377 " \$(shell \$(GTK_CONFIG) --cflags)").
1378 " -D _FILE_OFFSET_BITS=64\n".
1379 "XLDFLAGS = \$(LDFLAGS) \$(shell \$(GTK_CONFIG) --libs)\n".
1380 "ULDFLAGS = \$(LDFLAGS)\n".
1381 "ifeq (,\$(findstring NO_GSSAPI,\$(COMPAT)))\n".
1382 "ifeq (,\$(findstring STATIC_GSSAPI,\$(COMPAT)))\n".
1383 "XLDFLAGS+= -ldl\n".
1384 "ULDFLAGS+= -ldl\n".
1386 "CFLAGS+= -DNO_LIBDL \$(shell \$(KRB5CONFIG) --cflags gssapi)\n".
1387 "XLDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
1388 "ULDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
1391 "INSTALL=install\n".
1392 "INSTALL_PROGRAM=\$(INSTALL)\n".
1393 "INSTALL_DATA=\$(INSTALL)\n".
1394 "prefix=/usr/local\n".
1395 "exec_prefix=\$(prefix)\n".
1396 "bindir=\$(exec_prefix)/bin\n".
1397 "mandir=\$(prefix)/man\n".
1398 "man1dir=\$(mandir)/man1\n".
1400 &def($makefile_extra{'gtk'}->{'vars'}) .
1405 print &splitline("all:" . join "", map { " $_" }
1406 &progrealnames("X:XT:U:UT"));
1408 foreach $p (&prognames("X:XT:U:UT")) {
1409 ($prog, $type) = split ",", $p;
1410 ($ldflags = $type) =~ s/T$//;
1411 $objstr = &objects($p, "X.o", undef, undef);
1412 print &splitline($prog . ": " . $objstr), "\n";
1413 $libstr = &objects($p, undef, undef, "-lX");
1414 print &splitline("\t\$(CC) -o \$@ " .
1415 $objstr . " \$(${ldflags}LDFLAGS) $libstr", 69), "\n\n";
1417 foreach $d (&deps("X.o", undef, $dirpfx, "/", "gtk")) {
1418 if ($forceobj{$d->{obj_orig}}) {
1419 printf("%s: FORCE\n", $d->{obj});
1421 print &splitline(sprintf("%s: %s", $d->{obj},
1422 join " ", @{$d->{deps}})), "\n";
1424 print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
1427 print &def($makefile_extra{'gtk'}->{'end'});
1429 "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:XT:U:UT")) . "\n";
1431 select STDOUT; close OUT;
1434 if (defined $makefiles{'unix'}) {
1435 $dirpfx = &dirpfx($makefiles{'unix'}, "/");
1437 ##-- GTK-free pure-Unix makefile for non-GUI apps only
1438 open OUT, ">$makefiles{'unix'}"; select OUT;
1440 "# Makefile for $project_name under Unix.\n".
1441 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1442 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1443 # gcc command line option is -D not /D
1444 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
1448 "# You can define this path to point at your tools if you need to\n".
1449 "# TOOLPATH = /opt/gcc/bin\n".
1450 "CC = \$(TOOLPATH)cc\n".
1452 "-include Makefile.local\n".
1454 "unexport CFLAGS # work around a weird issue with krb5-config\n".
1456 &splitline("CFLAGS = -O2 -Wall -Werror -g " .
1457 (join " ", map {"-I$dirpfx$_"} @srcdirs)).
1458 " -D _FILE_OFFSET_BITS=64\n".
1459 "ULDFLAGS = \$(LDFLAGS)\n".
1460 "INSTALL=install\n".
1461 "INSTALL_PROGRAM=\$(INSTALL)\n".
1462 "INSTALL_DATA=\$(INSTALL)\n".
1463 "prefix=/usr/local\n".
1464 "exec_prefix=\$(prefix)\n".
1465 "bindir=\$(exec_prefix)/bin\n".
1466 "mandir=\$(prefix)/man\n".
1467 "man1dir=\$(mandir)/man1\n".
1469 &def($makefile_extra{'unix'}->{'vars'}) .
1474 print &splitline("all:" . join "", map { " $_" } &progrealnames("U:UT"));
1476 foreach $p (&prognames("U:UT")) {
1477 ($prog, $type) = split ",", $p;
1478 $objstr = &objects($p, "X.o", undef, undef);
1479 print &splitline($prog . ": " . $objstr), "\n";
1480 $libstr = &objects($p, undef, undef, "-lX");
1481 print &splitline("\t\$(CC) -o \$@ " .
1482 $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
1484 foreach $d (&deps("X.o", undef, $dirpfx, "/", "unix")) {
1485 if ($forceobj{$d->{obj_orig}}) {
1486 printf("%s: FORCE\n", $d->{obj});
1488 print &splitline(sprintf("%s: %s", $d->{obj},
1489 join " ", @{$d->{deps}})), "\n";
1491 print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
1494 print &def($makefile_extra{'unix'}->{'end'});
1496 "\trm -f *.o". (join "", map { " $_" } &progrealnames("U:UT")) . "\n";
1498 select STDOUT; close OUT;
1501 if (defined $makefiles{'am'}) {
1502 die "Makefile.am in a subdirectory is not supported\n"
1503 if &dirpfx($makefiles{'am'}, "/") ne "";
1505 ##-- Unix/autoconf Makefile.am
1506 open OUT, ">$makefiles{'am'}"; select OUT;
1508 "# Makefile.am for $project_name under Unix with Autoconf/Automake.\n".
1509 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1510 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n\n";
1512 # 2014-02-22: as of automake-1.14 we begin to get complained at if
1513 # we don't use this option
1514 print "AUTOMAKE_OPTIONS = subdir-objects\n\n";
1516 # Complete list of source and header files. Not used by the
1517 # auto-generated parts of this makefile, but Recipe might like to
1518 # have it available as a variable so that mandatory-rebuild things
1519 # (version.o) can conveniently be made to depend on it.
1520 @sources = ("allsources", "=", sort keys %allsourcefiles);
1521 print &splitline(join " ", @sources), "\n\n";
1523 @cliprogs = ("bin_PROGRAMS", "=");
1524 foreach $p (&prognames("U")) {
1525 ($prog, $type) = split ",", $p;
1526 push @cliprogs, $prog;
1528 @allprogs = @cliprogs;
1529 foreach $p (&prognames("X")) {
1530 ($prog, $type) = split ",", $p;
1531 push @allprogs, $prog;
1533 print "if HAVE_GTK\n";
1534 print &splitline(join " ", @allprogs), "\n";
1536 print &splitline(join " ", @cliprogs), "\n";
1539 @noinstcliprogs = ("noinst_PROGRAMS", "=");
1540 foreach $p (&prognames("XT:UT")) {
1541 ($prog, $type) = split ",", $p;
1542 push @noinstcliprogs, $prog;
1544 print &splitline(join " ", @noinstcliprogs), "\n";
1547 foreach $d (&deps("X", undef, "", "/", "am")) {
1548 $objtosrc{$d->{obj}} = $d->{deps}->[0];
1551 print &splitline(join " ", "AM_CPPFLAGS", "=",
1552 map {"-I\$(srcdir)/$_"} @srcdirs), "\n";
1554 @amcflags = ("\$(COMPAT)", "\$(XFLAGS)", "\$(WARNINGOPTS)");
1555 print "if HAVE_GTK\n";
1556 print &splitline(join " ", "AM_CFLAGS", "=",
1557 "\$(GTK_CFLAGS)", @amcflags), "\n";
1559 print &splitline(join " ", "AM_CFLAGS", "=", @amcflags), "\n";
1562 %amspeciallibs = ();
1563 foreach $obj (sort { $a cmp $b } keys %{$cflags{'am'}}) {
1564 my $flags = $cflags{'am'}->{$obj};
1565 $flags = "" if $flags !~ s/^C//;
1566 print "lib${obj}_a_SOURCES = ", $objtosrc{$obj}, "\n";
1567 print &splitline(join " ", "lib${obj}_a_CFLAGS", "=", @amcflags,
1569 $amspeciallibs{$obj} = "lib${obj}.a";
1571 print &splitline(join " ", "noinst_LIBRARIES", "=",
1572 sort { $a cmp $b } values %amspeciallibs), "\n\n";
1574 foreach $p (&prognames("X:XT:U:UT")) {
1575 ($prog, $type) = split ",", $p;
1576 print "if HAVE_GTK\n" if $type eq "X" || $type eq "XT";
1577 @progsources = ("${prog}_SOURCES", "=");
1580 $objstr = &objects($p, "X", undef, undef);
1581 foreach $obj (split / /,$objstr) {
1582 if ($amspeciallibs{$obj}) {
1583 push @ldadd, $amspeciallibs{$obj};
1585 $sourcefiles{$objtosrc{$obj}} = 1;
1588 push @progsources, sort { $a cmp $b } keys %sourcefiles;
1589 print &splitline(join " ", @progsources), "\n";
1590 if ($type eq "X" || $type eq "XT") {
1591 push @ldadd, "\$(GTK_LIBS)";
1594 print &splitline(join " ", "${prog}_LDADD", "=", @ldadd), "\n";
1596 print "endif\n" if $type eq "X" || $type eq "XT";
1599 print &def($makefile_extra{'am'}->{'end'});
1600 select STDOUT; close OUT;
1603 if (defined $makefiles{'lcc'}) {
1604 $dirpfx = &dirpfx($makefiles{'lcc'}, "\\");
1607 open OUT, ">$makefiles{'lcc'}"; select OUT;
1609 "# Makefile for $project_name under lcc.\n".
1610 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1611 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1612 # lcc command line option is -D not /D
1613 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
1617 "# If you rename this file to `Makefile', you should change this line,\n".
1618 "# so that the .rsp files still depend on the correct makefile.\n".
1619 "MAKEFILE = Makefile.lcc\n".
1621 "# C compilation flags\n".
1622 "CFLAGS = -D_WINDOWS " .
1623 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
1625 "# Resource compilation flags\n".
1626 "RCFLAGS = ".(join " ", map {"-I$dirpfx$_"} @srcdirs)."\n".
1628 "# Get include directory for resource compiler\n".
1630 &def($makefile_extra{'lcc'}->{'vars'}) .
1632 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
1634 foreach $p (&prognames("G:C")) {
1635 ($prog, $type) = split ",", $p;
1636 $objstr = &objects($p, "X.obj", "X.res", undef);
1637 print &splitline("$prog.exe: " . $objstr ), "\n";
1638 $subsystemtype = '';
1639 if ($type eq "G") { $subsystemtype = "-subsystem windows"; }
1640 my $libss = "shell32.lib wsock32.lib ws2_32.lib winspool.lib winmm.lib imm32.lib";
1641 print &splitline("\tlcclnk $subsystemtype -o $prog.exe $objstr $libss");
1645 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "lcc")) {
1646 if ($forceobj{$d->{obj_orig}}) {
1647 printf("%s: FORCE\n", $d->{obj});
1649 print &splitline(sprintf("%s: %s", $d->{obj},
1650 join " ", @{$d->{deps}})), "\n";
1652 if ($d->{obj} =~ /\.obj$/) {
1653 print &splitline("\tlcc -O -p6 \$(COMPAT)".
1654 " \$(CFLAGS) \$(XFLAGS) ".$d->{deps}->[0],69)."\n";
1656 print &splitline("\tlrc \$(RCFL) -r \$(RCFLAGS) ".
1657 $d->{deps}->[0],69)."\n";
1661 print &def($makefile_extra{'lcc'}->{'end'});
1669 select STDOUT; close OUT;
1672 if (defined $makefiles{'osx'}) {
1673 $dirpfx = &dirpfx($makefiles{'osx'}, "/");
1675 ##-- Mac OS X makefile
1676 open OUT, ">$makefiles{'osx'}"; select OUT;
1678 "# Makefile for $project_name under Mac OS X.\n".
1679 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1680 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1681 # gcc command line option is -D not /D
1682 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
1685 "CC = \$(TOOLPATH)gcc\n".
1687 &splitline("CFLAGS = -O2 -Wall -Werror -g " .
1688 (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
1689 "MLDFLAGS = -framework Cocoa\n".
1692 &def($makefile_extra{'osx'}->{'vars'}) .
1694 &splitline("all:" . join "", map { " $_" } &progrealnames("MX:U:UT")) .
1696 foreach $p (&prognames("MX")) {
1697 ($prog, $type) = split ",", $p;
1698 $objstr = &objects($p, "X.o", undef, undef);
1699 $icon = &special($p, ".icns");
1700 $infoplist = &special($p, "info.plist");
1701 print "${prog}.app:\n\tmkdir -p \$\@\n";
1702 print "${prog}.app/Contents: ${prog}.app\n\tmkdir -p \$\@\n";
1703 print "${prog}.app/Contents/MacOS: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1704 $targets = "${prog}.app/Contents/MacOS/$prog";
1705 if (defined $icon) {
1706 print "${prog}.app/Contents/Resources: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1707 print "${prog}.app/Contents/Resources/${prog}.icns: ${prog}.app/Contents/Resources $icon\n\tcp $icon \$\@\n";
1708 $targets .= " ${prog}.app/Contents/Resources/${prog}.icns";
1710 if (defined $infoplist) {
1711 print "${prog}.app/Contents/Info.plist: ${prog}.app/Contents/Resources $infoplist\n\tcp $infoplist \$\@\n";
1712 $targets .= " ${prog}.app/Contents/Info.plist";
1714 $targets .= " \$(${prog}_extra)";
1715 print &splitline("${prog}: $targets", 69) . "\n\n";
1716 print &splitline("${prog}.app/Contents/MacOS/$prog: ".
1717 "${prog}.app/Contents/MacOS " . $objstr), "\n";
1718 $libstr = &objects($p, undef, undef, "-lX");
1719 print &splitline("\t\$(CC) \$(MLDFLAGS) -o \$@ " .
1720 $objstr . " $libstr", 69), "\n\n";
1722 foreach $p (&prognames("U:UT")) {
1723 ($prog, $type) = split ",", $p;
1724 $objstr = &objects($p, "X.o", undef, undef);
1725 print &splitline($prog . ": " . $objstr), "\n";
1726 $libstr = &objects($p, undef, undef, "-lX");
1727 print &splitline("\t\$(CC) \$(ULDFLAGS) -o \$@ " .
1728 $objstr . " $libstr", 69), "\n\n";
1730 foreach $d (&deps("X.o", undef, $dirpfx, "/", "osx")) {
1731 if ($forceobj{$d->{obj_orig}}) {
1732 printf("%s: FORCE\n", $d->{obj});
1734 print &splitline(sprintf("%s: %s", $d->{obj},
1735 join " ", @{$d->{deps}})), "\n";
1737 $firstdep = $d->{deps}->[0];
1738 if ($firstdep =~ /\.c$/) {
1739 print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
1740 } elsif ($firstdep =~ /\.m$/) {
1741 print "\t\$(CC) -x objective-c \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
1744 print "\n".&def($makefile_extra{'osx'}->{'end'});
1746 "\trm -f *.o *.dmg". (join "", map { " $_" } &progrealnames("U:UT")) . "\n".
1750 select STDOUT; close OUT;
1753 if (defined $makefiles{'devcppproj'}) {
1754 $dirpfx = &dirpfx($makefiles{'devcppproj'}, "\\");
1757 ##-- Dev-C++ 5 projects
1759 # Note: All files created in this section are written in binary
1760 # mode to prevent any posibility of misinterpreted line endings.
1761 # I don't know if Dev-C++ is as touchy as MSVC with LF-only line
1762 # endings. But however, CRLF line endings are the common way on
1763 # Win32 machines where Dev-C++ is running.
1764 # Hence, in order for mkfiles.pl to generate CRLF project files
1765 # even when run from Unix, I make sure all files are binary and
1766 # explicitly write the CRLFs.
1768 # Create directories if necessary
1769 mkdir $makefiles{'devcppproj'}
1770 if(! -d $makefiles{'devcppproj'});
1771 chdir $makefiles{'devcppproj'};
1772 @deps = &deps("X.obj", "X.res", $dirpfx, "\\", "devcppproj");
1773 %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;
1774 # Make dir names FAT/NTFS compatible
1775 my @srcdirs = @srcdirs;
1776 for ($i=0; $i<@srcdirs; $i++) {
1777 $srcdirs[$i] =~ s/\//\\/g;
1778 $srcdirs[$i] =~ s/\\$//;
1780 # Create the project files
1781 # Get names of all Windows projects (GUI and console)
1782 my @prognames = &prognames("G:C");
1783 foreach $progname (@prognames) {
1784 create_devcpp_project(\%all_object_deps, $progname);
1789 sub create_devcpp_project {
1790 my ($all_object_deps, $progname) = @_;
1791 # Construct program's dependency info (Taken from 'vcproj', seems to work right here, too.)
1796 %resource_files = ();
1797 @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");
1798 foreach $object_file (@object_files) {
1799 next if defined $seen_objects{$object_file};
1800 $seen_objects{$object_file} = 1;
1801 if($object_file =~ /\.lib$/io) {
1802 $lib_files{$object_file} = 1;
1805 $object_deps = $all_object_deps{$object_file};
1806 foreach $object_dep (@$object_deps) {
1807 if($object_dep =~ /\.c$/io) {
1808 $source_files{$object_dep} = 1;
1811 if($object_dep =~ /\.h$/io) {
1812 $header_files{$object_dep} = 1;
1815 if($object_dep =~ /\.(rc|ico)$/io) {
1816 $resource_files{$object_dep} = 1;
1821 $libs = join " ", sort keys %lib_files;
1822 @source_files = sort keys %source_files;
1823 @header_files = sort keys %header_files;
1824 @resources = sort keys %resource_files;
1825 ($windows_project, $type) = split ",", $progname;
1826 mkdir $windows_project
1827 if(! -d $windows_project);
1828 chdir $windows_project;
1830 $subsys = ($type eq "G") ? "0" : "1"; # 0 = Win32 GUI, 1 = Win32 Console
1831 open OUT, ">$windows_project.dev"; binmode OUT; select OUT;
1833 "# DEV-C++ 5 Project File - $windows_project.dev\r\n".
1834 "# ** DO NOT EDIT **\r\n".
1836 # No difference between DEBUG and RELEASE here as in 'vcproj', because
1837 # Dev-C++ does not support mutiple compilation profiles in one single project.
1838 # (At least I can say this for Dev-C++ 5 Beta)
1840 "FileName=$windows_project.dev\r\n".
1841 "Name=$windows_project\r\n".
1845 # Multimon is disabled here, as Dev-C++ (Version 5 Beta) does not have multimon.h
1846 "Compiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
1847 "CppCompiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
1848 "Includes=" . (join ";", map {"..\\..\\$dirpfx$_"} @srcdirs) . "\r\n".
1849 "Linker=-ladvapi32 -lcomctl32 -lcomdlg32 -lgdi32 -limm32 -lshell32 -luser32 -lwinmm -lwinspool_\@\@_\r\n".
1851 "UnitCount=" . (@source_files + @header_files + @resources) . "\r\n".
1852 "Folders=\"Header Files\",\"Resource Files\",\"Source Files\"\r\n".
1854 "PrivateResource=${windows_project}_private.rc\r\n".
1855 "ResourceIncludes=..\\..\\..\\WINDOWS\r\n".
1856 "MakeIncludes=\r\n".
1857 "Icon=\r\n". # It's ok to leave this blank.
1859 "ObjectOutput=\r\n".
1860 "OverrideOutput=0\r\n".
1861 "OverrideOutputName=$windows_project.exe\r\n".
1862 "HostApplication=\r\n".
1864 "UseCustomMakefile=0\r\n".
1865 "CustomMakefile=\r\n".
1866 "IncludeVersionInfo=0\r\n".
1867 "SupportXPThemes=0\r\n".
1868 "CompilerSet=0\r\n".
1869 "CompilerSettings=0000000000000000000000\r\n".
1872 foreach $source_file (@source_files) {
1874 "[Unit$unit_count]\r\n".
1875 "FileName=..\\..\\$source_file\r\n".
1876 "Folder=Source Files\r\n".
1880 "Priority=1000\r\n".
1881 "OverrideBuildCmd=0\r\n".
1886 foreach $header_file (@header_files) {
1888 "[Unit$unit_count]\r\n".
1889 "FileName=..\\..\\$header_file\r\n".
1890 "Folder=Header Files\r\n".
1892 "CompileCpp=1\r\n". # Dev-C++ want's to compile all header files with both compilers C and C++. It does not hurt.
1894 "Priority=1000\r\n".
1895 "OverrideBuildCmd=0\r\n".
1900 foreach $resource_file (@resources) {
1901 if ($resource_file =~ /.*\.(ico|cur|bmp|dlg|rc2|rct|bin|rgs|gif|jpg|jpeg|jpe)/io) { # Default filter as in 'vcproj'
1902 $Compile = "0"; # Don't compile images and other binary resource files
1906 $CompileCpp = "1"; # Dev-C++ want's to compile all .rc files with both compilers C and C++. It does not hurt.
1909 "[Unit$unit_count]\r\n".
1910 "FileName=..\\..\\$resource_file\r\n".
1911 "Folder=Resource Files\r\n".
1912 "Compile=$Compile\r\n".
1913 "CompileCpp=$CompileCpp\r\n".
1915 "Priority=1000\r\n".
1916 "OverrideBuildCmd=0\r\n".
1921 #Note: By default, [VersionInfo] is not used.
1923 "[VersionInfo]\r\n".
1928 "LanguageID=1033\r\n".
1929 "CharsetID=1252\r\n".
1931 "FileVersion=0.1\r\n".
1932 "FileDescription=\r\n".
1933 "InternalName=\r\n".
1934 "LegalCopyright=\r\n".
1935 "LegalTrademarks=\r\n".
1936 "OriginalFilename=$windows_project.exe\r\n".
1937 "ProductName=$windows_project\r\n".
1938 "ProductVersion=0.1\r\n".
1939 "AutoIncBuildNr=0\r\n";
1940 select STDOUT; close OUT;
1945 # All done, so do the Unix postprocessing if asked to.
1949 system "./mkauto.sh";
1950 die "mkfiles.pl: mkauto.sh returned $?\n" if $? > 0;
1951 if ($do_unix == 1) {
1952 chdir ($targetdir = "unix")
1953 or die "$targetdir: chdir: $!\n";
1955 system "./configure", @confargs;
1956 die "mkfiles.pl: configure returned $?\n" if $? > 0;
1959 sub invent_guid($) {
1962 # Invent a GUID for use in Visual Studio project files. We need
1963 # a few of these for every executable file we build.
1965 # In order to avoid having to use the non-core Perl module
1966 # Data::GUID, and also arrange for GUIDs to be stable, we generate
1967 # our GUIDs by hashing a pile of fixed (but originally randomly
1968 # generated) data with the filename for which we need an id.
1970 # Hashing _just_ the filenames would clearly be cheating (it's
1971 # quite conceivable that someone might hash the same string for
1972 # another reason and so generate a colliding GUID), but hashing a
1973 # whole SHA-512 data block of random gibberish as well should make
1974 # these GUIDs pseudo-random enough to not collide with anyone
1977 my $randdata = pack "N*",
1978 0xD4AB035F,0x76998BA0,0x2DCCB0BD,0x6D3FA320,0x53638051,0xFE312F35,
1979 0xDE1CECC0,0x784DF852,0x6C9F4589,0x54B7AC23,0x14E7A1C4,0xF9BF04DF,
1980 0x19C08B6D,0x3FB69EF1,0xB2DA9043,0xDB5362F3,0x25718DB6,0x733560DA,
1981 0xFEF871B0,0xFECF7A0C,0x67D19C95,0xB492E911,0xF5D562A3,0xFCE1D478,
1982 0x02C50434,0xF7326B7E,0x93D39872,0xCF0D0269,0x9EF24C0F,0x827689AD,
1983 0x88BD20BC,0x74EA6AFE,0x29223682,0xB9AB9287,0x7EA7CE4F,0xCF81B379,
1984 0x9AE4A954,0x81C7AD97,0x2FF2F031,0xC51DA3C2,0xD311CCE7,0x0A31EB8B,
1985 0x1AB04242,0xAF53B714,0xFC574D40,0x8CB4ED01,0x29FEB16F,0x4904D7ED,
1986 0xF5C5F5E1,0xF138A4C2,0xA9D881CE,0xCEA65187,0x4421BA97,0x0EE8428E,
1987 0x9556E384,0x6D0484C9,0x561BD84B,0xD9516A40,0x6B4FD33F,0xDDFFE4C8,
1988 0x3D5DF8A5,0xFE6B7D99,0x3443371B,0xF4E30A3E,0xE62B9FDA,0x6BAA75DB,
1989 0x9EF3C2C7,0x6815CA42,0xE6536076,0xF851E6E2,0x39D16E69,0xBCDF3BB6,
1990 0x50EFFA41,0x378CDF2A,0xB5EC0D0C,0x1E94C433,0xE818241A,0x2689EB1F,
1991 0xB649CEF9,0xD7344D46,0x59C1BB13,0x27511FDF,0x7DAD1768,0xB355E29E,
1992 0xDFAE550C,0x2433005B,0x09DE10B0,0xAA00BA6B,0xC144ED2D,0x8513D007,
1993 0xB0315232,0x7A10DAB6,0x1D97654E,0xF048214D,0xE3059E75,0x83C225D1,
1994 0xFC7AB177,0x83F2B553,0x79F7A0AF,0x1C94582C,0xF5E4AF4B,0xFB39C865,
1995 0x58ABEB27,0xAAB28058,0x52C15A89,0x0EBE9741,0x343F4D26,0xF941202A,
1996 0xA32FD32F,0xDCC055B8,0x64281BF3,0x468BD7BA,0x0CEE09D3,0xBB5FD2B6,
1997 0xA528D412,0xA6A6967E,0xEAAF5DAE,0xDE7B2FAE,0xCA36887B,0x0DE196EB,
1998 0x74B95EF0,0x9EB8B7C2,0x020BFC83,0x1445086F,0xBF4B61B2,0x89AFACEC,
1999 0x80A5CD69,0xC790F744,0x435A6998,0x8DE7AC48,0x32F31BC9,0x8F760D3D,
2000 0xF02A74CB,0xD7B47E20,0x9EC91035,0x70FDE74D,0x9B531362,0x9D81739A,
2001 0x59ADC2EB,0x511555B5,0xCA84B8D5,0x3EC325FF,0x2E442A4C,0x82AF30D9,
2002 0xBFD3EC87,0x90C59E07,0x1C6DC991,0x2D16B822,0x7EA44EB5,0x3A655A39,
2003 0xAB640886,0x09311821,0x777801D9,0x489DBE61,0xA1FFEC65,0x978B49B1,
2004 0x7DB700CD,0x263CF3D6,0xF977E89F,0xBA0B3D01,0x6C6CED19,0x1BE6F23A,
2005 0x19E0ED98,0x8E71A499,0x70BA3271,0x3FB7EE98,0xABA46848,0x2B797959,
2006 0x72C6DE59,0xE08B795C,0x02936C39,0x02185CCB,0xD6F3CE18,0xD0157A40,
2007 0x833DEC3F,0x319B00C4,0x97B59513,0x900B81FD,0x9A022379,0x16E44E1A,
2008 0x0C4CC540,0xCA98E7F9,0xF9431A26,0x290BCFAC,0x406B82C0,0xBC1C4585,
2009 0x55C54528,0x811EBB77,0xD4EDD4F3,0xA70DC02E,0x8AD5C0D1,0x28D64EF4,
2010 0xBEFF5C69,0x99852C4A,0xB4BBFF7B,0x069230AC,0xA3E141FA,0x4E99FB0E,
2011 0xBC154DAA,0x323C7F15,0x86E0247E,0x2EEA3054,0xC9CA1D32,0x8964A006,
2012 0xC93978AC,0xF9B2C159,0x03F2079E,0xB051D284,0x4A7EA9A9,0xF001DA1F,
2013 0xD47A0DAA,0xCF7B6B73,0xF18293B2,0x84303E34,0xF8BC76C4,0xAFBEE24F,
2014 0xB589CA80,0x77B5BF86,0x21B9FD5B,0x1A5071DF,0xA3863110,0x0E50CA61,
2015 0x939151A5,0xD2A59021,0x83A9CDCE,0xCEC69767,0xC906BB16,0x3EE1FF4D,
2016 0x1321EAE4,0x0BF940D6,0x52471E61,0x8A087056,0x66E54293,0xF84AAB9B,
2017 0x08835EF1,0x8F12B77A,0xD86935A5,0x200281D7,0xCD3C37C9,0x30ABEC05,
2018 0x7067E8A0,0x608C4838,0xC9F51CDE,0xA6D318DE,0x41C05B2A,0x694CCE0E,
2019 0xC7842451,0xA3194393,0xFBDC2C84,0xA6D2B577,0xC91E7924,0x01EDA708,
2020 0x22FBB61E,0x662F9B7B,0xDE3150C3,0x2397058C;
2021 my $digest = sha512_hex($name . "\0" . $randdata);
2022 return sprintf("%s-%s-%04x-%04x-%s",
2023 substr($digest,0,8),
2024 substr($digest,8,4),
2025 0x4000 | (0xFFF & hex(substr($digest,12,4))),
2026 0x8000 | (0x3FFF & hex(substr($digest,16,4))),
2027 substr($digest,20,12));