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