mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
More portability fixes.
[originally from svn r4137]
This commit is contained in:
parent
7bd6bec8e4
commit
1e13fdc572
4
Recipe
4
Recipe
@ -19,6 +19,10 @@
|
|||||||
!makefile lcc Makefile.lcc
|
!makefile lcc Makefile.lcc
|
||||||
!makefile gtk unix/Makefile.gtk
|
!makefile gtk unix/Makefile.gtk
|
||||||
!makefile mpw mac/Makefile.mpw
|
!makefile mpw mac/Makefile.mpw
|
||||||
|
# Source directories.
|
||||||
|
!srcdir charset/
|
||||||
|
!srcdir unix/
|
||||||
|
!srcdir mac/
|
||||||
|
|
||||||
# Help text added to the top of each Makefile, with /D converted
|
# Help text added to the top of each Makefile, with /D converted
|
||||||
# into -D as appropriate for the particular Makefile.
|
# into -D as appropriate for the particular Makefile.
|
||||||
|
56
mkfiles.pl
56
mkfiles.pl
@ -7,6 +7,12 @@
|
|||||||
# files to compute #include dependencies. Finally, writes out the
|
# files to compute #include dependencies. Finally, writes out the
|
||||||
# various target Makefiles.
|
# various target Makefiles.
|
||||||
|
|
||||||
|
# PuTTY specifics which could still do with removing:
|
||||||
|
# - Mac makefile is not portabilised at all. Include directories
|
||||||
|
# are hardwired, and also the libraries are fixed. This is
|
||||||
|
# mainly because I was too scared to go anywhere near it.
|
||||||
|
# - sbcsgen.pl is still run at startup.
|
||||||
|
|
||||||
use FileHandle;
|
use FileHandle;
|
||||||
use Cwd;
|
use Cwd;
|
||||||
|
|
||||||
@ -23,7 +29,7 @@ open IN, "Recipe" or do {
|
|||||||
# dependency analysis.
|
# dependency analysis.
|
||||||
eval 'chdir "charset"; require "sbcsgen.pl"; chdir ".."';
|
eval 'chdir "charset"; require "sbcsgen.pl"; chdir ".."';
|
||||||
|
|
||||||
@incdirs = ("", "charset/", "unix/", "mac/");
|
@srcdirs = ("./");
|
||||||
|
|
||||||
$divert = undef; # ref to scalar in which text is currently being put
|
$divert = undef; # ref to scalar in which text is currently being put
|
||||||
$help = ""; # list of newline-free lines of help text
|
$help = ""; # list of newline-free lines of help text
|
||||||
@ -43,6 +49,7 @@ while (<IN>) {
|
|||||||
if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = \$help; next; }
|
if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = \$help; next; }
|
||||||
if ($_[0] eq "!end") { $divert = undef; next; }
|
if ($_[0] eq "!end") { $divert = undef; next; }
|
||||||
if ($_[0] eq "!name") { $project_name = $_[1]; next; }
|
if ($_[0] eq "!name") { $project_name = $_[1]; next; }
|
||||||
|
if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; }
|
||||||
if ($_[0] eq "!makefile" and &mfval($_[1])) { $makefiles{$_[1]}=$_[2]; next;}
|
if ($_[0] eq "!makefile" and &mfval($_[1])) { $makefiles{$_[1]}=$_[2]; next;}
|
||||||
if ($_[0] eq "!begin") {
|
if ($_[0] eq "!begin") {
|
||||||
if (&mfval($_[1])) {
|
if (&mfval($_[1])) {
|
||||||
@ -210,12 +217,23 @@ sub mfval($) {
|
|||||||
|
|
||||||
# Utility routines while writing out the Makefiles.
|
# Utility routines while writing out the Makefiles.
|
||||||
|
|
||||||
|
sub dirpfx {
|
||||||
|
my ($path) = shift @_;
|
||||||
|
my ($sep) = shift @_;
|
||||||
|
my $ret = "", $i;
|
||||||
|
while (($i = index $path, $sep) >= 0) {
|
||||||
|
$path = substr $path, ($i + length $sep);
|
||||||
|
$ret .= "..$sep";
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
sub findfile {
|
sub findfile {
|
||||||
my ($name) = @_;
|
my ($name) = @_;
|
||||||
my $dir, $i, $outdir = "";
|
my $dir, $i, $outdir = "";
|
||||||
unless (defined $findfilecache{$name}) {
|
unless (defined $findfilecache{$name}) {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach $dir (@incdirs) {
|
foreach $dir (@srcdirs) {
|
||||||
$outdir = $dir, $i++ if -f "$dir$name";
|
$outdir = $dir, $i++ if -f "$dir$name";
|
||||||
}
|
}
|
||||||
die "multiple instances of source file $name\n" if $i > 1;
|
die "multiple instances of source file $name\n" if $i > 1;
|
||||||
@ -321,6 +339,7 @@ sub manpages {
|
|||||||
# Now we're ready to output the actual Makefiles.
|
# Now we're ready to output the actual Makefiles.
|
||||||
|
|
||||||
if (defined $makefiles{'cygwin'}) {
|
if (defined $makefiles{'cygwin'}) {
|
||||||
|
$dirpfx = &dirpfx($makefiles{'cygwin'}, "/");
|
||||||
|
|
||||||
##-- CygWin makefile
|
##-- CygWin makefile
|
||||||
open OUT, ">$makefiles{'cygwin'}"; select OUT;
|
open OUT, ">$makefiles{'cygwin'}"; select OUT;
|
||||||
@ -345,7 +364,9 @@ if (defined $makefiles{'cygwin'}) {
|
|||||||
"# RCINC = --include-dir c:\\cygwin\\include\\\n".
|
"# RCINC = --include-dir c:\\cygwin\\include\\\n".
|
||||||
"\n".
|
"\n".
|
||||||
&splitline("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
|
&splitline("CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
|
||||||
" -D_NO_OLDNAMES -DNO_MULTIMON -I.")."\n".
|
" -D_NO_OLDNAMES -DNO_MULTIMON " .
|
||||||
|
(join " ", map {"-I$dirpfx$_"} @srcdirs)) .
|
||||||
|
"\n".
|
||||||
"LDFLAGS = -mno-cygwin -s\n".
|
"LDFLAGS = -mno-cygwin -s\n".
|
||||||
&splitline("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1".
|
&splitline("RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1".
|
||||||
" --define WINVER=0x0400 --define MINGW32_FIX=1")."\n".
|
" --define WINVER=0x0400 --define MINGW32_FIX=1")."\n".
|
||||||
@ -370,7 +391,7 @@ if (defined $makefiles{'cygwin'}) {
|
|||||||
"-Wl,-Map,$prog.map " .
|
"-Wl,-Map,$prog.map " .
|
||||||
$objstr . " $libstr", 69), "\n\n";
|
$objstr . " $libstr", 69), "\n\n";
|
||||||
}
|
}
|
||||||
foreach $d (&deps("X.o", "X.res.o", "", "/")) {
|
foreach $d (&deps("X.o", "X.res.o", $dirpfx, "/")) {
|
||||||
print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
|
print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
|
||||||
"\n";
|
"\n";
|
||||||
}
|
}
|
||||||
@ -385,6 +406,8 @@ if (defined $makefiles{'cygwin'}) {
|
|||||||
|
|
||||||
##-- Borland makefile
|
##-- Borland makefile
|
||||||
if (defined $makefiles{'borland'}) {
|
if (defined $makefiles{'borland'}) {
|
||||||
|
$dirpfx = &dirpfx($makefiles{'borland'}, "\\");
|
||||||
|
|
||||||
%stdlibs = ( # Borland provides many Win32 API libraries intrinsically
|
%stdlibs = ( # Borland provides many Win32 API libraries intrinsically
|
||||||
"advapi32" => 1,
|
"advapi32" => 1,
|
||||||
"comctl32" => 1,
|
"comctl32" => 1,
|
||||||
@ -421,7 +444,9 @@ if (defined $makefiles{'borland'}) {
|
|||||||
"\n".
|
"\n".
|
||||||
".c.obj:\n".
|
".c.obj:\n".
|
||||||
&splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT) \$(FWHACK)".
|
&splitline("\tbcc32 -w-aus -w-ccc -w-par -w-pia \$(COMPAT) \$(FWHACK)".
|
||||||
" \$(XFLAGS) \$(CFLAGS) /c \$*.c",69)."\n".
|
" \$(XFLAGS) \$(CFLAGS) ".
|
||||||
|
(join " ", map {"-I$dirpfx$_"} @srcdirs) .
|
||||||
|
"/c \$*.c",69)."\n".
|
||||||
".rc.res:\n".
|
".rc.res:\n".
|
||||||
&splitline("\tbrcc32 \$(FWHACK) \$(RCFL) -i \$(BCB)\\include -r".
|
&splitline("\tbrcc32 \$(FWHACK) \$(RCFL) -i \$(BCB)\\include -r".
|
||||||
" -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401 \$*.rc",69)."\n".
|
" -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401 \$*.rc",69)."\n".
|
||||||
@ -463,7 +488,7 @@ if (defined $makefiles{'borland'}) {
|
|||||||
print "\techo " . &objects($p, undef, "X.res", undef) . " >> $prog.rsp\n";
|
print "\techo " . &objects($p, undef, "X.res", undef) . " >> $prog.rsp\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
foreach $d (&deps("X.obj", "X.res", "", "\\")) {
|
foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\")) {
|
||||||
print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
|
print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
|
||||||
"\n";
|
"\n";
|
||||||
}
|
}
|
||||||
@ -484,6 +509,8 @@ if (defined $makefiles{'borland'}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (defined $makefiles{'vc'}) {
|
if (defined $makefiles{'vc'}) {
|
||||||
|
$dirpfx = &dirpfx($makefiles{'vc'}, "\\");
|
||||||
|
|
||||||
##-- Visual C++ makefile
|
##-- Visual C++ makefile
|
||||||
open OUT, ">$makefiles{'vc'}"; select OUT;
|
open OUT, ">$makefiles{'vc'}"; select OUT;
|
||||||
print
|
print
|
||||||
@ -533,7 +560,7 @@ if (defined $makefiles{'vc'}) {
|
|||||||
}
|
}
|
||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
foreach $d (&deps("X.obj", "X.res", "", "\\")) {
|
foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\")) {
|
||||||
print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
|
print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
|
||||||
"\n";
|
"\n";
|
||||||
}
|
}
|
||||||
@ -816,6 +843,7 @@ if (defined $makefiles{'vcproj'}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (defined $makefiles{'gtk'}) {
|
if (defined $makefiles{'gtk'}) {
|
||||||
|
$dirpfx = &dirpfx($makefiles{'gtk'}, "/");
|
||||||
|
|
||||||
##-- X/GTK/Unix makefile
|
##-- X/GTK/Unix makefile
|
||||||
open OUT, ">$makefiles{'gtk'}"; select OUT;
|
open OUT, ">$makefiles{'gtk'}"; select OUT;
|
||||||
@ -832,7 +860,9 @@ if (defined $makefiles{'gtk'}) {
|
|||||||
"# TOOLPATH = /opt/gcc/bin\n".
|
"# TOOLPATH = /opt/gcc/bin\n".
|
||||||
"CC = \$(TOOLPATH)cc\n".
|
"CC = \$(TOOLPATH)cc\n".
|
||||||
"\n".
|
"\n".
|
||||||
&splitline("CFLAGS = -O2 -Wall -Werror -g -I. -I.. -I../charset `gtk-config --cflags`")."\n".
|
&splitline("CFLAGS = -O2 -Wall -Werror -g " .
|
||||||
|
(join " ", map {"-I$dirpfx$_"} @srcdirs) .
|
||||||
|
" `gtk-config --cflags`")."\n".
|
||||||
"XLDFLAGS = `gtk-config --libs`\n".
|
"XLDFLAGS = `gtk-config --libs`\n".
|
||||||
"ULDFLAGS =#\n".
|
"ULDFLAGS =#\n".
|
||||||
"INSTALL=install\n",
|
"INSTALL=install\n",
|
||||||
@ -859,7 +889,7 @@ if (defined $makefiles{'gtk'}) {
|
|||||||
print &splitline("\t\$(CC)" . $mw . " \$(${type}LDFLAGS) -o \$@ " .
|
print &splitline("\t\$(CC)" . $mw . " \$(${type}LDFLAGS) -o \$@ " .
|
||||||
$objstr . " $libstr", 69), "\n\n";
|
$objstr . " $libstr", 69), "\n\n";
|
||||||
}
|
}
|
||||||
foreach $d (&deps("X.o", undef, "../", "/")) {
|
foreach $d (&deps("X.o", undef, $dirpfx, "/")) {
|
||||||
print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
|
print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
|
||||||
"\n";
|
"\n";
|
||||||
}
|
}
|
||||||
@ -1011,6 +1041,8 @@ if (defined $makefiles{'mpw'}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (defined $makefiles{'lcc'}) {
|
if (defined $makefiles{'lcc'}) {
|
||||||
|
$dirpfx = &dirpfx($makefiles{'lcc'}, "\\");
|
||||||
|
|
||||||
##-- lcc makefile
|
##-- lcc makefile
|
||||||
open OUT, ">$makefiles{'lcc'}"; select OUT;
|
open OUT, ">$makefiles{'lcc'}"; select OUT;
|
||||||
print
|
print
|
||||||
@ -1027,7 +1059,9 @@ if (defined $makefiles{'lcc'}) {
|
|||||||
"MAKEFILE = Makefile.lcc\n".
|
"MAKEFILE = Makefile.lcc\n".
|
||||||
"\n".
|
"\n".
|
||||||
"# C compilation flags\n".
|
"# C compilation flags\n".
|
||||||
"CFLAGS = -D_WINDOWS\n".
|
"CFLAGS = -D_WINDOWS " .
|
||||||
|
(join " ", map {"-I$dirpfx$_"} @srcdirs) .
|
||||||
|
"\n".
|
||||||
"\n".
|
"\n".
|
||||||
"# Get include directory for resource compiler\n".
|
"# Get include directory for resource compiler\n".
|
||||||
"\n".
|
"\n".
|
||||||
@ -1050,7 +1084,7 @@ if (defined $makefiles{'lcc'}) {
|
|||||||
print "\n\n";
|
print "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach $d (&deps("X.obj", "X.res", "", "\\")) {
|
foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\")) {
|
||||||
print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
|
print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
|
||||||
"\n";
|
"\n";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user