Using plink with CVS - need to make sure the saved session uses SSH
[u/mdw/putty] / mkfiles.pl
CommitLineData
3d541627 1#!/usr/bin/env perl
2#
3# Makefile generator.
4# Produces the other PuTTY makefiles from the master one.
5
6open IN,"Makefile";
7@current = ();
8while (<IN>) {
9 chomp;
10 if (/^##--/) {
11 @words = split /\s+/,$_;
12 shift @words; # remove ##--
13 $i = shift @words; # first word
14 if (!defined $i) { # no words
15 @current = ();
16 } elsif (!defined $words[0]) { # only one word
17 @current = ($i);
18 } else { # at least two words
19 @current = map { $i . "." . $_ } @words;
20 foreach $i (@words) { $projects{$i} = $i; }
21 push @current, "objdefs";
22 }
23 } else {
24 foreach $i (@current) { $store{$i} .= $_ . "\n"; }
25 }
26}
27close IN;
28@projects = keys %projects;
29
30foreach $i (split '\n',$store{'gui-apps'}) {
31 $i =~ s/^# //;
6d2d5e8d 32 $speciallibs = [split ' ', $i];
33 $i = shift @$speciallibs; # take off project name
3d541627 34 $gui{$i} = 1;
6d2d5e8d 35 $libs{$i} = $speciallibs;
3d541627 36}
37
38foreach $i (split '\n',$store{'console-apps'}) {
39 $i =~ s/^# //;
6d2d5e8d 40 $speciallibs = [split ' ', $i];
41 $i = shift @$speciallibs; # take off project name
42 $gui{$i} = 0;
43 $libs{$i} = $speciallibs;
3d541627 44}
45
46sub project {
47 my ($p) = @_;
48 my ($q) = $store{"$p"} . $store{"objects.$p"} . $store{"resources.$p"};
49 $q =~ s/(\S+)\s[^\n]*\n/\$($1) /gs;
50 $q =~ s/ $//;
51 $q;
52}
53
54sub projlist {
55 my ($p) = @_;
56 my ($q) = $store{"$p"} . $store{"objects.$p"} . $store{"resources.$p"};
57 $q =~ s/(\S+)\s[^\n]*\n/$1 /gs;
58 my (@q) = split ' ',$q;
59 @q;
60}
61
62##-- CygWin makefile
63open OUT, ">Makefile.cyg"; select OUT;
64print
65"# Makefile for PuTTY under cygwin.\n";
66# gcc command line option is -D not /D
67($_ = $store{"help"}) =~ s/=\/D/=-D/gs;
68print $_;
69print
70"\n".
71"# You can define this path to point at your tools if you need to\n".
72"# TOOLPATH = c:\\cygwin\\bin\\ # or similar, if you're running Windows\n".
73"# TOOLPATH = /pkg/mingw32msvc/i386-mingw32msvc/bin/\n".
74"CC = \$(TOOLPATH)gcc\n".
75"RC = \$(TOOLPATH)windres\n".
76"# You may also need to tell windres where to find include files:\n".
77"# RCINC = --include-dir c:\\cygwin\\include\\\n".
78"\n".
f730b86a 79"CFLAGS = -mno-cygwin -Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT -D_NO_OLDNAMES -I.\n".
80"LDFLAGS = -mno-cygwin -s\n".
83623b0a 81"RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1 --define WINVER=0x0400 --define MINGW32_FIX=1\n".
3d541627 82"LIBS = -ladvapi32 -luser32 -lgdi32 -lwsock32 -lcomctl32 -lcomdlg32\n".
83"OBJ=o\n".
f730b86a 84"RES=res.o\n".
3d541627 85"\n";
86print $store{"objdefs"};
87print
88"\n".
89".SUFFIXES:\n".
90"\n".
201e9294 91"%.o: %.c\n".
3d541627 92"\t\$(CC) \$(FWHACK) \$(CFLAGS) -c \$<\n".
93"\n".
f730b86a 94"%.res.o: %.rc\n".
6ed3635b 95"\t\$(RC) \$(FWHACK) \$(RCFL) \$(RCFLAGS) \$< \$\@\n".
3d541627 96"\n";
97foreach $p (@projects) {
98 print $p, ".exe: ", &project($p), "\n";
f730b86a 99 my $mw = $gui{$p} ? " -mwindows" : "";
6d2d5e8d 100 $libstr = "";
101 foreach $lib (@{$libs{$p}}) { $libstr .= " -l$lib"; }
102 print "\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " . &project($p), " \$(LIBS)$libstr\n\n";
3d541627 103}
104print $store{"dependencies"};
105print
106"\n".
74091dff 107"version.o: FORCE;\n".
3d541627 108"# Hack to force version.o to be rebuilt always\n".
109"FORCE:\n".
201e9294 110"\t\$(CC) \$(FWHACK) \$(CFLAGS) \$(VER) -c version.c\n\n".
3d541627 111"clean:\n".
112"\trm -f *.o *.exe *.res\n".
113"\n";
114select STDOUT; close OUT;
115
116##-- Borland makefile
117open OUT, ">Makefile.bor"; select OUT;
118print
a7088bde 119"# Makefile for PuTTY under Borland C++.\n";
3d541627 120# bcc32 command line option is -D not /D
121($_ = $store{"help"}) =~ s/=\/D/=-D/gs;
122print $_;
123print
124"\n".
125"# If you rename this file to `Makefile', you should change this line,\n".
126"# so that the .rsp files still depend on the correct makefile.\n".
127"MAKEFILE = Makefile.bor\n".
128"\n".
3d541627 129"# Get include directory for resource compiler\n".
130"!if !\$d(BCB)\n".
131"BCB = \$(MAKEDIR)\\..\n".
132"!endif\n".
133"\n".
134".c.obj:\n".
135"\tbcc32 \$(COMPAT) \$(FWHACK) \$(CFLAGS) /c \$*.c\n".
136".rc.res:\n".
a7088bde 137"\tbrcc32 \$(FWHACK) \$(RCFL) -i \$(BCB)\\include \\\n".
138"\t\t-r -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0400 \$*.rc\n".
3d541627 139"\n".
140"OBJ=obj\n".
141"RES=res\n".
142"\n";
143print $store{"objdefs"};
144print "\n";
145print "all:";
146print map { " $_.exe" } @projects;
147print "\n\n";
148foreach $p (@projects) {
149 print $p, ".exe: ", &project($p), " $p.rsp\n";
e2f8bc05 150 $ap = $gui{$p} ? " -aa" : " -ap";
a7088bde 151 print "\tilink32$ap -Gn -L\$(BCB)\\lib \@$p.rsp\n\n";
3d541627 152}
153foreach $p (@projects) {
154 print $p, ".rsp: \$(MAKEFILE)\n";
a7088bde 155 $c0w = $gui{$p} ? "c0w32" : "c0x32";
156 print "\techo $c0w + > $p.rsp\n";
157 @objlines = &projlist("objects.$p");
158 for ($i=0; $i<=$#objlines; $i++) {
159 $plus = ($i < $#objlines ? " +" : "");
160 print "\techo \$($objlines[$i])$plus >> $p.rsp\n";
3d541627 161 }
a7088bde 162 print "\techo $p.exe >> $p.rsp\n";
6d2d5e8d 163 @libs = @{$libs{$p}};
164 unshift @libs, "cw32", "import32";
165 $libstr = join ' ', @libs;
166 print "\techo nul,$libstr, >> $p.rsp\n";
a7088bde 167 print "\techo " . (join " ", &project("resources.$p")) . " >> $p.rsp\n";
3d541627 168 print "\n";
169}
170print $store{"dependencies"};
171print
172"\n".
173"version.o: FORCE\n".
174"# Hack to force version.o to be rebuilt always\n".
175"FORCE:\n".
176"\tbcc32 \$(FWHACK) \$(VER) \$(CFLAGS) /c version.c\n\n".
177"clean:\n".
178"\tdel *.obj\n".
179"\tdel *.exe\n".
180"\tdel *.res\n".
181"\tdel *.pch\n".
182"\tdel *.aps\n".
a7088bde 183"\tdel *.il*\n".
3d541627 184"\tdel *.pdb\n".
a7088bde 185"\tdel *.rsp\n".
186"\tdel *.tds\n".
187"\tdel *.\$\$\$\$\$\$\n";
3d541627 188select STDOUT; close OUT;