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 |
18 | use warnings; |
f7f27309 |
19 | use FileHandle; |
bc7af299 |
20 | use File::Basename; |
e35fb54b |
21 | use Cwd; |
f7f27309 |
22 | |
c1b71b1c |
23 | if ($#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 |
38 | open 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. |
d22c5414 |
49 | eval 'chdir "charset"; require "sbcsgen.pl"; chdir ".."; select STDOUT;'; |
2dc6356a |
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 |
61 | while (<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 |
148 | close IN; |
7603011f |
149 | |
c0458cfc |
150 | foreach $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 = (); |
162 | foreach $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 |
211 | while (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. |
236 | foreach $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 | |
255 | sub 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 |
270 | sub def { |
271 | my ($x) = shift @_; |
272 | return (defined $x) ? $x : ""; |
273 | } |
274 | |
cdd310bb |
275 | sub 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 |
293 | sub 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 |
313 | sub 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 |
335 | sub 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 |
349 | sub 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 | |
365 | sub 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 |
392 | sub 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 | |
404 | sub 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 |
416 | sub 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 |
430 | if (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". |
e354075e |
495 | "\trm -f *.o *.exe *.res.o *.so *.map\n". |
976374cd |
496 | "\n". |
497 | "FORCE:\n"; |
e35fb54b |
498 | select STDOUT; close OUT; |
7603011f |
499 | |
7603011f |
500 | } |
e35fb54b |
501 | |
502 | ##-- Borland makefile |
503 | if (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 | |
617 | if (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 |
703 | if (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 |
965 | if (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 |
1052 | if (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 |
1119 | if (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 | |
1387e90b |
1158 | print &splitline(join " ", "AM_CPPFLAGS", "=", |
1159 | map {"-I$dirpfx$_"} @srcdirs), "\n"; |
1160 | |
1161 | @amcflags = ("\$(COMPAT)", "\$(XFLAGS)", "\$(WARNINGOPTS)"); |
44747c53 |
1162 | print "if HAVE_GTK\n"; |
1163 | print &splitline(join " ", "AM_CFLAGS", "=", |
1164 | "\$(GTK_CFLAGS)", @amcflags), "\n"; |
1165 | print "else\n"; |
1166 | print &splitline(join " ", "AM_CFLAGS", "=", @amcflags), "\n"; |
1167 | print "endif\n\n"; |
1168 | |
1169 | %amspeciallibs = (); |
1170 | foreach $obj (sort { $a cmp $b } keys %{$cflags{'am'}}) { |
1171 | print "lib${obj}_a_SOURCES = ", $objtosrc{$obj}, "\n"; |
1172 | print &splitline(join " ", "lib${obj}_a_CFLAGS", "=", @amcflags, |
1173 | $cflags{'am'}->{$obj}), "\n"; |
1174 | $amspeciallibs{$obj} = "lib${obj}.a"; |
1175 | } |
1176 | print &splitline(join " ", "noinst_LIBRARIES", "=", |
1177 | sort { $a cmp $b } values %amspeciallibs), "\n\n"; |
1178 | |
1179 | foreach $p (&prognames("X:U")) { |
1180 | ($prog, $type) = split ",", $p; |
1181 | print "if HAVE_GTK\n" if $type eq "X"; |
1182 | @progsources = ("${prog}_SOURCES", "="); |
1183 | %sourcefiles = (); |
1184 | @ldadd = (); |
1185 | $objstr = &objects($p, "X", undef, undef); |
1186 | foreach $obj (split / /,$objstr) { |
1187 | if ($amspeciallibs{$obj}) { |
1188 | push @ldadd, $amspeciallibs{$obj}; |
1189 | } else { |
1190 | $sourcefiles{$objtosrc{$obj}} = 1; |
1191 | } |
976374cd |
1192 | } |
44747c53 |
1193 | push @progsources, sort { $a cmp $b } keys %sourcefiles; |
1194 | print &splitline(join " ", @progsources), "\n"; |
1195 | if ($type eq "X") { |
1196 | push @ldadd, "\$(GTK_LIBS)"; |
1197 | } |
1198 | if (@ldadd) { |
1199 | print &splitline(join " ", "${prog}_LDADD", "=", @ldadd), "\n"; |
1200 | } |
1201 | print "endif\n" if $type eq "X"; |
1202 | print "\n"; |
e35fb54b |
1203 | } |
44747c53 |
1204 | print $makefile_extra{'am'}->{'end'}; |
e35fb54b |
1205 | select STDOUT; close OUT; |
1206 | } |
f8422c0b |
1207 | |
e35fb54b |
1208 | if (defined $makefiles{'lcc'}) { |
cdd310bb |
1209 | $dirpfx = &dirpfx($makefiles{'lcc'}, "\\"); |
1210 | |
e35fb54b |
1211 | ##-- lcc makefile |
1212 | open OUT, ">$makefiles{'lcc'}"; select OUT; |
1213 | print |
1214 | "# Makefile for $project_name under lcc.\n". |
1215 | "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". |
1216 | "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; |
1217 | # lcc command line option is -D not /D |
4877ec8d |
1218 | ($_ = $help) =~ s/([=" ])\/D/$1-D/gs; |
e35fb54b |
1219 | print $_; |
1220 | print |
1221 | "\n". |
1222 | "# If you rename this file to `Makefile', you should change this line,\n". |
1223 | "# so that the .rsp files still depend on the correct makefile.\n". |
1224 | "MAKEFILE = Makefile.lcc\n". |
1225 | "\n". |
1226 | "# C compilation flags\n". |
cdd310bb |
1227 | "CFLAGS = -D_WINDOWS " . |
1228 | (join " ", map {"-I$dirpfx$_"} @srcdirs) . |
1229 | "\n". |
976374cd |
1230 | "# Resource compilation flags\n". |
1231 | "RCFLAGS = \n". |
e35fb54b |
1232 | "\n". |
1233 | "# Get include directory for resource compiler\n". |
77603464 |
1234 | "\n". |
1235 | $makefile_extra{'lcc'}->{'vars'} . |
4e95095a |
1236 | "\n"; |
1ddda1ca |
1237 | print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C")); |
e35fb54b |
1238 | print "\n\n"; |
1ddda1ca |
1239 | foreach $p (&prognames("G:C")) { |
e35fb54b |
1240 | ($prog, $type) = split ",", $p; |
1241 | $objstr = &objects($p, "X.obj", "X.res", undef); |
1242 | print &splitline("$prog.exe: " . $objstr ), "\n"; |
4877ec8d |
1243 | $subsystemtype = ''; |
e35fb54b |
1244 | if ($type eq "G") { $subsystemtype = "-subsystem windows"; } |
1245 | my $libss = "shell32.lib wsock32.lib ws2_32.lib winspool.lib winmm.lib imm32.lib"; |
1246 | print &splitline("\tlcclnk $subsystemtype -o $prog.exe $objstr $libss"); |
1247 | print "\n\n"; |
1248 | } |
4e95095a |
1249 | |
6da41155 |
1250 | foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "lcc")) { |
976374cd |
1251 | if ($forceobj{$d->{obj_orig}}) { |
1252 | printf("%s: FORCE\n", $d->{obj}); |
1253 | } else { |
1254 | print &splitline(sprintf("%s: %s", $d->{obj}, |
1255 | join " ", @{$d->{deps}})), "\n"; |
1256 | } |
6da41155 |
1257 | if ($d->{obj} =~ /\.obj$/) { |
d8284c29 |
1258 | print &splitline("\tlcc -O -p6 \$(COMPAT)". |
a77c6ed3 |
1259 | " \$(CFLAGS) \$(XFLAGS) ".$d->{deps}->[0],69)."\n"; |
6da41155 |
1260 | } else { |
976374cd |
1261 | print &splitline("\tlrc \$(RCFL) -r \$(RCFLAGS) ". |
1262 | $d->{deps}->[0],69)."\n"; |
6da41155 |
1263 | } |
e35fb54b |
1264 | } |
1265 | print "\n"; |
77603464 |
1266 | print $makefile_extra{'lcc'}->{'end'}; |
e35fb54b |
1267 | print "\nclean:\n". |
1268 | "\t-del *.obj\n". |
1269 | "\t-del *.exe\n". |
976374cd |
1270 | "\t-del *.res\n". |
1271 | "\n". |
1272 | "FORCE:\n"; |
4e95095a |
1273 | |
e35fb54b |
1274 | select STDOUT; close OUT; |
1275 | } |
1ddda1ca |
1276 | |
1277 | if (defined $makefiles{'osx'}) { |
1278 | $dirpfx = &dirpfx($makefiles{'osx'}, "/"); |
1279 | |
1280 | ##-- Mac OS X makefile |
1281 | open OUT, ">$makefiles{'osx'}"; select OUT; |
1282 | print |
1283 | "# Makefile for $project_name under Mac OS X.\n". |
1284 | "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". |
1285 | "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; |
1286 | # gcc command line option is -D not /D |
4877ec8d |
1287 | ($_ = $help) =~ s/([=" ])\/D/$1-D/gs; |
1ddda1ca |
1288 | print $_; |
1289 | print |
1290 | "CC = \$(TOOLPATH)gcc\n". |
1291 | "\n". |
1292 | &splitline("CFLAGS = -O2 -Wall -Werror -g " . |
1293 | (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n". |
1294 | "MLDFLAGS = -framework Cocoa\n". |
1295 | "ULDFLAGS =\n". |
1ddda1ca |
1296 | "\n" . |
77603464 |
1297 | $makefile_extra{'osx'}->{'vars'} . |
1298 | "\n" . |
1299 | &splitline("all:" . join "", map { " $_" } &progrealnames("MX:U")) . |
1ddda1ca |
1300 | "\n"; |
1301 | foreach $p (&prognames("MX")) { |
1302 | ($prog, $type) = split ",", $p; |
1303 | $objstr = &objects($p, "X.o", undef, undef); |
1304 | $icon = &special($p, ".icns"); |
1305 | $infoplist = &special($p, "info.plist"); |
1306 | print "${prog}.app:\n\tmkdir -p \$\@\n"; |
1307 | print "${prog}.app/Contents: ${prog}.app\n\tmkdir -p \$\@\n"; |
1308 | print "${prog}.app/Contents/MacOS: ${prog}.app/Contents\n\tmkdir -p \$\@\n"; |
1309 | $targets = "${prog}.app/Contents/MacOS/$prog"; |
1310 | if (defined $icon) { |
1311 | print "${prog}.app/Contents/Resources: ${prog}.app/Contents\n\tmkdir -p \$\@\n"; |
1312 | print "${prog}.app/Contents/Resources/${prog}.icns: ${prog}.app/Contents/Resources $icon\n\tcp $icon \$\@\n"; |
1313 | $targets .= " ${prog}.app/Contents/Resources/${prog}.icns"; |
1314 | } |
1315 | if (defined $infoplist) { |
1316 | print "${prog}.app/Contents/Info.plist: ${prog}.app/Contents/Resources $infoplist\n\tcp $infoplist \$\@\n"; |
1317 | $targets .= " ${prog}.app/Contents/Info.plist"; |
1318 | } |
1319 | $targets .= " \$(${prog}_extra)"; |
1320 | print &splitline("${prog}: $targets", 69) . "\n\n"; |
1321 | print &splitline("${prog}.app/Contents/MacOS/$prog: ". |
1322 | "${prog}.app/Contents/MacOS " . $objstr), "\n"; |
1323 | $libstr = &objects($p, undef, undef, "-lX"); |
4877ec8d |
1324 | print &splitline("\t\$(CC) \$(MLDFLAGS) -o \$@ " . |
1ddda1ca |
1325 | $objstr . " $libstr", 69), "\n\n"; |
1326 | } |
1327 | foreach $p (&prognames("U")) { |
1328 | ($prog, $type) = split ",", $p; |
1329 | $objstr = &objects($p, "X.o", undef, undef); |
1330 | print &splitline($prog . ": " . $objstr), "\n"; |
1331 | $libstr = &objects($p, undef, undef, "-lX"); |
4877ec8d |
1332 | print &splitline("\t\$(CC) \$(ULDFLAGS) -o \$@ " . |
1ddda1ca |
1333 | $objstr . " $libstr", 69), "\n\n"; |
1334 | } |
4877ec8d |
1335 | foreach $d (&deps("X.o", undef, $dirpfx, "/", "osx")) { |
976374cd |
1336 | if ($forceobj{$d->{obj_orig}}) { |
1337 | printf("%s: FORCE\n", $d->{obj}); |
1338 | } else { |
1339 | print &splitline(sprintf("%s: %s", $d->{obj}, |
1340 | join " ", @{$d->{deps}})), "\n"; |
1341 | } |
1ddda1ca |
1342 | $firstdep = $d->{deps}->[0]; |
1343 | if ($firstdep =~ /\.c$/) { |
a77c6ed3 |
1344 | print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n"; |
1ddda1ca |
1345 | } elsif ($firstdep =~ /\.m$/) { |
a77c6ed3 |
1346 | print "\t\$(CC) -x objective-c \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n"; |
1ddda1ca |
1347 | } |
1348 | } |
4877ec8d |
1349 | print "\n".&def($makefile_extra{'osx'}->{'end'}); |
1ddda1ca |
1350 | print "\nclean:\n". |
976374cd |
1351 | "\trm -f *.o *.dmg". (join "", map { " $_" } &progrealnames("U")) . "\n". |
4877ec8d |
1352 | "\trm -rf *.app\n". |
976374cd |
1353 | "\n". |
1354 | "FORCE:\n"; |
1ddda1ca |
1355 | select STDOUT; close OUT; |
1356 | } |
985b6440 |
1357 | |
1358 | if (defined $makefiles{'devcppproj'}) { |
1359 | $dirpfx = &dirpfx($makefiles{'devcppproj'}, "\\"); |
1360 | $orig_dir = cwd; |
1361 | |
1362 | ##-- Dev-C++ 5 projects |
1363 | # |
1364 | # Note: All files created in this section are written in binary |
1365 | # mode to prevent any posibility of misinterpreted line endings. |
1366 | # I don't know if Dev-C++ is as touchy as MSVC with LF-only line |
1367 | # endings. But however, CRLF line endings are the common way on |
1368 | # Win32 machines where Dev-C++ is running. |
1369 | # Hence, in order for mkfiles.pl to generate CRLF project files |
1370 | # even when run from Unix, I make sure all files are binary and |
1371 | # explicitly write the CRLFs. |
1372 | # |
1373 | # Create directories if necessary |
1374 | mkdir $makefiles{'devcppproj'} |
1375 | if(! -d $makefiles{'devcppproj'}); |
1376 | chdir $makefiles{'devcppproj'}; |
1377 | @deps = &deps("X.obj", "X.res", $dirpfx, "\\", "devcppproj"); |
1378 | %all_object_deps = map {$_->{obj} => $_->{deps}} @deps; |
1379 | # Make dir names FAT/NTFS compatible |
1380 | my @srcdirs = @srcdirs; |
1381 | for ($i=0; $i<@srcdirs; $i++) { |
1382 | $srcdirs[$i] =~ s/\//\\/g; |
1383 | $srcdirs[$i] =~ s/\\$//; |
1384 | } |
1385 | # Create the project files |
1386 | # Get names of all Windows projects (GUI and console) |
1387 | my @prognames = &prognames("G:C"); |
1388 | foreach $progname (@prognames) { |
1389 | create_devcpp_project(\%all_object_deps, $progname); |
1390 | } |
1391 | |
bc7af299 |
1392 | chdir $orig_dir; |
1393 | |
985b6440 |
1394 | sub create_devcpp_project { |
1395 | my ($all_object_deps, $progname) = @_; |
1396 | # Construct program's dependency info (Taken from 'vcproj', seems to work right here, too.) |
1397 | %seen_objects = (); |
1398 | %lib_files = (); |
1399 | %source_files = (); |
1400 | %header_files = (); |
1401 | %resource_files = (); |
1402 | @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib"); |
1403 | foreach $object_file (@object_files) { |
1404 | next if defined $seen_objects{$object_file}; |
1405 | $seen_objects{$object_file} = 1; |
1406 | if($object_file =~ /\.lib$/io) { |
1407 | $lib_files{$object_file} = 1; |
1408 | next; |
1409 | } |
1410 | $object_deps = $all_object_deps{$object_file}; |
1411 | foreach $object_dep (@$object_deps) { |
1412 | if($object_dep =~ /\.c$/io) { |
1413 | $source_files{$object_dep} = 1; |
1414 | next; |
1415 | } |
1416 | if($object_dep =~ /\.h$/io) { |
1417 | $header_files{$object_dep} = 1; |
1418 | next; |
1419 | } |
1420 | if($object_dep =~ /\.(rc|ico)$/io) { |
1421 | $resource_files{$object_dep} = 1; |
1422 | next; |
1423 | } |
1424 | } |
1425 | } |
1426 | $libs = join " ", sort keys %lib_files; |
1427 | @source_files = sort keys %source_files; |
1428 | @header_files = sort keys %header_files; |
1429 | @resources = sort keys %resource_files; |
1430 | ($windows_project, $type) = split ",", $progname; |
1431 | mkdir $windows_project |
1432 | if(! -d $windows_project); |
1433 | chdir $windows_project; |
1434 | |
1435 | $subsys = ($type eq "G") ? "0" : "1"; # 0 = Win32 GUI, 1 = Win32 Console |
1436 | open OUT, ">$windows_project.dev"; binmode OUT; select OUT; |
1437 | print |
1438 | "# DEV-C++ 5 Project File - $windows_project.dev\r\n". |
1439 | "# ** DO NOT EDIT **\r\n". |
1440 | "\r\n". |
1441 | # No difference between DEBUG and RELEASE here as in 'vcproj', because |
1442 | # Dev-C++ does not support mutiple compilation profiles in one single project. |
1443 | # (At least I can say this for Dev-C++ 5 Beta) |
1444 | "[Project]\r\n". |
1445 | "FileName=$windows_project.dev\r\n". |
1446 | "Name=$windows_project\r\n". |
1447 | "Ver=1\r\n". |
1448 | "IsCpp=1\r\n". |
1449 | "Type=$subsys\r\n". |
1450 | # Multimon is disabled here, as Dev-C++ (Version 5 Beta) does not have multimon.h |
1451 | "Compiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n". |
1452 | "CppCompiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n". |
1453 | "Includes=" . (join ";", map {"..\\..\\$dirpfx$_"} @srcdirs) . "\r\n". |
1454 | "Linker=-ladvapi32 -lcomctl32 -lcomdlg32 -lgdi32 -limm32 -lshell32 -luser32 -lwinmm -lwinspool_\@\@_\r\n". |
1455 | "Libs=\r\n". |
1456 | "UnitCount=" . (@source_files + @header_files + @resources) . "\r\n". |
1457 | "Folders=\"Header Files\",\"Resource Files\",\"Source Files\"\r\n". |
1458 | "ObjFiles=\r\n". |
1459 | "PrivateResource=${windows_project}_private.rc\r\n". |
1460 | "ResourceIncludes=..\\..\\..\\WINDOWS\r\n". |
1461 | "MakeIncludes=\r\n". |
1462 | "Icon=\r\n". # It's ok to leave this blank. |
1463 | "ExeOutput=\r\n". |
1464 | "ObjectOutput=\r\n". |
1465 | "OverrideOutput=0\r\n". |
1466 | "OverrideOutputName=$windows_project.exe\r\n". |
1467 | "HostApplication=\r\n". |
1468 | "CommandLine=\r\n". |
1469 | "UseCustomMakefile=0\r\n". |
1470 | "CustomMakefile=\r\n". |
1471 | "IncludeVersionInfo=0\r\n". |
1472 | "SupportXPThemes=0\r\n". |
1473 | "CompilerSet=0\r\n". |
1474 | "CompilerSettings=0000000000000000000000\r\n". |
1475 | "\r\n"; |
1476 | $unit_count = 1; |
1477 | foreach $source_file (@source_files) { |
1478 | print |
1479 | "[Unit$unit_count]\r\n". |
1480 | "FileName=..\\..\\$source_file\r\n". |
1481 | "Folder=Source Files\r\n". |
1482 | "Compile=1\r\n". |
1483 | "CompileCpp=0\r\n". |
1484 | "Link=1\r\n". |
1485 | "Priority=1000\r\n". |
1486 | "OverrideBuildCmd=0\r\n". |
1487 | "BuildCmd=\r\n". |
1488 | "\r\n"; |
1489 | $unit_count++; |
1490 | } |
1491 | foreach $header_file (@header_files) { |
1492 | print |
1493 | "[Unit$unit_count]\r\n". |
1494 | "FileName=..\\..\\$header_file\r\n". |
1495 | "Folder=Header Files\r\n". |
1496 | "Compile=1\r\n". |
1497 | "CompileCpp=1\r\n". # Dev-C++ want's to compile all header files with both compilers C and C++. It does not hurt. |
1498 | "Link=1\r\n". |
1499 | "Priority=1000\r\n". |
1500 | "OverrideBuildCmd=0\r\n". |
1501 | "BuildCmd=\r\n". |
1502 | "\r\n"; |
1503 | $unit_count++; |
1504 | } |
1505 | foreach $resource_file (@resources) { |
1506 | if ($resource_file =~ /.*\.(ico|cur|bmp|dlg|rc2|rct|bin|rgs|gif|jpg|jpeg|jpe)/io) { # Default filter as in 'vcproj' |
1507 | $Compile = "0"; # Don't compile images and other binary resource files |
1508 | $CompileCpp = "0"; |
1509 | } else { |
1510 | $Compile = "1"; |
1511 | $CompileCpp = "1"; # Dev-C++ want's to compile all .rc files with both compilers C and C++. It does not hurt. |
1512 | } |
1513 | print |
1514 | "[Unit$unit_count]\r\n". |
1515 | "FileName=..\\..\\$resource_file\r\n". |
1516 | "Folder=Resource Files\r\n". |
1517 | "Compile=$Compile\r\n". |
1518 | "CompileCpp=$CompileCpp\r\n". |
1519 | "Link=0\r\n". |
1520 | "Priority=1000\r\n". |
1521 | "OverrideBuildCmd=0\r\n". |
1522 | "BuildCmd=\r\n". |
1523 | "\r\n"; |
1524 | $unit_count++; |
1525 | } |
1526 | #Note: By default, [VersionInfo] is not used. |
1527 | print |
1528 | "[VersionInfo]\r\n". |
1529 | "Major=0\r\n". |
1530 | "Minor=0\r\n". |
1531 | "Release=1\r\n". |
1532 | "Build=1\r\n". |
1533 | "LanguageID=1033\r\n". |
1534 | "CharsetID=1252\r\n". |
1535 | "CompanyName=\r\n". |
1536 | "FileVersion=0.1\r\n". |
1537 | "FileDescription=\r\n". |
1538 | "InternalName=\r\n". |
1539 | "LegalCopyright=\r\n". |
1540 | "LegalTrademarks=\r\n". |
1541 | "OriginalFilename=$windows_project.exe\r\n". |
1542 | "ProductName=$windows_project\r\n". |
1543 | "ProductVersion=0.1\r\n". |
1544 | "AutoIncBuildNr=0\r\n"; |
1545 | select STDOUT; close OUT; |
1546 | chdir ".."; |
1547 | } |
1548 | } |
bc7af299 |
1549 | |
1550 | # All done, so do the Unix postprocessing if asked to. |
1551 | |
1552 | if ($do_unix) { |
1553 | chdir $orig_dir; |
1554 | system "./mkauto.sh"; |
1555 | die "mkfiles.pl: mkauto.sh returned $?\n" if $? > 0; |
c1b71b1c |
1556 | if ($do_unix == 1) { |
1557 | chdir ($targetdir = dirname($makefiles{"am"})) |
1558 | or die "$targetdir: chdir: $!\n"; |
1559 | } |
bc7af299 |
1560 | system "./configure", @confargs; |
1561 | die "mkfiles.pl: configure returned $?\n" if $? > 0; |
1562 | } |