diff options
author | Franklin Wei <git@fwei.tk> | 2017-04-29 18:21:56 -0400 |
---|---|---|
committer | Franklin Wei <git@fwei.tk> | 2017-04-29 18:24:42 -0400 |
commit | 881746789a489fad85aae8317555f73dbe261556 (patch) | |
tree | cec2946362c4698c8db3c10f3242ef546c2c22dd /apps/plugins/puzzles/src/mkfiles.pl | |
parent | 03dd4b92be7dcd5c8ab06da3810887060e06abd5 (diff) | |
download | rockbox-881746789a489fad85aae8317555f73dbe261556.tar.gz rockbox-881746789a489fad85aae8317555f73dbe261556.zip |
puzzles: refactor and resync with upstream
This brings puzzles up-to-date with upstream revision
2d333750272c3967cfd5cd3677572cddeaad5932, though certain changes made
by me, including cursor-only Untangle and some compilation fixes
remain. Upstream code has been moved to its separate subdirectory and
future syncs can be done by simply copying over the new sources.
Change-Id: Ia6506ca5f78c3627165ea6791d38db414ace0804
Diffstat (limited to 'apps/plugins/puzzles/src/mkfiles.pl')
-rwxr-xr-x | apps/plugins/puzzles/src/mkfiles.pl | 1807 |
1 files changed, 1807 insertions, 0 deletions
diff --git a/apps/plugins/puzzles/src/mkfiles.pl b/apps/plugins/puzzles/src/mkfiles.pl new file mode 100755 index 0000000000..c1623dfd12 --- /dev/null +++ b/apps/plugins/puzzles/src/mkfiles.pl | |||
@@ -0,0 +1,1807 @@ | |||
1 | #!/usr/bin/env perl | ||
2 | # | ||
3 | # Cross-platform Makefile generator. | ||
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 | |||
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. | ||
15 | |||
16 | # Other things undone: | ||
17 | # - special-define objects (foo.o[PREPROCSYMBOL]) are not | ||
18 | # supported in the mac or vcproj makefiles. | ||
19 | |||
20 | use warnings; | ||
21 | use IO::Handle; | ||
22 | use Cwd; | ||
23 | use File::Basename; | ||
24 | |||
25 | while ($#ARGV >= 0) { | ||
26 | if ($ARGV[0] eq "-U") { | ||
27 | # Convenience for Unix users: -U means that after we finish what | ||
28 | # we're doing here, we also run mkauto.sh and then 'configure'. So | ||
29 | # it's a one-stop shop for regenerating the actual end-product | ||
30 | # Unix makefile. | ||
31 | # | ||
32 | # Arguments supplied after -U go to configure. | ||
33 | $do_unix = 1; | ||
34 | shift @ARGV; | ||
35 | @confargs = @ARGV; | ||
36 | @ARGV = (); | ||
37 | } else { | ||
38 | die "unrecognised command-line argument '$ARGV[0]'\n"; | ||
39 | } | ||
40 | } | ||
41 | |||
42 | @filestack = (); | ||
43 | $in = new IO::Handle; | ||
44 | open $in, "Recipe" or do { | ||
45 | # We want to deal correctly with being run from one of the | ||
46 | # subdirs in the source tree. So if we can't find Recipe here, | ||
47 | # try one level up. | ||
48 | chdir ".."; | ||
49 | open $in, "Recipe" or die "unable to open Recipe file\n"; | ||
50 | }; | ||
51 | push @filestack, $in; | ||
52 | |||
53 | # HACK: One of the source files in `charset' is auto-generated by | ||
54 | # sbcsgen.pl. We need to generate that _now_, before attempting | ||
55 | # dependency analysis. | ||
56 | eval 'chdir "charset"; require "sbcsgen.pl"; chdir ".."'; | ||
57 | |||
58 | @srcdirs = ("./"); | ||
59 | |||
60 | $divert = undef; # ref to array of refs of scalars in which text is | ||
61 | # currently being put | ||
62 | $help = ""; # list of newline-free lines of help text | ||
63 | $project_name = "project"; # this is a good enough default | ||
64 | %makefiles = (); # maps makefile types to output makefile pathnames | ||
65 | %makefile_extra = (); # maps makefile types to extra Makefile text | ||
66 | %programs = (); # maps prog name + type letter to listref of objects/resources | ||
67 | %groups = (); # maps group name to listref of objects/resources | ||
68 | |||
69 | @allobjs = (); # all object file names | ||
70 | |||
71 | readinput: while (1) { | ||
72 | $in = $filestack[$#filestack]; | ||
73 | while (not defined ($_ = <$in>)) { | ||
74 | close $filestack[$#filestack]; | ||
75 | pop @filestack; | ||
76 | last readinput if 0 == scalar @filestack; | ||
77 | $in = $filestack[$#filestack]; | ||
78 | } | ||
79 | chomp; | ||
80 | @_ = split; | ||
81 | |||
82 | # If we're gathering help text, keep doing so. | ||
83 | if (defined $divert) { | ||
84 | if ((defined $_[0]) && $_[0] eq "!end") { | ||
85 | $divert = undef; | ||
86 | } else { | ||
87 | for my $ref (@$divert) { | ||
88 | ${$ref} .= "$_\n"; | ||
89 | } | ||
90 | } | ||
91 | next; | ||
92 | } | ||
93 | # Skip comments and blank lines. | ||
94 | next if /^\s*#/ or scalar @_ == 0; | ||
95 | |||
96 | if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = [\$help]; next; } | ||
97 | if ($_[0] eq "!name") { $project_name = $_[1]; next; } | ||
98 | if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; } | ||
99 | if ($_[0] eq "!makefile" and &mfval($_[1])) { $makefiles{$_[1]}=$_[2]; next;} | ||
100 | if ($_[0] eq "!specialobj" and &mfval($_[1])) { $specialobj{$_[1]}->{$_[2]} = 1; next;} | ||
101 | if ($_[0] eq "!cflags" and &mfval($_[1])) { | ||
102 | ($rest = $_) =~ s/^\s*\S+\s+\S+\s+\S+\s*//; # find rest of input line | ||
103 | $rest = 1 if $rest eq ""; | ||
104 | $cflags{$_[1]}->{$_[2]} = $rest; | ||
105 | next; | ||
106 | } | ||
107 | if ($_[0] eq "!begin") { | ||
108 | my @args = @_; | ||
109 | shift @args; | ||
110 | $divert = []; | ||
111 | for my $component (@args) { | ||
112 | if ($component =~ /^>(.*)/) { | ||
113 | push @$divert, \$auxfiles{$1}; | ||
114 | } elsif ($component =~ /^([^_]*)(_.*)?$/ and &mfval($1)) { | ||
115 | push @$divert, \$makefile_extra{$component}; | ||
116 | } | ||
117 | } | ||
118 | next; | ||
119 | } | ||
120 | if ($_[0] eq "!include") { | ||
121 | @newfiles = (); | ||
122 | for ($i = 1; $i <= $#_; $i++) { | ||
123 | push @newfiles, (sort glob $_[$i]); | ||
124 | } | ||
125 | for ($i = $#newfiles; $i >= 0; $i--) { | ||
126 | $file = $newfiles[$i]; | ||
127 | $f = new IO::Handle; | ||
128 | open $f, "<$file" or die "unable to open include file '$file'\n"; | ||
129 | push @filestack, $f; | ||
130 | } | ||
131 | next; | ||
132 | } | ||
133 | |||
134 | # Now we have an ordinary line. See if it's an = line, a : line | ||
135 | # or a + line. | ||
136 | @objs = @_; | ||
137 | |||
138 | if ($_[0] eq "+") { | ||
139 | $listref = $lastlistref; | ||
140 | $prog = undef; | ||
141 | die "$.: unexpected + line\n" if !defined $lastlistref; | ||
142 | } elsif ($_[1] eq "=") { | ||
143 | $groups{$_[0]} = []; | ||
144 | $listref = $groups{$_[0]}; | ||
145 | $prog = undef; | ||
146 | shift @objs; # eat the group name | ||
147 | } elsif ($_[1] eq "+=") { | ||
148 | $groups{$_[0]} = [] if !defined $groups{$_[0]}; | ||
149 | $listref = $groups{$_[0]}; | ||
150 | $prog = undef; | ||
151 | shift @objs; # eat the group name | ||
152 | } elsif ($_[1] eq ":") { | ||
153 | $listref = []; | ||
154 | $prog = $_[0]; | ||
155 | shift @objs; # eat the program name | ||
156 | } else { | ||
157 | die "$.: unrecognised line type: '$_'\n"; | ||
158 | } | ||
159 | shift @objs; # eat the +, the = or the : | ||
160 | |||
161 | while (scalar @objs > 0) { | ||
162 | $i = shift @objs; | ||
163 | if ($groups{$i}) { | ||
164 | foreach $j (@{$groups{$i}}) { unshift @objs, $j; } | ||
165 | } elsif (($i eq "[G]" or $i eq "[C]" or $i eq "[M]" or | ||
166 | $i eq "[X]" or $i eq "[U]" or $i eq "[MX]") and defined $prog) { | ||
167 | $type = substr($i,1,(length $i)-2); | ||
168 | } else { | ||
169 | if ($i =~ /\?$/) { | ||
170 | # Object files with a trailing question mark are optional: | ||
171 | # the build can proceed fine without them, so we only use | ||
172 | # them if their primary source files are present. | ||
173 | $i =~ s/\?$//; | ||
174 | $i = undef unless defined &finddep($i); | ||
175 | } elsif ($i =~ /\|/) { | ||
176 | # Object file descriptions containing a vertical bar are | ||
177 | # lists of choices: we use the _first_ one whose primary | ||
178 | # source file is present. | ||
179 | @options = split /\|/, $i; | ||
180 | $j = undef; | ||
181 | foreach $k (@options) { | ||
182 | $j=$k, last if defined &finddep($k); | ||
183 | } | ||
184 | die "no alternative found for $i\n" unless defined $j; | ||
185 | $i = $j; | ||
186 | } | ||
187 | if (defined $i) { | ||
188 | push @$listref, $i; | ||
189 | push @allobjs, $i; | ||
190 | } | ||
191 | } | ||
192 | } | ||
193 | if ($prog and $type) { | ||
194 | die "multiple program entries for $prog [$type]\n" | ||
195 | if defined $programs{$prog . "," . $type}; | ||
196 | $programs{$prog . "," . $type} = $listref; | ||
197 | } | ||
198 | $lastlistref = $listref; | ||
199 | } | ||
200 | |||
201 | foreach $aux (sort keys %auxfiles) { | ||
202 | open AUX, ">$aux"; | ||
203 | print AUX $auxfiles{$aux}; | ||
204 | close AUX; | ||
205 | } | ||
206 | |||
207 | # Find object file names with predefines (in square brackets after | ||
208 | # the module name), and decide on actual object names for them. | ||
209 | foreach $i (@allobjs) { | ||
210 | if ($i !~ /\[/) { | ||
211 | $objname{$i} = $i; | ||
212 | $srcname{$i} = $i; | ||
213 | $usedobjname{$i} = 1; | ||
214 | } | ||
215 | } | ||
216 | foreach $i (@allobjs) { | ||
217 | if ($i =~ /^(.*)\[([^\]]*)/) { | ||
218 | $defs{$i} = [ split ",",$2 ]; | ||
219 | $srcname{$i} = $s = $1; | ||
220 | $index = 1; | ||
221 | while (1) { | ||
222 | $maxlen = length $s; | ||
223 | $maxlen = 8 if $maxlen < 8; | ||
224 | $chop = $maxlen - length $index; | ||
225 | $chop = length $s if $chop > length $s; | ||
226 | $chop = 0 if $chop < 0; | ||
227 | $name = substr($s, 0, $chop) . $index; | ||
228 | $index++, next if $usedobjname{$name}; | ||
229 | $objname{$i} = $name; | ||
230 | $usedobjname{$name} = 1; | ||
231 | last; | ||
232 | } | ||
233 | } | ||
234 | } | ||
235 | |||
236 | # Now retrieve the complete list of objects and resource files, and | ||
237 | # construct dependency data for them. While we're here, expand the | ||
238 | # object list for each program, and complain if its type isn't set. | ||
239 | @prognames = sort keys %programs; | ||
240 | %depends = (); | ||
241 | @scanlist = (); | ||
242 | foreach $i (@prognames) { | ||
243 | ($prog, $type) = split ",", $i; | ||
244 | # Strip duplicate object names. | ||
245 | $prev = ''; | ||
246 | @list = grep { $status = ($prev ne $_); $prev=$_; $status } | ||
247 | sort @{$programs{$i}}; | ||
248 | $programs{$i} = [@list]; | ||
249 | foreach $jj (@list) { | ||
250 | $j = $srcname{$jj}; | ||
251 | $file = &finddep($j); | ||
252 | if (defined $file) { | ||
253 | $depends{$jj} = [$file]; | ||
254 | push @scanlist, $file; | ||
255 | } | ||
256 | } | ||
257 | } | ||
258 | |||
259 | # Scan each file on @scanlist and find further inclusions. | ||
260 | # Inclusions are given by lines of the form `#include "otherfile"' | ||
261 | # (system headers are automatically ignored by this because they'll | ||
262 | # be given in angle brackets). Files included by this method are | ||
263 | # added back on to @scanlist to be scanned in turn (if not already | ||
264 | # done). | ||
265 | # | ||
266 | # Resource scripts (.rc) can also include a file by means of a line | ||
267 | # ending `ICON "filename"'. Files included by this method are not | ||
268 | # added to @scanlist because they can never include further files. | ||
269 | # | ||
270 | # In this pass we write out a hash %further which maps a source | ||
271 | # file name into a listref containing further source file names. | ||
272 | |||
273 | %further = (); | ||
274 | while (scalar @scanlist > 0) { | ||
275 | $file = shift @scanlist; | ||
276 | next if defined $further{$file}; # skip if we've already done it | ||
277 | $further{$file} = []; | ||
278 | $dirfile = &findfile($file); | ||
279 | open IN, "$dirfile" or die "unable to open source file $file\n"; | ||
280 | while (<IN>) { | ||
281 | chomp; | ||
282 | /^\s*#include\s+\"([^\"]+)\"/ and do { | ||
283 | push @{$further{$file}}, $1; | ||
284 | push @scanlist, $1; | ||
285 | next; | ||
286 | }; | ||
287 | /ICON\s+\"([^\"]+)\"\s*$/ and do { | ||
288 | push @{$further{$file}}, $1; | ||
289 | next; | ||
290 | } | ||
291 | } | ||
292 | close IN; | ||
293 | } | ||
294 | |||
295 | # Now we're ready to generate the final dependencies section. For | ||
296 | # each key in %depends, we must expand the dependencies list by | ||
297 | # iteratively adding entries from %further. | ||
298 | foreach $i (keys %depends) { | ||
299 | %dep = (); | ||
300 | @scanlist = @{$depends{$i}}; | ||
301 | foreach $i (@scanlist) { $dep{$i} = 1; } | ||
302 | while (scalar @scanlist > 0) { | ||
303 | $file = shift @scanlist; | ||
304 | foreach $j (@{$further{$file}}) { | ||
305 | if (!$dep{$j}) { | ||
306 | $dep{$j} = 1; | ||
307 | push @{$depends{$i}}, $j; | ||
308 | push @scanlist, $j; | ||
309 | } | ||
310 | } | ||
311 | } | ||
312 | # printf "%s: %s\n", $i, join ' ',@{$depends{$i}}; | ||
313 | } | ||
314 | |||
315 | # Validation of input. | ||
316 | |||
317 | sub mfval($) { | ||
318 | my ($type) = @_; | ||
319 | # Returns true if the argument is a known makefile type. Otherwise, | ||
320 | # prints a warning and returns false; | ||
321 | if (grep { $type eq $_ } | ||
322 | ("vc","vcproj","cygwin","borland","lcc","gtk","am","mpw","nestedvm","osx","wce","gnustep","emcc")) { | ||
323 | return 1; | ||
324 | } | ||
325 | warn "$.:unknown makefile type '$type'\n"; | ||
326 | return 0; | ||
327 | } | ||
328 | |||
329 | # Utility routines while writing out the Makefiles. | ||
330 | |||
331 | sub dirpfx { | ||
332 | my ($path) = shift @_; | ||
333 | my ($sep) = shift @_; | ||
334 | my $ret = ""; | ||
335 | my $i; | ||
336 | while (($i = index $path, $sep) >= 0) { | ||
337 | $path = substr $path, ($i + length $sep); | ||
338 | $ret .= "..$sep"; | ||
339 | } | ||
340 | return $ret; | ||
341 | } | ||
342 | |||
343 | sub findfile { | ||
344 | my ($name) = @_; | ||
345 | my $dir; | ||
346 | my $i; | ||
347 | my $outdir = undef; | ||
348 | unless (defined $findfilecache{$name}) { | ||
349 | $i = 0; | ||
350 | foreach $dir (@srcdirs) { | ||
351 | $outdir = $dir, $i++ if -f "$dir$name"; | ||
352 | } | ||
353 | die "multiple instances of source file $name\n" if $i > 1; | ||
354 | $findfilecache{$name} = (defined $outdir ? $outdir . $name : undef); | ||
355 | } | ||
356 | return $findfilecache{$name}; | ||
357 | } | ||
358 | |||
359 | sub finddep { | ||
360 | my $j = shift @_; | ||
361 | my $file; | ||
362 | # Find the first dependency of an object. | ||
363 | |||
364 | # Dependencies for "x" start with "x.c" or "x.m" (depending on | ||
365 | # which one exists). | ||
366 | # Dependencies for "x.res" start with "x.rc". | ||
367 | # Dependencies for "x.rsrc" start with "x.r". | ||
368 | # Both types of file are pushed on the list of files to scan. | ||
369 | # Libraries (.lib) don't have dependencies at all. | ||
370 | if ($j =~ /^(.*)\.res$/) { | ||
371 | $file = "$1.rc"; | ||
372 | } elsif ($j =~ /^(.*)\.rsrc$/) { | ||
373 | $file = "$1.r"; | ||
374 | } elsif ($j !~ /\./) { | ||
375 | $file = "$j.c"; | ||
376 | $file = "$j.m" unless &findfile($file); | ||
377 | } else { | ||
378 | # For everything else, we assume it's its own dependency. | ||
379 | $file = $j; | ||
380 | } | ||
381 | $file = undef unless &findfile($file); | ||
382 | return $file; | ||
383 | } | ||
384 | |||
385 | sub objects { | ||
386 | my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_; | ||
387 | my @ret; | ||
388 | my ($i, $x, $y); | ||
389 | ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ? $_ : "" } ($otmpl, $rtmpl, $ltmpl); | ||
390 | @ret = (); | ||
391 | foreach $ii (@{$programs{$prog}}) { | ||
392 | $i = $objname{$ii}; | ||
393 | $x = ""; | ||
394 | if ($i =~ /^(.*)\.(res|rsrc)/) { | ||
395 | $y = $1; | ||
396 | ($x = $rtmpl) =~ s/X/$y/; | ||
397 | } elsif ($i =~ /^(.*)\.lib/) { | ||
398 | $y = $1; | ||
399 | ($x = $ltmpl) =~ s/X/$y/; | ||
400 | } elsif ($i !~ /\./) { | ||
401 | ($x = $otmpl) =~ s/X/$i/; | ||
402 | } | ||
403 | push @ret, $x if $x ne ""; | ||
404 | } | ||
405 | return join " ", @ret; | ||
406 | } | ||
407 | |||
408 | sub special { | ||
409 | my ($prog, $suffix) = @_; | ||
410 | my @ret; | ||
411 | my ($i, $x, $y); | ||
412 | @ret = (); | ||
413 | foreach $ii (@{$programs{$prog}}) { | ||
414 | $i = $objname{$ii}; | ||
415 | if (substr($i, (length $i) - (length $suffix)) eq $suffix) { | ||
416 | push @ret, $i; | ||
417 | } | ||
418 | } | ||
419 | return join " ", @ret; | ||
420 | } | ||
421 | |||
422 | sub splitline { | ||
423 | my ($line, $width, $splitchar) = @_; | ||
424 | my $result = ""; | ||
425 | my $len; | ||
426 | $len = (defined $width ? $width : 76); | ||
427 | $splitchar = (defined $splitchar ? $splitchar : '\\'); | ||
428 | while (length $line > $len) { | ||
429 | $line =~ /^(.{0,$len})\s(.*)$/ or $line =~ /^(.{$len,}?\s(.*)$/; | ||
430 | $result .= $1; | ||
431 | $result .= " ${splitchar}\n\t\t" if $2 ne ''; | ||
432 | $line = $2; | ||
433 | $len = 60; | ||
434 | } | ||
435 | return $result . $line; | ||
436 | } | ||
437 | |||
438 | sub deps { | ||
439 | my ($otmpl, $rtmpl, $prefix, $dirsep, $depchar, $splitchar) = @_; | ||
440 | my ($i, $x, $y); | ||
441 | my @deps; | ||
442 | my @ret; | ||
443 | @ret = (); | ||
444 | $depchar ||= ':'; | ||
445 | foreach $ii (sort keys %depends) { | ||
446 | $i = $objname{$ii}; | ||
447 | next if $specialobj{$mftyp}->{$i}; | ||
448 | if ($i =~ /^(.*)\.(res|rsrc)/) { | ||
449 | next if !defined $rtmpl; | ||
450 | $y = $1; | ||
451 | ($x = $rtmpl) =~ s/X/$y/; | ||
452 | } else { | ||
453 | ($x = $otmpl) =~ s/X/$i/; | ||
454 | } | ||
455 | @deps = @{$depends{$ii}}; | ||
456 | # Skip things which are their own dependency. | ||
457 | next if grep { $_ eq $i } @deps; | ||
458 | @deps = map { | ||
459 | $_ = &findfile($_); | ||
460 | s/\//$dirsep/g; | ||
461 | $_ = $prefix . $_; | ||
462 | } @deps; | ||
463 | push @ret, {obj => $x, deps => [@deps], defs => $defs{$ii}}; | ||
464 | } | ||
465 | return @ret; | ||
466 | } | ||
467 | |||
468 | sub prognames { | ||
469 | my ($types) = @_; | ||
470 | my ($n, $prog, $type); | ||
471 | my @ret; | ||
472 | @ret = (); | ||
473 | foreach $n (@prognames) { | ||
474 | ($prog, $type) = split ",", $n; | ||
475 | push @ret, $n if index(":$types:", ":$type:") >= 0; | ||
476 | } | ||
477 | return @ret; | ||
478 | } | ||
479 | |||
480 | sub progrealnames { | ||
481 | my ($types) = @_; | ||
482 | my ($n, $prog, $type); | ||
483 | my @ret; | ||
484 | @ret = (); | ||
485 | foreach $n (@prognames) { | ||
486 | ($prog, $type) = split ",", $n; | ||
487 | push @ret, $prog if index(":$types:", ":$type:") >= 0; | ||
488 | } | ||
489 | return @ret; | ||
490 | } | ||
491 | |||
492 | sub manpages { | ||
493 | my ($types,$suffix) = @_; | ||
494 | |||
495 | # assume that all UNIX programs have a man page | ||
496 | if($suffix eq "1" && $types =~ /:X:/) { | ||
497 | return map("$_.1", &progrealnames($types)); | ||
498 | } | ||
499 | return (); | ||
500 | } | ||
501 | |||
502 | $orig_dir = cwd; | ||
503 | |||
504 | # Now we're ready to output the actual Makefiles. | ||
505 | |||
506 | if (defined $makefiles{'cygwin'}) { | ||
507 | $mftyp = 'cygwin'; | ||
508 | $dirpfx = &dirpfx($makefiles{'cygwin'}, "/"); | ||
509 | |||
510 | ##-- CygWin makefile | ||
511 | open OUT, ">$makefiles{'cygwin'}"; select OUT; | ||
512 | |||
513 | "# Makefile for $project_name under cygwin.\n". | ||
514 | "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". | ||
515 | "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; | ||
516 | # gcc command line option is -D not /D | ||
517 | ($_ = $help) =~ s/=\/D/=-D/gs; | ||
518 | print $_; | ||
519 | |||
520 | "\n". | ||
521 | "# You can define this path to point at your tools if you need to\n". | ||
522 | "# TOOLPATH = c:\\cygwin\\bin\\ # or similar, if you're running Windows\n". | ||
523 | "# TOOLPATH = /pkg/mingw32msvc/i386-mingw32msvc/bin/\n". | ||
524 | "CC = \$(TOOLPATH)gcc\n". | ||
525 | "RC = \$(TOOLPATH)windres\n". | ||
526 | "# Uncomment the following two lines to compile under Winelib\n". | ||
527 | "# CC = winegcc\n". | ||
528 | "# RC = wrc\n". | ||
529 | "# You may also need to tell windres where to find include files:\n". | ||
530 | "# RCINC = --include-dir c:\\cygwin\\include\\\n". | ||
531 | "\n". | ||
532 | &splitline("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT". | ||
533 | " -D_NO_OLDNAMES -DNO_MULTIMON -DNO_HTMLHELP " . | ||
534 | (join " ", map {"-I$dirpfx$_"} @srcdirs)) . | ||
535 | "\n". | ||
536 | "LDFLAGS = -mno-cygwin -s\n". | ||
537 | &splitline("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1". | ||
538 | " --define WINVER=0x0400 --define MINGW32_FIX=1 " . | ||
539 | (join " ", map {"--include $dirpfx$_"} @srcdirs) )."\n". | ||
540 | "\n"; | ||
541 | print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C")); | ||
542 | print "\n\n"; | ||
543 | foreach $p (&prognames("G:C")) { | ||
544 | ($prog, $type) = split ",", $p; | ||
545 | $objstr = &objects($p, "X.o", "X.res.o", undef); | ||
546 | print &splitline($prog . ".exe: " . $objstr), "\n"; | ||
547 | my $mw = $type eq "G" ? " -mwindows" : ""; | ||
548 | $libstr = &objects($p, undef, undef, "-lX"); | ||
549 | print &splitline("\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " . | ||
550 | "-Wl,-Map,$prog.map " . | ||
551 | $objstr . " $libstr", 69), "\n\n"; | ||
552 | } | ||
553 | foreach $d (&deps("X.o", "X.res.o", $dirpfx, "/")) { | ||
554 | print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})), | ||
555 | "\n"; | ||
556 | if ($d->{obj} =~ /\.res\.o$/) { | ||
557 | print "\t\$(RC) \$(FWHACK) \$(RCFL) \$(RCFLAGS) \$< \$\@\n"; | ||
558 | } else { | ||
559 | $deflist = join "", map { " -D$_" } @{$d->{defs}}; | ||
560 | print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS)" . | ||
561 | " \$(XFLAGS)$deflist -c \$< -o \$\@\n"; | ||
562 | } | ||
563 | } | ||
564 | print "\n"; | ||
565 | print $makefile_extra{'cygwin'} || ""; | ||
566 | print "\nclean:\n". | ||
567 | "\trm -f *.o *.exe *.res.o *.map\n". | ||
568 | "\n"; | ||
569 | select STDOUT; close OUT; | ||
570 | |||
571 | } | ||
572 | |||
573 | ##-- Borland makefile | ||
574 | if (defined $makefiles{'borland'}) { | ||
575 | $mftyp = 'borland'; | ||
576 | $dirpfx = &dirpfx($makefiles{'borland'}, "\\"); | ||
577 | |||
578 | %stdlibs = ( # Borland provides many Win32 API libraries intrinsically | ||
579 | "advapi32" => 1, | ||
580 | "comctl32" => 1, | ||
581 | "comdlg32" => 1, | ||
582 | "gdi32" => 1, | ||
583 | "imm32" => 1, | ||
584 | "shell32" => 1, | ||
585 | "user32" => 1, | ||
586 | "winmm" => 1, | ||
587 | "winspool" => 1, | ||
588 | "wsock32" => 1, | ||
589 | ); | ||
590 | open OUT, ">$makefiles{'borland'}"; select OUT; | ||
591 | |||
592 | "# Makefile for $project_name under Borland C.\n". | ||
593 | "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". | ||
594 | "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; | ||
595 | # bcc32 command line option is -D not /D | ||
596 | ($_ = $help) =~ s/=\/D/=-D/gs; | ||
597 | print $_; | ||
598 | |||
599 | "\n". | ||
600 | "# If you rename this file to `Makefile', you should change this line,\n". | ||
601 | "# so that the .rsp files still depend on the correct makefile.\n". | ||
602 | "MAKEFILE = Makefile.bor\n". | ||
603 | "\n". | ||
604 | "# C compilation flags\n". | ||
605 | "CFLAGS = -D_WINDOWS -DWINVER=0x0401\n". | ||
606 | "\n". | ||
607 | "# Get include directory for resource compiler\n". | ||
608 | "!if !\$d(BCB)\n". | ||
609 | "BCB = \$(MAKEDIR)\\..\n". | ||
610 | "!endif\n". | ||
611 | "\n"; | ||
612 | print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C")); | ||
613 | print "\n\n"; | ||
614 | foreach $p (&prognames("G:C")) { | ||
615 | ($prog, $type) = split ",", $p; | ||
616 | $objstr = &objects($p, "X.obj", "X.res", undef); | ||
617 | print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n"; | ||
618 | my $ap = ($type eq "G") ? "-aa" : "-ap"; | ||
619 | print "\tilink32 $ap -Gn -L\$(BCB)\\lib \@$prog.rsp\n\n"; | ||
620 | } | ||
621 | foreach $p (&prognames("G:C")) { | ||
622 | ($prog, $type) = split ",", $p; | ||
623 | print $prog, ".rsp: \$(MAKEFILE)\n"; | ||
624 | $objstr = &objects($p, "X.obj", undef, undef); | ||
625 | @objlist = split " ", $objstr; | ||
626 | @objlines = (""); | ||
627 | foreach $i (@objlist) { | ||
628 | if (length($objlines[$#objlines] . " $i") > 50) { | ||
629 | push @objlines, ""; | ||
630 | } | ||
631 | $objlines[$#objlines] .= " $i"; | ||
632 | } | ||
633 | $c0w = ($type eq "G") ? "c0w32" : "c0x32"; | ||
634 | print "\techo $c0w + > $prog.rsp\n"; | ||
635 | for ($i=0; $i<=$#objlines; $i++) { | ||
636 | $plus = ($i < $#objlines ? " +" : ""); | ||
637 | print "\techo$objlines[$i]$plus >> $prog.rsp\n"; | ||
638 | } | ||
639 | print "\techo $prog.exe >> $prog.rsp\n"; | ||
640 | $objstr = &objects($p, "X.obj", "X.res", undef); | ||
641 | @libs = split " ", &objects($p, undef, undef, "X"); | ||
642 | @libs = grep { !$stdlibs{$_} } @libs; | ||
643 | unshift @libs, "cw32", "import32"; | ||
644 | $libstr = join ' ', @libs; | ||
645 | print "\techo nul,$libstr, >> $prog.rsp\n"; | ||
646 | print "\techo " . &objects($p, undef, "X.res", undef) . " >> $prog.rsp\n"; | ||
647 | print "\n"; | ||
648 | } | ||
649 | foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\")) { | ||
650 | print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})), | ||
651 | "\n"; | ||
652 | if ($d->{obj} =~ /\.res$/) { | ||
653 | print &splitline("\tbrcc32 \$(FWHACK) \$(RCFL) " . | ||
654 | "-i \$(BCB)\\include -r -DNO_WINRESRC_H -DWIN32". | ||
655 | " -D_WIN32 -DWINVER=0x0401 \$*.rc",69)."\n"; | ||
656 | } else { | ||
657 | $deflist = join "", map { " -D$_" } @{$d->{defs}}; | ||
658 | print &splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT)" . | ||
659 | " \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist ". | ||
660 | (join " ", map {"-I$dirpfx$_"} @srcdirs) . | ||
661 | " /o$d->{obj} /c ".$d->{deps}->[0],69)."\n"; | ||
662 | } | ||
663 | } | ||
664 | print "\n"; | ||
665 | print $makefile_extra{'borland'} || ""; | ||
666 | print "\nclean:\n". | ||
667 | "\t-del *.obj\n". | ||
668 | "\t-del *.exe\n". | ||
669 | "\t-del *.res\n". | ||
670 | "\t-del *.pch\n". | ||
671 | "\t-del *.aps\n". | ||
672 | "\t-del *.il*\n". | ||
673 | "\t-del *.pdb\n". | ||
674 | "\t-del *.rsp\n". | ||
675 | "\t-del *.tds\n". | ||
676 | "\t-del *.\$\$\$\$\$\$\n"; | ||
677 | select STDOUT; close OUT; | ||
678 | } | ||
679 | |||
680 | if (defined $makefiles{'vc'}) { | ||
681 | $mftyp = 'vc'; | ||
682 | $dirpfx = &dirpfx($makefiles{'vc'}, "\\"); | ||
683 | |||
684 | ##-- Visual C++ makefile | ||
685 | open OUT, ">$makefiles{'vc'}"; select OUT; | ||
686 | |||
687 | "# Makefile for $project_name under Visual C.\n". | ||
688 | "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". | ||
689 | "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; | ||
690 | print $help; | ||
691 | |||
692 | "\n". | ||
693 | "# If you rename this file to `Makefile', you should change this line,\n". | ||
694 | "# so that the .rsp files still depend on the correct makefile.\n". | ||
695 | "MAKEFILE = Makefile.vc\n". | ||
696 | "\n". | ||
697 | "# C compilation flags\n". | ||
698 | "CFLAGS = /nologo /W3 /O1 /D_WINDOWS /D_WIN32_WINDOWS=0x401 /DWINVER=0x401 /I.\n". | ||
699 | "LFLAGS = /incremental:no /fixed\n". | ||
700 | "\n"; | ||
701 | print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C")); | ||
702 | print "\n\n"; | ||
703 | foreach $p (&prognames("G:C")) { | ||
704 | ($prog, $type) = split ",", $p; | ||
705 | $objstr = &objects($p, "X.obj", "X.res", undef); | ||
706 | print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n"; | ||
707 | print "\tlink \$(LFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n"; | ||
708 | } | ||
709 | foreach $p (&prognames("G:C")) { | ||
710 | ($prog, $type) = split ",", $p; | ||
711 | print $prog, ".rsp: \$(MAKEFILE)\n"; | ||
712 | $objstr = &objects($p, "X.obj", "X.res", "X.lib"); | ||
713 | @objlist = split " ", $objstr; | ||
714 | @objlines = (""); | ||
715 | foreach $i (@objlist) { | ||
716 | if (length($objlines[$#objlines] . " $i") > 50) { | ||
717 | push @objlines, ""; | ||
718 | } | ||
719 | $objlines[$#objlines] .= " $i"; | ||
720 | } | ||
721 | $subsys = ($type eq "G") ? "windows" : "console"; | ||
722 | print "\techo /nologo /subsystem:$subsys > $prog.rsp\n"; | ||
723 | for ($i=0; $i<=$#objlines; $i++) { | ||
724 | print "\techo$objlines[$i] >> $prog.rsp\n"; | ||
725 | } | ||
726 | print "\n"; | ||
727 | } | ||
728 | foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\")) { | ||
729 | print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})), | ||
730 | "\n"; | ||
731 | if ($d->{obj} =~ /\.res$/) { | ||
732 | print "\trc \$(FWHACK) \$(RCFL) -r -DWIN32 -D_WIN32 ". | ||
733 | "-DWINVER=0x0400 -fo".$d->{obj}." ".$d->{deps}->[0]."\n"; | ||
734 | } else { | ||
735 | $deflist = join "", map { " /D$_" } @{$d->{defs}}; | ||
736 | print "\tcl \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist". | ||
737 | " /c ".$d->{deps}->[0]." /Fo$d->{obj}\n"; | ||
738 | } | ||
739 | } | ||
740 | print "\n"; | ||
741 | print $makefile_extra{'vc'} || ""; | ||
742 | print "\nclean: tidy\n". | ||
743 | "\t-del *.exe\n\n". | ||
744 | "tidy:\n". | ||
745 | "\t-del *.obj\n". | ||
746 | "\t-del *.res\n". | ||
747 | "\t-del *.pch\n". | ||
748 | "\t-del *.aps\n". | ||
749 | "\t-del *.ilk\n". | ||
750 | "\t-del *.pdb\n". | ||
751 | "\t-del *.rsp\n". | ||
752 | "\t-del *.dsp\n". | ||
753 | "\t-del *.dsw\n". | ||
754 | "\t-del *.ncb\n". | ||
755 | "\t-del *.opt\n". | ||
756 | "\t-del *.plg\n". | ||
757 | "\t-del *.map\n". | ||
758 | "\t-del *.idb\n". | ||
759 | "\t-del debug.log\n"; | ||
760 | select STDOUT; close OUT; | ||
761 | } | ||
762 | |||
763 | if (defined $makefiles{'wce'}) { | ||
764 | $mftyp = 'wce'; | ||
765 | $dirpfx = &dirpfx($makefiles{'wce'}, "\\"); | ||
766 | |||
767 | ##-- eMbedded Visual C PocketPC makefile | ||
768 | open OUT, ">$makefiles{'wce'}"; select OUT; | ||
769 | |||
770 | "# Makefile for $project_name on PocketPC using eMbedded Visual C.\n". | ||
771 | "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". | ||
772 | "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; | ||
773 | print $help; | ||
774 | |||
775 | "\n". | ||
776 | "# If you rename this file to `Makefile', you should change this line,\n". | ||
777 | "# so that the .rsp files still depend on the correct makefile.\n". | ||
778 | "MAKEFILE = Makefile.wce\n". | ||
779 | "\n". | ||
780 | "# This makefile expects the environment to have been set up by one\n". | ||
781 | "# of the PocketPC batch files wcearmv4.bat and wceemulator.bat. No\n". | ||
782 | "# other build targets are currently supported, because they would\n". | ||
783 | "# need a section in this if statement.\n". | ||
784 | "!if \"\$(TARGETCPU)\" == \"emulator\"\n". | ||
785 | "PLATFORM_DEFS=/D \"_i386_\" /D \"i_386_\" /D \"_X86_\" /D \"x86\"\n". | ||
786 | "CC=cl\n". | ||
787 | "BASELIBS=commctrl.lib coredll.lib corelibc.lib aygshell.lib\n". | ||
788 | "MACHINE=IX86\n". | ||
789 | "!else\n". | ||
790 | "PLATFORM_DEFS=/D \"ARM\" /D \"_ARM_\" /D \"ARMV4\"\n". | ||
791 | "CC=clarm\n". | ||
792 | "BASELIBS=commctrl.lib coredll.lib aygshell.lib\n". | ||
793 | "MACHINE=ARM\n". | ||
794 | "!endif\n". | ||
795 | "\n". | ||
796 | "# C compilation flags\n". | ||
797 | "CFLAGS = /nologo /W3 /O1 /MC /D _WIN32_WCE=420 /D \"WIN32_PLATFORM_PSPC=400\" /D UNDER_CE=420 \\\n". | ||
798 | " \$(PLATFORM_DEFS) \\\n". | ||
799 | " /D \"UNICODE\" /D \"_UNICODE\" /D \"NDEBUG\" /D \"NO_HTMLHELP\"\n". | ||
800 | "\n". | ||
801 | "LFLAGS = /nologo /incremental:no \\\n". | ||
802 | " /base:0x00010000 /stack:0x10000,0x1000 /entry:WinMainCRTStartup \\\n". | ||
803 | " /nodefaultlib:libc.lib /nodefaultlib:libcmt.lib /nodefaultlib:msvcrt.lib /nodefaultlib:OLDNAMES.lib \\\n". | ||
804 | " /subsystem:windowsce,4.20 /align:4096 /MACHINE:\$(MACHINE)\n". | ||
805 | "\n". | ||
806 | "RCFL = /d UNDER_CE=420 /d _WIN32_WCE=420 /d \"WIN32_PLATFORM_PSPC=400\" \\\n". | ||
807 | " \$(PLATFORM_DEFS) \\\n". | ||
808 | " /d \"NDEBUG\" /d \"UNICODE\" /d \"_UNICODE\"\n". | ||
809 | "\n"; | ||
810 | print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G")); | ||
811 | print "\n\n"; | ||
812 | foreach $p (&prognames("G")) { | ||
813 | ($prog, $type) = split ",", $p; | ||
814 | $objstr = &objects($p, "X.obj", "X.res", undef); | ||
815 | print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n"; | ||
816 | print "\tlink \$(LFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n"; | ||
817 | } | ||
818 | foreach $p (&prognames("G")) { | ||
819 | ($prog, $type) = split ",", $p; | ||
820 | print $prog, ".rsp: \$(MAKEFILE)\n"; | ||
821 | $objstr = &objects($p, "X.obj", "X.res", undef); | ||
822 | @objlist = split " ", $objstr; | ||
823 | @objlines = (""); | ||
824 | foreach $i (@objlist) { | ||
825 | if (length($objlines[$#objlines] . " $i") > 50) { | ||
826 | push @objlines, ""; | ||
827 | } | ||
828 | $objlines[$#objlines] .= " $i"; | ||
829 | } | ||
830 | print "\techo \$(BASELIBS) > $prog.rsp\n"; | ||
831 | for ($i=0; $i<=$#objlines; $i++) { | ||
832 | print "\techo$objlines[$i] >> $prog.rsp\n"; | ||
833 | } | ||
834 | print "\n"; | ||
835 | } | ||
836 | foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\")) { | ||
837 | print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})), | ||
838 | "\n"; | ||
839 | if ($d->{obj} =~ /\.res$/) { | ||
840 | print "\trc \$(FWHACK) \$(RCFL) -r -fo". | ||
841 | $d->{obj}." ".$d->{deps}->[0]."\n"; | ||
842 | } else { | ||
843 | $deflist = join "", map { " /D$_" } @{$d->{defs}}; | ||
844 | print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist". | ||
845 | " /c ".$d->{deps}->[0]." /Fo$d->{obj}\n"; | ||
846 | } | ||
847 | } | ||
848 | print "\n"; | ||
849 | print $makefile_extra{'wce'} || ""; | ||
850 | print "\nclean: tidy\n". | ||
851 | "\t-del *.exe\n\n". | ||
852 | "tidy:\n". | ||
853 | "\t-del *.obj\n". | ||
854 | "\t-del *.res\n". | ||
855 | "\t-del *.pch\n". | ||
856 | "\t-del *.aps\n". | ||
857 | "\t-del *.ilk\n". | ||
858 | "\t-del *.pdb\n". | ||
859 | "\t-del *.rsp\n". | ||
860 | "\t-del *.dsp\n". | ||
861 | "\t-del *.dsw\n". | ||
862 | "\t-del *.ncb\n". | ||
863 | "\t-del *.opt\n". | ||
864 | "\t-del *.plg\n". | ||
865 | "\t-del *.map\n". | ||
866 | "\t-del *.idb\n". | ||
867 | "\t-del debug.log\n"; | ||
868 | select STDOUT; close OUT; | ||
869 | } | ||
870 | |||
871 | if (defined $makefiles{'vcproj'}) { | ||
872 | $mftyp = 'vcproj'; | ||
873 | |||
874 | ##-- MSVC 6 Workspace and projects | ||
875 | # | ||
876 | # Note: All files created in this section are written in binary | ||
877 | # mode, because although MSVC's command-line make can deal with | ||
878 | # LF-only line endings, MSVC project files really _need_ to be | ||
879 | # CRLF. Hence, in order for mkfiles.pl to generate usable project | ||
880 | # files even when run from Unix, I make sure all files are binary | ||
881 | # and explicitly write the CRLFs. | ||
882 | # | ||
883 | # Create directories if necessary | ||
884 | mkdir $makefiles{'vcproj'} | ||
885 | if(! -d $makefiles{'vcproj'}); | ||
886 | chdir $makefiles{'vcproj'}; | ||
887 | @deps = &deps("X.obj", "X.res", "", "\\"); | ||
888 | %all_object_deps = map {$_->{obj} => $_->{deps}} @deps; | ||
889 | # Create the project files | ||
890 | # Get names of all Windows projects (GUI and console) | ||
891 | my @prognames = &prognames("G:C"); | ||
892 | foreach $progname (@prognames) { | ||
893 | create_project(\%all_object_deps, $progname); | ||
894 | } | ||
895 | # Create the workspace file | ||
896 | open OUT, ">$project_name.dsw"; binmode OUT; select OUT; | ||
897 | |||
898 | "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n". | ||
899 | "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n". | ||
900 | "\r\n". | ||
901 | "###############################################################################\r\n". | ||
902 | "\r\n"; | ||
903 | # List projects | ||
904 | foreach $progname (@prognames) { | ||
905 | ($windows_project, $type) = split ",", $progname; | ||
906 | print "Project: \"$windows_project\"=\".\\$windows_project\\$windows_project.dsp\" - Package Owner=<4>\r\n"; | ||
907 | } | ||
908 | |||
909 | "\r\n". | ||
910 | "Package=<5>\r\n". | ||
911 | "{{{\r\n". | ||
912 | "}}}\r\n". | ||
913 | "\r\n". | ||
914 | "Package=<4>\r\n". | ||
915 | "{{{\r\n". | ||
916 | "}}}\r\n". | ||
917 | "\r\n". | ||
918 | "###############################################################################\r\n". | ||
919 | "\r\n". | ||
920 | "Global:\r\n". | ||
921 | "\r\n". | ||
922 | "Package=<5>\r\n". | ||
923 | "{{{\r\n". | ||
924 | "}}}\r\n". | ||
925 | "\r\n". | ||
926 | "Package=<3>\r\n". | ||
927 | "{{{\r\n". | ||
928 | "}}}\r\n". | ||
929 | "\r\n". | ||
930 | "###############################################################################\r\n". | ||
931 | "\r\n"; | ||
932 | select STDOUT; close OUT; | ||
933 | chdir $orig_dir; | ||
934 | |||
935 | sub create_project { | ||
936 | my ($all_object_deps, $progname) = @_; | ||
937 | # Construct program's dependency info | ||
938 | %seen_objects = (); | ||
939 | %lib_files = (); | ||
940 | %source_files = (); | ||
941 | %header_files = (); | ||
942 | %resource_files = (); | ||
943 | @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib"); | ||
944 | foreach $object_file (@object_files) { | ||
945 | next if defined $seen_objects{$object_file}; | ||
946 | $seen_objects{$object_file} = 1; | ||
947 | if($object_file =~ /\.lib$/io) { | ||
948 | $lib_files{$object_file} = 1; | ||
949 | next; | ||
950 | } | ||
951 | $object_deps = $all_object_deps{$object_file}; | ||
952 | foreach $object_dep (@$object_deps) { | ||
953 | if($object_dep =~ /\.c$/io) { | ||
954 | $source_files{$object_dep} = 1; | ||
955 | next; | ||
956 | } | ||
957 | if($object_dep =~ /\.h$/io) { | ||
958 | $header_files{$object_dep} = 1; | ||
959 | next; | ||
960 | } | ||
961 | if($object_dep =~ /\.(rc|ico)$/io) { | ||
962 | $resource_files{$object_dep} = 1; | ||
963 | next; | ||
964 | } | ||
965 | } | ||
966 | } | ||
967 | $libs = join " ", sort keys %lib_files; | ||
968 | @source_files = sort keys %source_files; | ||
969 | @header_files = sort keys %header_files; | ||
970 | @resources = sort keys %resource_files; | ||
971 | ($windows_project, $type) = split ",", $progname; | ||
972 | mkdir $windows_project | ||
973 | if(! -d $windows_project); | ||
974 | chdir $windows_project; | ||
975 | $subsys = ($type eq "G") ? "windows" : "console"; | ||
976 | open OUT, ">$windows_project.dsp"; binmode OUT; select OUT; | ||
977 | |||
978 | "# Microsoft Developer Studio Project File - Name=\"$windows_project\" - Package Owner=<4>\r\n". | ||
979 | "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n". | ||
980 | "# ** DO NOT EDIT **\r\n". | ||
981 | "\r\n". | ||
982 | "# TARGTYPE \"Win32 (x86) Application\" 0x0101\r\n". | ||
983 | "\r\n". | ||
984 | "CFG=$windows_project - Win32 Debug\r\n". | ||
985 | "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n". | ||
986 | "!MESSAGE use the Export Makefile command and run\r\n". | ||
987 | "!MESSAGE \r\n". | ||
988 | "!MESSAGE NMAKE /f \"$windows_project.mak\".\r\n". | ||
989 | "!MESSAGE \r\n". | ||
990 | "!MESSAGE You can specify a configuration when running NMAKE\r\n". | ||
991 | "!MESSAGE by defining the macro CFG on the command line. For example:\r\n". | ||
992 | "!MESSAGE \r\n". | ||
993 | "!MESSAGE NMAKE /f \"$windows_project.mak\" CFG=\"$windows_project - Win32 Debug\"\r\n". | ||
994 | "!MESSAGE \r\n". | ||
995 | "!MESSAGE Possible choices for configuration are:\r\n". | ||
996 | "!MESSAGE \r\n". | ||
997 | "!MESSAGE \"$windows_project - Win32 Release\" (based on \"Win32 (x86) Application\")\r\n". | ||
998 | "!MESSAGE \"$windows_project - Win32 Debug\" (based on \"Win32 (x86) Application\")\r\n". | ||
999 | "!MESSAGE \r\n". | ||
1000 | "\r\n". | ||
1001 | "# Begin Project\r\n". | ||
1002 | "# PROP AllowPerConfigDependencies 0\r\n". | ||
1003 | "# PROP Scc_ProjName \"\"\r\n". | ||
1004 | "# PROP Scc_LocalPath \"\"\r\n". | ||
1005 | "CPP=cl.exe\r\n". | ||
1006 | "MTL=midl.exe\r\n". | ||
1007 | "RSC=rc.exe\r\n". | ||
1008 | "\r\n". | ||
1009 | "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n". | ||
1010 | "\r\n". | ||
1011 | "# PROP BASE Use_MFC 0\r\n". | ||
1012 | "# PROP BASE Use_Debug_Libraries 0\r\n". | ||
1013 | "# PROP BASE Output_Dir \"Release\"\r\n". | ||
1014 | "# PROP BASE Intermediate_Dir \"Release\"\r\n". | ||
1015 | "# PROP BASE Target_Dir \"\"\r\n". | ||
1016 | "# PROP Use_MFC 0\r\n". | ||
1017 | "# PROP Use_Debug_Libraries 0\r\n". | ||
1018 | "# PROP Output_Dir \"Release\"\r\n". | ||
1019 | "# PROP Intermediate_Dir \"Release\"\r\n". | ||
1020 | "# PROP Ignore_Export_Lib 0\r\n". | ||
1021 | "# PROP Target_Dir \"\"\r\n". | ||
1022 | "# ADD BASE CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n". | ||
1023 | "# ADD CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n". | ||
1024 | "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n". | ||
1025 | "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n". | ||
1026 | "# ADD BASE RSC /l 0x809 /d \"NDEBUG\"\r\n". | ||
1027 | "# ADD RSC /l 0x809 /d \"NDEBUG\"\r\n". | ||
1028 | "BSC32=bscmake.exe\r\n". | ||
1029 | "# ADD BASE BSC32 /nologo\r\n". | ||
1030 | "# ADD BSC32 /nologo\r\n". | ||
1031 | "LINK32=link.exe\r\n". | ||
1032 | "# 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". | ||
1033 | "# ADD LINK32 $libs /nologo /subsystem:$subsys /machine:I386\r\n". | ||
1034 | "# SUBTRACT LINK32 /pdb:none\r\n". | ||
1035 | "\r\n". | ||
1036 | "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n". | ||
1037 | "\r\n". | ||
1038 | "# PROP BASE Use_MFC 0\r\n". | ||
1039 | "# PROP BASE Use_Debug_Libraries 1\r\n". | ||
1040 | "# PROP BASE Output_Dir \"Debug\"\r\n". | ||
1041 | "# PROP BASE Intermediate_Dir \"Debug\"\r\n". | ||
1042 | "# PROP BASE Target_Dir \"\"\r\n". | ||
1043 | "# PROP Use_MFC 0\r\n". | ||
1044 | "# PROP Use_Debug_Libraries 1\r\n". | ||
1045 | "# PROP Output_Dir \"Debug\"\r\n". | ||
1046 | "# PROP Intermediate_Dir \"Debug\"\r\n". | ||
1047 | "# PROP Ignore_Export_Lib 0\r\n". | ||
1048 | "# PROP Target_Dir \"\"\r\n". | ||
1049 | "# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n". | ||
1050 | "# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n". | ||
1051 | "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n". | ||
1052 | "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n". | ||
1053 | "# ADD BASE RSC /l 0x809 /d \"_DEBUG\"\r\n". | ||
1054 | "# ADD RSC /l 0x809 /d \"_DEBUG\"\r\n". | ||
1055 | "BSC32=bscmake.exe\r\n". | ||
1056 | "# ADD BASE BSC32 /nologo\r\n". | ||
1057 | "# ADD BSC32 /nologo\r\n". | ||
1058 | "LINK32=link.exe\r\n". | ||
1059 | "# 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". | ||
1060 | "# ADD LINK32 $libs /nologo /subsystem:$subsys /debug /machine:I386 /pdbtype:sept\r\n". | ||
1061 | "# SUBTRACT LINK32 /pdb:none\r\n". | ||
1062 | "\r\n". | ||
1063 | "!ENDIF \r\n". | ||
1064 | "\r\n". | ||
1065 | "# Begin Target\r\n". | ||
1066 | "\r\n". | ||
1067 | "# Name \"$windows_project - Win32 Release\"\r\n". | ||
1068 | "# Name \"$windows_project - Win32 Debug\"\r\n". | ||
1069 | "# Begin Group \"Source Files\"\r\n". | ||
1070 | "\r\n". | ||
1071 | "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n"; | ||
1072 | foreach $source_file (@source_files) { | ||
1073 | |||
1074 | "# Begin Source File\r\n". | ||
1075 | "\r\n". | ||
1076 | "SOURCE=..\\..\\$source_file\r\n"; | ||
1077 | if($source_file =~ /ssh\.c/io) { | ||
1078 | # Disable 'Edit and continue' as Visual Studio can't handle the macros | ||
1079 | |||
1080 | "\r\n". | ||
1081 | "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n". | ||
1082 | "\r\n". | ||
1083 | "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n". | ||
1084 | "\r\n". | ||
1085 | "# ADD CPP /Zi\r\n". | ||
1086 | "\r\n". | ||
1087 | "!ENDIF \r\n". | ||
1088 | "\r\n"; | ||
1089 | } | ||
1090 | print "# End Source File\r\n"; | ||
1091 | } | ||
1092 | |||
1093 | "# End Group\r\n". | ||
1094 | "# Begin Group \"Header Files\"\r\n". | ||
1095 | "\r\n". | ||
1096 | "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n"; | ||
1097 | foreach $header_file (@header_files) { | ||
1098 | |||
1099 | "# Begin Source File\r\n". | ||
1100 | "\r\n". | ||
1101 | "SOURCE=..\\..\\$header_file\r\n". | ||
1102 | "# End Source File\r\n"; | ||
1103 | } | ||
1104 | |||
1105 | "# End Group\r\n". | ||
1106 | "# Begin Group \"Resource Files\"\r\n". | ||
1107 | "\r\n". | ||
1108 | "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n"; | ||
1109 | foreach $resource_file (@resources) { | ||
1110 | |||
1111 | "# Begin Source File\r\n". | ||
1112 | "\r\n". | ||
1113 | "SOURCE=..\\..\\$resource_file\r\n". | ||
1114 | "# End Source File\r\n"; | ||
1115 | } | ||
1116 | |||
1117 | "# End Group\r\n". | ||
1118 | "# End Target\r\n". | ||
1119 | "# End Project\r\n"; | ||
1120 | select STDOUT; close OUT; | ||
1121 | chdir ".."; | ||
1122 | } | ||
1123 | } | ||
1124 | |||
1125 | if (defined $makefiles{'gtk'}) { | ||
1126 | $mftyp = 'gtk'; | ||
1127 | $dirpfx = &dirpfx($makefiles{'gtk'}, "/"); | ||
1128 | |||
1129 | ##-- X/GTK/Unix makefile | ||
1130 | open OUT, ">$makefiles{'gtk'}"; select OUT; | ||
1131 | |||
1132 | "# Makefile for $project_name under X/GTK and Unix.\n". | ||
1133 | "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". | ||
1134 | "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; | ||
1135 | # gcc command line option is -D not /D | ||
1136 | ($_ = $help) =~ s/=\/D/=-D/gs; | ||
1137 | print $_; | ||
1138 | |||
1139 | "\n". | ||
1140 | "# You can define this path to point at your tools if you need to\n". | ||
1141 | "# TOOLPATH = /opt/gcc/bin\n". | ||
1142 | "CC := \$(TOOLPATH)\$(CC)\n". | ||
1143 | "# You can manually set this to `gtk-config' or `pkg-config gtk+-1.2'\n". | ||
1144 | "# (depending on what works on your system) if you want to enforce\n". | ||
1145 | "# building with GTK 1.2, or you can set it to `pkg-config gtk+-2.0'\n". | ||
1146 | "# if you want to enforce 2.0. The default is to try 2.0 and fall back\n". | ||
1147 | "# to 1.2 if it isn't found.\n". | ||
1148 | "GTK_CONFIG = sh -c 'pkg-config gtk+-2.0 \$\$0 2>/dev/null || gtk-config \$\$0'\n". | ||
1149 | "\n". | ||
1150 | &splitline("CFLAGS := -O2 -Wall -Werror -ansi -pedantic -g " . | ||
1151 | (join " ", map {"-I$dirpfx$_"} @srcdirs) . | ||
1152 | " `\$(GTK_CONFIG) --cflags` \$(CFLAGS)")."\n". | ||
1153 | "XLIBS = `\$(GTK_CONFIG) --libs` -lm\n". | ||
1154 | "ULIBS = -lm#\n". | ||
1155 | "INSTALL=install\n", | ||
1156 | "INSTALL_PROGRAM=\$(INSTALL)\n", | ||
1157 | "INSTALL_DATA=\$(INSTALL)\n", | ||
1158 | "prefix=/usr/local\n", | ||
1159 | "exec_prefix=\$(prefix)\n", | ||
1160 | "bindir=\$(exec_prefix)/bin\n", | ||
1161 | "gamesdir=\$(exec_prefix)/games\n", | ||
1162 | "mandir=\$(prefix)/man\n", | ||
1163 | "man1dir=\$(mandir)/man1\n", | ||
1164 | "\n"; | ||
1165 | print &splitline("all:" . join "", map { " \$(BINPREFIX)$_" } | ||
1166 | &progrealnames("X:U")); | ||
1167 | print "\n\n"; | ||
1168 | foreach $p (&prognames("X:U")) { | ||
1169 | ($prog, $type) = split ",", $p; | ||
1170 | $objstr = &objects($p, "X.o", undef, undef); | ||
1171 | print &splitline("\$(BINPREFIX)" . $prog . ": " . $objstr), "\n"; | ||
1172 | $libstr = &objects($p, undef, undef, "-lX"); | ||
1173 | print &splitline("\t\$(CC) -o \$@ $objstr $libstr \$(XLFLAGS) \$(${type}LIBS)", 69), | ||
1174 | "\n\n"; | ||
1175 | } | ||
1176 | foreach $d (&deps("X.o", undef, $dirpfx, "/")) { | ||
1177 | print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})), | ||
1178 | "\n"; | ||
1179 | $deflist = join "", map { " -D$_" } @{$d->{defs}}; | ||
1180 | print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist" . | ||
1181 | " -c \$< -o \$\@\n"; | ||
1182 | } | ||
1183 | print "\n"; | ||
1184 | print $makefile_extra{'gtk'} || ""; | ||
1185 | print "\nclean:\n". | ||
1186 | "\trm -f *.o". (join "", map { " \$(BINPREFIX)$_" } &progrealnames("X:U")) . "\n"; | ||
1187 | select STDOUT; close OUT; | ||
1188 | } | ||
1189 | |||
1190 | if (defined $makefiles{'am'}) { | ||
1191 | $mftyp = 'am'; | ||
1192 | die "Makefile.am in a subdirectory is not supported\n" | ||
1193 | if &dirpfx($makefiles{'am'}, "/") ne ""; | ||
1194 | |||
1195 | ##-- Unix/autoconf Makefile.am | ||
1196 | open OUT, ">$makefiles{'am'}"; select OUT; | ||
1197 | |||
1198 | "# Makefile.am for $project_name under Unix with Autoconf/Automake.\n". | ||
1199 | "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". | ||
1200 | "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n\n"; | ||
1201 | |||
1202 | print $makefile_extra{'am_begin'} || ""; | ||
1203 | |||
1204 | # All programs go in noinstprogs by default. If you want them | ||
1205 | # installed anywhere else, you have to also add them to | ||
1206 | # bin_PROGRAMS using '!begin am'. (Automake doesn't seem to mind | ||
1207 | # having a program name in _both_ of bin_PROGRAMS and | ||
1208 | # noinst_PROGRAMS.) | ||
1209 | @noinstprogs = (); | ||
1210 | foreach $p (&prognames("X:U")) { | ||
1211 | ($prog, $type) = split ",", $p; | ||
1212 | push @noinstprogs, $prog; | ||
1213 | } | ||
1214 | print &splitline(join " ", "noinst_PROGRAMS", "=", @noinstprogs), "\n"; | ||
1215 | |||
1216 | %objtosrc = (); | ||
1217 | %amspeciallibs = (); | ||
1218 | %amlibobjname = (); | ||
1219 | %allsources = (); | ||
1220 | foreach $d (&deps("X", undef, "", "/", "am")) { | ||
1221 | my $obj = $d->{obj}; | ||
1222 | my $use_archive = 0; | ||
1223 | |||
1224 | if (defined $d->{defs}) { | ||
1225 | # This file needs to go in an archive, so that we can | ||
1226 | # change the preprocess flags to include some -Ds | ||
1227 | $use_archive = 1; | ||
1228 | $archivecppflags{$obj} = [map { " -D$_" } @{$d->{defs}}]; | ||
1229 | } | ||
1230 | if (defined $cflags{'am'} && $cflags{'am'}->{$obj}) { | ||
1231 | # This file needs to go in an archive, so that we can | ||
1232 | # change the compile flags as specified in Recipe | ||
1233 | $use_archive = 1; | ||
1234 | $archivecflags{$obj} = [$cflags{'am'}->{$obj}]; | ||
1235 | } | ||
1236 | if ($use_archive) { | ||
1237 | $amspeciallibs{$obj} = "lib${obj}.a"; | ||
1238 | $amlibobjname{$obj} = "lib${obj}_a-" . | ||
1239 | basename($d->{deps}->[0], ".c", ".m") . | ||
1240 | ".\$(OBJEXT)"; | ||
1241 | } | ||
1242 | $objtosrc{$obj} = $d->{deps}; | ||
1243 | map { $allsources{$_} = 1 } @{$d->{deps}}; | ||
1244 | } | ||
1245 | |||
1246 | # 2014-02-22: as of automake-1.14 we begin to get complained at if | ||
1247 | # we don't use this option | ||
1248 | print "AUTOMAKE_OPTIONS = subdir-objects\n\n"; | ||
1249 | |||
1250 | # Complete list of source and header files. Not used by the | ||
1251 | # auto-generated parts of this makefile, but Recipe might like to | ||
1252 | # have it available as a variable so that mandatory-rebuild things | ||
1253 | # (version.o) can conveniently be made to depend on it. | ||
1254 | print &splitline(join " ", "allsources", "=", | ||
1255 | sort {$a cmp $b} keys %allsources), "\n\n"; | ||
1256 | |||
1257 | @amcppflags = map {"-I\$(srcdir)/$_"} @srcdirs; | ||
1258 | print &splitline(join " ", "AM_CPPFLAGS", "=", @amcppflags, "\n"); | ||
1259 | |||
1260 | @amcflags = ("\$(GTK_CFLAGS)", "\$(WARNINGOPTS)"); | ||
1261 | print &splitline(join " ", "AM_CFLAGS", "=", @amcflags), "\n"; | ||
1262 | |||
1263 | %amlibsused = (); | ||
1264 | foreach $p (&prognames("X:U")) { | ||
1265 | ($prog, $type) = split ",", $p; | ||
1266 | @progsources = ("${prog}_SOURCES", "="); | ||
1267 | %sourcefiles = (); | ||
1268 | @ldadd = (); | ||
1269 | $objstr = &objects($p, "X", undef, undef); | ||
1270 | foreach $obj (split / /,$objstr) { | ||
1271 | if ($amspeciallibs{$obj}) { | ||
1272 | $amlibsused{$obj} = 1; | ||
1273 | push @ldadd, $amlibobjname{$obj}; | ||
1274 | } else { | ||
1275 | map { $sourcefiles{$_} = 1 } @{$objtosrc{$obj}}; | ||
1276 | } | ||
1277 | } | ||
1278 | push @progsources, sort { $a cmp $b } keys %sourcefiles; | ||
1279 | print &splitline(join " ", @progsources), "\n"; | ||
1280 | if ($type eq "X") { | ||
1281 | push @ldadd, "\$(GTK_LIBS)"; | ||
1282 | } | ||
1283 | push @ldadd, "-lm"; | ||
1284 | print &splitline(join " ", "${prog}_LDADD", "=", @ldadd), "\n"; | ||
1285 | print "\n"; | ||
1286 | } | ||
1287 | |||
1288 | foreach $obj (sort { $a cmp $b } keys %amlibsused) { | ||
1289 | print &splitline(join " ", "lib${obj}_a_SOURCES", "=", | ||
1290 | @{$objtosrc{$obj}}), "\n"; | ||
1291 | print &splitline(join " ", "lib${obj}_a_CPPFLAGS", "=", | ||
1292 | @amcflags, @{$archivecppflags{$obj}}), "\n" | ||
1293 | if $archivecppflags{$obj}; | ||
1294 | print &splitline(join " ", "lib${obj}_a_CFLAGS", "=", | ||
1295 | @amcflags, @{$archivecflags{$obj}}), "\n" | ||
1296 | if $archivecflags{$obj}; | ||
1297 | } | ||
1298 | print &splitline(join " ", "noinst_LIBRARIES", "=", | ||
1299 | sort { $a cmp $b } | ||
1300 | map { $amspeciallibs{$_} } | ||
1301 | keys %amlibsused), | ||
1302 | "\n\n"; | ||
1303 | |||
1304 | print $makefile_extra{'am'} || ""; | ||
1305 | select STDOUT; close OUT; | ||
1306 | } | ||
1307 | |||
1308 | if (defined $makefiles{'mpw'}) { | ||
1309 | $mftyp = 'mpw'; | ||
1310 | ##-- MPW Makefile | ||
1311 | open OUT, ">$makefiles{'mpw'}"; select OUT; | ||
1312 | |||
1313 | "# Makefile for $project_name under MPW.\n#\n". | ||
1314 | "# This file was created by `mkfiles.pl' from the `Recipe' file.\n". | ||
1315 | "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; | ||
1316 | # MPW command line option is -d not /D | ||
1317 | ($_ = $help) =~ s/=\/D/=-d /gs; | ||
1318 | print $_; | ||
1319 | print "\n\n". | ||
1320 | "ROptions = `Echo \"{VER}\" | StreamEdit -e \"1,\$ replace /=(\xc5)\xa81\xb0/ 'STR=\xb6\xb6\xb6\xb6\xb6\"' \xa81 '\xb6\xb6\xb6\xb6\xb6\"'\"`". | ||
1321 | "\n". | ||
1322 | "C_68K = {C}\n". | ||
1323 | "C_CFM68K = {C}\n". | ||
1324 | "C_PPC = {PPCC}\n". | ||
1325 | "C_Carbon = {PPCC}\n". | ||
1326 | "\n". | ||
1327 | "# -w 35 disables \"unused parameter\" warnings\n". | ||
1328 | "COptions = -i : -i :: -i ::charset -w 35 -w err -proto strict -ansi on \xb6\n". | ||
1329 | " -notOnce\n". | ||
1330 | "COptions_68K = {COptions} -model far -opt time\n". | ||
1331 | "# Enabling \"-opt space\" for CFM-68K gives me undefined references to\n". | ||
1332 | "# _\$LDIVT and _\$LMODT.\n". | ||
1333 | "COptions_CFM68K = {COptions} -model cfmSeg -opt time\n". | ||
1334 | "COptions_PPC = {COptions} -opt size -traceback\n". | ||
1335 | "COptions_Carbon = {COptions} -opt size -traceback -d TARGET_API_MAC_CARBON\n". | ||
1336 | "\n". | ||
1337 | "Link_68K = ILink\n". | ||
1338 | "Link_CFM68K = ILink\n". | ||
1339 | "Link_PPC = PPCLink\n". | ||
1340 | "Link_Carbon = PPCLink\n". | ||
1341 | "\n". | ||
1342 | "LinkOptions = -c 'pTTY'\n". | ||
1343 | "LinkOptions_68K = {LinkOptions} -br 68k -model far -compact\n". | ||
1344 | "LinkOptions_CFM68K = {LinkOptions} -br 020 -model cfmseg -compact\n". | ||
1345 | "LinkOptions_PPC = {LinkOptions}\n". | ||
1346 | "LinkOptions_Carbon = -m __appstart -w {LinkOptions}\n". | ||
1347 | "\n". | ||
1348 | "Libs_68K = \"{CLibraries}StdCLib.far.o\" \xb6\n". | ||
1349 | " \"{Libraries}MacRuntime.o\" \xb6\n". | ||
1350 | " \"{Libraries}MathLib.far.o\" \xb6\n". | ||
1351 | " \"{Libraries}IntEnv.far.o\" \xb6\n". | ||
1352 | " \"{Libraries}Interface.o\" \xb6\n". | ||
1353 | " \"{Libraries}Navigation.far.o\" \xb6\n". | ||
1354 | " \"{Libraries}OpenTransport.o\" \xb6\n". | ||
1355 | " \"{Libraries}OpenTransportApp.o\" \xb6\n". | ||
1356 | " \"{Libraries}OpenTptInet.o\" \xb6\n". | ||
1357 | " \"{Libraries}UnicodeConverterLib.far.o\"\n". | ||
1358 | "\n". | ||
1359 | "Libs_CFM = \"{SharedLibraries}InterfaceLib\" \xb6\n". | ||
1360 | " \"{SharedLibraries}StdCLib\" \xb6\n". | ||
1361 | " \"{SharedLibraries}AppearanceLib\" \xb6\n". | ||
1362 | " -weaklib AppearanceLib \xb6\n". | ||
1363 | " \"{SharedLibraries}NavigationLib\" \xb6\n". | ||
1364 | " -weaklib NavigationLib \xb6\n". | ||
1365 | " \"{SharedLibraries}TextCommon\" \xb6\n". | ||
1366 | " -weaklib TextCommon \xb6\n". | ||
1367 | " \"{SharedLibraries}UnicodeConverter\" \xb6\n". | ||
1368 | " -weaklib UnicodeConverter\n". | ||
1369 | "\n". | ||
1370 | "Libs_CFM68K = {Libs_CFM} \xb6\n". | ||
1371 | " \"{CFM68KLibraries}NuMacRuntime.o\"\n". | ||
1372 | "\n". | ||
1373 | "Libs_PPC = {Libs_CFM} \xb6\n". | ||
1374 | " \"{SharedLibraries}ControlsLib\" \xb6\n". | ||
1375 | " -weaklib ControlsLib \xb6\n". | ||
1376 | " \"{SharedLibraries}WindowsLib\" \xb6\n". | ||
1377 | " -weaklib WindowsLib \xb6\n". | ||
1378 | " \"{SharedLibraries}OpenTransportLib\" \xb6\n". | ||
1379 | " -weaklib OTClientLib \xb6\n". | ||
1380 | " -weaklib OTClientUtilLib \xb6\n". | ||
1381 | " \"{SharedLibraries}OpenTptInternetLib\" \xb6\n". | ||
1382 | " -weaklib OTInetClientLib \xb6\n". | ||
1383 | " \"{PPCLibraries}StdCRuntime.o\" \xb6\n". | ||
1384 | " \"{PPCLibraries}PPCCRuntime.o\" \xb6\n". | ||
1385 | " \"{PPCLibraries}CarbonAccessors.o\" \xb6\n". | ||
1386 | " \"{PPCLibraries}OpenTransportAppPPC.o\" \xb6\n". | ||
1387 | " \"{PPCLibraries}OpenTptInetPPC.o\"\n". | ||
1388 | "\n". | ||
1389 | "Libs_Carbon = \"{PPCLibraries}CarbonStdCLib.o\" \xb6\n". | ||
1390 | " \"{PPCLibraries}StdCRuntime.o\" \xb6\n". | ||
1391 | " \"{PPCLibraries}PPCCRuntime.o\" \xb6\n". | ||
1392 | " \"{SharedLibraries}CarbonLib\" \xb6\n". | ||
1393 | " \"{SharedLibraries}StdCLib\"\n". | ||
1394 | "\n"; | ||
1395 | print &splitline("all \xc4 " . join(" ", &progrealnames("M")), undef, "\xb6"); | ||
1396 | print "\n\n"; | ||
1397 | foreach $p (&prognames("M")) { | ||
1398 | ($prog, $type) = split ",", $p; | ||
1399 | |||
1400 | print &splitline("$prog \xc4 $prog.68k $prog.ppc $prog.carbon", | ||
1401 | undef, "\xb6"), "\n\n"; | ||
1402 | |||
1403 | $rsrc = &objects($p, "", "X.rsrc", undef); | ||
1404 | |||
1405 | foreach $arch (qw(68K CFM68K PPC Carbon)) { | ||
1406 | $objstr = &objects($p, "X.\L$arch\E.o", "", undef); | ||
1407 | print &splitline("$prog.\L$arch\E \xc4 $objstr $rsrc", undef, "\xb6"); | ||
1408 | print "\n"; | ||
1409 | print &splitline("\tDuplicate -y $rsrc {Targ}", 69, "\xb6"), "\n"; | ||
1410 | print &splitline("\t{Link_$arch} -o {Targ} -fragname $prog " . | ||
1411 | "{LinkOptions_$arch} " . | ||
1412 | $objstr . " {Libs_$arch}", 69, "\xb6"), "\n"; | ||
1413 | print &splitline("\tSetFile -a BMi {Targ}", 69, "\xb6"), "\n\n"; | ||
1414 | } | ||
1415 | |||
1416 | } | ||
1417 | foreach $d (&deps("", "X.rsrc", "::", ":")) { | ||
1418 | next unless $d->{obj}; | ||
1419 | print &splitline(sprintf("%s \xc4 %s", $d->{obj}, join " ", @{$d->{deps}}), | ||
1420 | undef, "\xb6"), "\n"; | ||
1421 | print "\tRez ", $d->{deps}->[0], " -o {Targ} {ROptions}\n\n"; | ||
1422 | } | ||
1423 | foreach $arch (qw(68K CFM68K)) { | ||
1424 | foreach $d (&deps("X.\L$arch\E.o", "", "::", ":")) { | ||
1425 | next unless $d->{obj}; | ||
1426 | print &splitline(sprintf("%s \xc4 %s", $d->{obj}, | ||
1427 | join " ", @{$d->{deps}}), | ||
1428 | undef, "\xb6"), "\n"; | ||
1429 | print "\t{C_$arch} ", $d->{deps}->[0], | ||
1430 | " -o {Targ} {COptions_$arch}\n\n"; | ||
1431 | } | ||
1432 | } | ||
1433 | foreach $arch (qw(PPC Carbon)) { | ||
1434 | foreach $d (&deps("X.\L$arch\E.o", "", "::", ":")) { | ||
1435 | next unless $d->{obj}; | ||
1436 | print &splitline(sprintf("%s \xc4 %s", $d->{obj}, | ||
1437 | join " ", @{$d->{deps}}), | ||
1438 | undef, "\xb6"), "\n"; | ||
1439 | # The odd stuff here seems to stop afpd getting confused. | ||
1440 | print "\techo -n > {Targ}\n"; | ||
1441 | print "\tsetfile -t XCOF {Targ}\n"; | ||
1442 | print "\t{C_$arch} ", $d->{deps}->[0], | ||
1443 | " -o {Targ} {COptions_$arch}\n\n"; | ||
1444 | } | ||
1445 | } | ||
1446 | select STDOUT; close OUT; | ||
1447 | } | ||
1448 | |||
1449 | if (defined $makefiles{'lcc'}) { | ||
1450 | $mftyp = 'lcc'; | ||
1451 | $dirpfx = &dirpfx($makefiles{'lcc'}, "\\"); | ||
1452 | |||
1453 | ##-- lcc makefile | ||
1454 | open OUT, ">$makefiles{'lcc'}"; select OUT; | ||
1455 | |||
1456 | "# Makefile for $project_name under lcc.\n". | ||
1457 | "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". | ||
1458 | "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; | ||
1459 | # lcc command line option is -D not /D | ||
1460 | ($_ = $help) =~ s/=\/D/=-D/gs; | ||
1461 | print $_; | ||
1462 | |||
1463 | "\n". | ||
1464 | "# If you rename this file to `Makefile', you should change this line,\n". | ||
1465 | "# so that the .rsp files still depend on the correct makefile.\n". | ||
1466 | "MAKEFILE = Makefile.lcc\n". | ||
1467 | "\n". | ||
1468 | "# C compilation flags\n". | ||
1469 | "CFLAGS = -D_WINDOWS " . | ||
1470 | (join " ", map {"-I$dirpfx$_"} @srcdirs) . | ||
1471 | "\n". | ||
1472 | "\n". | ||
1473 | "# Get include directory for resource compiler\n". | ||
1474 | "\n"; | ||
1475 | print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C")); | ||
1476 | print "\n\n"; | ||
1477 | foreach $p (&prognames("G:C")) { | ||
1478 | ($prog, $type) = split ",", $p; | ||
1479 | $objstr = &objects($p, "X.obj", "X.res", undef); | ||
1480 | print &splitline("$prog.exe: " . $objstr ), "\n"; | ||
1481 | $subsystemtype = undef; | ||
1482 | if ($type eq "G") { $subsystemtype = "-subsystem windows"; } | ||
1483 | my $libss = "shell32.lib wsock32.lib ws2_32.lib winspool.lib winmm.lib imm32.lib"; | ||
1484 | print &splitline("\tlcclnk $subsystemtype -o $prog.exe $objstr $libss"); | ||
1485 | print "\n\n"; | ||
1486 | } | ||
1487 | |||
1488 | foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\")) { | ||
1489 | print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})), | ||
1490 | "\n"; | ||
1491 | if ($d->{obj} =~ /\.res$/) { | ||
1492 | print &splitline("\tlrc \$(FWHACK) \$(RCFL) -r \$*.rc",69)."\n"; | ||
1493 | } else { | ||
1494 | $deflist = join "", map { " -D$_" } @{$d->{defs}}; | ||
1495 | print &splitline("\tlcc -O -p6 \$(COMPAT) \$(FWHACK) \$(CFLAGS)". | ||
1496 | " \$(XFLAGS)$deflist ".$d->{deps}->[0]." -o \$\@",69)."\n"; | ||
1497 | } | ||
1498 | } | ||
1499 | print "\n"; | ||
1500 | print $makefile_extra{'lcc'} || ""; | ||
1501 | print "\nclean:\n". | ||
1502 | "\t-del *.obj\n". | ||
1503 | "\t-del *.exe\n". | ||
1504 | "\t-del *.res\n"; | ||
1505 | |||
1506 | select STDOUT; close OUT; | ||
1507 | } | ||
1508 | |||
1509 | if (defined $makefiles{'nestedvm'}) { | ||
1510 | $mftyp = 'nestedvm'; | ||
1511 | $dirpfx = &dirpfx($makefiles{'nestedvm'}, "/"); | ||
1512 | |||
1513 | ##-- NestedVM makefile | ||
1514 | open OUT, ">$makefiles{'nestedvm'}"; select OUT; | ||
1515 | |||
1516 | "# Makefile for $project_name under NestedVM.\n". | ||
1517 | "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". | ||
1518 | "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; | ||
1519 | # gcc command line option is -D not /D | ||
1520 | ($_ = $help) =~ s/=\/D/=-D/gs; | ||
1521 | print $_; | ||
1522 | |||
1523 | "\n". | ||
1524 | "# This path points at the nestedvm root directory\n". | ||
1525 | "NESTEDVM = /opt/nestedvm\n". | ||
1526 | "# You can define this path to point at your tools if you need to\n". | ||
1527 | "TOOLPATH = \$(NESTEDVM)/upstream/install/bin\n". | ||
1528 | "CC = \$(TOOLPATH)/mips-unknown-elf-gcc\n". | ||
1529 | "\n". | ||
1530 | &splitline("CFLAGS = -O2 -Wall -Werror -DSLOW_SYSTEM -g " . | ||
1531 | (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n". | ||
1532 | "\n"; | ||
1533 | print &splitline("all:" . join "", map { " $_.jar" } &progrealnames("X")); | ||
1534 | print "\n\n"; | ||
1535 | foreach $p (&prognames("X")) { | ||
1536 | ($prog, $type) = split ",", $p; | ||
1537 | $objstr = &objects($p, "X.o", undef, undef); | ||
1538 | $objstr =~ s/gtk\.o/nestedvm\.o/g; | ||
1539 | print &splitline($prog . ".mips: " . $objstr), "\n"; | ||
1540 | $libstr = &objects($p, undef, undef, "-lX"); | ||
1541 | print &splitline("\t\$(CC) \$(${type}LDFLAGS) -o \$@ " . | ||
1542 | $objstr . " $libstr -lm", 69), "\n\n"; | ||
1543 | } | ||
1544 | foreach $d (&deps("X.o", undef, $dirpfx, "/")) { | ||
1545 | $oobjs = $d->{obj}; | ||
1546 | $ddeps= join " ", @{$d->{deps}}; | ||
1547 | $oobjs =~ s/gtk/nestedvm/g; | ||
1548 | $ddeps =~ s/gtk/nestedvm/g; | ||
1549 | print &splitline(sprintf("%s: %s", $oobjs, $ddeps)), | ||
1550 | "\n"; | ||
1551 | $deflist = join "", map { " -D$_" } @{$d->{defs}}; | ||
1552 | print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist" . | ||
1553 | " -c \$< -o \$\@\n"; | ||
1554 | } | ||
1555 | print "\n"; | ||
1556 | print $makefile_extra{'nestedvm'} || ""; | ||
1557 | print "\nclean:\n". | ||
1558 | "\trm -rf *.o *.mips *.class *.html *.jar org applet.manifest\n"; | ||
1559 | select STDOUT; close OUT; | ||
1560 | } | ||
1561 | |||
1562 | if (defined $makefiles{'osx'}) { | ||
1563 | $mftyp = 'osx'; | ||
1564 | $dirpfx = &dirpfx($makefiles{'osx'}, "/"); | ||
1565 | @osxarchs = ('i386'); | ||
1566 | |||
1567 | ##-- Mac OS X makefile | ||
1568 | open OUT, ">$makefiles{'osx'}"; select OUT; | ||
1569 | |||
1570 | "# Makefile for $project_name under Mac OS X.\n". | ||
1571 | "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". | ||
1572 | "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; | ||
1573 | # gcc command line option is -D not /D | ||
1574 | ($_ = $help) =~ s/=\/D/=-D/gs; | ||
1575 | print $_; | ||
1576 | |||
1577 | "CC = \$(TOOLPATH)gcc\n". | ||
1578 | "LIPO = \$(TOOLPATH)lipo\n". | ||
1579 | "\n". | ||
1580 | &splitline("CFLAGS = -O2 -Wall -Werror -g " . | ||
1581 | (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n". | ||
1582 | "LDFLAGS = -framework Cocoa\n". | ||
1583 | &splitline("all:" . join "", map { " $_" } &progrealnames("MX:U")) . | ||
1584 | "\n"; | ||
1585 | print $makefile_extra{'osx'} || ""; | ||
1586 | print "\n". | ||
1587 | ".SUFFIXES: .o .c .m\n". | ||
1588 | "\n"; | ||
1589 | print "\n\n"; | ||
1590 | foreach $p (&prognames("MX")) { | ||
1591 | ($prog, $type) = split ",", $p; | ||
1592 | $icon = &special($p, ".icns"); | ||
1593 | $infoplist = &special($p, "info.plist"); | ||
1594 | print "${prog}.app:\n\tmkdir -p \$\@\n"; | ||
1595 | print "${prog}.app/Contents: ${prog}.app\n\tmkdir -p \$\@\n"; | ||
1596 | print "${prog}.app/Contents/MacOS: ${prog}.app/Contents\n\tmkdir -p \$\@\n"; | ||
1597 | $targets = "${prog}.app/Contents/MacOS/$prog"; | ||
1598 | if (defined $icon) { | ||
1599 | print "${prog}.app/Contents/Resources: ${prog}.app/Contents\n\tmkdir -p \$\@\n"; | ||
1600 | print "${prog}.app/Contents/Resources/${prog}.icns: ${prog}.app/Contents/Resources $icon\n\tcp $icon \$\@\n"; | ||
1601 | $targets .= " ${prog}.app/Contents/Resources/${prog}.icns"; | ||
1602 | } | ||
1603 | if (defined $infoplist) { | ||
1604 | print "${prog}.app/Contents/Info.plist: ${prog}.app/Contents/Resources $infoplist\n\tcp $infoplist \$\@\n"; | ||
1605 | $targets .= " ${prog}.app/Contents/Info.plist"; | ||
1606 | } | ||
1607 | $targets .= " \$(${prog}_extra)"; | ||
1608 | print &splitline("${prog}: $targets", 69) . "\n\n"; | ||
1609 | $libstr = &objects($p, undef, undef, "-lX"); | ||
1610 | $archbins = ""; | ||
1611 | foreach $arch (@osxarchs) { | ||
1612 | $objstr = &objects($p, "X.${arch}.o", undef, undef); | ||
1613 | print &splitline("${prog}.${arch}.bin: " . $objstr), "\n"; | ||
1614 | print &splitline("\t\$(CC) -arch ${arch} -mmacosx-version-min=10.4 \$(LDFLAGS) -o \$@ " . | ||
1615 | $objstr . " $libstr", 69), "\n\n"; | ||
1616 | $archbins .= " ${prog}.${arch}.bin"; | ||
1617 | } | ||
1618 | print &splitline("${prog}.app/Contents/MacOS/$prog: ". | ||
1619 | "${prog}.app/Contents/MacOS" . $archbins), "\n"; | ||
1620 | print &splitline("\t\$(LIPO) -create $archbins -output \$@", 69), "\n\n"; | ||
1621 | } | ||
1622 | foreach $p (&prognames("U")) { | ||
1623 | ($prog, $type) = split ",", $p; | ||
1624 | $libstr = &objects($p, undef, undef, "-lX"); | ||
1625 | $archbins = ""; | ||
1626 | foreach $arch (@osxarchs) { | ||
1627 | $objstr = &objects($p, "X.${arch}.o", undef, undef); | ||
1628 | print &splitline("${prog}.${arch}: " . $objstr), "\n"; | ||
1629 | print &splitline("\t\$(CC) -arch ${arch} -mmacosx-version-min=10.4 \$(ULDFLAGS) -o \$@ " . | ||
1630 | $objstr . " $libstr", 69), "\n\n"; | ||
1631 | $archbins .= " ${prog}.${arch}"; | ||
1632 | } | ||
1633 | print &splitline("${prog}:" . $archbins), "\n"; | ||
1634 | print &splitline("\t\$(LIPO) -create $archbins -output \$@", 69), "\n\n"; | ||
1635 | } | ||
1636 | foreach $arch (@osxarchs) { | ||
1637 | foreach $d (&deps("X.${arch}.o", undef, $dirpfx, "/")) { | ||
1638 | print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})), | ||
1639 | "\n"; | ||
1640 | $deflist = join "", map { " -D$_" } @{$d->{defs}}; | ||
1641 | if ($d->{deps}->[0] =~ /\.m$/) { | ||
1642 | print "\t\$(CC) -arch $arch -mmacosx-version-min=10.4 -x objective-c \$(COMPAT) \$(FWHACK) \$(CFLAGS)". | ||
1643 | " \$(XFLAGS)$deflist -c \$< -o \$\@\n"; | ||
1644 | } else { | ||
1645 | print "\t\$(CC) -arch $arch -mmacosx-version-min=10.4 \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist" . | ||
1646 | " -c \$< -o \$\@\n"; | ||
1647 | } | ||
1648 | } | ||
1649 | } | ||
1650 | print "\nclean:\n". | ||
1651 | "\trm -f *.o *.dmg". (join "", map { my $a=$_; (" $a", map { " ${a}.$_" } @osxarchs) } &progrealnames("U")) . "\n". | ||
1652 | "\trm -rf *.app\n"; | ||
1653 | select STDOUT; close OUT; | ||
1654 | } | ||
1655 | |||
1656 | if (defined $makefiles{'gnustep'}) { | ||
1657 | $mftyp = 'gnustep'; | ||
1658 | $dirpfx = &dirpfx($makefiles{'gnustep'}, "/"); | ||
1659 | |||
1660 | ##-- GNUstep makefile (use with 'gs_make -f Makefile.gnustep') | ||
1661 | |||
1662 | # This is a pretty evil way to do things. In an ideal world, I'd | ||
1663 | # use the approved GNUstep makefile mechanism which just defines a | ||
1664 | # variable or two saying what source files go into what binary and | ||
1665 | # then includes application.make. Unfortunately, that has the | ||
1666 | # automake-ish limitation that it doesn't let you choose different | ||
1667 | # command lines for each object, so I can't arrange for all those | ||
1668 | # files with -DTHIS and -DTHAT to Just Work. | ||
1669 | # | ||
1670 | # A simple if ugly fix would be to have mkfiles.pl construct a | ||
1671 | # directory full of stub C files of the form '#define thing', | ||
1672 | # '#include "real_source_file"', and then reference those in this | ||
1673 | # makefile. That would also make it easy to build a proper | ||
1674 | # automake makefile. | ||
1675 | open OUT, ">$makefiles{'gnustep'}"; select OUT; | ||
1676 | |||
1677 | "# Makefile for $project_name under GNUstep.\n". | ||
1678 | "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". | ||
1679 | "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; | ||
1680 | # gcc command line option is -D not /D | ||
1681 | ($_ = $help) =~ s/=\/D/=-D/gs; | ||
1682 | print $_; | ||
1683 | |||
1684 | "NEEDS_GUI=yes\n". | ||
1685 | "include \$(GNUSTEP_MAKEFILES)/common.make\n". | ||
1686 | "include \$(GNUSTEP_MAKEFILES)/rules.make\n". | ||
1687 | "include \$(GNUSTEP_MAKEFILES)/Instance/rules.make\n". | ||
1688 | "\n". | ||
1689 | &splitline("all::" . join "", map { " $_" } &progrealnames("MX:U")) . | ||
1690 | "\n"; | ||
1691 | print $makefile_extra{'gnustep'} || ""; | ||
1692 | print "\n". | ||
1693 | ".SUFFIXES: .o .c .m\n". | ||
1694 | "\n"; | ||
1695 | print "\n\n"; | ||
1696 | foreach $p (&prognames("MX")) { | ||
1697 | ($prog, $type) = split ",", $p; | ||
1698 | $icon = &special($p, ".icns"); | ||
1699 | $infoplist = &special($p, "info.plist"); | ||
1700 | print "${prog}.app:\n\tmkdir -p \$\@\n"; | ||
1701 | $targets = "${prog}.app ${prog}.app/$prog"; | ||
1702 | if (defined $icon) { | ||
1703 | print "${prog}.app/Resources: ${prog}.app\n\tmkdir -p \$\@\n"; | ||
1704 | print "${prog}.app/Resources/${prog}.icns: ${prog}.app/Resources $icon\n\tcp $icon \$\@\n"; | ||
1705 | $targets .= " ${prog}.app/Resources/${prog}.icns"; | ||
1706 | } | ||
1707 | if (defined $infoplist) { | ||
1708 | print "${prog}.app/Info.plist: ${prog}.app $infoplist\n\tcp $infoplist \$\@\n"; | ||
1709 | $targets .= " ${prog}.app/Info.plist"; | ||
1710 | } | ||
1711 | $targets .= " \$(${prog}_extra)"; | ||
1712 | print &splitline("${prog}: $targets", 69) . "\n\n"; | ||
1713 | $libstr = &objects($p, undef, undef, "-lX"); | ||
1714 | $objstr = &objects($p, "X.o", undef, undef); | ||
1715 | print &splitline("${prog}.app/$prog: " . $objstr), "\n"; | ||
1716 | print &splitline("\t\$(CC) \$(ALL_LDFLAGS) -o \$@ " . $objstr . " \$(ALL_LIB_DIRS) $libstr \$(ALL_LIBS)", 69), "\n\n"; | ||
1717 | } | ||
1718 | foreach $p (&prognames("U")) { | ||
1719 | ($prog, $type) = split ",", $p; | ||
1720 | $libstr = &objects($p, undef, undef, "-lX"); | ||
1721 | $objstr = &objects($p, "X.o", undef, undef); | ||
1722 | print &splitline("${prog}: " . $objstr), "\n"; | ||
1723 | print &splitline("\t\$(CC) \$(ULDFLAGS) -o \$@ " . $objstr . " $libstr", 69), "\n\n"; | ||
1724 | } | ||
1725 | foreach $d (&deps("X.o", undef, $dirpfx, "/")) { | ||
1726 | print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})), | ||
1727 | "\n"; | ||
1728 | $deflist = join "", map { " -D$_" } @{$d->{defs}}; | ||
1729 | if ($d->{deps}->[0] =~ /\.m$/) { | ||
1730 | print "\t\$(CC) -DGNUSTEP \$(ALL_OBJCFLAGS) \$(COMPAT) \$(FWHACK) \$(OBJCFLAGS)". | ||
1731 | " \$(XFLAGS)$deflist -c \$< -o \$\@\n"; | ||
1732 | } else { | ||
1733 | print "\t\$(CC) \$(ALL_CFLAGS) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist" . | ||
1734 | " -c \$< -o \$\@\n"; | ||
1735 | } | ||
1736 | } | ||
1737 | print "\nclean::\n". | ||
1738 | "\trm -f *.o ". (join " ", &progrealnames("U")) . "\n". | ||
1739 | "\trm -rf *.app\n"; | ||
1740 | select STDOUT; close OUT; | ||
1741 | } | ||
1742 | |||
1743 | if (defined $makefiles{'emcc'}) { | ||
1744 | $mftyp = 'emcc'; | ||
1745 | $dirpfx = &dirpfx($makefiles{'emcc'}, "/"); | ||
1746 | |||
1747 | ##-- Makefile for building Javascript puzzles via Emscripten | ||
1748 | |||
1749 | open OUT, ">$makefiles{'emcc'}"; select OUT; | ||
1750 | |||
1751 | "# Makefile for $project_name using Emscripten. Requires GNU make.\n". | ||
1752 | "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". | ||
1753 | "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; | ||
1754 | # emcc command line option is -D not /D | ||
1755 | ($_ = $help) =~ s/=\/D/=-D/gs; | ||
1756 | print $_; | ||
1757 | |||
1758 | "\n". | ||
1759 | "# This can be set on the command line to point at the emcc command,\n". | ||
1760 | "# if it is not on your PATH.\n". | ||
1761 | "EMCC = emcc\n". | ||
1762 | "\n". | ||
1763 | &splitline("CFLAGS = -DSLOW_SYSTEM " . | ||
1764 | (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n". | ||
1765 | "\n"; | ||
1766 | $output_js_files = join "", map { " \$(OUTPREFIX)$_.js" } &progrealnames("X"); | ||
1767 | print &splitline("all:" . $output_js_files); | ||
1768 | print "\n\n"; | ||
1769 | foreach $p (&prognames("X")) { | ||
1770 | ($prog, $type) = split ",", $p; | ||
1771 | $objstr = &objects($p, "X.o", undef, undef); | ||
1772 | $objstr =~ s/gtk\.o/emcc\.o/g; | ||
1773 | print &splitline("\$(OUTPREFIX)" . $prog . ".js: " . $objstr . " emccpre.js emcclib.js emccx.json"), "\n"; | ||
1774 | print "\t\$(EMCC) -o \$(OUTPREFIX)".$prog.".js ". | ||
1775 | "-O2 ". | ||
1776 | "-s ASM_JS=1 ". | ||
1777 | "--pre-js emccpre.js ". | ||
1778 | "--js-library emcclib.js ". | ||
1779 | "-s EXPORTED_FUNCTIONS=\"`sed 's://.*::' emccx.json | tr -d ' \\n'`\" " . $objstr . "\n\n"; | ||
1780 | } | ||
1781 | foreach $d (&deps("X.o", undef, $dirpfx, "/")) { | ||
1782 | $oobjs = $d->{obj}; | ||
1783 | $ddeps= join " ", @{$d->{deps}}; | ||
1784 | $oobjs =~ s/gtk/emcc/g; | ||
1785 | $ddeps =~ s/gtk/emcc/g; | ||
1786 | print &splitline(sprintf("%s: %s", $oobjs, $ddeps)), | ||
1787 | "\n"; | ||
1788 | $deflist = join "", map { " -D$_" } @{$d->{defs}}; | ||
1789 | print "\t\$(EMCC) \$(CFLAGS) \$(XFLAGS)$deflist" . | ||
1790 | " -c \$< -o \$\@\n"; | ||
1791 | } | ||
1792 | print "\n"; | ||
1793 | print $makefile_extra{'emcc'} || ""; | ||
1794 | print "\nclean:\n". | ||
1795 | "\trm -rf *.o $output_js_files\n"; | ||
1796 | select STDOUT; close OUT; | ||
1797 | } | ||
1798 | |||
1799 | # All done, so do the Unix postprocessing if asked to. | ||
1800 | |||
1801 | if ($do_unix) { | ||
1802 | chdir $orig_dir; | ||
1803 | system "./mkauto.sh"; | ||
1804 | die "mkfiles.pl: mkauto.sh returned $?\n" if $? > 0; | ||
1805 | system "./configure", @confargs; | ||
1806 | die "mkfiles.pl: configure returned $?\n" if $? > 0; | ||
1807 | } | ||