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