No, I take that back: we _do_ have a mechanism for suppressing reads
[u/mdw/putty] / mkfiles.pl
CommitLineData
52a1ed22 1#!/usr/bin/env perl
3d541627 2#
e35fb54b 3# Cross-platform Makefile generator.
7603011f 4#
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.
9
cdd310bb 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.
976374cd 15#
16# FIXME: no attempt made to handle !forceobj in the project files.
cdd310bb 17
52a1ed22 18use warnings;
f7f27309 19use FileHandle;
bc7af299 20use File::Basename;
e35fb54b 21use Cwd;
f7f27309 22
c1b71b1c 23if ($#ARGV >= 0 and ($ARGV[0] eq "-u" or $ARGV[0] eq "-U")) {
bc7af299 24 # Convenience for Unix users: -u means that after we finish what
25 # we're doing here, we also run mkauto.sh and then 'configure' in
26 # the Unix subdirectory. So it's a one-stop shop for regenerating
27 # the actual end-product Unix makefile.
28 #
29 # Arguments supplied after -u go to configure.
c1b71b1c 30 #
31 # -U is identical, but runs 'configure' at the _top_ level, for
32 # people who habitually do that.
33 $do_unix = ($ARGV[0] eq "-U" ? 2 : 1);
bc7af299 34 shift @ARGV;
35 @confargs = @ARGV;
bc7af299 36}
37
e3109730 38open IN, "Recipe" or do {
39 # We want to deal correctly with being run from one of the
40 # subdirs in the source tree. So if we can't find Recipe here,
41 # try one level up.
42 chdir "..";
43 open IN, "Recipe" or die "unable to open Recipe file\n";
44};
7603011f 45
2dc6356a 46# HACK: One of the source files in `charset' is auto-generated by
47# sbcsgen.pl. We need to generate that _now_, before attempting
48# dependency analysis.
49eval 'chdir "charset"; require "sbcsgen.pl"; chdir ".."';
50
cdd310bb 51@srcdirs = ("./");
f7f27309 52
e35fb54b 53$divert = undef; # ref to scalar in which text is currently being put
7603011f 54$help = ""; # list of newline-free lines of help text
e35fb54b 55$project_name = "project"; # this is a good enough default
56%makefiles = (); # maps makefile types to output makefile pathnames
57%makefile_extra = (); # maps makefile types to extra Makefile text
c282cde3 58%programs = (); # maps prog name + type letter to listref of objects/resources
7603011f 59%groups = (); # maps group name to listref of objects/resources
3d541627 60
3d541627 61while (<IN>) {
62 chomp;
4877ec8d 63 @_ = split;
64
65 # If we're gathering help text, keep doing so.
66 if (defined $divert) {
67 if ((defined $_[0]) && $_[0] eq "!end") {
68 $divert = undef;
69 } else {
70 ${$divert} .= "$_\n";
71 }
72 next;
73 }
74 # Skip comments and blank lines.
75 next if /^\s*#/ or scalar @_ == 0;
76
e35fb54b 77 if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = \$help; next; }
78 if ($_[0] eq "!end") { $divert = undef; next; }
79 if ($_[0] eq "!name") { $project_name = $_[1]; next; }
cdd310bb 80 if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; }
e35fb54b 81 if ($_[0] eq "!makefile" and &mfval($_[1])) { $makefiles{$_[1]}=$_[2]; next;}
6da41155 82 if ($_[0] eq "!specialobj" and &mfval($_[1])) { $specialobj{$_[1]}->{$_[2]} = 1; next;}
44747c53 83 if ($_[0] eq "!cflags" and &mfval($_[1])) {
84 ($rest = $_) =~ s/^\s*\S+\s+\S+\s+\S+\s*//; # find rest of input line
85 $rest = 1 if $rest eq "";
86 $cflags{$_[1]}->{$_[2]} = $rest;
87 next;
88 }
976374cd 89 if ($_[0] eq "!forceobj") { $forceobj{$_[1]} = 1; next; }
e35fb54b 90 if ($_[0] eq "!begin") {
91 if (&mfval($_[1])) {
77603464 92 $sect = $_[2] ? $_[2] : "end";
93 $divert = \($makefile_extra{$_[1]}->{$sect});
e35fb54b 94 } else {
4877ec8d 95 $dummy = '';
e35fb54b 96 $divert = \$dummy;
97 }
98 next;
99 }
77603464 100 # If we're gathering help/verbatim text, keep doing so.
e35fb54b 101 if (defined $divert) { ${$divert} .= "$_\n"; next; }
7603011f 102 # Ignore blank lines.
103 next if scalar @_ == 0;
104
105 # Now we have an ordinary line. See if it's an = line, a : line
106 # or a + line.
107 @objs = @_;
108
109 if ($_[0] eq "+") {
110 $listref = $lastlistref;
111 $prog = undef;
112 die "$.: unexpected + line\n" if !defined $lastlistref;
113 } elsif ($_[1] eq "=") {
114 $groups{$_[0]} = [] if !defined $groups{$_[0]};
115 $listref = $groups{$_[0]};
116 $prog = undef;
117 shift @objs; # eat the group name
118 } elsif ($_[1] eq ":") {
c282cde3 119 $listref = [];
7603011f 120 $prog = $_[0];
121 shift @objs; # eat the program name
3d541627 122 } else {
7603011f 123 die "$.: unrecognised line type\n";
3d541627 124 }
7603011f 125 shift @objs; # eat the +, the = or the :
126
127 while (scalar @objs > 0) {
128 $i = shift @objs;
129 if ($groups{$i}) {
130 foreach $j (@{$groups{$i}}) { unshift @objs, $j; }
a86a2725 131 } elsif (($i eq "[G]" or $i eq "[C]" or $i eq "[M]" or
1ddda1ca 132 $i eq "[X]" or $i eq "[U]" or $i eq "[MX]") and defined $prog) {
133 $type = substr($i,1,(length $i)-2);
7603011f 134 } else {
135 push @$listref, $i;
136 }
137 }
c282cde3 138 if ($prog and $type) {
139 die "multiple program entries for $prog [$type]\n"
e35fb54b 140 if defined $programs{$prog . "," . $type};
c282cde3 141 $programs{$prog . "," . $type} = $listref;
142 }
7603011f 143 $lastlistref = $listref;
3d541627 144}
7603011f 145
3d541627 146close IN;
7603011f 147
148# Now retrieve the complete list of objects and resource files, and
149# construct dependency data for them. While we're here, expand the
150# object list for each program, and complain if its type isn't set.
151@prognames = sort keys %programs;
152%depends = ();
153@scanlist = ();
154foreach $i (@prognames) {
c282cde3 155 ($prog, $type) = split ",", $i;
7603011f 156 # Strip duplicate object names.
4877ec8d 157 $prev = '';
7603011f 158 @list = grep { $status = ($prev ne $_); $prev=$_; $status }
159 sort @{$programs{$i}};
160 $programs{$i} = [@list];
161 foreach $j (@list) {
1ddda1ca 162 # Dependencies for "x" start with "x.c" or "x.m" (depending on
163 # which one exists).
7603011f 164 # Dependencies for "x.res" start with "x.rc".
c88dc003 165 # Dependencies for "x.rsrc" start with "x.r".
7603011f 166 # Both types of file are pushed on the list of files to scan.
167 # Libraries (.lib) don't have dependencies at all.
168 if ($j =~ /^(.*)\.res$/) {
169 $file = "$1.rc";
170 $depends{$j} = [$file];
171 push @scanlist, $file;
c88dc003 172 } elsif ($j =~ /^(.*)\.rsrc$/) {
173 $file = "$1.r";
174 $depends{$j} = [$file];
175 push @scanlist, $file;
1ddda1ca 176 } elsif ($j !~ /\./) {
7603011f 177 $file = "$j.c";
1ddda1ca 178 $file = "$j.m" unless &findfile($file);
7603011f 179 $depends{$j} = [$file];
180 push @scanlist, $file;
181 }
182 }
183}
184
185# Scan each file on @scanlist and find further inclusions.
186# Inclusions are given by lines of the form `#include "otherfile"'
187# (system headers are automatically ignored by this because they'll
188# be given in angle brackets). Files included by this method are
189# added back on to @scanlist to be scanned in turn (if not already
190# done).
191#
0f2ab471 192# Resource scripts (.rc) can also include a file by means of:
193# - a line # ending `ICON "filename"';
194# - a line ending `RT_MANIFEST "filename"'.
195# Files included by this method are not added to @scanlist because
196# they can never include further files.
7603011f 197#
198# In this pass we write out a hash %further which maps a source
199# file name into a listref containing further source file names.
200
201%further = ();
44747c53 202%allsourcefiles = (); # this is wanted by some makefiles
7603011f 203while (scalar @scanlist > 0) {
204 $file = shift @scanlist;
205 next if defined $further{$file}; # skip if we've already done it
7603011f 206 $further{$file} = [];
f7f27309 207 $dirfile = &findfile($file);
44747c53 208 $allsourcefiles{$dirfile} = 1;
f7f27309 209 open IN, "$dirfile" or die "unable to open source file $file\n";
7603011f 210 while (<IN>) {
211 chomp;
212 /^\s*#include\s+\"([^\"]+)\"/ and do {
213 push @{$further{$file}}, $1;
214 push @scanlist, $1;
215 next;
216 };
0f2ab471 217 /(RT_MANIFEST|ICON)\s+\"([^\"]+)\"\s*$/ and do {
218 push @{$further{$file}}, $2;
7603011f 219 next;
220 }
221 }
222 close IN;
3d541627 223}
224
7603011f 225# Now we're ready to generate the final dependencies section. For
226# each key in %depends, we must expand the dependencies list by
227# iteratively adding entries from %further.
228foreach $i (keys %depends) {
229 %dep = ();
230 @scanlist = @{$depends{$i}};
231 foreach $i (@scanlist) { $dep{$i} = 1; }
232 while (scalar @scanlist > 0) {
233 $file = shift @scanlist;
234 foreach $j (@{$further{$file}}) {
4877ec8d 235 if (!$dep{$j}) {
7603011f 236 $dep{$j} = 1;
e35fb54b 237 push @{$depends{$i}}, $j;
238 push @scanlist, $j;
7603011f 239 }
240 }
241 }
242# printf "%s: %s\n", $i, join ' ',@{$depends{$i}};
3d541627 243}
244
e35fb54b 245# Validation of input.
246
247sub mfval($) {
248 my ($type) = @_;
249 # Returns true if the argument is a known makefile type. Otherwise,
250 # prints a warning and returns false;
251 if (grep { $type eq $_ }
b89e7e07 252 ("vc","vcproj","cygwin","borland","lcc","devcppproj","gtk","unix",
44747c53 253 "am","osx",)) {
e35fb54b 254 return 1;
255 }
256 warn "$.:unknown makefile type '$type'\n";
257 return 0;
258}
259
7603011f 260# Utility routines while writing out the Makefiles.
261
4877ec8d 262sub def {
263 my ($x) = shift @_;
264 return (defined $x) ? $x : "";
265}
266
cdd310bb 267sub dirpfx {
268 my ($path) = shift @_;
269 my ($sep) = shift @_;
4877ec8d 270 my $ret = "";
271 my $i;
6da41155 272
273 while (($i = index $path, $sep) >= 0 ||
274 ($j = index $path, "/") >= 0) {
275 if ($i >= 0 and ($j < 0 or $i < $j)) {
276 $path = substr $path, ($i + length $sep);
277 } else {
278 $path = substr $path, ($j + 1);
279 }
cdd310bb 280 $ret .= "..$sep";
281 }
282 return $ret;
283}
284
f7f27309 285sub findfile {
286 my ($name) = @_;
4877ec8d 287 my $dir = '';
1ddda1ca 288 my $i;
289 my $outdir = undef;
b6b40d9b 290 unless (defined $findfilecache{$name}) {
291 $i = 0;
cdd310bb 292 foreach $dir (@srcdirs) {
4877ec8d 293 if (-f "$dir$name") {
294 $outdir = $dir;
295 $i++;
296 $outdir =~ s/^\.\///;
297 }
b6b40d9b 298 }
299 die "multiple instances of source file $name\n" if $i > 1;
1ddda1ca 300 $findfilecache{$name} = (defined $outdir ? $outdir . $name : undef);
f7f27309 301 }
b6b40d9b 302 return $findfilecache{$name};
f7f27309 303}
304
7603011f 305sub objects {
f7f27309 306 my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_;
7603011f 307 my @ret;
308 my ($i, $x, $y);
4877ec8d 309 ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ? $_ : "" } ($otmpl, $rtmpl, $ltmpl);
7603011f 310 @ret = ();
311 foreach $i (@{$programs{$prog}}) {
f7f27309 312 $x = "";
c88dc003 313 if ($i =~ /^(.*)\.(res|rsrc)/) {
7603011f 314 $y = $1;
315 ($x = $rtmpl) =~ s/X/$y/;
7603011f 316 } elsif ($i =~ /^(.*)\.lib/) {
317 $y = $1;
318 ($x = $ltmpl) =~ s/X/$y/;
1ddda1ca 319 } elsif ($i !~ /\./) {
7603011f 320 ($x = $otmpl) =~ s/X/$i/;
7603011f 321 }
f7f27309 322 push @ret, $x if $x ne "";
7603011f 323 }
324 return join " ", @ret;
3d541627 325}
326
1ddda1ca 327sub special {
328 my ($prog, $suffix) = @_;
329 my @ret;
330 my ($i, $x, $y);
4877ec8d 331 ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ? $_ : "" } ($otmpl, $rtmpl, $ltmpl);
1ddda1ca 332 @ret = ();
333 foreach $i (@{$programs{$prog}}) {
334 if (substr($i, (length $i) - (length $suffix)) eq $suffix) {
335 push @ret, $i;
336 }
337 }
338 return (scalar @ret) ? (join " ", @ret) : undef;
339}
340
7603011f 341sub splitline {
a86a2725 342 my ($line, $width, $splitchar) = @_;
4877ec8d 343 my $result = "";
344 my $len;
7603011f 345 $len = (defined $width ? $width : 76);
a86a2725 346 $splitchar = (defined $splitchar ? $splitchar : '\\');
7603011f 347 while (length $line > $len) {
348 $line =~ /^(.{0,$len})\s(.*)$/ or $line =~ /^(.{$len,}?\s(.*)$/;
b76d219a 349 $result .= $1;
350 $result .= " ${splitchar}\n\t\t" if $2 ne '';
7603011f 351 $line = $2;
352 $len = 60;
353 }
354 return $result . $line;
355}
356
357sub deps {
6da41155 358 my ($otmpl, $rtmpl, $prefix, $dirsep, $mftyp, $depchar, $splitchar) = @_;
7603011f 359 my ($i, $x, $y);
4877ec8d 360 my @deps;
361 my @ret;
a86a2725 362 @ret = ();
363 $depchar ||= ':';
7603011f 364 foreach $i (sort keys %depends) {
6da41155 365 next if $specialobj{$mftyp}->{$i};
c88dc003 366 if ($i =~ /^(.*)\.(res|rsrc)/) {
f7f27309 367 next if !defined $rtmpl;
7603011f 368 $y = $1;
369 ($x = $rtmpl) =~ s/X/$y/;
370 } else {
371 ($x = $otmpl) =~ s/X/$i/;
372 }
f7f27309 373 @deps = @{$depends{$i}};
374 @deps = map {
375 $_ = &findfile($_);
376 s/\//$dirsep/g;
377 $_ = $prefix . $_;
378 } @deps;
976374cd 379 push @ret, {obj => $x, obj_orig => $i, deps => [@deps]};
7603011f 380 }
a86a2725 381 return @ret;
3d541627 382}
383
f7f27309 384sub prognames {
385 my ($types) = @_;
c282cde3 386 my ($n, $prog, $type);
387 my @ret;
388 @ret = ();
389 foreach $n (@prognames) {
390 ($prog, $type) = split ",", $n;
1ddda1ca 391 push @ret, $n if index(":$types:", ":$type:") >= 0;
c282cde3 392 }
393 return @ret;
394}
395
396sub progrealnames {
397 my ($types) = @_;
398 my ($n, $prog, $type);
f7f27309 399 my @ret;
400 @ret = ();
401 foreach $n (@prognames) {
c282cde3 402 ($prog, $type) = split ",", $n;
1ddda1ca 403 push @ret, $prog if index(":$types:", ":$type:") >= 0;
f7f27309 404 }
405 return @ret;
406}
407
c76d309d 408sub manpages {
409 my ($types,$suffix) = @_;
410
411 # assume that all UNIX programs have a man page
1ddda1ca 412 if($suffix eq "1" && $types =~ /:X:/) {
c76d309d 413 return map("$_.1", &progrealnames($types));
414 }
415 return ();
416}
417
bc7af299 418$orig_dir = cwd;
419
7603011f 420# Now we're ready to output the actual Makefiles.
421
e35fb54b 422if (defined $makefiles{'cygwin'}) {
cdd310bb 423 $dirpfx = &dirpfx($makefiles{'cygwin'}, "/");
3d541627 424
e35fb54b 425 ##-- CygWin makefile
426 open OUT, ">$makefiles{'cygwin'}"; select OUT;
427 print
428 "# Makefile for $project_name under cygwin.\n".
429 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
430 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
431 # gcc command line option is -D not /D
4877ec8d 432 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
e35fb54b 433 print $_;
434 print
435 "\n".
436 "# You can define this path to point at your tools if you need to\n".
437 "# TOOLPATH = c:\\cygwin\\bin\\ # or similar, if you're running Windows\n".
438 "# TOOLPATH = /pkg/mingw32msvc/i386-mingw32msvc/bin/\n".
439 "CC = \$(TOOLPATH)gcc\n".
440 "RC = \$(TOOLPATH)windres\n".
441 "# Uncomment the following two lines to compile under Winelib\n".
442 "# CC = winegcc\n".
443 "# RC = wrc\n".
444 "# You may also need to tell windres where to find include files:\n".
445 "# RCINC = --include-dir c:\\cygwin\\include\\\n".
446 "\n".
447 &splitline("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
db6452be 448 " -D_NO_OLDNAMES -DNO_MULTIMON -DNO_HTMLHELP " .
cdd310bb 449 (join " ", map {"-I$dirpfx$_"} @srcdirs)) .
450 "\n".
e35fb54b 451 "LDFLAGS = -mno-cygwin -s\n".
452 &splitline("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1".
33205978 453 " --define WINVER=0x0400")."\n".
e35fb54b 454 "\n".
77603464 455 $makefile_extra{'cygwin'}->{'vars'} .
456 "\n".
e35fb54b 457 ".SUFFIXES:\n".
e35fb54b 458 "\n";
1ddda1ca 459 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
e35fb54b 460 print "\n\n";
1ddda1ca 461 foreach $p (&prognames("G:C")) {
e35fb54b 462 ($prog, $type) = split ",", $p;
463 $objstr = &objects($p, "X.o", "X.res.o", undef);
464 print &splitline($prog . ".exe: " . $objstr), "\n";
465 my $mw = $type eq "G" ? " -mwindows" : "";
466 $libstr = &objects($p, undef, undef, "-lX");
467 print &splitline("\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " .
468 "-Wl,-Map,$prog.map " .
469 $objstr . " $libstr", 69), "\n\n";
7603011f 470 }
6da41155 471 foreach $d (&deps("X.o", "X.res.o", $dirpfx, "/", "cygwin")) {
976374cd 472 if ($forceobj{$d->{obj_orig}}) {
473 printf ("%s: FORCE\n", $d->{obj});
474 } else {
475 print &splitline(sprintf("%s: %s", $d->{obj},
476 join " ", @{$d->{deps}})), "\n";
477 }
6da41155 478 if ($d->{obj} =~ /\.res\.o$/) {
d8284c29 479 print "\t\$(RC) \$(RCFL) \$(RCFLAGS) ".$d->{deps}->[0]." ".$d->{obj}."\n\n";
6da41155 480 } else {
a77c6ed3 481 print "\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c ".$d->{deps}->[0]."\n\n";
6da41155 482 }
e35fb54b 483 }
484 print "\n";
77603464 485 print $makefile_extra{'cygwin'}->{'end'};
e35fb54b 486 print "\nclean:\n".
487 "\trm -f *.o *.exe *.res.o *.map\n".
976374cd 488 "\n".
489 "FORCE:\n";
e35fb54b 490 select STDOUT; close OUT;
7603011f 491
7603011f 492}
e35fb54b 493
494##-- Borland makefile
495if (defined $makefiles{'borland'}) {
cdd310bb 496 $dirpfx = &dirpfx($makefiles{'borland'}, "\\");
497
e35fb54b 498 %stdlibs = ( # Borland provides many Win32 API libraries intrinsically
499 "advapi32" => 1,
500 "comctl32" => 1,
501 "comdlg32" => 1,
502 "gdi32" => 1,
503 "imm32" => 1,
504 "shell32" => 1,
505 "user32" => 1,
506 "winmm" => 1,
507 "winspool" => 1,
508 "wsock32" => 1,
509 );
510 open OUT, ">$makefiles{'borland'}"; select OUT;
511 print
512 "# Makefile for $project_name under Borland C.\n".
513 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
514 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
515 # bcc32 command line option is -D not /D
4877ec8d 516 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
e35fb54b 517 print $_;
518 print
519 "\n".
520 "# If you rename this file to `Makefile', you should change this line,\n".
521 "# so that the .rsp files still depend on the correct makefile.\n".
522 "MAKEFILE = Makefile.bor\n".
523 "\n".
524 "# C compilation flags\n".
06c3eadd 525 "CFLAGS = -D_WINDOWS -DWINVER=0x0500\n".
976374cd 526 "# Resource compilation flags\n".
527 "RCFLAGS = -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401\n".
e35fb54b 528 "\n".
529 "# Get include directory for resource compiler\n".
530 "!if !\$d(BCB)\n".
531 "BCB = \$(MAKEDIR)\\..\n".
532 "!endif\n".
533 "\n".
77603464 534 $makefile_extra{'borland'}->{'vars'} .
535 "\n".
e35fb54b 536 ".c.obj:\n".
d8284c29 537 &splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT)".
a77c6ed3 538 " \$(CFLAGS) \$(XFLAGS) ".
cdd310bb 539 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
ba58fbaa 540 " /c \$*.c",69)."\n".
e35fb54b 541 ".rc.res:\n".
d8284c29 542 &splitline("\tbrcc32 \$(RCFL) -i \$(BCB)\\include -r".
976374cd 543 " \$(RCFLAGS) \$*.rc",69)."\n".
e35fb54b 544 "\n";
1ddda1ca 545 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
e35fb54b 546 print "\n\n";
1ddda1ca 547 foreach $p (&prognames("G:C")) {
e35fb54b 548 ($prog, $type) = split ",", $p;
4877ec8d 549 $objstr = &objects($p, "X.obj", "X.res", undef);
e35fb54b 550 print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
551 my $ap = ($type eq "G") ? "-aa" : "-ap";
552 print "\tilink32 $ap -Gn -L\$(BCB)\\lib \@$prog.rsp\n\n";
7603011f 553 }
1ddda1ca 554 foreach $p (&prognames("G:C")) {
e35fb54b 555 ($prog, $type) = split ",", $p;
556 print $prog, ".rsp: \$(MAKEFILE)\n";
557 $objstr = &objects($p, "X.obj", undef, undef);
558 @objlist = split " ", $objstr;
559 @objlines = ("");
560 foreach $i (@objlist) {
561 if (length($objlines[$#objlines] . " $i") > 50) {
562 push @objlines, "";
563 }
564 $objlines[$#objlines] .= " $i";
565 }
566 $c0w = ($type eq "G") ? "c0w32" : "c0x32";
567 print "\techo $c0w + > $prog.rsp\n";
568 for ($i=0; $i<=$#objlines; $i++) {
569 $plus = ($i < $#objlines ? " +" : "");
570 print "\techo$objlines[$i]$plus >> $prog.rsp\n";
571 }
572 print "\techo $prog.exe >> $prog.rsp\n";
573 $objstr = &objects($p, "X.obj", "X.res", undef);
574 @libs = split " ", &objects($p, undef, undef, "X");
575 @libs = grep { !$stdlibs{$_} } @libs;
576 unshift @libs, "cw32", "import32";
577 $libstr = join ' ', @libs;
578 print "\techo nul,$libstr, >> $prog.rsp\n";
579 print "\techo " . &objects($p, undef, "X.res", undef) . " >> $prog.rsp\n";
580 print "\n";
581 }
6da41155 582 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "borland")) {
976374cd 583 if ($forceobj{$d->{obj_orig}}) {
584 printf("%s: FORCE\n", $d->{obj});
585 } else {
586 print &splitline(sprintf("%s: %s", $d->{obj},
587 join " ", @{$d->{deps}})), "\n";
588 }
e35fb54b 589 }
590 print "\n";
77603464 591 print $makefile_extra{'borland'}->{'end'};
e35fb54b 592 print "\nclean:\n".
593 "\t-del *.obj\n".
594 "\t-del *.exe\n".
595 "\t-del *.res\n".
596 "\t-del *.pch\n".
597 "\t-del *.aps\n".
598 "\t-del *.il*\n".
599 "\t-del *.pdb\n".
600 "\t-del *.rsp\n".
601 "\t-del *.tds\n".
976374cd 602 "\t-del *.\$\$\$\$\$\$\n".
603 "\n".
604 "FORCE:\n".
605 "\t-rem dummy command\n";
e35fb54b 606 select STDOUT; close OUT;
7603011f 607}
e35fb54b 608
609if (defined $makefiles{'vc'}) {
cdd310bb 610 $dirpfx = &dirpfx($makefiles{'vc'}, "\\");
611
e35fb54b 612 ##-- Visual C++ makefile
613 open OUT, ">$makefiles{'vc'}"; select OUT;
614 print
615 "# Makefile for $project_name under Visual C.\n".
616 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
617 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
618 print $help;
619 print
620 "\n".
621 "# If you rename this file to `Makefile', you should change this line,\n".
622 "# so that the .rsp files still depend on the correct makefile.\n".
623 "MAKEFILE = Makefile.vc\n".
624 "\n".
625 "# C compilation flags\n".
6da41155 626 "CFLAGS = /nologo /W3 /O1 " .
627 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
06c3eadd 628 " /D_WINDOWS /D_WIN32_WINDOWS=0x500 /DWINVER=0x500\n".
e35fb54b 629 "LFLAGS = /incremental:no /fixed\n".
976374cd 630 "RCFLAGS = -DWIN32 -D_WIN32 -DWINVER=0x0400\n".
e35fb54b 631 "\n".
77603464 632 $makefile_extra{'vc'}->{'vars'} .
633 "\n".
a86a2725 634 "\n";
1ddda1ca 635 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
e35fb54b 636 print "\n\n";
1ddda1ca 637 foreach $p (&prognames("G:C")) {
e35fb54b 638 ($prog, $type) = split ",", $p;
639 $objstr = &objects($p, "X.obj", "X.res", undef);
640 print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
d7656baf 641 print "\tlink \$(LFLAGS) \$(XLFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n";
e35fb54b 642 }
1ddda1ca 643 foreach $p (&prognames("G:C")) {
e35fb54b 644 ($prog, $type) = split ",", $p;
645 print $prog, ".rsp: \$(MAKEFILE)\n";
646 $objstr = &objects($p, "X.obj", "X.res", "X.lib");
647 @objlist = split " ", $objstr;
648 @objlines = ("");
649 foreach $i (@objlist) {
650 if (length($objlines[$#objlines] . " $i") > 50) {
651 push @objlines, "";
652 }
653 $objlines[$#objlines] .= " $i";
654 }
655 $subsys = ($type eq "G") ? "windows" : "console";
656 print "\techo /nologo /subsystem:$subsys > $prog.rsp\n";
657 for ($i=0; $i<=$#objlines; $i++) {
658 print "\techo$objlines[$i] >> $prog.rsp\n";
659 }
660 print "\n";
661 }
6da41155 662 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "vc")) {
976374cd 663 $extradeps = $forceobj{$d->{obj_orig}} ? ["*.c","*.h","*.rc"] : [];
664 print &splitline(sprintf("%s: %s", $d->{obj},
665 join " ", @$extradeps, @{$d->{deps}})), "\n";
6da41155 666 if ($d->{obj} =~ /.obj$/) {
a77c6ed3 667 print "\tcl \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c ".$d->{deps}->[0],"\n\n";
6da41155 668 } else {
976374cd 669 print "\trc \$(RCFL) -r \$(RCFLAGS) ".$d->{deps}->[0],"\n\n";
6da41155 670 }
e35fb54b 671 }
672 print "\n";
77603464 673 print $makefile_extra{'vc'}->{'end'};
e35fb54b 674 print "\nclean: tidy\n".
675 "\t-del *.exe\n\n".
676 "tidy:\n".
677 "\t-del *.obj\n".
678 "\t-del *.res\n".
679 "\t-del *.pch\n".
680 "\t-del *.aps\n".
681 "\t-del *.ilk\n".
682 "\t-del *.pdb\n".
683 "\t-del *.rsp\n".
684 "\t-del *.dsp\n".
685 "\t-del *.dsw\n".
686 "\t-del *.ncb\n".
687 "\t-del *.opt\n".
688 "\t-del *.plg\n".
689 "\t-del *.map\n".
690 "\t-del *.idb\n".
691 "\t-del debug.log\n";
692 select STDOUT; close OUT;
a86a2725 693}
f7f27309 694
e35fb54b 695if (defined $makefiles{'vcproj'}) {
6da41155 696 $dirpfx = &dirpfx($makefiles{'vcproj'}, "\\");
58de2f3c 697
e35fb54b 698 ##-- MSVC 6 Workspace and projects
699 #
700 # Note: All files created in this section are written in binary
701 # mode, because although MSVC's command-line make can deal with
702 # LF-only line endings, MSVC project files really _need_ to be
703 # CRLF. Hence, in order for mkfiles.pl to generate usable project
704 # files even when run from Unix, I make sure all files are binary
705 # and explicitly write the CRLFs.
706 #
707 # Create directories if necessary
708 mkdir $makefiles{'vcproj'}
709 if(! -d $makefiles{'vcproj'});
710 chdir $makefiles{'vcproj'};
6da41155 711 @deps = &deps("X.obj", "X.res", $dirpfx, "\\", "vcproj");
e35fb54b 712 %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;
713 # Create the project files
714 # Get names of all Windows projects (GUI and console)
1ddda1ca 715 my @prognames = &prognames("G:C");
e35fb54b 716 foreach $progname (@prognames) {
985b6440 717 create_vc_project(\%all_object_deps, $progname);
e35fb54b 718 }
719 # Create the workspace file
720 open OUT, ">$project_name.dsw"; binmode OUT; select OUT;
721 print
722 "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n".
723 "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n".
724 "\r\n".
725 "###############################################################################\r\n".
726 "\r\n";
727 # List projects
728 foreach $progname (@prognames) {
729 ($windows_project, $type) = split ",", $progname;
730 print "Project: \"$windows_project\"=\".\\$windows_project\\$windows_project.dsp\" - Package Owner=<4>\r\n";
731 }
732 print
733 "\r\n".
734 "Package=<5>\r\n".
735 "{{{\r\n".
736 "}}}\r\n".
737 "\r\n".
738 "Package=<4>\r\n".
739 "{{{\r\n".
740 "}}}\r\n".
741 "\r\n".
742 "###############################################################################\r\n".
743 "\r\n".
744 "Global:\r\n".
745 "\r\n".
746 "Package=<5>\r\n".
747 "{{{\r\n".
748 "}}}\r\n".
749 "\r\n".
750 "Package=<3>\r\n".
751 "{{{\r\n".
752 "}}}\r\n".
753 "\r\n".
754 "###############################################################################\r\n".
755 "\r\n";
756 select STDOUT; close OUT;
757 chdir $orig_dir;
758
985b6440 759 sub create_vc_project {
e35fb54b 760 my ($all_object_deps, $progname) = @_;
761 # Construct program's dependency info
762 %seen_objects = ();
763 %lib_files = ();
764 %source_files = ();
765 %header_files = ();
766 %resource_files = ();
767 @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");
768 foreach $object_file (@object_files) {
769 next if defined $seen_objects{$object_file};
770 $seen_objects{$object_file} = 1;
771 if($object_file =~ /\.lib$/io) {
772 $lib_files{$object_file} = 1;
773 next;
774 }
775 $object_deps = $all_object_deps{$object_file};
776 foreach $object_dep (@$object_deps) {
777 if($object_dep =~ /\.c$/io) {
778 $source_files{$object_dep} = 1;
779 next;
58de2f3c 780 }
e35fb54b 781 if($object_dep =~ /\.h$/io) {
782 $header_files{$object_dep} = 1;
783 next;
58de2f3c 784 }
e35fb54b 785 if($object_dep =~ /\.(rc|ico)$/io) {
786 $resource_files{$object_dep} = 1;
787 next;
58de2f3c 788 }
e35fb54b 789 }
790 }
791 $libs = join " ", sort keys %lib_files;
792 @source_files = sort keys %source_files;
793 @header_files = sort keys %header_files;
794 @resources = sort keys %resource_files;
795 ($windows_project, $type) = split ",", $progname;
796 mkdir $windows_project
797 if(! -d $windows_project);
798 chdir $windows_project;
799 $subsys = ($type eq "G") ? "windows" : "console";
800 open OUT, ">$windows_project.dsp"; binmode OUT; select OUT;
801 print
802 "# Microsoft Developer Studio Project File - Name=\"$windows_project\" - Package Owner=<4>\r\n".
803 "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n".
804 "# ** DO NOT EDIT **\r\n".
805 "\r\n".
806 "# TARGTYPE \"Win32 (x86) Application\" 0x0101\r\n".
807 "\r\n".
808 "CFG=$windows_project - Win32 Debug\r\n".
809 "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n".
810 "!MESSAGE use the Export Makefile command and run\r\n".
811 "!MESSAGE \r\n".
812 "!MESSAGE NMAKE /f \"$windows_project.mak\".\r\n".
813 "!MESSAGE \r\n".
814 "!MESSAGE You can specify a configuration when running NMAKE\r\n".
815 "!MESSAGE by defining the macro CFG on the command line. For example:\r\n".
816 "!MESSAGE \r\n".
817 "!MESSAGE NMAKE /f \"$windows_project.mak\" CFG=\"$windows_project - Win32 Debug\"\r\n".
818 "!MESSAGE \r\n".
819 "!MESSAGE Possible choices for configuration are:\r\n".
820 "!MESSAGE \r\n".
821 "!MESSAGE \"$windows_project - Win32 Release\" (based on \"Win32 (x86) Application\")\r\n".
822 "!MESSAGE \"$windows_project - Win32 Debug\" (based on \"Win32 (x86) Application\")\r\n".
823 "!MESSAGE \r\n".
824 "\r\n".
825 "# Begin Project\r\n".
826 "# PROP AllowPerConfigDependencies 0\r\n".
827 "# PROP Scc_ProjName \"\"\r\n".
828 "# PROP Scc_LocalPath \"\"\r\n".
829 "CPP=cl.exe\r\n".
830 "MTL=midl.exe\r\n".
831 "RSC=rc.exe\r\n".
832 "\r\n".
833 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
834 "\r\n".
835 "# PROP BASE Use_MFC 0\r\n".
836 "# PROP BASE Use_Debug_Libraries 0\r\n".
837 "# PROP BASE Output_Dir \"Release\"\r\n".
838 "# PROP BASE Intermediate_Dir \"Release\"\r\n".
839 "# PROP BASE Target_Dir \"\"\r\n".
840 "# PROP Use_MFC 0\r\n".
841 "# PROP Use_Debug_Libraries 0\r\n".
842 "# PROP Output_Dir \"Release\"\r\n".
843 "# PROP Intermediate_Dir \"Release\"\r\n".
844 "# PROP Ignore_Export_Lib 0\r\n".
845 "# PROP Target_Dir \"\"\r\n".
6da41155 846 "# ADD BASE CPP /nologo /W3 /GX /O2 ".
847 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
848 " /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
849 "# ADD CPP /nologo /W3 /GX /O2 ".
850 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
851 " /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
e35fb54b 852 "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
853 "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
854 "# ADD BASE RSC /l 0x809 /d \"NDEBUG\"\r\n".
855 "# ADD RSC /l 0x809 /d \"NDEBUG\"\r\n".
856 "BSC32=bscmake.exe\r\n".
857 "# ADD BASE BSC32 /nologo\r\n".
858 "# ADD BSC32 /nologo\r\n".
859 "LINK32=link.exe\r\n".
860 "# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:$subsys /machine:I386\r\n".
861 "# ADD LINK32 $libs /nologo /subsystem:$subsys /machine:I386\r\n".
862 "# SUBTRACT LINK32 /pdb:none\r\n".
863 "\r\n".
864 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
865 "\r\n".
866 "# PROP BASE Use_MFC 0\r\n".
867 "# PROP BASE Use_Debug_Libraries 1\r\n".
868 "# PROP BASE Output_Dir \"Debug\"\r\n".
869 "# PROP BASE Intermediate_Dir \"Debug\"\r\n".
870 "# PROP BASE Target_Dir \"\"\r\n".
871 "# PROP Use_MFC 0\r\n".
872 "# PROP Use_Debug_Libraries 1\r\n".
873 "# PROP Output_Dir \"Debug\"\r\n".
874 "# PROP Intermediate_Dir \"Debug\"\r\n".
875 "# PROP Ignore_Export_Lib 0\r\n".
876 "# PROP Target_Dir \"\"\r\n".
6da41155 877 "# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od ".
878 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
879 " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
880 "# ADD CPP /nologo /W3 /Gm /GX /ZI /Od ".
881 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
882 " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
e35fb54b 883 "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
884 "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
885 "# ADD BASE RSC /l 0x809 /d \"_DEBUG\"\r\n".
886 "# ADD RSC /l 0x809 /d \"_DEBUG\"\r\n".
887 "BSC32=bscmake.exe\r\n".
888 "# ADD BASE BSC32 /nologo\r\n".
889 "# ADD BSC32 /nologo\r\n".
890 "LINK32=link.exe\r\n".
891 "# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:$subsys /debug /machine:I386 /pdbtype:sept\r\n".
892 "# ADD LINK32 $libs /nologo /subsystem:$subsys /debug /machine:I386 /pdbtype:sept\r\n".
893 "# SUBTRACT LINK32 /pdb:none\r\n".
894 "\r\n".
895 "!ENDIF \r\n".
896 "\r\n".
897 "# Begin Target\r\n".
898 "\r\n".
899 "# Name \"$windows_project - Win32 Release\"\r\n".
900 "# Name \"$windows_project - Win32 Debug\"\r\n".
901 "# Begin Group \"Source Files\"\r\n".
902 "\r\n".
903 "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
904 foreach $source_file (@source_files) {
905 print
906 "# Begin Source File\r\n".
907 "\r\n".
908 "SOURCE=..\\..\\$source_file\r\n";
909 if($source_file =~ /ssh\.c/io) {
910 # Disable 'Edit and continue' as Visual Studio can't handle the macros
58de2f3c 911 print
e35fb54b 912 "\r\n".
913 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
914 "\r\n".
915 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
916 "\r\n".
917 "# ADD CPP /Zi\r\n".
918 "\r\n".
919 "!ENDIF \r\n".
920 "\r\n";
921 }
922 print "# End Source File\r\n";
923 }
924 print
925 "# End Group\r\n".
926 "# Begin Group \"Header Files\"\r\n".
927 "\r\n".
928 "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
929 foreach $header_file (@header_files) {
930 print
931 "# Begin Source File\r\n".
932 "\r\n".
933 "SOURCE=..\\..\\$header_file\r\n".
934 "# End Source File\r\n";
58de2f3c 935 }
e35fb54b 936 print
937 "# End Group\r\n".
938 "# Begin Group \"Resource Files\"\r\n".
939 "\r\n".
940 "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
941 foreach $resource_file (@resources) {
942 print
943 "# Begin Source File\r\n".
944 "\r\n".
945 "SOURCE=..\\..\\$resource_file\r\n".
946 "# End Source File\r\n";
947 }
948 print
949 "# End Group\r\n".
950 "# End Target\r\n".
951 "# End Project\r\n";
952 select STDOUT; close OUT;
953 chdir "..";
954 }
a86a2725 955}
a86a2725 956
e35fb54b 957if (defined $makefiles{'gtk'}) {
cdd310bb 958 $dirpfx = &dirpfx($makefiles{'gtk'}, "/");
d37a507a 959
e35fb54b 960 ##-- X/GTK/Unix makefile
961 open OUT, ">$makefiles{'gtk'}"; select OUT;
962 print
963 "# Makefile for $project_name under X/GTK and Unix.\n".
964 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
965 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
966 # gcc command line option is -D not /D
4877ec8d 967 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
e35fb54b 968 print $_;
969 print
970 "\n".
971 "# You can define this path to point at your tools if you need to\n".
972 "# TOOLPATH = /opt/gcc/bin\n".
973 "CC = \$(TOOLPATH)cc\n".
42af6a67 974 "# If necessary set the path to krb5-config here\n".
975 "KRB5CONFIG=krb5-config\n".
f160b7b8 976 "# You can manually set this to `gtk-config' or `pkg-config gtk+-1.2'\n".
977 "# (depending on what works on your system) if you want to enforce\n".
c349ffb1 978 "# building with GTK 1.2, or you can set it to `pkg-config gtk+-2.0 x11'\n".
f160b7b8 979 "# if you want to enforce 2.0. The default is to try 2.0 and fall back\n".
980 "# to 1.2 if it isn't found.\n".
c349ffb1 981 "GTK_CONFIG = sh -c 'pkg-config gtk+-2.0 x11 \$\$0 2>/dev/null || gtk-config \$\$0'\n".
e35fb54b 982 "\n".
3290cec9 983 "-include Makefile.local\n".
984 "\n".
9ac18d71 985 "unexport CFLAGS # work around a weird issue with krb5-config\n".
986 "\n".
cdd310bb 987 &splitline("CFLAGS = -O2 -Wall -Werror -g " .
988 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
c407e146 989 " \$(shell \$(GTK_CONFIG) --cflags)").
0ac1920c 990 " -D _FILE_OFFSET_BITS=64\n".
c407e146 991 "XLDFLAGS = \$(LDFLAGS) \$(shell \$(GTK_CONFIG) --libs)\n".
0dbe2956 992 "ULDFLAGS = \$(LDFLAGS)\n".
42af6a67 993 "ifeq (,\$(findstring NO_GSSAPI,\$(COMPAT)))\n".
b3d375b2 994 "ifeq (,\$(findstring STATIC_GSSAPI,\$(COMPAT)))\n".
995 "XLDFLAGS+= -ldl\n".
996 "ULDFLAGS+= -ldl\n".
997 "else\n".
998 "CFLAGS+= -DNO_LIBDL \$(shell \$(KRB5CONFIG) --cflags gssapi)\n".
c407e146 999 "XLDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
b3d375b2 1000 "ULDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
1001 "endif\n".
666b0d2a 1002 "endif\n".
1003 "INSTALL=install\n".
1004 "INSTALL_PROGRAM=\$(INSTALL)\n".
1005 "INSTALL_DATA=\$(INSTALL)\n".
1006 "prefix=/usr/local\n".
1007 "exec_prefix=\$(prefix)\n".
1008 "bindir=\$(exec_prefix)/bin\n".
1009 "mandir=\$(prefix)/man\n".
1010 "man1dir=\$(mandir)/man1\n".
e35fb54b 1011 "\n".
4877ec8d 1012 &def($makefile_extra{'gtk'}->{'vars'}) .
77603464 1013 "\n".
e35fb54b 1014 ".SUFFIXES:\n".
1015 "\n".
e35fb54b 1016 "\n";
1ddda1ca 1017 print &splitline("all:" . join "", map { " $_" } &progrealnames("X:U"));
e35fb54b 1018 print "\n\n";
1ddda1ca 1019 foreach $p (&prognames("X:U")) {
e35fb54b 1020 ($prog, $type) = split ",", $p;
1021 $objstr = &objects($p, "X.o", undef, undef);
1022 print &splitline($prog . ": " . $objstr), "\n";
1023 $libstr = &objects($p, undef, undef, "-lX");
4877ec8d 1024 print &splitline("\t\$(CC) -o \$@ " .
0dbe2956 1025 $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
e35fb54b 1026 }
6da41155 1027 foreach $d (&deps("X.o", undef, $dirpfx, "/", "gtk")) {
976374cd 1028 if ($forceobj{$d->{obj_orig}}) {
1029 printf("%s: FORCE\n", $d->{obj});
1030 } else {
1031 print &splitline(sprintf("%s: %s", $d->{obj},
1032 join " ", @{$d->{deps}})), "\n";
1033 }
a77c6ed3 1034 print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
76d3a838 1035 }
1036 print "\n";
1037 print $makefile_extra{'gtk'}->{'end'};
1038 print "\nclean:\n".
1039 "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:U")) . "\n";
976374cd 1040 print "\nFORCE:\n";
76d3a838 1041 select STDOUT; close OUT;
1042}
1043
b89e7e07 1044if (defined $makefiles{'unix'}) {
1045 $dirpfx = &dirpfx($makefiles{'unix'}, "/");
1046
1047 ##-- GTK-free pure-Unix makefile for non-GUI apps only
1048 open OUT, ">$makefiles{'unix'}"; select OUT;
1049 print
1050 "# Makefile for $project_name under Unix.\n".
1051 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1052 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1053 # gcc command line option is -D not /D
4877ec8d 1054 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
b89e7e07 1055 print $_;
1056 print
1057 "\n".
1058 "# You can define this path to point at your tools if you need to\n".
1059 "# TOOLPATH = /opt/gcc/bin\n".
1060 "CC = \$(TOOLPATH)cc\n".
b89e7e07 1061 "\n".
1062 "-include Makefile.local\n".
1063 "\n".
1064 "unexport CFLAGS # work around a weird issue with krb5-config\n".
1065 "\n".
1066 &splitline("CFLAGS = -O2 -Wall -Werror -g " .
1067 (join " ", map {"-I$dirpfx$_"} @srcdirs)).
1068 " -D _FILE_OFFSET_BITS=64\n".
1069 "ULDFLAGS = \$(LDFLAGS)\n".
b89e7e07 1070 "INSTALL=install\n".
1071 "INSTALL_PROGRAM=\$(INSTALL)\n".
1072 "INSTALL_DATA=\$(INSTALL)\n".
1073 "prefix=/usr/local\n".
1074 "exec_prefix=\$(prefix)\n".
1075 "bindir=\$(exec_prefix)/bin\n".
1076 "mandir=\$(prefix)/man\n".
1077 "man1dir=\$(mandir)/man1\n".
1078 "\n".
4877ec8d 1079 &def($makefile_extra{'unix'}->{'vars'}) .
b89e7e07 1080 "\n".
1081 ".SUFFIXES:\n".
1082 "\n".
1083 "\n";
1084 print &splitline("all:" . join "", map { " $_" } &progrealnames("U"));
1085 print "\n\n";
1086 foreach $p (&prognames("U")) {
1087 ($prog, $type) = split ",", $p;
1088 $objstr = &objects($p, "X.o", undef, undef);
1089 print &splitline($prog . ": " . $objstr), "\n";
1090 $libstr = &objects($p, undef, undef, "-lX");
4877ec8d 1091 print &splitline("\t\$(CC) -o \$@ " .
b89e7e07 1092 $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
1093 }
1094 foreach $d (&deps("X.o", undef, $dirpfx, "/", "unix")) {
1095 if ($forceobj{$d->{obj_orig}}) {
1096 printf("%s: FORCE\n", $d->{obj});
1097 } else {
1098 print &splitline(sprintf("%s: %s", $d->{obj},
1099 join " ", @{$d->{deps}})), "\n";
1100 }
1101 print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
1102 }
1103 print "\n";
4877ec8d 1104 print &def($makefile_extra{'unix'}->{'end'});
b89e7e07 1105 print "\nclean:\n".
1106 "\trm -f *.o". (join "", map { " $_" } &progrealnames("U")) . "\n";
1107 print "\nFORCE:\n";
1108 select STDOUT; close OUT;
1109}
1110
44747c53 1111if (defined $makefiles{'am'}) {
1112 $dirpfx = "\$(srcdir)/" . &dirpfx($makefiles{'am'}, "/");
76d3a838 1113
44747c53 1114 ##-- Unix/autoconf Makefile.am
1115 open OUT, ">$makefiles{'am'}"; select OUT;
76d3a838 1116 print
44747c53 1117 "# Makefile.am for $project_name under Unix with Autoconf/Automake.\n".
76d3a838 1118 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
44747c53 1119 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n\n";
1120
1121 # Complete list of source and header files. Not used by the
1122 # auto-generated parts of this makefile, but Recipe might like to
1123 # have it available as a variable so that mandatory-rebuild things
1124 # (version.o) can conveniently be made to depend on it.
1125 @sources = ("allsources", "=",
1126 map {"${dirpfx}$_"} sort keys %allsourcefiles);
1127 print &splitline(join " ", @sources), "\n\n";
1128
1129 @cliprogs = ("bin_PROGRAMS", "=");
1130 foreach $p (&prognames("U")) {
76d3a838 1131 ($prog, $type) = split ",", $p;
44747c53 1132 push @cliprogs, $prog;
76d3a838 1133 }
44747c53 1134 @allprogs = @cliprogs;
1135 foreach $p (&prognames("X")) {
1136 ($prog, $type) = split ",", $p;
1137 push @allprogs, $prog;
1138 }
1139 print "if HAVE_GTK\n";
1140 print &splitline(join " ", @allprogs), "\n";
1141 print "else\n";
1142 print &splitline(join " ", @cliprogs), "\n";
1143 print "endif\n\n";
1144
1145 %objtosrc = ();
1146 foreach $d (&deps("X", undef, $dirpfx, "/", "am")) {
1147 $objtosrc{$d->{obj}} = $d->{deps}->[0];
1148 }
1149
1150 @amcflags = ("\$(COMPAT)", "\$(XFLAGS)", map {"-I$dirpfx$_"} @srcdirs);
1151 print "if HAVE_GTK\n";
1152 print &splitline(join " ", "AM_CFLAGS", "=",
1153 "\$(GTK_CFLAGS)", @amcflags), "\n";
1154 print "else\n";
1155 print &splitline(join " ", "AM_CFLAGS", "=", @amcflags), "\n";
1156 print "endif\n\n";
1157
1158 %amspeciallibs = ();
1159 foreach $obj (sort { $a cmp $b } keys %{$cflags{'am'}}) {
1160 print "lib${obj}_a_SOURCES = ", $objtosrc{$obj}, "\n";
1161 print &splitline(join " ", "lib${obj}_a_CFLAGS", "=", @amcflags,
1162 $cflags{'am'}->{$obj}), "\n";
1163 $amspeciallibs{$obj} = "lib${obj}.a";
1164 }
1165 print &splitline(join " ", "noinst_LIBRARIES", "=",
1166 sort { $a cmp $b } values %amspeciallibs), "\n\n";
1167
1168 foreach $p (&prognames("X:U")) {
1169 ($prog, $type) = split ",", $p;
1170 print "if HAVE_GTK\n" if $type eq "X";
1171 @progsources = ("${prog}_SOURCES", "=");
1172 %sourcefiles = ();
1173 @ldadd = ();
1174 $objstr = &objects($p, "X", undef, undef);
1175 foreach $obj (split / /,$objstr) {
1176 if ($amspeciallibs{$obj}) {
1177 push @ldadd, $amspeciallibs{$obj};
1178 } else {
1179 $sourcefiles{$objtosrc{$obj}} = 1;
1180 }
976374cd 1181 }
44747c53 1182 push @progsources, sort { $a cmp $b } keys %sourcefiles;
1183 print &splitline(join " ", @progsources), "\n";
1184 if ($type eq "X") {
1185 push @ldadd, "\$(GTK_LIBS)";
1186 }
1187 if (@ldadd) {
1188 print &splitline(join " ", "${prog}_LDADD", "=", @ldadd), "\n";
1189 }
1190 print "endif\n" if $type eq "X";
1191 print "\n";
e35fb54b 1192 }
44747c53 1193 print $makefile_extra{'am'}->{'end'};
e35fb54b 1194 select STDOUT; close OUT;
1195}
f8422c0b 1196
e35fb54b 1197if (defined $makefiles{'lcc'}) {
cdd310bb 1198 $dirpfx = &dirpfx($makefiles{'lcc'}, "\\");
1199
e35fb54b 1200 ##-- lcc makefile
1201 open OUT, ">$makefiles{'lcc'}"; select OUT;
1202 print
1203 "# Makefile for $project_name under lcc.\n".
1204 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1205 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1206 # lcc command line option is -D not /D
4877ec8d 1207 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
e35fb54b 1208 print $_;
1209 print
1210 "\n".
1211 "# If you rename this file to `Makefile', you should change this line,\n".
1212 "# so that the .rsp files still depend on the correct makefile.\n".
1213 "MAKEFILE = Makefile.lcc\n".
1214 "\n".
1215 "# C compilation flags\n".
cdd310bb 1216 "CFLAGS = -D_WINDOWS " .
1217 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
1218 "\n".
976374cd 1219 "# Resource compilation flags\n".
1220 "RCFLAGS = \n".
e35fb54b 1221 "\n".
1222 "# Get include directory for resource compiler\n".
77603464 1223 "\n".
1224 $makefile_extra{'lcc'}->{'vars'} .
4e95095a 1225 "\n";
1ddda1ca 1226 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
e35fb54b 1227 print "\n\n";
1ddda1ca 1228 foreach $p (&prognames("G:C")) {
e35fb54b 1229 ($prog, $type) = split ",", $p;
1230 $objstr = &objects($p, "X.obj", "X.res", undef);
1231 print &splitline("$prog.exe: " . $objstr ), "\n";
4877ec8d 1232 $subsystemtype = '';
e35fb54b 1233 if ($type eq "G") { $subsystemtype = "-subsystem windows"; }
1234 my $libss = "shell32.lib wsock32.lib ws2_32.lib winspool.lib winmm.lib imm32.lib";
1235 print &splitline("\tlcclnk $subsystemtype -o $prog.exe $objstr $libss");
1236 print "\n\n";
1237 }
4e95095a 1238
6da41155 1239 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "lcc")) {
976374cd 1240 if ($forceobj{$d->{obj_orig}}) {
1241 printf("%s: FORCE\n", $d->{obj});
1242 } else {
1243 print &splitline(sprintf("%s: %s", $d->{obj},
1244 join " ", @{$d->{deps}})), "\n";
1245 }
6da41155 1246 if ($d->{obj} =~ /\.obj$/) {
d8284c29 1247 print &splitline("\tlcc -O -p6 \$(COMPAT)".
a77c6ed3 1248 " \$(CFLAGS) \$(XFLAGS) ".$d->{deps}->[0],69)."\n";
6da41155 1249 } else {
976374cd 1250 print &splitline("\tlrc \$(RCFL) -r \$(RCFLAGS) ".
1251 $d->{deps}->[0],69)."\n";
6da41155 1252 }
e35fb54b 1253 }
1254 print "\n";
77603464 1255 print $makefile_extra{'lcc'}->{'end'};
e35fb54b 1256 print "\nclean:\n".
1257 "\t-del *.obj\n".
1258 "\t-del *.exe\n".
976374cd 1259 "\t-del *.res\n".
1260 "\n".
1261 "FORCE:\n";
4e95095a 1262
e35fb54b 1263 select STDOUT; close OUT;
1264}
1ddda1ca 1265
1266if (defined $makefiles{'osx'}) {
1267 $dirpfx = &dirpfx($makefiles{'osx'}, "/");
1268
1269 ##-- Mac OS X makefile
1270 open OUT, ">$makefiles{'osx'}"; select OUT;
1271 print
1272 "# Makefile for $project_name under Mac OS X.\n".
1273 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
1274 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
1275 # gcc command line option is -D not /D
4877ec8d 1276 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
1ddda1ca 1277 print $_;
1278 print
1279 "CC = \$(TOOLPATH)gcc\n".
1280 "\n".
1281 &splitline("CFLAGS = -O2 -Wall -Werror -g " .
1282 (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
1283 "MLDFLAGS = -framework Cocoa\n".
1284 "ULDFLAGS =\n".
1ddda1ca 1285 "\n" .
77603464 1286 $makefile_extra{'osx'}->{'vars'} .
1287 "\n" .
1288 &splitline("all:" . join "", map { " $_" } &progrealnames("MX:U")) .
1ddda1ca 1289 "\n";
1290 foreach $p (&prognames("MX")) {
1291 ($prog, $type) = split ",", $p;
1292 $objstr = &objects($p, "X.o", undef, undef);
1293 $icon = &special($p, ".icns");
1294 $infoplist = &special($p, "info.plist");
1295 print "${prog}.app:\n\tmkdir -p \$\@\n";
1296 print "${prog}.app/Contents: ${prog}.app\n\tmkdir -p \$\@\n";
1297 print "${prog}.app/Contents/MacOS: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1298 $targets = "${prog}.app/Contents/MacOS/$prog";
1299 if (defined $icon) {
1300 print "${prog}.app/Contents/Resources: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
1301 print "${prog}.app/Contents/Resources/${prog}.icns: ${prog}.app/Contents/Resources $icon\n\tcp $icon \$\@\n";
1302 $targets .= " ${prog}.app/Contents/Resources/${prog}.icns";
1303 }
1304 if (defined $infoplist) {
1305 print "${prog}.app/Contents/Info.plist: ${prog}.app/Contents/Resources $infoplist\n\tcp $infoplist \$\@\n";
1306 $targets .= " ${prog}.app/Contents/Info.plist";
1307 }
1308 $targets .= " \$(${prog}_extra)";
1309 print &splitline("${prog}: $targets", 69) . "\n\n";
1310 print &splitline("${prog}.app/Contents/MacOS/$prog: ".
1311 "${prog}.app/Contents/MacOS " . $objstr), "\n";
1312 $libstr = &objects($p, undef, undef, "-lX");
4877ec8d 1313 print &splitline("\t\$(CC) \$(MLDFLAGS) -o \$@ " .
1ddda1ca 1314 $objstr . " $libstr", 69), "\n\n";
1315 }
1316 foreach $p (&prognames("U")) {
1317 ($prog, $type) = split ",", $p;
1318 $objstr = &objects($p, "X.o", undef, undef);
1319 print &splitline($prog . ": " . $objstr), "\n";
1320 $libstr = &objects($p, undef, undef, "-lX");
4877ec8d 1321 print &splitline("\t\$(CC) \$(ULDFLAGS) -o \$@ " .
1ddda1ca 1322 $objstr . " $libstr", 69), "\n\n";
1323 }
4877ec8d 1324 foreach $d (&deps("X.o", undef, $dirpfx, "/", "osx")) {
976374cd 1325 if ($forceobj{$d->{obj_orig}}) {
1326 printf("%s: FORCE\n", $d->{obj});
1327 } else {
1328 print &splitline(sprintf("%s: %s", $d->{obj},
1329 join " ", @{$d->{deps}})), "\n";
1330 }
1ddda1ca 1331 $firstdep = $d->{deps}->[0];
1332 if ($firstdep =~ /\.c$/) {
a77c6ed3 1333 print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
1ddda1ca 1334 } elsif ($firstdep =~ /\.m$/) {
a77c6ed3 1335 print "\t\$(CC) -x objective-c \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
1ddda1ca 1336 }
1337 }
4877ec8d 1338 print "\n".&def($makefile_extra{'osx'}->{'end'});
1ddda1ca 1339 print "\nclean:\n".
976374cd 1340 "\trm -f *.o *.dmg". (join "", map { " $_" } &progrealnames("U")) . "\n".
4877ec8d 1341 "\trm -rf *.app\n".
976374cd 1342 "\n".
1343 "FORCE:\n";
1ddda1ca 1344 select STDOUT; close OUT;
1345}
985b6440 1346
1347if (defined $makefiles{'devcppproj'}) {
1348 $dirpfx = &dirpfx($makefiles{'devcppproj'}, "\\");
1349 $orig_dir = cwd;
1350
1351 ##-- Dev-C++ 5 projects
1352 #
1353 # Note: All files created in this section are written in binary
1354 # mode to prevent any posibility of misinterpreted line endings.
1355 # I don't know if Dev-C++ is as touchy as MSVC with LF-only line
1356 # endings. But however, CRLF line endings are the common way on
1357 # Win32 machines where Dev-C++ is running.
1358 # Hence, in order for mkfiles.pl to generate CRLF project files
1359 # even when run from Unix, I make sure all files are binary and
1360 # explicitly write the CRLFs.
1361 #
1362 # Create directories if necessary
1363 mkdir $makefiles{'devcppproj'}
1364 if(! -d $makefiles{'devcppproj'});
1365 chdir $makefiles{'devcppproj'};
1366 @deps = &deps("X.obj", "X.res", $dirpfx, "\\", "devcppproj");
1367 %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;
1368 # Make dir names FAT/NTFS compatible
1369 my @srcdirs = @srcdirs;
1370 for ($i=0; $i<@srcdirs; $i++) {
1371 $srcdirs[$i] =~ s/\//\\/g;
1372 $srcdirs[$i] =~ s/\\$//;
1373 }
1374 # Create the project files
1375 # Get names of all Windows projects (GUI and console)
1376 my @prognames = &prognames("G:C");
1377 foreach $progname (@prognames) {
1378 create_devcpp_project(\%all_object_deps, $progname);
1379 }
1380
bc7af299 1381 chdir $orig_dir;
1382
985b6440 1383 sub create_devcpp_project {
1384 my ($all_object_deps, $progname) = @_;
1385 # Construct program's dependency info (Taken from 'vcproj', seems to work right here, too.)
1386 %seen_objects = ();
1387 %lib_files = ();
1388 %source_files = ();
1389 %header_files = ();
1390 %resource_files = ();
1391 @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");
1392 foreach $object_file (@object_files) {
1393 next if defined $seen_objects{$object_file};
1394 $seen_objects{$object_file} = 1;
1395 if($object_file =~ /\.lib$/io) {
1396 $lib_files{$object_file} = 1;
1397 next;
1398 }
1399 $object_deps = $all_object_deps{$object_file};
1400 foreach $object_dep (@$object_deps) {
1401 if($object_dep =~ /\.c$/io) {
1402 $source_files{$object_dep} = 1;
1403 next;
1404 }
1405 if($object_dep =~ /\.h$/io) {
1406 $header_files{$object_dep} = 1;
1407 next;
1408 }
1409 if($object_dep =~ /\.(rc|ico)$/io) {
1410 $resource_files{$object_dep} = 1;
1411 next;
1412 }
1413 }
1414 }
1415 $libs = join " ", sort keys %lib_files;
1416 @source_files = sort keys %source_files;
1417 @header_files = sort keys %header_files;
1418 @resources = sort keys %resource_files;
1419 ($windows_project, $type) = split ",", $progname;
1420 mkdir $windows_project
1421 if(! -d $windows_project);
1422 chdir $windows_project;
1423
1424 $subsys = ($type eq "G") ? "0" : "1"; # 0 = Win32 GUI, 1 = Win32 Console
1425 open OUT, ">$windows_project.dev"; binmode OUT; select OUT;
1426 print
1427 "# DEV-C++ 5 Project File - $windows_project.dev\r\n".
1428 "# ** DO NOT EDIT **\r\n".
1429 "\r\n".
1430 # No difference between DEBUG and RELEASE here as in 'vcproj', because
1431 # Dev-C++ does not support mutiple compilation profiles in one single project.
1432 # (At least I can say this for Dev-C++ 5 Beta)
1433 "[Project]\r\n".
1434 "FileName=$windows_project.dev\r\n".
1435 "Name=$windows_project\r\n".
1436 "Ver=1\r\n".
1437 "IsCpp=1\r\n".
1438 "Type=$subsys\r\n".
1439 # Multimon is disabled here, as Dev-C++ (Version 5 Beta) does not have multimon.h
1440 "Compiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
1441 "CppCompiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
1442 "Includes=" . (join ";", map {"..\\..\\$dirpfx$_"} @srcdirs) . "\r\n".
1443 "Linker=-ladvapi32 -lcomctl32 -lcomdlg32 -lgdi32 -limm32 -lshell32 -luser32 -lwinmm -lwinspool_\@\@_\r\n".
1444 "Libs=\r\n".
1445 "UnitCount=" . (@source_files + @header_files + @resources) . "\r\n".
1446 "Folders=\"Header Files\",\"Resource Files\",\"Source Files\"\r\n".
1447 "ObjFiles=\r\n".
1448 "PrivateResource=${windows_project}_private.rc\r\n".
1449 "ResourceIncludes=..\\..\\..\\WINDOWS\r\n".
1450 "MakeIncludes=\r\n".
1451 "Icon=\r\n". # It's ok to leave this blank.
1452 "ExeOutput=\r\n".
1453 "ObjectOutput=\r\n".
1454 "OverrideOutput=0\r\n".
1455 "OverrideOutputName=$windows_project.exe\r\n".
1456 "HostApplication=\r\n".
1457 "CommandLine=\r\n".
1458 "UseCustomMakefile=0\r\n".
1459 "CustomMakefile=\r\n".
1460 "IncludeVersionInfo=0\r\n".
1461 "SupportXPThemes=0\r\n".
1462 "CompilerSet=0\r\n".
1463 "CompilerSettings=0000000000000000000000\r\n".
1464 "\r\n";
1465 $unit_count = 1;
1466 foreach $source_file (@source_files) {
1467 print
1468 "[Unit$unit_count]\r\n".
1469 "FileName=..\\..\\$source_file\r\n".
1470 "Folder=Source Files\r\n".
1471 "Compile=1\r\n".
1472 "CompileCpp=0\r\n".
1473 "Link=1\r\n".
1474 "Priority=1000\r\n".
1475 "OverrideBuildCmd=0\r\n".
1476 "BuildCmd=\r\n".
1477 "\r\n";
1478 $unit_count++;
1479 }
1480 foreach $header_file (@header_files) {
1481 print
1482 "[Unit$unit_count]\r\n".
1483 "FileName=..\\..\\$header_file\r\n".
1484 "Folder=Header Files\r\n".
1485 "Compile=1\r\n".
1486 "CompileCpp=1\r\n". # Dev-C++ want's to compile all header files with both compilers C and C++. It does not hurt.
1487 "Link=1\r\n".
1488 "Priority=1000\r\n".
1489 "OverrideBuildCmd=0\r\n".
1490 "BuildCmd=\r\n".
1491 "\r\n";
1492 $unit_count++;
1493 }
1494 foreach $resource_file (@resources) {
1495 if ($resource_file =~ /.*\.(ico|cur|bmp|dlg|rc2|rct|bin|rgs|gif|jpg|jpeg|jpe)/io) { # Default filter as in 'vcproj'
1496 $Compile = "0"; # Don't compile images and other binary resource files
1497 $CompileCpp = "0";
1498 } else {
1499 $Compile = "1";
1500 $CompileCpp = "1"; # Dev-C++ want's to compile all .rc files with both compilers C and C++. It does not hurt.
1501 }
1502 print
1503 "[Unit$unit_count]\r\n".
1504 "FileName=..\\..\\$resource_file\r\n".
1505 "Folder=Resource Files\r\n".
1506 "Compile=$Compile\r\n".
1507 "CompileCpp=$CompileCpp\r\n".
1508 "Link=0\r\n".
1509 "Priority=1000\r\n".
1510 "OverrideBuildCmd=0\r\n".
1511 "BuildCmd=\r\n".
1512 "\r\n";
1513 $unit_count++;
1514 }
1515 #Note: By default, [VersionInfo] is not used.
1516 print
1517 "[VersionInfo]\r\n".
1518 "Major=0\r\n".
1519 "Minor=0\r\n".
1520 "Release=1\r\n".
1521 "Build=1\r\n".
1522 "LanguageID=1033\r\n".
1523 "CharsetID=1252\r\n".
1524 "CompanyName=\r\n".
1525 "FileVersion=0.1\r\n".
1526 "FileDescription=\r\n".
1527 "InternalName=\r\n".
1528 "LegalCopyright=\r\n".
1529 "LegalTrademarks=\r\n".
1530 "OriginalFilename=$windows_project.exe\r\n".
1531 "ProductName=$windows_project\r\n".
1532 "ProductVersion=0.1\r\n".
1533 "AutoIncBuildNr=0\r\n";
1534 select STDOUT; close OUT;
1535 chdir "..";
1536 }
1537}
bc7af299 1538
1539# All done, so do the Unix postprocessing if asked to.
1540
1541if ($do_unix) {
1542 chdir $orig_dir;
1543 system "./mkauto.sh";
1544 die "mkfiles.pl: mkauto.sh returned $?\n" if $? > 0;
c1b71b1c 1545 if ($do_unix == 1) {
1546 chdir ($targetdir = dirname($makefiles{"am"}))
1547 or die "$targetdir: chdir: $!\n";
1548 }
bc7af299 1549 system "./configure", @confargs;
1550 die "mkfiles.pl: configure returned $?\n" if $? > 0;
1551}