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