3 # Cross-platform Makefile generator.
\r
5 # Reads the file `Recipe' to determine the list of generated
\r
6 # executables and their component objects. Then reads the source
\r
7 # files to compute #include dependencies. Finally, writes out the
\r
8 # various target Makefiles.
\r
10 # PuTTY specifics which could still do with removing:
\r
11 # - Mac makefile is not portabilised at all. Include directories
\r
12 # are hardwired, and also the libraries are fixed. This is
\r
13 # mainly because I was too scared to go anywhere near it.
\r
14 # - sbcsgen.pl is still run at startup.
\r
16 # FIXME: no attempt made to handle !forceobj in the project files.
\r
23 if ($#ARGV >= 0 and ($ARGV[0] eq "-u" or $ARGV[0] eq "-U")) {
\r
24 # Convenience for Unix users: -u means that after we finish what
\r
25 # we're doing here, we also run mkauto.sh and then 'configure' in
\r
26 # the Unix subdirectory. So it's a one-stop shop for regenerating
\r
27 # the actual end-product Unix makefile.
\r
29 # Arguments supplied after -u go to configure.
\r
31 # -U is identical, but runs 'configure' at the _top_ level, for
\r
32 # people who habitually do that.
\r
33 $do_unix = ($ARGV[0] eq "-U" ? 2 : 1);
\r
38 open IN, "Recipe" or do {
\r
39 # We want to deal correctly with being run from one of the
\r
40 # subdirs in the source tree. So if we can't find Recipe here,
\r
43 open IN, "Recipe" or die "unable to open Recipe file\n";
\r
46 # HACK: One of the source files in `charset' is auto-generated by
\r
47 # sbcsgen.pl. We need to generate that _now_, before attempting
\r
48 # dependency analysis.
\r
49 eval 'chdir "charset"; require "sbcsgen.pl"; chdir ".."';
\r
53 $divert = undef; # ref to scalar in which text is currently being put
\r
54 $help = ""; # list of newline-free lines of help text
\r
55 $project_name = "project"; # this is a good enough default
\r
56 %makefiles = (); # maps makefile types to output makefile pathnames
\r
57 %makefile_extra = (); # maps makefile types to extra Makefile text
\r
58 %programs = (); # maps prog name + type letter to listref of objects/resources
\r
59 %groups = (); # maps group name to listref of objects/resources
\r
65 # If we're gathering help text, keep doing so.
\r
66 if (defined $divert) {
\r
67 if ((defined $_[0]) && $_[0] eq "!end") {
\r
70 ${$divert} .= "$_\n";
\r
74 # Skip comments and blank lines.
\r
75 next if /^\s*#/ or scalar @_ == 0;
\r
77 if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = \$help; next; }
\r
78 if ($_[0] eq "!end") { $divert = undef; next; }
\r
79 if ($_[0] eq "!name") { $project_name = $_[1]; next; }
\r
80 if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; }
\r
81 if ($_[0] eq "!makefile" and &mfval($_[1])) { $makefiles{$_[1]}=$_[2]; next;}
\r
82 if ($_[0] eq "!specialobj" and &mfval($_[1])) { $specialobj{$_[1]}->{$_[2]} = 1; next;}
\r
83 if ($_[0] eq "!cflags" and &mfval($_[1])) {
\r
84 ($rest = $_) =~ s/^\s*\S+\s+\S+\s+\S+\s*//; # find rest of input line
\r
85 $rest = 1 if $rest eq "";
\r
86 $cflags{$_[1]}->{$_[2]} = $rest;
\r
89 if ($_[0] eq "!forceobj") { $forceobj{$_[1]} = 1; next; }
\r
90 if ($_[0] eq "!begin") {
\r
91 if ($_[1] =~ /^>(.*)/) {
\r
92 $divert = \$auxfiles{$1};
\r
93 } elsif (&mfval($_[1])) {
\r
94 $sect = $_[2] ? $_[2] : "end";
\r
95 $divert = \($makefile_extra{$_[1]}->{$sect});
\r
102 # If we're gathering help/verbatim text, keep doing so.
\r
103 if (defined $divert) { ${$divert} .= "$_\n"; next; }
\r
104 # Ignore blank lines.
\r
105 next if scalar @_ == 0;
\r
107 # Now we have an ordinary line. See if it's an = line, a : line
\r
111 if ($_[0] eq "+") {
\r
112 $listref = $lastlistref;
\r
114 die "$.: unexpected + line\n" if !defined $lastlistref;
\r
115 } elsif ($_[1] eq "=") {
\r
116 $groups{$_[0]} = [] if !defined $groups{$_[0]};
\r
117 $listref = $groups{$_[0]};
\r
119 shift @objs; # eat the group name
\r
120 } elsif ($_[1] eq ":") {
\r
123 shift @objs; # eat the program name
\r
125 die "$.: unrecognised line type\n";
\r
127 shift @objs; # eat the +, the = or the :
\r
129 while (scalar @objs > 0) {
\r
132 foreach $j (@{$groups{$i}}) { unshift @objs, $j; }
\r
133 } elsif (($i eq "[G]" or $i eq "[C]" or $i eq "[M]" or
\r
134 $i eq "[X]" or $i eq "[U]" or $i eq "[MX]") and defined $prog) {
\r
135 $type = substr($i,1,(length $i)-2);
\r
137 push @$listref, $i;
\r
140 if ($prog and $type) {
\r
141 die "multiple program entries for $prog [$type]\n"
\r
142 if defined $programs{$prog . "," . $type};
\r
143 $programs{$prog . "," . $type} = $listref;
\r
145 $lastlistref = $listref;
\r
150 foreach $aux (sort keys %auxfiles) {
\r
152 print AUX $auxfiles{$aux};
\r
156 # Now retrieve the complete list of objects and resource files, and
\r
157 # construct dependency data for them. While we're here, expand the
\r
158 # object list for each program, and complain if its type isn't set.
\r
159 @prognames = sort keys %programs;
\r
162 foreach $i (@prognames) {
\r
163 ($prog, $type) = split ",", $i;
\r
164 # Strip duplicate object names.
\r
166 @list = grep { $status = ($prev ne $_); $prev=$_; $status }
\r
167 sort @{$programs{$i}};
\r
168 $programs{$i} = [@list];
\r
169 foreach $j (@list) {
\r
170 # Dependencies for "x" start with "x.c" or "x.m" (depending on
\r
171 # which one exists).
\r
172 # Dependencies for "x.res" start with "x.rc".
\r
173 # Dependencies for "x.rsrc" start with "x.r".
\r
174 # Both types of file are pushed on the list of files to scan.
\r
175 # Libraries (.lib) don't have dependencies at all.
\r
176 if ($j =~ /^(.*)\.res$/) {
\r
178 $depends{$j} = [$file];
\r
179 push @scanlist, $file;
\r
180 } elsif ($j =~ /^(.*)\.rsrc$/) {
\r
182 $depends{$j} = [$file];
\r
183 push @scanlist, $file;
\r
184 } elsif ($j !~ /\./) {
\r
186 $file = "$j.m" unless &findfile($file);
\r
187 $depends{$j} = [$file];
\r
188 push @scanlist, $file;
\r
193 # Scan each file on @scanlist and find further inclusions.
\r
194 # Inclusions are given by lines of the form `#include "otherfile"'
\r
195 # (system headers are automatically ignored by this because they'll
\r
196 # be given in angle brackets). Files included by this method are
\r
197 # added back on to @scanlist to be scanned in turn (if not already
\r
200 # Resource scripts (.rc) can also include a file by means of:
\r
201 # - a line # ending `ICON "filename"';
\r
202 # - a line ending `RT_MANIFEST "filename"'.
\r
203 # Files included by this method are not added to @scanlist because
\r
204 # they can never include further files.
\r
206 # In this pass we write out a hash %further which maps a source
\r
207 # file name into a listref containing further source file names.
\r
210 %allsourcefiles = (); # this is wanted by some makefiles
\r
211 while (scalar @scanlist > 0) {
\r
212 $file = shift @scanlist;
\r
213 next if defined $further{$file}; # skip if we've already done it
\r
214 $further{$file} = [];
\r
215 $dirfile = &findfile($file);
\r
216 $allsourcefiles{$dirfile} = 1;
\r
217 open IN, "$dirfile" or die "unable to open source file $file\n";
\r
220 /^\s*#include\s+\"([^\"]+)\"/ and do {
\r
221 push @{$further{$file}}, $1;
\r
222 push @scanlist, $1;
\r
225 /(RT_MANIFEST|ICON)\s+\"([^\"]+)\"\s*$/ and do {
\r
226 push @{$further{$file}}, $2;
\r
233 # Now we're ready to generate the final dependencies section. For
\r
234 # each key in %depends, we must expand the dependencies list by
\r
235 # iteratively adding entries from %further.
\r
236 foreach $i (keys %depends) {
\r
238 @scanlist = @{$depends{$i}};
\r
239 foreach $i (@scanlist) { $dep{$i} = 1; }
\r
240 while (scalar @scanlist > 0) {
\r
241 $file = shift @scanlist;
\r
242 foreach $j (@{$further{$file}}) {
\r
245 push @{$depends{$i}}, $j;
\r
246 push @scanlist, $j;
\r
250 # printf "%s: %s\n", $i, join ' ',@{$depends{$i}};
\r
253 # Validation of input.
\r
257 # Returns true if the argument is a known makefile type. Otherwise,
\r
258 # prints a warning and returns false;
\r
259 if (grep { $type eq $_ }
\r
260 ("vc","vcproj","cygwin","borland","lcc","devcppproj","gtk","unix",
\r
264 warn "$.:unknown makefile type '$type'\n";
\r
268 # Utility routines while writing out the Makefiles.
\r
271 my ($x) = shift @_;
\r
272 return (defined $x) ? $x : "";
\r
276 my ($path) = shift @_;
\r
277 my ($sep) = shift @_;
\r
281 while (($i = index $path, $sep) >= 0 ||
\r
282 ($j = index $path, "/") >= 0) {
\r
283 if ($i >= 0 and ($j < 0 or $i < $j)) {
\r
284 $path = substr $path, ($i + length $sep);
\r
286 $path = substr $path, ($j + 1);
\r
297 my $outdir = undef;
\r
298 unless (defined $findfilecache{$name}) {
\r
300 foreach $dir (@srcdirs) {
\r
301 if (-f "$dir$name") {
\r
304 $outdir =~ s/^\.\///;
\r
307 die "multiple instances of source file $name\n" if $i > 1;
\r
308 $findfilecache{$name} = (defined $outdir ? $outdir . $name : undef);
\r
310 return $findfilecache{$name};
\r
314 my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_;
\r
317 ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ? $_ : "" } ($otmpl, $rtmpl, $ltmpl);
\r
319 foreach $i (@{$programs{$prog}}) {
\r
321 if ($i =~ /^(.*)\.(res|rsrc)/) {
\r
323 ($x = $rtmpl) =~ s/X/$y/;
\r
324 } elsif ($i =~ /^(.*)\.lib/) {
\r
326 ($x = $ltmpl) =~ s/X/$y/;
\r
327 } elsif ($i !~ /\./) {
\r
328 ($x = $otmpl) =~ s/X/$i/;
\r
330 push @ret, $x if $x ne "";
\r
332 return join " ", @ret;
\r
336 my ($prog, $suffix) = @_;
\r
339 ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ? $_ : "" } ($otmpl, $rtmpl, $ltmpl);
\r
341 foreach $i (@{$programs{$prog}}) {
\r
342 if (substr($i, (length $i) - (length $suffix)) eq $suffix) {
\r
346 return (scalar @ret) ? (join " ", @ret) : undef;
\r
350 my ($line, $width, $splitchar) = @_;
\r
353 $len = (defined $width ? $width : 76);
\r
354 $splitchar = (defined $splitchar ? $splitchar : '\\');
\r
355 while (length $line > $len) {
\r
356 $line =~ /^(.{0,$len})\s(.*)$/ or $line =~ /^(.{$len,}?\s(.*)$/;
\r
358 $result .= " ${splitchar}\n\t\t" if $2 ne '';
\r
362 return $result . $line;
\r
366 my ($otmpl, $rtmpl, $prefix, $dirsep, $mftyp, $depchar, $splitchar) = @_;
\r
372 foreach $i (sort keys %depends) {
\r
373 next if $specialobj{$mftyp}->{$i};
\r
374 if ($i =~ /^(.*)\.(res|rsrc)/) {
\r
375 next if !defined $rtmpl;
\r
377 ($x = $rtmpl) =~ s/X/$y/;
\r
379 ($x = $otmpl) =~ s/X/$i/;
\r
381 @deps = @{$depends{$i}};
\r
383 $_ = &findfile($_);
\r
387 push @ret, {obj => $x, obj_orig => $i, deps => [@deps]};
\r
394 my ($n, $prog, $type);
\r
397 foreach $n (@prognames) {
\r
398 ($prog, $type) = split ",", $n;
\r
399 push @ret, $n if index(":$types:", ":$type:") >= 0;
\r
404 sub progrealnames {
\r
406 my ($n, $prog, $type);
\r
409 foreach $n (@prognames) {
\r
410 ($prog, $type) = split ",", $n;
\r
411 push @ret, $prog if index(":$types:", ":$type:") >= 0;
\r
417 my ($types,$suffix) = @_;
\r
419 # assume that all UNIX programs have a man page
\r
420 if($suffix eq "1" && $types =~ /:X:/) {
\r
421 return map("$_.1", &progrealnames($types));
\r
428 # Now we're ready to output the actual Makefiles.
\r
430 if (defined $makefiles{'cygwin'}) {
\r
431 $dirpfx = &dirpfx($makefiles{'cygwin'}, "/");
\r
433 ##-- CygWin makefile
\r
434 open OUT, ">$makefiles{'cygwin'}"; select OUT;
\r
436 "# Makefile for $project_name under Cygwin, MinGW, or Winelib.\n".
\r
437 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
\r
438 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
\r
439 # gcc command line option is -D not /D
\r
440 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
\r
444 "# You can define this path to point at your tools if you need to\n".
\r
445 "# TOOLPATH = c:\\cygwin\\bin\\ # or similar, if you're running Windows\n".
\r
446 "# TOOLPATH = /pkg/mingw32msvc/i386-mingw32msvc/bin/\n".
\r
447 "CC = \$(TOOLPATH)gcc\n".
\r
448 "RC = \$(TOOLPATH)windres\n".
\r
449 "# Uncomment the following two lines to compile under Winelib\n".
\r
450 "# CC = winegcc\n".
\r
452 "# You may also need to tell windres where to find include files:\n".
\r
453 "# RCINC = --include-dir c:\\cygwin\\include\\\n".
\r
455 &splitline("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
\r
456 " -D_NO_OLDNAMES -DNO_MULTIMON -DNO_HTMLHELP -DNO_SECUREZEROMEMORY " .
\r
457 (join " ", map {"-I$dirpfx$_"} @srcdirs)) .
\r
459 "LDFLAGS = -mno-cygwin -s\n".
\r
460 &splitline("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1".
\r
461 " --define WINVER=0x0400")."\n".
\r
463 $makefile_extra{'cygwin'}->{'vars'} .
\r
467 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
\r
469 foreach $p (&prognames("G:C")) {
\r
470 ($prog, $type) = split ",", $p;
\r
471 $objstr = &objects($p, "X.o", "X.res.o", undef);
\r
472 print &splitline($prog . ".exe: " . $objstr), "\n";
\r
473 my $mw = $type eq "G" ? " -mwindows" : "";
\r
474 $libstr = &objects($p, undef, undef, "-lX");
\r
475 print &splitline("\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " .
\r
476 "-Wl,-Map,$prog.map " .
\r
477 $objstr . " $libstr", 69), "\n\n";
\r
479 foreach $d (&deps("X.o", "X.res.o", $dirpfx, "/", "cygwin")) {
\r
480 if ($forceobj{$d->{obj_orig}}) {
\r
481 printf ("%s: FORCE\n", $d->{obj});
\r
483 print &splitline(sprintf("%s: %s", $d->{obj},
\r
484 join " ", @{$d->{deps}})), "\n";
\r
486 if ($d->{obj} =~ /\.res\.o$/) {
\r
487 print "\t\$(RC) \$(RCFL) \$(RCFLAGS) ".$d->{deps}->[0]." -o ".$d->{obj}."\n\n";
\r
489 print "\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c ".$d->{deps}->[0]."\n\n";
\r
493 print $makefile_extra{'cygwin'}->{'end'};
\r
494 print "\nclean:\n".
\r
495 "\trm -f *.o *.exe *.res.o *.so *.map\n".
\r
498 select STDOUT; close OUT;
\r
502 ##-- Borland makefile
\r
503 if (defined $makefiles{'borland'}) {
\r
504 $dirpfx = &dirpfx($makefiles{'borland'}, "\\");
\r
506 %stdlibs = ( # Borland provides many Win32 API libraries intrinsically
\r
518 open OUT, ">$makefiles{'borland'}"; select OUT;
\r
520 "# Makefile for $project_name under Borland C.\n".
\r
521 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
\r
522 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
\r
523 # bcc32 command line option is -D not /D
\r
524 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
\r
528 "# If you rename this file to `Makefile', you should change this line,\n".
\r
529 "# so that the .rsp files still depend on the correct makefile.\n".
\r
530 "MAKEFILE = Makefile.bor\n".
\r
532 "# C compilation flags\n".
\r
533 "CFLAGS = -D_WINDOWS -DWINVER=0x0500\n".
\r
534 "# Resource compilation flags\n".
\r
535 "RCFLAGS = -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401\n".
\r
537 "# Get include directory for resource compiler\n".
\r
539 "BCB = \$(MAKEDIR)\\..\n".
\r
542 $makefile_extra{'borland'}->{'vars'} .
\r
545 &splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT)".
\r
546 " \$(CFLAGS) \$(XFLAGS) ".
\r
547 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
\r
548 " /c \$*.c",69)."\n".
\r
550 &splitline("\tbrcc32 \$(RCFL) -i \$(BCB)\\include -r".
\r
551 " \$(RCFLAGS) \$*.rc",69)."\n".
\r
553 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
\r
555 foreach $p (&prognames("G:C")) {
\r
556 ($prog, $type) = split ",", $p;
\r
557 $objstr = &objects($p, "X.obj", "X.res", undef);
\r
558 print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
\r
559 my $ap = ($type eq "G") ? "-aa" : "-ap";
\r
560 print "\tilink32 $ap -Gn -L\$(BCB)\\lib \@$prog.rsp\n\n";
\r
562 foreach $p (&prognames("G:C")) {
\r
563 ($prog, $type) = split ",", $p;
\r
564 print $prog, ".rsp: \$(MAKEFILE)\n";
\r
565 $objstr = &objects($p, "X.obj", undef, undef);
\r
566 @objlist = split " ", $objstr;
\r
568 foreach $i (@objlist) {
\r
569 if (length($objlines[$#objlines] . " $i") > 50) {
\r
570 push @objlines, "";
\r
572 $objlines[$#objlines] .= " $i";
\r
574 $c0w = ($type eq "G") ? "c0w32" : "c0x32";
\r
575 print "\techo $c0w + > $prog.rsp\n";
\r
576 for ($i=0; $i<=$#objlines; $i++) {
\r
577 $plus = ($i < $#objlines ? " +" : "");
\r
578 print "\techo$objlines[$i]$plus >> $prog.rsp\n";
\r
580 print "\techo $prog.exe >> $prog.rsp\n";
\r
581 $objstr = &objects($p, "X.obj", "X.res", undef);
\r
582 @libs = split " ", &objects($p, undef, undef, "X");
\r
583 @libs = grep { !$stdlibs{$_} } @libs;
\r
584 unshift @libs, "cw32", "import32";
\r
585 $libstr = join ' ', @libs;
\r
586 print "\techo nul,$libstr, >> $prog.rsp\n";
\r
587 print "\techo " . &objects($p, undef, "X.res", undef) . " >> $prog.rsp\n";
\r
590 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "borland")) {
\r
591 if ($forceobj{$d->{obj_orig}}) {
\r
592 printf("%s: FORCE\n", $d->{obj});
\r
594 print &splitline(sprintf("%s: %s", $d->{obj},
\r
595 join " ", @{$d->{deps}})), "\n";
\r
599 print $makefile_extra{'borland'}->{'end'};
\r
600 print "\nclean:\n".
\r
610 "\t-del *.\$\$\$\$\$\$\n".
\r
613 "\t-rem dummy command\n";
\r
614 select STDOUT; close OUT;
\r
617 if (defined $makefiles{'vc'}) {
\r
618 $dirpfx = &dirpfx($makefiles{'vc'}, "\\");
\r
620 ##-- Visual C++ makefile
\r
621 open OUT, ">$makefiles{'vc'}"; select OUT;
\r
623 "# Makefile for $project_name under Visual C.\n".
\r
624 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
\r
625 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
\r
629 "# If you rename this file to `Makefile', you should change this line,\n".
\r
630 "# so that the .rsp files still depend on the correct makefile.\n".
\r
631 "MAKEFILE = Makefile.vc\n".
\r
633 "# C compilation flags\n".
\r
634 "CFLAGS = /nologo /W3 /O1 " .
\r
635 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
\r
636 " /D_WINDOWS /D_WIN32_WINDOWS=0x500 /DWINVER=0x500\n".
\r
637 "LFLAGS = /incremental:no /fixed\n".
\r
638 "RCFLAGS = -DWIN32 -D_WIN32 -DWINVER=0x0400\n".
\r
640 $makefile_extra{'vc'}->{'vars'} .
\r
643 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
\r
645 foreach $p (&prognames("G:C")) {
\r
646 ($prog, $type) = split ",", $p;
\r
647 $objstr = &objects($p, "X.obj", "X.res", undef);
\r
648 print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
\r
649 print "\tlink \$(LFLAGS) \$(XLFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n";
\r
651 foreach $p (&prognames("G:C")) {
\r
652 ($prog, $type) = split ",", $p;
\r
653 print $prog, ".rsp: \$(MAKEFILE)\n";
\r
654 $objstr = &objects($p, "X.obj", "X.res", "X.lib");
\r
655 @objlist = split " ", $objstr;
\r
657 foreach $i (@objlist) {
\r
658 if (length($objlines[$#objlines] . " $i") > 50) {
\r
659 push @objlines, "";
\r
661 $objlines[$#objlines] .= " $i";
\r
663 $subsys = ($type eq "G") ? "windows" : "console";
\r
664 print "\techo /nologo /subsystem:$subsys > $prog.rsp\n";
\r
665 for ($i=0; $i<=$#objlines; $i++) {
\r
666 print "\techo$objlines[$i] >> $prog.rsp\n";
\r
670 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "vc")) {
\r
671 $extradeps = $forceobj{$d->{obj_orig}} ? ["*.c","*.h","*.rc"] : [];
\r
672 print &splitline(sprintf("%s: %s", $d->{obj},
\r
673 join " ", @$extradeps, @{$d->{deps}})), "\n";
\r
674 if ($d->{obj} =~ /.obj$/) {
\r
675 print "\tcl \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c ".$d->{deps}->[0],"\n\n";
\r
677 print "\trc \$(RCFL) -r \$(RCFLAGS) ".$d->{deps}->[0],"\n\n";
\r
681 print $makefile_extra{'vc'}->{'end'};
\r
682 print "\nclean: tidy\n".
\r
683 "\t-del *.exe\n\n".
\r
699 "\t-del debug.log\n";
\r
700 select STDOUT; close OUT;
\r
703 if (defined $makefiles{'vcproj'}) {
\r
704 $dirpfx = &dirpfx($makefiles{'vcproj'}, "\\");
\r
706 ##-- MSVC 6 Workspace and projects
\r
708 # Note: All files created in this section are written in binary
\r
709 # mode, because although MSVC's command-line make can deal with
\r
710 # LF-only line endings, MSVC project files really _need_ to be
\r
711 # CRLF. Hence, in order for mkfiles.pl to generate usable project
\r
712 # files even when run from Unix, I make sure all files are binary
\r
713 # and explicitly write the CRLFs.
\r
715 # Create directories if necessary
\r
716 mkdir $makefiles{'vcproj'}
\r
717 if(! -d $makefiles{'vcproj'});
\r
718 chdir $makefiles{'vcproj'};
\r
719 @deps = &deps("X.obj", "X.res", $dirpfx, "\\", "vcproj");
\r
720 %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;
\r
721 # Create the project files
\r
722 # Get names of all Windows projects (GUI and console)
\r
723 my @prognames = &prognames("G:C");
\r
724 foreach $progname (@prognames) {
\r
725 create_vc_project(\%all_object_deps, $progname);
\r
727 # Create the workspace file
\r
728 open OUT, ">$project_name.dsw"; binmode OUT; select OUT;
\r
730 "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n".
\r
731 "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n".
\r
733 "###############################################################################\r\n".
\r
736 foreach $progname (@prognames) {
\r
737 ($windows_project, $type) = split ",", $progname;
\r
738 print "Project: \"$windows_project\"=\".\\$windows_project\\$windows_project.dsp\" - Package Owner=<4>\r\n";
\r
750 "###############################################################################\r\n".
\r
762 "###############################################################################\r\n".
\r
764 select STDOUT; close OUT;
\r
767 sub create_vc_project {
\r
768 my ($all_object_deps, $progname) = @_;
\r
769 # Construct program's dependency info
\r
770 %seen_objects = ();
\r
772 %source_files = ();
\r
773 %header_files = ();
\r
774 %resource_files = ();
\r
775 @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");
\r
776 foreach $object_file (@object_files) {
\r
777 next if defined $seen_objects{$object_file};
\r
778 $seen_objects{$object_file} = 1;
\r
779 if($object_file =~ /\.lib$/io) {
\r
780 $lib_files{$object_file} = 1;
\r
783 $object_deps = $all_object_deps{$object_file};
\r
784 foreach $object_dep (@$object_deps) {
\r
785 if($object_dep =~ /\.c$/io) {
\r
786 $source_files{$object_dep} = 1;
\r
789 if($object_dep =~ /\.h$/io) {
\r
790 $header_files{$object_dep} = 1;
\r
793 if($object_dep =~ /\.(rc|ico)$/io) {
\r
794 $resource_files{$object_dep} = 1;
\r
799 $libs = join " ", sort keys %lib_files;
\r
800 @source_files = sort keys %source_files;
\r
801 @header_files = sort keys %header_files;
\r
802 @resources = sort keys %resource_files;
\r
803 ($windows_project, $type) = split ",", $progname;
\r
804 mkdir $windows_project
\r
805 if(! -d $windows_project);
\r
806 chdir $windows_project;
\r
807 $subsys = ($type eq "G") ? "windows" : "console";
\r
808 open OUT, ">$windows_project.dsp"; binmode OUT; select OUT;
\r
810 "# Microsoft Developer Studio Project File - Name=\"$windows_project\" - Package Owner=<4>\r\n".
\r
811 "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n".
\r
812 "# ** DO NOT EDIT **\r\n".
\r
814 "# TARGTYPE \"Win32 (x86) Application\" 0x0101\r\n".
\r
816 "CFG=$windows_project - Win32 Debug\r\n".
\r
817 "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n".
\r
818 "!MESSAGE use the Export Makefile command and run\r\n".
\r
820 "!MESSAGE NMAKE /f \"$windows_project.mak\".\r\n".
\r
822 "!MESSAGE You can specify a configuration when running NMAKE\r\n".
\r
823 "!MESSAGE by defining the macro CFG on the command line. For example:\r\n".
\r
825 "!MESSAGE NMAKE /f \"$windows_project.mak\" CFG=\"$windows_project - Win32 Debug\"\r\n".
\r
827 "!MESSAGE Possible choices for configuration are:\r\n".
\r
829 "!MESSAGE \"$windows_project - Win32 Release\" (based on \"Win32 (x86) Application\")\r\n".
\r
830 "!MESSAGE \"$windows_project - Win32 Debug\" (based on \"Win32 (x86) Application\")\r\n".
\r
833 "# Begin Project\r\n".
\r
834 "# PROP AllowPerConfigDependencies 0\r\n".
\r
835 "# PROP Scc_ProjName \"\"\r\n".
\r
836 "# PROP Scc_LocalPath \"\"\r\n".
\r
838 "MTL=midl.exe\r\n".
\r
841 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
\r
843 "# PROP BASE Use_MFC 0\r\n".
\r
844 "# PROP BASE Use_Debug_Libraries 0\r\n".
\r
845 "# PROP BASE Output_Dir \"Release\"\r\n".
\r
846 "# PROP BASE Intermediate_Dir \"Release\"\r\n".
\r
847 "# PROP BASE Target_Dir \"\"\r\n".
\r
848 "# PROP Use_MFC 0\r\n".
\r
849 "# PROP Use_Debug_Libraries 0\r\n".
\r
850 "# PROP Output_Dir \"Release\"\r\n".
\r
851 "# PROP Intermediate_Dir \"Release\"\r\n".
\r
852 "# PROP Ignore_Export_Lib 0\r\n".
\r
853 "# PROP Target_Dir \"\"\r\n".
\r
854 "# ADD BASE CPP /nologo /W3 /GX /O2 ".
\r
855 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
\r
856 " /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
\r
857 "# ADD CPP /nologo /W3 /GX /O2 ".
\r
858 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
\r
859 " /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\r\n".
\r
860 "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
\r
861 "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n".
\r
862 "# ADD BASE RSC /l 0x809 /d \"NDEBUG\"\r\n".
\r
863 "# ADD RSC /l 0x809 /d \"NDEBUG\"\r\n".
\r
864 "BSC32=bscmake.exe\r\n".
\r
865 "# ADD BASE BSC32 /nologo\r\n".
\r
866 "# ADD BSC32 /nologo\r\n".
\r
867 "LINK32=link.exe\r\n".
\r
868 "# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:$subsys /machine:I386\r\n".
\r
869 "# ADD LINK32 $libs /nologo /subsystem:$subsys /machine:I386\r\n".
\r
870 "# SUBTRACT LINK32 /pdb:none\r\n".
\r
872 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
\r
874 "# PROP BASE Use_MFC 0\r\n".
\r
875 "# PROP BASE Use_Debug_Libraries 1\r\n".
\r
876 "# PROP BASE Output_Dir \"Debug\"\r\n".
\r
877 "# PROP BASE Intermediate_Dir \"Debug\"\r\n".
\r
878 "# PROP BASE Target_Dir \"\"\r\n".
\r
879 "# PROP Use_MFC 0\r\n".
\r
880 "# PROP Use_Debug_Libraries 1\r\n".
\r
881 "# PROP Output_Dir \"Debug\"\r\n".
\r
882 "# PROP Intermediate_Dir \"Debug\"\r\n".
\r
883 "# PROP Ignore_Export_Lib 0\r\n".
\r
884 "# PROP Target_Dir \"\"\r\n".
\r
885 "# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od ".
\r
886 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
\r
887 " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
\r
888 "# ADD CPP /nologo /W3 /Gm /GX /ZI /Od ".
\r
889 (join " ", map {"/I \"..\\..\\$dirpfx$_\""} @srcdirs) .
\r
890 " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\r\n".
\r
891 "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
\r
892 "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n".
\r
893 "# ADD BASE RSC /l 0x809 /d \"_DEBUG\"\r\n".
\r
894 "# ADD RSC /l 0x809 /d \"_DEBUG\"\r\n".
\r
895 "BSC32=bscmake.exe\r\n".
\r
896 "# ADD BASE BSC32 /nologo\r\n".
\r
897 "# ADD BSC32 /nologo\r\n".
\r
898 "LINK32=link.exe\r\n".
\r
899 "# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:$subsys /debug /machine:I386 /pdbtype:sept\r\n".
\r
900 "# ADD LINK32 $libs /nologo /subsystem:$subsys /debug /machine:I386 /pdbtype:sept\r\n".
\r
901 "# SUBTRACT LINK32 /pdb:none\r\n".
\r
905 "# Begin Target\r\n".
\r
907 "# Name \"$windows_project - Win32 Release\"\r\n".
\r
908 "# Name \"$windows_project - Win32 Debug\"\r\n".
\r
909 "# Begin Group \"Source Files\"\r\n".
\r
911 "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n";
\r
912 foreach $source_file (@source_files) {
\r
914 "# Begin Source File\r\n".
\r
916 "SOURCE=..\\..\\$source_file\r\n";
\r
917 if($source_file =~ /ssh\.c/io) {
\r
918 # Disable 'Edit and continue' as Visual Studio can't handle the macros
\r
921 "!IF \"\$(CFG)\" == \"$windows_project - Win32 Release\"\r\n".
\r
923 "!ELSEIF \"\$(CFG)\" == \"$windows_project - Win32 Debug\"\r\n".
\r
925 "# ADD CPP /Zi\r\n".
\r
930 print "# End Source File\r\n";
\r
934 "# Begin Group \"Header Files\"\r\n".
\r
936 "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n";
\r
937 foreach $header_file (@header_files) {
\r
939 "# Begin Source File\r\n".
\r
941 "SOURCE=..\\..\\$header_file\r\n".
\r
942 "# End Source File\r\n";
\r
946 "# Begin Group \"Resource Files\"\r\n".
\r
948 "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n";
\r
949 foreach $resource_file (@resources) {
\r
951 "# Begin Source File\r\n".
\r
953 "SOURCE=..\\..\\$resource_file\r\n".
\r
954 "# End Source File\r\n";
\r
958 "# End Target\r\n".
\r
959 "# End Project\r\n";
\r
960 select STDOUT; close OUT;
\r
965 if (defined $makefiles{'gtk'}) {
\r
966 $dirpfx = &dirpfx($makefiles{'gtk'}, "/");
\r
968 ##-- X/GTK/Unix makefile
\r
969 open OUT, ">$makefiles{'gtk'}"; select OUT;
\r
971 "# Makefile for $project_name under X/GTK and Unix.\n".
\r
972 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
\r
973 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
\r
974 # gcc command line option is -D not /D
\r
975 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
\r
979 "# You can define this path to point at your tools if you need to\n".
\r
980 "# TOOLPATH = /opt/gcc/bin\n".
\r
981 "CC = \$(TOOLPATH)cc\n".
\r
982 "# If necessary set the path to krb5-config here\n".
\r
983 "KRB5CONFIG=krb5-config\n".
\r
984 "# You can manually set this to `gtk-config' or `pkg-config gtk+-1.2'\n".
\r
985 "# (depending on what works on your system) if you want to enforce\n".
\r
986 "# building with GTK 1.2, or you can set it to `pkg-config gtk+-2.0 x11'\n".
\r
987 "# if you want to enforce 2.0. The default is to try 2.0 and fall back\n".
\r
988 "# to 1.2 if it isn't found.\n".
\r
989 "GTK_CONFIG = sh -c 'pkg-config gtk+-2.0 x11 \$\$0 2>/dev/null || gtk-config \$\$0'\n".
\r
991 "-include Makefile.local\n".
\r
993 "unexport CFLAGS # work around a weird issue with krb5-config\n".
\r
995 &splitline("CFLAGS = -O2 -Wall -Werror -g " .
\r
996 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
\r
997 " \$(shell \$(GTK_CONFIG) --cflags)").
\r
998 " -D _FILE_OFFSET_BITS=64\n".
\r
999 "XLDFLAGS = \$(LDFLAGS) \$(shell \$(GTK_CONFIG) --libs)\n".
\r
1000 "ULDFLAGS = \$(LDFLAGS)\n".
\r
1001 "ifeq (,\$(findstring NO_GSSAPI,\$(COMPAT)))\n".
\r
1002 "ifeq (,\$(findstring STATIC_GSSAPI,\$(COMPAT)))\n".
\r
1003 "XLDFLAGS+= -ldl\n".
\r
1004 "ULDFLAGS+= -ldl\n".
\r
1006 "CFLAGS+= -DNO_LIBDL \$(shell \$(KRB5CONFIG) --cflags gssapi)\n".
\r
1007 "XLDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
\r
1008 "ULDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
\r
1011 "INSTALL=install\n".
\r
1012 "INSTALL_PROGRAM=\$(INSTALL)\n".
\r
1013 "INSTALL_DATA=\$(INSTALL)\n".
\r
1014 "prefix=/usr/local\n".
\r
1015 "exec_prefix=\$(prefix)\n".
\r
1016 "bindir=\$(exec_prefix)/bin\n".
\r
1017 "mandir=\$(prefix)/man\n".
\r
1018 "man1dir=\$(mandir)/man1\n".
\r
1020 &def($makefile_extra{'gtk'}->{'vars'}) .
\r
1025 print &splitline("all:" . join "", map { " $_" } &progrealnames("X:U"));
\r
1027 foreach $p (&prognames("X:U")) {
\r
1028 ($prog, $type) = split ",", $p;
\r
1029 $objstr = &objects($p, "X.o", undef, undef);
\r
1030 print &splitline($prog . ": " . $objstr), "\n";
\r
1031 $libstr = &objects($p, undef, undef, "-lX");
\r
1032 print &splitline("\t\$(CC) -o \$@ " .
\r
1033 $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
\r
1035 foreach $d (&deps("X.o", undef, $dirpfx, "/", "gtk")) {
\r
1036 if ($forceobj{$d->{obj_orig}}) {
\r
1037 printf("%s: FORCE\n", $d->{obj});
\r
1039 print &splitline(sprintf("%s: %s", $d->{obj},
\r
1040 join " ", @{$d->{deps}})), "\n";
\r
1042 print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
\r
1045 print $makefile_extra{'gtk'}->{'end'};
\r
1046 print "\nclean:\n".
\r
1047 "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:U")) . "\n";
\r
1048 print "\nFORCE:\n";
\r
1049 select STDOUT; close OUT;
\r
1052 if (defined $makefiles{'unix'}) {
\r
1053 $dirpfx = &dirpfx($makefiles{'unix'}, "/");
\r
1055 ##-- GTK-free pure-Unix makefile for non-GUI apps only
\r
1056 open OUT, ">$makefiles{'unix'}"; select OUT;
\r
1058 "# Makefile for $project_name under Unix.\n".
\r
1059 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
\r
1060 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
\r
1061 # gcc command line option is -D not /D
\r
1062 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
\r
1066 "# You can define this path to point at your tools if you need to\n".
\r
1067 "# TOOLPATH = /opt/gcc/bin\n".
\r
1068 "CC = \$(TOOLPATH)cc\n".
\r
1070 "-include Makefile.local\n".
\r
1072 "unexport CFLAGS # work around a weird issue with krb5-config\n".
\r
1074 &splitline("CFLAGS = -O2 -Wall -Werror -g " .
\r
1075 (join " ", map {"-I$dirpfx$_"} @srcdirs)).
\r
1076 " -D _FILE_OFFSET_BITS=64\n".
\r
1077 "ULDFLAGS = \$(LDFLAGS)\n".
\r
1078 "INSTALL=install\n".
\r
1079 "INSTALL_PROGRAM=\$(INSTALL)\n".
\r
1080 "INSTALL_DATA=\$(INSTALL)\n".
\r
1081 "prefix=/usr/local\n".
\r
1082 "exec_prefix=\$(prefix)\n".
\r
1083 "bindir=\$(exec_prefix)/bin\n".
\r
1084 "mandir=\$(prefix)/man\n".
\r
1085 "man1dir=\$(mandir)/man1\n".
\r
1087 &def($makefile_extra{'unix'}->{'vars'}) .
\r
1092 print &splitline("all:" . join "", map { " $_" } &progrealnames("U"));
\r
1094 foreach $p (&prognames("U")) {
\r
1095 ($prog, $type) = split ",", $p;
\r
1096 $objstr = &objects($p, "X.o", undef, undef);
\r
1097 print &splitline($prog . ": " . $objstr), "\n";
\r
1098 $libstr = &objects($p, undef, undef, "-lX");
\r
1099 print &splitline("\t\$(CC) -o \$@ " .
\r
1100 $objstr . " \$(${type}LDFLAGS) $libstr", 69), "\n\n";
\r
1102 foreach $d (&deps("X.o", undef, $dirpfx, "/", "unix")) {
\r
1103 if ($forceobj{$d->{obj_orig}}) {
\r
1104 printf("%s: FORCE\n", $d->{obj});
\r
1106 print &splitline(sprintf("%s: %s", $d->{obj},
\r
1107 join " ", @{$d->{deps}})), "\n";
\r
1109 print &splitline("\t\$(CC) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) -c $d->{deps}->[0]\n");
\r
1112 print &def($makefile_extra{'unix'}->{'end'});
\r
1113 print "\nclean:\n".
\r
1114 "\trm -f *.o". (join "", map { " $_" } &progrealnames("U")) . "\n";
\r
1115 print "\nFORCE:\n";
\r
1116 select STDOUT; close OUT;
\r
1119 if (defined $makefiles{'am'}) {
\r
1120 $dirpfx = "\$(srcdir)/" . &dirpfx($makefiles{'am'}, "/");
\r
1122 ##-- Unix/autoconf Makefile.am
\r
1123 open OUT, ">$makefiles{'am'}"; select OUT;
\r
1125 "# Makefile.am for $project_name under Unix with Autoconf/Automake.\n".
\r
1126 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
\r
1127 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n\n";
\r
1129 # Complete list of source and header files. Not used by the
\r
1130 # auto-generated parts of this makefile, but Recipe might like to
\r
1131 # have it available as a variable so that mandatory-rebuild things
\r
1132 # (version.o) can conveniently be made to depend on it.
\r
1133 @sources = ("allsources", "=",
\r
1134 map {"${dirpfx}$_"} sort keys %allsourcefiles);
\r
1135 print &splitline(join " ", @sources), "\n\n";
\r
1137 @cliprogs = ("bin_PROGRAMS", "=");
\r
1138 foreach $p (&prognames("U")) {
\r
1139 ($prog, $type) = split ",", $p;
\r
1140 push @cliprogs, $prog;
\r
1142 @allprogs = @cliprogs;
\r
1143 foreach $p (&prognames("X")) {
\r
1144 ($prog, $type) = split ",", $p;
\r
1145 push @allprogs, $prog;
\r
1147 print "if HAVE_GTK\n";
\r
1148 print &splitline(join " ", @allprogs), "\n";
\r
1150 print &splitline(join " ", @cliprogs), "\n";
\r
1151 print "endif\n\n";
\r
1154 foreach $d (&deps("X", undef, $dirpfx, "/", "am")) {
\r
1155 $objtosrc{$d->{obj}} = $d->{deps}->[0];
\r
1158 print &splitline(join " ", "AM_CPPFLAGS", "=",
\r
1159 map {"-I$dirpfx$_"} @srcdirs), "\n";
\r
1161 @amcflags = ("\$(COMPAT)", "\$(XFLAGS)", "\$(WARNINGOPTS)");
\r
1162 print "if HAVE_GTK\n";
\r
1163 print &splitline(join " ", "AM_CFLAGS", "=",
\r
1164 "\$(GTK_CFLAGS)", @amcflags), "\n";
\r
1166 print &splitline(join " ", "AM_CFLAGS", "=", @amcflags), "\n";
\r
1167 print "endif\n\n";
\r
1169 %amspeciallibs = ();
\r
1170 foreach $obj (sort { $a cmp $b } keys %{$cflags{'am'}}) {
\r
1171 print "lib${obj}_a_SOURCES = ", $objtosrc{$obj}, "\n";
\r
1172 print &splitline(join " ", "lib${obj}_a_CFLAGS", "=", @amcflags,
\r
1173 $cflags{'am'}->{$obj}), "\n";
\r
1174 $amspeciallibs{$obj} = "lib${obj}.a";
\r
1176 print &splitline(join " ", "noinst_LIBRARIES", "=",
\r
1177 sort { $a cmp $b } values %amspeciallibs), "\n\n";
\r
1179 foreach $p (&prognames("X:U")) {
\r
1180 ($prog, $type) = split ",", $p;
\r
1181 print "if HAVE_GTK\n" if $type eq "X";
\r
1182 @progsources = ("${prog}_SOURCES", "=");
\r
1183 %sourcefiles = ();
\r
1185 $objstr = &objects($p, "X", undef, undef);
\r
1186 foreach $obj (split / /,$objstr) {
\r
1187 if ($amspeciallibs{$obj}) {
\r
1188 push @ldadd, $amspeciallibs{$obj};
\r
1190 $sourcefiles{$objtosrc{$obj}} = 1;
\r
1193 push @progsources, sort { $a cmp $b } keys %sourcefiles;
\r
1194 print &splitline(join " ", @progsources), "\n";
\r
1195 if ($type eq "X") {
\r
1196 push @ldadd, "\$(GTK_LIBS)";
\r
1199 print &splitline(join " ", "${prog}_LDADD", "=", @ldadd), "\n";
\r
1201 print "endif\n" if $type eq "X";
\r
1204 print $makefile_extra{'am'}->{'end'};
\r
1205 select STDOUT; close OUT;
\r
1208 if (defined $makefiles{'lcc'}) {
\r
1209 $dirpfx = &dirpfx($makefiles{'lcc'}, "\\");
\r
1212 open OUT, ">$makefiles{'lcc'}"; select OUT;
\r
1214 "# Makefile for $project_name under lcc.\n".
\r
1215 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
\r
1216 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
\r
1217 # lcc command line option is -D not /D
\r
1218 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
\r
1222 "# If you rename this file to `Makefile', you should change this line,\n".
\r
1223 "# so that the .rsp files still depend on the correct makefile.\n".
\r
1224 "MAKEFILE = Makefile.lcc\n".
\r
1226 "# C compilation flags\n".
\r
1227 "CFLAGS = -D_WINDOWS " .
\r
1228 (join " ", map {"-I$dirpfx$_"} @srcdirs) .
\r
1230 "# Resource compilation flags\n".
\r
1233 "# Get include directory for resource compiler\n".
\r
1235 $makefile_extra{'lcc'}->{'vars'} .
\r
1237 print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
\r
1239 foreach $p (&prognames("G:C")) {
\r
1240 ($prog, $type) = split ",", $p;
\r
1241 $objstr = &objects($p, "X.obj", "X.res", undef);
\r
1242 print &splitline("$prog.exe: " . $objstr ), "\n";
\r
1243 $subsystemtype = '';
\r
1244 if ($type eq "G") { $subsystemtype = "-subsystem windows"; }
\r
1245 my $libss = "shell32.lib wsock32.lib ws2_32.lib winspool.lib winmm.lib imm32.lib";
\r
1246 print &splitline("\tlcclnk $subsystemtype -o $prog.exe $objstr $libss");
\r
1250 foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\", "lcc")) {
\r
1251 if ($forceobj{$d->{obj_orig}}) {
\r
1252 printf("%s: FORCE\n", $d->{obj});
\r
1254 print &splitline(sprintf("%s: %s", $d->{obj},
\r
1255 join " ", @{$d->{deps}})), "\n";
\r
1257 if ($d->{obj} =~ /\.obj$/) {
\r
1258 print &splitline("\tlcc -O -p6 \$(COMPAT)".
\r
1259 " \$(CFLAGS) \$(XFLAGS) ".$d->{deps}->[0],69)."\n";
\r
1261 print &splitline("\tlrc \$(RCFL) -r \$(RCFLAGS) ".
\r
1262 $d->{deps}->[0],69)."\n";
\r
1266 print $makefile_extra{'lcc'}->{'end'};
\r
1267 print "\nclean:\n".
\r
1274 select STDOUT; close OUT;
\r
1277 if (defined $makefiles{'osx'}) {
\r
1278 $dirpfx = &dirpfx($makefiles{'osx'}, "/");
\r
1280 ##-- Mac OS X makefile
\r
1281 open OUT, ">$makefiles{'osx'}"; select OUT;
\r
1283 "# Makefile for $project_name under Mac OS X.\n".
\r
1284 "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
\r
1285 "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
\r
1286 # gcc command line option is -D not /D
\r
1287 ($_ = $help) =~ s/([=" ])\/D/$1-D/gs;
\r
1290 "CC = \$(TOOLPATH)gcc\n".
\r
1292 &splitline("CFLAGS = -O2 -Wall -Werror -g " .
\r
1293 (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
\r
1294 "MLDFLAGS = -framework Cocoa\n".
\r
1297 $makefile_extra{'osx'}->{'vars'} .
\r
1299 &splitline("all:" . join "", map { " $_" } &progrealnames("MX:U")) .
\r
1301 foreach $p (&prognames("MX")) {
\r
1302 ($prog, $type) = split ",", $p;
\r
1303 $objstr = &objects($p, "X.o", undef, undef);
\r
1304 $icon = &special($p, ".icns");
\r
1305 $infoplist = &special($p, "info.plist");
\r
1306 print "${prog}.app:\n\tmkdir -p \$\@\n";
\r
1307 print "${prog}.app/Contents: ${prog}.app\n\tmkdir -p \$\@\n";
\r
1308 print "${prog}.app/Contents/MacOS: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
\r
1309 $targets = "${prog}.app/Contents/MacOS/$prog";
\r
1310 if (defined $icon) {
\r
1311 print "${prog}.app/Contents/Resources: ${prog}.app/Contents\n\tmkdir -p \$\@\n";
\r
1312 print "${prog}.app/Contents/Resources/${prog}.icns: ${prog}.app/Contents/Resources $icon\n\tcp $icon \$\@\n";
\r
1313 $targets .= " ${prog}.app/Contents/Resources/${prog}.icns";
\r
1315 if (defined $infoplist) {
\r
1316 print "${prog}.app/Contents/Info.plist: ${prog}.app/Contents/Resources $infoplist\n\tcp $infoplist \$\@\n";
\r
1317 $targets .= " ${prog}.app/Contents/Info.plist";
\r
1319 $targets .= " \$(${prog}_extra)";
\r
1320 print &splitline("${prog}: $targets", 69) . "\n\n";
\r
1321 print &splitline("${prog}.app/Contents/MacOS/$prog: ".
\r
1322 "${prog}.app/Contents/MacOS " . $objstr), "\n";
\r
1323 $libstr = &objects($p, undef, undef, "-lX");
\r
1324 print &splitline("\t\$(CC) \$(MLDFLAGS) -o \$@ " .
\r
1325 $objstr . " $libstr", 69), "\n\n";
\r
1327 foreach $p (&prognames("U")) {
\r
1328 ($prog, $type) = split ",", $p;
\r
1329 $objstr = &objects($p, "X.o", undef, undef);
\r
1330 print &splitline($prog . ": " . $objstr), "\n";
\r
1331 $libstr = &objects($p, undef, undef, "-lX");
\r
1332 print &splitline("\t\$(CC) \$(ULDFLAGS) -o \$@ " .
\r
1333 $objstr . " $libstr", 69), "\n\n";
\r
1335 foreach $d (&deps("X.o", undef, $dirpfx, "/", "osx")) {
\r
1336 if ($forceobj{$d->{obj_orig}}) {
\r
1337 printf("%s: FORCE\n", $d->{obj});
\r
1339 print &splitline(sprintf("%s: %s", $d->{obj},
\r
1340 join " ", @{$d->{deps}})), "\n";
\r
1342 $firstdep = $d->{deps}->[0];
\r
1343 if ($firstdep =~ /\.c$/) {
\r
1344 print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
\r
1345 } elsif ($firstdep =~ /\.m$/) {
\r
1346 print "\t\$(CC) -x objective-c \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS) -c \$<\n";
\r
1349 print "\n".&def($makefile_extra{'osx'}->{'end'});
\r
1350 print "\nclean:\n".
\r
1351 "\trm -f *.o *.dmg". (join "", map { " $_" } &progrealnames("U")) . "\n".
\r
1352 "\trm -rf *.app\n".
\r
1355 select STDOUT; close OUT;
\r
1358 if (defined $makefiles{'devcppproj'}) {
\r
1359 $dirpfx = &dirpfx($makefiles{'devcppproj'}, "\\");
\r
1362 ##-- Dev-C++ 5 projects
\r
1364 # Note: All files created in this section are written in binary
\r
1365 # mode to prevent any posibility of misinterpreted line endings.
\r
1366 # I don't know if Dev-C++ is as touchy as MSVC with LF-only line
\r
1367 # endings. But however, CRLF line endings are the common way on
\r
1368 # Win32 machines where Dev-C++ is running.
\r
1369 # Hence, in order for mkfiles.pl to generate CRLF project files
\r
1370 # even when run from Unix, I make sure all files are binary and
\r
1371 # explicitly write the CRLFs.
\r
1373 # Create directories if necessary
\r
1374 mkdir $makefiles{'devcppproj'}
\r
1375 if(! -d $makefiles{'devcppproj'});
\r
1376 chdir $makefiles{'devcppproj'};
\r
1377 @deps = &deps("X.obj", "X.res", $dirpfx, "\\", "devcppproj");
\r
1378 %all_object_deps = map {$_->{obj} => $_->{deps}} @deps;
\r
1379 # Make dir names FAT/NTFS compatible
\r
1380 my @srcdirs = @srcdirs;
\r
1381 for ($i=0; $i<@srcdirs; $i++) {
\r
1382 $srcdirs[$i] =~ s/\//\\/g;
\r
1383 $srcdirs[$i] =~ s/\\$//;
\r
1385 # Create the project files
\r
1386 # Get names of all Windows projects (GUI and console)
\r
1387 my @prognames = &prognames("G:C");
\r
1388 foreach $progname (@prognames) {
\r
1389 create_devcpp_project(\%all_object_deps, $progname);
\r
1394 sub create_devcpp_project {
\r
1395 my ($all_object_deps, $progname) = @_;
\r
1396 # Construct program's dependency info (Taken from 'vcproj', seems to work right here, too.)
\r
1397 %seen_objects = ();
\r
1399 %source_files = ();
\r
1400 %header_files = ();
\r
1401 %resource_files = ();
\r
1402 @object_files = split " ", &objects($progname, "X.obj", "X.res", "X.lib");
\r
1403 foreach $object_file (@object_files) {
\r
1404 next if defined $seen_objects{$object_file};
\r
1405 $seen_objects{$object_file} = 1;
\r
1406 if($object_file =~ /\.lib$/io) {
\r
1407 $lib_files{$object_file} = 1;
\r
1410 $object_deps = $all_object_deps{$object_file};
\r
1411 foreach $object_dep (@$object_deps) {
\r
1412 if($object_dep =~ /\.c$/io) {
\r
1413 $source_files{$object_dep} = 1;
\r
1416 if($object_dep =~ /\.h$/io) {
\r
1417 $header_files{$object_dep} = 1;
\r
1420 if($object_dep =~ /\.(rc|ico)$/io) {
\r
1421 $resource_files{$object_dep} = 1;
\r
1426 $libs = join " ", sort keys %lib_files;
\r
1427 @source_files = sort keys %source_files;
\r
1428 @header_files = sort keys %header_files;
\r
1429 @resources = sort keys %resource_files;
\r
1430 ($windows_project, $type) = split ",", $progname;
\r
1431 mkdir $windows_project
\r
1432 if(! -d $windows_project);
\r
1433 chdir $windows_project;
\r
1435 $subsys = ($type eq "G") ? "0" : "1"; # 0 = Win32 GUI, 1 = Win32 Console
\r
1436 open OUT, ">$windows_project.dev"; binmode OUT; select OUT;
\r
1438 "# DEV-C++ 5 Project File - $windows_project.dev\r\n".
\r
1439 "# ** DO NOT EDIT **\r\n".
\r
1441 # No difference between DEBUG and RELEASE here as in 'vcproj', because
\r
1442 # Dev-C++ does not support mutiple compilation profiles in one single project.
\r
1443 # (At least I can say this for Dev-C++ 5 Beta)
\r
1445 "FileName=$windows_project.dev\r\n".
\r
1446 "Name=$windows_project\r\n".
\r
1449 "Type=$subsys\r\n".
\r
1450 # Multimon is disabled here, as Dev-C++ (Version 5 Beta) does not have multimon.h
\r
1451 "Compiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
\r
1452 "CppCompiler=-W -D__GNUWIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNO_MULTIMON -D_MBCS_\@\@_\r\n".
\r
1453 "Includes=" . (join ";", map {"..\\..\\$dirpfx$_"} @srcdirs) . "\r\n".
\r
1454 "Linker=-ladvapi32 -lcomctl32 -lcomdlg32 -lgdi32 -limm32 -lshell32 -luser32 -lwinmm -lwinspool_\@\@_\r\n".
\r
1456 "UnitCount=" . (@source_files + @header_files + @resources) . "\r\n".
\r
1457 "Folders=\"Header Files\",\"Resource Files\",\"Source Files\"\r\n".
\r
1459 "PrivateResource=${windows_project}_private.rc\r\n".
\r
1460 "ResourceIncludes=..\\..\\..\\WINDOWS\r\n".
\r
1461 "MakeIncludes=\r\n".
\r
1462 "Icon=\r\n". # It's ok to leave this blank.
\r
1464 "ObjectOutput=\r\n".
\r
1465 "OverrideOutput=0\r\n".
\r
1466 "OverrideOutputName=$windows_project.exe\r\n".
\r
1467 "HostApplication=\r\n".
\r
1468 "CommandLine=\r\n".
\r
1469 "UseCustomMakefile=0\r\n".
\r
1470 "CustomMakefile=\r\n".
\r
1471 "IncludeVersionInfo=0\r\n".
\r
1472 "SupportXPThemes=0\r\n".
\r
1473 "CompilerSet=0\r\n".
\r
1474 "CompilerSettings=0000000000000000000000\r\n".
\r
1477 foreach $source_file (@source_files) {
\r
1479 "[Unit$unit_count]\r\n".
\r
1480 "FileName=..\\..\\$source_file\r\n".
\r
1481 "Folder=Source Files\r\n".
\r
1483 "CompileCpp=0\r\n".
\r
1485 "Priority=1000\r\n".
\r
1486 "OverrideBuildCmd=0\r\n".
\r
1491 foreach $header_file (@header_files) {
\r
1493 "[Unit$unit_count]\r\n".
\r
1494 "FileName=..\\..\\$header_file\r\n".
\r
1495 "Folder=Header Files\r\n".
\r
1497 "CompileCpp=1\r\n". # Dev-C++ want's to compile all header files with both compilers C and C++. It does not hurt.
\r
1499 "Priority=1000\r\n".
\r
1500 "OverrideBuildCmd=0\r\n".
\r
1505 foreach $resource_file (@resources) {
\r
1506 if ($resource_file =~ /.*\.(ico|cur|bmp|dlg|rc2|rct|bin|rgs|gif|jpg|jpeg|jpe)/io) { # Default filter as in 'vcproj'
\r
1507 $Compile = "0"; # Don't compile images and other binary resource files
\r
1508 $CompileCpp = "0";
\r
1511 $CompileCpp = "1"; # Dev-C++ want's to compile all .rc files with both compilers C and C++. It does not hurt.
\r
1514 "[Unit$unit_count]\r\n".
\r
1515 "FileName=..\\..\\$resource_file\r\n".
\r
1516 "Folder=Resource Files\r\n".
\r
1517 "Compile=$Compile\r\n".
\r
1518 "CompileCpp=$CompileCpp\r\n".
\r
1520 "Priority=1000\r\n".
\r
1521 "OverrideBuildCmd=0\r\n".
\r
1526 #Note: By default, [VersionInfo] is not used.
\r
1528 "[VersionInfo]\r\n".
\r
1533 "LanguageID=1033\r\n".
\r
1534 "CharsetID=1252\r\n".
\r
1535 "CompanyName=\r\n".
\r
1536 "FileVersion=0.1\r\n".
\r
1537 "FileDescription=\r\n".
\r
1538 "InternalName=\r\n".
\r
1539 "LegalCopyright=\r\n".
\r
1540 "LegalTrademarks=\r\n".
\r
1541 "OriginalFilename=$windows_project.exe\r\n".
\r
1542 "ProductName=$windows_project\r\n".
\r
1543 "ProductVersion=0.1\r\n".
\r
1544 "AutoIncBuildNr=0\r\n";
\r
1545 select STDOUT; close OUT;
\r
1550 # All done, so do the Unix postprocessing if asked to.
\r
1554 system "./mkauto.sh";
\r
1555 die "mkfiles.pl: mkauto.sh returned $?\n" if $? > 0;
\r
1556 if ($do_unix == 1) {
\r
1557 chdir ($targetdir = dirname($makefiles{"am"}))
\r
1558 or die "$targetdir: chdir: $!\n";
\r
1560 system "./configure", @confargs;
\r
1561 die "mkfiles.pl: configure returned $?\n" if $? > 0;
\r