1999-12-13 20:21:42 +03:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
#
|
|
|
|
# Makefile generator.
|
|
|
|
# Produces the other PuTTY makefiles from the master one.
|
|
|
|
|
|
|
|
open IN,"Makefile";
|
|
|
|
@current = ();
|
|
|
|
while (<IN>) {
|
|
|
|
chomp;
|
|
|
|
if (/^##--/) {
|
|
|
|
@words = split /\s+/,$_;
|
|
|
|
shift @words; # remove ##--
|
|
|
|
$i = shift @words; # first word
|
|
|
|
if (!defined $i) { # no words
|
|
|
|
@current = ();
|
|
|
|
} elsif (!defined $words[0]) { # only one word
|
|
|
|
@current = ($i);
|
|
|
|
} else { # at least two words
|
|
|
|
@current = map { $i . "." . $_ } @words;
|
|
|
|
foreach $i (@words) { $projects{$i} = $i; }
|
|
|
|
push @current, "objdefs";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
foreach $i (@current) { $store{$i} .= $_ . "\n"; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close IN;
|
|
|
|
@projects = keys %projects;
|
|
|
|
|
|
|
|
foreach $i (split '\n',$store{'gui-apps'}) {
|
|
|
|
$i =~ s/^# //;
|
2000-10-06 19:54:04 +04:00
|
|
|
$speciallibs = [split ' ', $i];
|
|
|
|
$i = shift @$speciallibs; # take off project name
|
1999-12-13 20:21:42 +03:00
|
|
|
$gui{$i} = 1;
|
2000-10-06 19:54:04 +04:00
|
|
|
$libs{$i} = $speciallibs;
|
1999-12-13 20:21:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach $i (split '\n',$store{'console-apps'}) {
|
|
|
|
$i =~ s/^# //;
|
2000-10-06 19:54:04 +04:00
|
|
|
$speciallibs = [split ' ', $i];
|
|
|
|
$i = shift @$speciallibs; # take off project name
|
|
|
|
$gui{$i} = 0;
|
|
|
|
$libs{$i} = $speciallibs;
|
1999-12-13 20:21:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
sub project {
|
|
|
|
my ($p) = @_;
|
|
|
|
my ($q) = $store{"$p"} . $store{"objects.$p"} . $store{"resources.$p"};
|
|
|
|
$q =~ s/(\S+)\s[^\n]*\n/\$($1) /gs;
|
|
|
|
$q =~ s/ $//;
|
|
|
|
$q;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub projlist {
|
|
|
|
my ($p) = @_;
|
|
|
|
my ($q) = $store{"$p"} . $store{"objects.$p"} . $store{"resources.$p"};
|
|
|
|
$q =~ s/(\S+)\s[^\n]*\n/$1 /gs;
|
|
|
|
my (@q) = split ' ',$q;
|
|
|
|
@q;
|
|
|
|
}
|
|
|
|
|
|
|
|
##-- CygWin makefile
|
|
|
|
open OUT, ">Makefile.cyg"; select OUT;
|
|
|
|
print
|
|
|
|
"# Makefile for PuTTY under cygwin.\n";
|
|
|
|
# gcc command line option is -D not /D
|
|
|
|
($_ = $store{"help"}) =~ s/=\/D/=-D/gs;
|
|
|
|
print $_;
|
|
|
|
print
|
|
|
|
"\n".
|
|
|
|
"# You can define this path to point at your tools if you need to\n".
|
|
|
|
"# TOOLPATH = c:\\cygwin\\bin\\ # or similar, if you're running Windows\n".
|
|
|
|
"# TOOLPATH = /pkg/mingw32msvc/i386-mingw32msvc/bin/\n".
|
|
|
|
"CC = \$(TOOLPATH)gcc\n".
|
|
|
|
"RC = \$(TOOLPATH)windres\n".
|
|
|
|
"# You may also need to tell windres where to find include files:\n".
|
|
|
|
"# RCINC = --include-dir c:\\cygwin\\include\\\n".
|
|
|
|
"\n".
|
2001-09-15 18:58:26 +04:00
|
|
|
"CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT".
|
|
|
|
" -DNO_SECURITY -D_NO_OLDNAMES -I.\n".
|
2000-02-20 14:01:00 +03:00
|
|
|
"LDFLAGS = -mno-cygwin -s\n".
|
2000-09-19 12:24:51 +04:00
|
|
|
"RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1 --define WINVER=0x0400 --define MINGW32_FIX=1\n".
|
2001-08-15 23:41:14 +04:00
|
|
|
"LIBS = -ladvapi32 -luser32 -lgdi32 -lwsock32 -lcomctl32 -lcomdlg32 -lwinmm -limm32\n".
|
1999-12-13 20:21:42 +03:00
|
|
|
"OBJ=o\n".
|
2000-02-20 14:01:00 +03:00
|
|
|
"RES=res.o\n".
|
1999-12-13 20:21:42 +03:00
|
|
|
"\n";
|
|
|
|
print $store{"objdefs"};
|
|
|
|
print
|
|
|
|
"\n".
|
|
|
|
".SUFFIXES:\n".
|
|
|
|
"\n".
|
1999-12-14 12:29:55 +03:00
|
|
|
"%.o: %.c\n".
|
2001-05-13 15:46:00 +04:00
|
|
|
"\t\$(CC) \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) -c \$<\n".
|
1999-12-13 20:21:42 +03:00
|
|
|
"\n".
|
2000-02-20 14:01:00 +03:00
|
|
|
"%.res.o: %.rc\n".
|
2000-01-19 15:16:19 +03:00
|
|
|
"\t\$(RC) \$(FWHACK) \$(RCFL) \$(RCFLAGS) \$< \$\@\n".
|
1999-12-13 20:21:42 +03:00
|
|
|
"\n";
|
2001-04-28 16:07:41 +04:00
|
|
|
print "all:";
|
|
|
|
print map { " $_.exe" } @projects;
|
|
|
|
print "\n\n";
|
1999-12-13 20:21:42 +03:00
|
|
|
foreach $p (@projects) {
|
|
|
|
print $p, ".exe: ", &project($p), "\n";
|
2000-02-20 14:01:00 +03:00
|
|
|
my $mw = $gui{$p} ? " -mwindows" : "";
|
2000-10-06 19:54:04 +04:00
|
|
|
$libstr = "";
|
|
|
|
foreach $lib (@{$libs{$p}}) { $libstr .= " -l$lib"; }
|
|
|
|
print "\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " . &project($p), " \$(LIBS)$libstr\n\n";
|
1999-12-13 20:21:42 +03:00
|
|
|
}
|
|
|
|
print $store{"dependencies"};
|
|
|
|
print
|
|
|
|
"\n".
|
2000-01-19 15:11:38 +03:00
|
|
|
"version.o: FORCE;\n".
|
1999-12-13 20:21:42 +03:00
|
|
|
"# Hack to force version.o to be rebuilt always\n".
|
|
|
|
"FORCE:\n".
|
1999-12-14 12:29:55 +03:00
|
|
|
"\t\$(CC) \$(FWHACK) \$(CFLAGS) \$(VER) -c version.c\n\n".
|
1999-12-13 20:21:42 +03:00
|
|
|
"clean:\n".
|
|
|
|
"\trm -f *.o *.exe *.res\n".
|
|
|
|
"\n";
|
|
|
|
select STDOUT; close OUT;
|
|
|
|
|
|
|
|
##-- Borland makefile
|
|
|
|
open OUT, ">Makefile.bor"; select OUT;
|
|
|
|
print
|
2000-03-08 12:41:17 +03:00
|
|
|
"# Makefile for PuTTY under Borland C++.\n";
|
1999-12-13 20:21:42 +03:00
|
|
|
# bcc32 command line option is -D not /D
|
|
|
|
($_ = $store{"help"}) =~ s/=\/D/=-D/gs;
|
|
|
|
print $_;
|
|
|
|
print
|
|
|
|
"\n".
|
|
|
|
"# If you rename this file to `Makefile', you should change this line,\n".
|
|
|
|
"# so that the .rsp files still depend on the correct makefile.\n".
|
|
|
|
"MAKEFILE = Makefile.bor\n".
|
|
|
|
"\n".
|
2001-10-18 01:21:03 +04:00
|
|
|
"# C compilation flags\n".
|
|
|
|
"CFLAGS = -DWINVER=0x0401\n".
|
|
|
|
"\n".
|
1999-12-13 20:21:42 +03:00
|
|
|
"# Get include directory for resource compiler\n".
|
|
|
|
"!if !\$d(BCB)\n".
|
|
|
|
"BCB = \$(MAKEDIR)\\..\n".
|
|
|
|
"!endif\n".
|
|
|
|
"\n".
|
|
|
|
".c.obj:\n".
|
2001-05-28 14:26:10 +04:00
|
|
|
"\tbcc32 -w-aus -w-ccc -w-par \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) /c \$*.c\n".
|
1999-12-13 20:21:42 +03:00
|
|
|
".rc.res:\n".
|
2000-03-08 12:41:17 +03:00
|
|
|
"\tbrcc32 \$(FWHACK) \$(RCFL) -i \$(BCB)\\include \\\n".
|
2001-10-18 01:21:03 +04:00
|
|
|
"\t\t-r -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401 \$*.rc\n".
|
1999-12-13 20:21:42 +03:00
|
|
|
"\n".
|
|
|
|
"OBJ=obj\n".
|
|
|
|
"RES=res\n".
|
|
|
|
"\n";
|
|
|
|
print $store{"objdefs"};
|
|
|
|
print "\n";
|
|
|
|
print "all:";
|
|
|
|
print map { " $_.exe" } @projects;
|
|
|
|
print "\n\n";
|
|
|
|
foreach $p (@projects) {
|
|
|
|
print $p, ".exe: ", &project($p), " $p.rsp\n";
|
2000-06-21 20:08:08 +04:00
|
|
|
$ap = $gui{$p} ? " -aa" : " -ap";
|
2000-03-08 12:41:17 +03:00
|
|
|
print "\tilink32$ap -Gn -L\$(BCB)\\lib \@$p.rsp\n\n";
|
1999-12-13 20:21:42 +03:00
|
|
|
}
|
|
|
|
foreach $p (@projects) {
|
|
|
|
print $p, ".rsp: \$(MAKEFILE)\n";
|
2000-03-08 12:41:17 +03:00
|
|
|
$c0w = $gui{$p} ? "c0w32" : "c0x32";
|
|
|
|
print "\techo $c0w + > $p.rsp\n";
|
|
|
|
@objlines = &projlist("objects.$p");
|
|
|
|
for ($i=0; $i<=$#objlines; $i++) {
|
|
|
|
$plus = ($i < $#objlines ? " +" : "");
|
|
|
|
print "\techo \$($objlines[$i])$plus >> $p.rsp\n";
|
1999-12-13 20:21:42 +03:00
|
|
|
}
|
2000-03-08 12:41:17 +03:00
|
|
|
print "\techo $p.exe >> $p.rsp\n";
|
2000-10-06 19:54:04 +04:00
|
|
|
@libs = @{$libs{$p}};
|
|
|
|
unshift @libs, "cw32", "import32";
|
|
|
|
$libstr = join ' ', @libs;
|
|
|
|
print "\techo nul,$libstr, >> $p.rsp\n";
|
2000-03-08 12:41:17 +03:00
|
|
|
print "\techo " . (join " ", &project("resources.$p")) . " >> $p.rsp\n";
|
1999-12-13 20:21:42 +03:00
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
print $store{"dependencies"};
|
|
|
|
print
|
|
|
|
"\n".
|
|
|
|
"version.o: FORCE\n".
|
|
|
|
"# Hack to force version.o to be rebuilt always\n".
|
|
|
|
"FORCE:\n".
|
|
|
|
"\tbcc32 \$(FWHACK) \$(VER) \$(CFLAGS) /c version.c\n\n".
|
|
|
|
"clean:\n".
|
|
|
|
"\tdel *.obj\n".
|
|
|
|
"\tdel *.exe\n".
|
|
|
|
"\tdel *.res\n".
|
|
|
|
"\tdel *.pch\n".
|
|
|
|
"\tdel *.aps\n".
|
2000-03-08 12:41:17 +03:00
|
|
|
"\tdel *.il*\n".
|
1999-12-13 20:21:42 +03:00
|
|
|
"\tdel *.pdb\n".
|
2000-03-08 12:41:17 +03:00
|
|
|
"\tdel *.rsp\n".
|
|
|
|
"\tdel *.tds\n".
|
|
|
|
"\tdel *.\$\$\$\$\$\$\n";
|
1999-12-13 20:21:42 +03:00
|
|
|
select STDOUT; close OUT;
|