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