OSDN Git Service

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