From 3d541627ca0436e710c73b78ee9bf479141719cd Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 13 Dec 1999 17:21:42 +0000 Subject: [PATCH] Add multi-makefile management system git-svn-id: svn://svn.tartarus.org/sgt/putty@349 cda61777-01e9-0310-a592-d414129be87e --- Makefile | 156 ++++++++++++++++++++++++++++++++++--------------------- README | 6 +++ mkfiles.pl | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 274 insertions(+), 60 deletions(-) create mode 100755 mkfiles.pl diff --git a/Makefile b/Makefile index 00157caa..82aeeb2d 100644 --- a/Makefile +++ b/Makefile @@ -1,37 +1,67 @@ -# Makefile for PuTTY. Use `FWHACK=/DFWHACK' to cause the firewall hack -# to be built in. (requires rebuild of ssh.obj only) - -# Can also build with `VER=/DSNAPSHOT=1999-01-25' or -# `VER=/DRELEASE=0.43' to get version numbering; otherwise you'll -# get `Unidentified build'. - -# COMPAT=/DWIN32S_COMPAT will produce a binary that works (minimally) -# with Win32s +# Visual C++ Makefile for PuTTY. +# +# Use `nmake' to build. +# + +##-- help +# +# Extra options you can set: +# +# - FWHACK=/DFWHACK +# Enables a hack that tunnels through some firewall proxies. +# +# - VER=/DSNAPSHOT=1999-01-25 +# Generates executables whose About box report them as being a +# development snapshot. +# +# - VER=/DRELEASE=0.43 +# Generates executables whose About box report them as being a +# release version. +# +# - COMPAT=/DWIN32S_COMPAT +# Generates a binary that works (minimally) with Win32s. +# +##-- CFLAGS = /nologo /W3 /YX /O2 /Yd /D_WINDOWS /DDEBUG /ML /Fd .c.obj: cl $(COMPAT) $(FWHACK) $(CFLAGS) /c $*.c -POBJS1 = window.obj windlg.obj terminal.obj telnet.obj raw.obj -POBJS2 = xlat.obj ldisc.obj -OBJS1 = misc.obj noise.obj -OBJS2 = ssh.obj sshcrc.obj sshdes.obj sshmd5.obj sshrsa.obj sshrand.obj -OBJS3 = sshsha.obj sshblowf.obj version.obj sizetip.obj -RESRC = win_res.res +OBJ=obj +RES=res + +##-- objects putty +POBJS1 = window.$(OBJ) windlg.$(OBJ) terminal.$(OBJ) telnet.$(OBJ) raw.$(OBJ) +POBJS2 = xlat.$(OBJ) ldisc.$(OBJ) sizetip.$(OBJ) ssh.$(OBJ) +##-- objects pscp +SOBJS = scp.$(OBJ) windlg.$(OBJ) scpssh.$(OBJ) +##-- objects putty pscp +OBJS1 = misc.$(OBJ) noise.$(OBJ) +OBJS2 = sshcrc.$(OBJ) sshdes.$(OBJ) sshmd5.$(OBJ) sshrsa.$(OBJ) sshrand.$(OBJ) +OBJS3 = sshsha.$(OBJ) sshblowf.$(OBJ) version.$(OBJ) +##-- resources putty +PRESRC = win_res.$(RES) +##-- resources pscp +SRESRC = scp.$(RES) +##-- + +##-- gui-apps +# putty +##-- console-apps +# pscp +##-- + LIBS1 = advapi32.lib user32.lib gdi32.lib LIBS2 = wsock32.lib comctl32.lib comdlg32.lib -SCPOBJS = scp.obj windlg.obj misc.obj noise.obj -SCPOBJS2 = scpssh.obj sshcrc.obj sshdes.obj sshmd5.obj -SCPOBJS3 = sshrsa.obj sshrand.obj sshsha.obj sshblowf.obj version.obj all: putty.exe pscp.exe -putty.exe: $(POBJS1) $(POBJS2) $(OBJS1) $(OBJS2) $(OBJS3) $(RESRC) link.rsp +putty.exe: $(POBJS1) $(POBJS2) $(OBJS1) $(OBJS2) $(OBJS3) $(PRESRC) link.rsp link /debug -out:putty.exe @link.rsp -puttyd.exe: $(POBJS1) $(POBJS2) $(OBJS1) $(OBJS2) $(OBJS3) $(RESRC) link.rsp - link /debug -out:puttyd.exe @link.rsp +pscp.exe: $(SOBJS) $(OBJS1) $(OBJS2) $(OBJS3) $(SRESRC) scp.rsp + link /debug -out:pscp.exe @scp.rsp link.rsp: makefile echo /nologo /subsystem:windows > link.rsp @@ -40,55 +70,61 @@ link.rsp: makefile echo $(OBJS1) >> link.rsp echo $(OBJS2) >> link.rsp echo $(OBJS3) >> link.rsp - echo $(RESRC) >> link.rsp + echo $(PRESRC) >> link.rsp echo $(LIBS1) >> link.rsp echo $(LIBS2) >> link.rsp -window.obj: window.c putty.h win_res.h -windlg.obj: windlg.c putty.h ssh.h win_res.h -terminal.obj: terminal.c putty.h -sizetip.obj: sizetip.c putty.h -telnet.obj: telnet.c putty.h -raw.obj: raw.c putty.h -xlat.obj: xlat.c putty.h -ldisc.obj: ldisc.c putty.h -misc.obj: misc.c putty.h -noise.obj: noise.c putty.h ssh.h -ssh.obj: ssh.c ssh.h putty.h -sshcrc.obj: sshcrc.c ssh.h -sshdes.obj: sshdes.c ssh.h -sshmd5.obj: sshmd5.c ssh.h -sshrsa.obj: sshrsa.c ssh.h -sshsha.obj: sshsha.c ssh.h -sshrand.obj: sshrand.c ssh.h -sshblowf.obj: sshblowf.c ssh.h -version.obj: versionpseudotarget - @echo (built version.obj) +scp.rsp: makefile + echo /nologo /subsystem:console > scp.rsp + echo $(SOBJS) >> scp.rsp + echo $(OBJS1) >> scp.rsp + echo $(OBJS2) >> scp.rsp + echo $(OBJS3) >> scp.rsp + echo $(SRESRC) >> scp.rsp + echo $(LIBS1) >> scp.rsp + echo $(LIBS2) >> scp.rsp + +##-- dependencies +window.$(OBJ): window.c putty.h win_res.h +windlg.$(OBJ): windlg.c putty.h ssh.h win_res.h +terminal.$(OBJ): terminal.c putty.h +sizetip.$(OBJ): sizetip.c putty.h +telnet.$(OBJ): telnet.c putty.h +raw.$(OBJ): raw.c putty.h +xlat.$(OBJ): xlat.c putty.h +ldisc.$(OBJ): ldisc.c putty.h +misc.$(OBJ): misc.c putty.h +noise.$(OBJ): noise.c putty.h ssh.h +ssh.$(OBJ): ssh.c ssh.h putty.h +sshcrc.$(OBJ): sshcrc.c ssh.h +sshdes.$(OBJ): sshdes.c ssh.h +sshmd5.$(OBJ): sshmd5.c ssh.h +sshrsa.$(OBJ): sshrsa.c ssh.h +sshsha.$(OBJ): sshsha.c ssh.h +sshrand.$(OBJ): sshrand.c ssh.h +sshblowf.$(OBJ): sshblowf.c ssh.h +scp.$(OBJ): scp.c putty.h scp.h +scpssh.$(OBJ): scpssh.c putty.h ssh.h scp.h +version.$(OBJ): version.c +##-- # Hack to force version.obj to be rebuilt always +version.obj: versionpseudotarget + @echo (built version.obj) versionpseudotarget: cl $(FWHACK) $(VER) $(CFLAGS) /c version.c -win_res.res: win_res.rc win_res.h putty.ico +##-- dependencies +win_res.$(RES): win_res.rc win_res.h putty.ico +##-- +win_res.$(RES): rc $(FWHACK) -r -DWIN32 -D_WIN32 -DWINVER=0x0400 win_res.rc -pscp.exe: $(SCPOBJS) $(SCPOBJS2) $(SCPOBJS3) scp.res scp.rsp - link /debug -out:pscp.exe @scp.rsp - -scp.rsp: makefile - echo /nologo /subsystem:console > scp.rsp - echo $(SCPOBJS) >> scp.rsp - echo $(SCPOBJS2) >> scp.rsp - echo $(SCPOBJS3) >> scp.rsp - echo scp.res >> scp.rsp - echo $(LIBS1) >> scp.rsp - echo $(LIBS2) >> scp.rsp - -scp.obj: scp.c putty.h scp.h -scpssh.obj: scpssh.c putty.h ssh.h scp.h - -scp.res: scp.rc scp.ico - rc -r -DWIN32 -D_WIN32 -DWINVER=0x0400 scp.rc +##-- dependencies +scp.$(RES): scp.rc scp.ico +##-- +scp.$(RES): + rc $(FWHACK) -r -DWIN32 -D_WIN32 -DWINVER=0x0400 scp.rc clean: del *.obj diff --git a/README b/README index e8e2e67a..53f2c67e 100644 --- a/README +++ b/README @@ -19,6 +19,12 @@ problem while compiling PuTTY under VS6, you should: Alternatively disable the /ZI option, replacing it with a saner value, such as /Zi. +For other compilers, some alternative Makefiles are provided. These +Makefiles are generated automatically from the master `Makefile' by +the Perl script `mkfiles.pl'. Additions and corrections to the +script are more useful than additions and corrections to the +alternative Makefiles themselves. + The PuTTY home web site is http://www.chiark.greenend.org.uk/~sgtatham/putty.html diff --git a/mkfiles.pl b/mkfiles.pl new file mode 100755 index 00000000..70eed6c5 --- /dev/null +++ b/mkfiles.pl @@ -0,0 +1,172 @@ +#!/usr/bin/env perl +# +# Makefile generator. +# Produces the other PuTTY makefiles from the master one. + +open IN,"Makefile"; +@current = (); +while () { + 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/^# //; + $gui{$i} = 1; +} + +foreach $i (split '\n',$store{'console-apps'}) { + $i =~ s/^# //; + $gui{$i} = -0; +} + +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". +"CFLAGS = -g -O2 -D_WINDOWS -DDEBUG\n". +"RCFLAGS = \$(RCINC) --define WIN32=1 --define _WIN32=1 --define WINVER=0x0400\n". +"LIBS = -ladvapi32 -luser32 -lgdi32 -lwsock32 -lcomctl32 -lcomdlg32\n". +"OBJ=o\n". +"RES=res\n". +"\n"; +print $store{"objdefs"}; +print +"\n". +".SUFFIXES:\n". +"\n". +"%.o %.obj: %.c\n". +"\t\$(CC) \$(FWHACK) \$(CFLAGS) -c \$<\n". +"\n". +"%.res: %.rc\n". +"\t\$(RC) \$(FWHACK) \$(RCFLAGS) \$<\n". +"\n"; +foreach $p (@projects) { + print $p, ".exe: ", &project($p), "\n"; + print "\t\$(CC) \$(LDFLAGS) -o \$@ " . &project($p), " \$(LIBS)\n\n"; +} +print $store{"dependencies"}; +print +"\n". +"version.o: FORCE\n". +"# Hack to force version.o to be rebuilt always\n". +"FORCE:\n". +"\t\$(CC) \$(FWHACK) \$(CFLAGS) \$(VER) -c \$<\n\n". +"clean:\n". +"\trm -f *.o *.exe *.res\n". +"\n"; +select STDOUT; close OUT; + +##-- Borland makefile +open OUT, ">Makefile.bor"; select OUT; +print +"# Makefile for PuTTY under Borland C.\n"; +# 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". +"# Stop windows.h including winsock2.h which would conflict with winsock 1\n". +"CFLAGS = -DWIN32_LEAN_AND_MEAN\n". +"\n". +"# Get include directory for resource compiler\n". +"!if !\$d(BCB)\n". +"BCB = \$(MAKEDIR)\\..\n". +"!endif\n". +"\n". +".c.obj:\n". +"\tbcc32 \$(COMPAT) \$(FWHACK) \$(CFLAGS) /c \$*.c\n". +".rc.res:\n". +"\tbrc32 \$(FWHACK) -i \$(BCB)\\include \\\n". +"\t\t-r -DWIN32 -D_WIN32 -DWINVER=0x0400 \$*.rc\n". +"\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"; + $tw = $gui{$p} ? " -tW" : ""; + print "\tbcc32$tw -e$p.exe \@$p.rsp\n"; + print "\tbrc32 -fe$p.exe " . (join " ", &project("resources.$p")) . "\n\n"; +} +foreach $p (@projects) { + print $p, ".rsp: \$(MAKEFILE)\n"; + $arrow = ">"; + foreach $i (&projlist("objects.$p")) { + print "\techo \$($i) $arrow $p.rsp\n"; + $arrow = ">>"; + } + 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". +"\tdel *.ilk\n". +"\tdel *.pdb\n". +"\tdel *.rsp\n"; +select STDOUT; close OUT; -- 2.11.0