1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Replace mkfiles.pl with a CMake build system.

This brings various concrete advantages over the previous system:

 - consistent support for out-of-tree builds on all platforms

 - more thorough support for Visual Studio IDE project files

 - support for Ninja-based builds, which is particularly useful on
   Windows where the alternative nmake has no parallel option

 - a really simple set of build instructions that work the same way on
   all the major platforms (look how much shorter README is!)

 - better decoupling of the project configuration from the toolchain
   configuration, so that my Windows cross-building doesn't need
   (much) special treatment in CMakeLists.txt

 - configure-time tests on Windows as well as Linux, so that a lot of
   ad-hoc #ifdefs second-guessing a particular feature's presence from
   the compiler version can now be replaced by tests of the feature
   itself

Also some longer-term software-engineering advantages:

 - other people have actually heard of CMake, so they'll be able to
   produce patches to the new build setup more easily

 - unlike the old mkfiles.pl, CMake is not my personal problem to
   maintain

 - most importantly, mkfiles.pl was just a horrible pile of
   unmaintainable cruft, which even I found it painful to make changes
   to or to use, and desperately needed throwing in the bin. I've
   already thrown away all the variants of it I had in other projects
   of mine, and was only delaying this one so we could make the 0.75
   release branch first.

This change comes with a noticeable build-level restructuring. The
previous Recipe worked by compiling every object file exactly once,
and then making each executable by linking a precisely specified
subset of the same object files. But in CMake, that's not the natural
way to work - if you write the obvious command that puts the same
source file into two executable targets, CMake generates a makefile
that compiles it once per target. That can be an advantage, because it
gives you the freedom to compile it differently in each case (e.g.
with a #define telling it which program it's part of). But in a
project that has many executable targets and had carefully contrived
to _never_ need to build any module more than once, all it does is
bloat the build time pointlessly!

To avoid slowing down the build by a large factor, I've put most of
the modules of the code base into a collection of static libraries
organised vaguely thematically (SSH, other backends, crypto, network,
...). That means all those modules can still be compiled just once
each, because once each library is built it's reused unchanged for all
the executable targets.

One upside of this library-based structure is that now I don't have to
manually specify exactly which objects go into which programs any more
- it's enough to specify which libraries are needed, and the linker
will figure out the fine detail automatically. So there's less
maintenance to do in CMakeLists.txt when the source code changes.

But that reorganisation also adds fragility, because of the trad Unix
linker semantics of walking along the library list once each, so that
cyclic references between your libraries will provoke link errors. The
current setup builds successfully, but I suspect it only just manages
it.

(In particular, I've found that MinGW is the most finicky on this
score of the Windows compilers I've tried building with. So I've
included a MinGW test build in the new-look Buildscr, because
otherwise I think there'd be a significant risk of introducing
MinGW-only build failures due to library search order, which wasn't a
risk in the previous library-free build organisation.)

In the longer term I hope to be able to reduce the risk of that, via
gradual reorganisation (in particular, breaking up too-monolithic
modules, to reduce the risk of knock-on references when you included a
module for function A and it also contains function B with an
unsatisfied dependency you didn't really need). Ideally I want to
reach a state in which the libraries all have sensibly described
purposes, a clearly documented (partial) order in which they're
permitted to depend on each other, and a specification of what stubs
you have to put where if you're leaving one of them out (e.g.
nocrypto) and what callbacks you have to define in your non-library
objects to satisfy dependencies from things low in the stack (e.g.
out_of_memory()).

One thing that's gone completely missing in this migration,
unfortunately, is the unfinished MacOS port linked against Quartz GTK.
That's because it turned out that I can't currently build it myself,
on my own Mac: my previous installation of GTK had bit-rotted as a
side effect of an Xcode upgrade, and I haven't yet been able to
persuade jhbuild to make me a new one. So I can't even build the MacOS
port with the _old_ makefiles, and hence, I have no way of checking
that the new ones also work. I hope to bring that port back to life at
some point, but I don't want it to block the rest of this change.
This commit is contained in:
Simon Tatham 2021-04-10 15:21:11 +01:00
parent 97f7a7cb4d
commit c19e7215dd
44 changed files with 1272 additions and 3176 deletions

32
.gitignore vendored
View File

@ -19,9 +19,6 @@
/*.tds
/*.td2
/*.map
/Makefile.mgw
/Makefile.vc
/Makefile.lcc
/MSVC
/*.log
/*.GID
@ -56,27 +53,9 @@
/.bmake
/build.log
/build.out
/uxconfig.h
/empty.h
/config.status
/Makefile.am
/Makefile.in
/Makefile
/compile
/config.status
/configure
/stamp-h1
/aclocal.m4
/ar-lib
/autom4te.cache
/depcomp
/install-sh
/local
/missing
/uxconfig.in
/uxconfig.in~
/uxconfig.h
/licence.h
/*.a
/charset/sbcsdat.c
/contrib/cygtermd/cygtermd.exe
@ -102,9 +81,6 @@
/icons/*.icns
/icons/*.xpm
/icons/*.c
/unix/Makefile.gtk
/unix/Makefile.ux
/unix/Makefile.local
/unix/empty.h
/unix/plink
/unix/pterm
@ -133,14 +109,6 @@
/windows/*.td2
/windows/*.map
/windows/*.rcpp
/windows/Makefile.clangcl
/windows/Makefile.mgw
/windows/Makefile.vc
/windows/Makefile.lcc
/windows/MSVC
/windows/DEVCPP
/windows/VS2010
/windows/VS2012
/windows/*.log
/windows/*.GID
/windows/local

140
Buildscr
View File

@ -74,12 +74,6 @@ ifneq "$(PRERELEASE)" "" set Uxarcsuffix -$(PRERELEASE)~pre$(Ndate).$(vcsid)
ifneq "$(SNAPSHOT)" "" set Uxarcsuffix -$(Lastver)-$(Date).$(vcsid)
ifeq "$(RELEASE)$(PRERELEASE)$(SNAPSHOT)" "" set Uxarcsuffix -custom-$(Date).$(vcsid)
# Set up the version number for the autoconf system.
ifneq "$(RELEASE)" "" set Autoconfver $(RELEASE)
ifneq "$(PRERELEASE)" "" set Autoconfver $(PRERELEASE)~pre$(Ndate).$(vcsid)
ifneq "$(SNAPSHOT)" "" set Autoconfver $(Lastver)-$(Date).$(vcsid)
ifeq "$(RELEASE)$(PRERELEASE)$(SNAPSHOT)" "" set Autoconfver Custom.$(Date).$(vcsid)
# Set up the filenames for the Windows installers (minus extension,
# which goes on later).
ifneq "$(RELEASE)" "" set Isuffix $(RELEASE)-installer
@ -122,31 +116,37 @@ ifneq "$(SNAPSHOT)" "" in putty do echo '$#define SNAPSHOT' >> version.h
in putty do echo '$#define TEXTVER "$(Textver)"' >> version.h
in putty do echo '$#define SSHVER "$(Sshver)"' >> version.h
in putty do echo '$#define BINARY_VERSION $(Winvercommas)' >> version.h
in putty do echo '$#define SOURCE_COMMIT "$(vcsfullid)"' >> version.h
# Set up the extra arguments for the main Windows nmake command. The
# user can define XFLAGS and MAKEARGS on the bob command line, to pass
# in extra compile and make options respectively (e.g. to do a
# debugging or Minefield build).
set Makeargs
ifneq "$(XFLAGS)" "" set Makeargs $(Makeargs) XFLAGS="$(XFLAGS)"
ifneq "$(MAKEARGS)" "" set Makeargs $(Makeargs) $(MAKEARGS)
# In cmake/gitcommit.cmake, replace the default output "unavailable"
# with the commit string generated by bob, so that people rebuilding
# the source archive will still get a useful value.
in putty do sed -i '/set(DEFAULT_COMMIT/s/unavailable/$(vcsfullid)/' cmake/gitcommit.cmake
in putty do ./mksrcarc.sh
in putty do ./mkunxarc.sh '$(Autoconfver)' '$(Uxarcsuffix)' $(Docmakever)
in putty do perl mkfiles.pl
in putty do ./mkunxarc.sh '$(Uxarcsuffix)' $(Docmakever)
in putty/doc do make $(Docmakever) putty.chm -j$(nproc)
delegate -
# Run the test suite, under self-delegation so that we don't leave any
# cruft lying around. This involves doing a build of the Unix tools
# (which is a useful double-check anyway to pick up any build failures)
in putty do ./mkauto.sh
in putty do ./configure CC=clang CFLAGS="-fsanitize=address -fsanitize=leak"
in putty do make -j$(nproc)
in putty do cmake . -DCMAKE_C_COMPILER=clang -DCMAKE_C_FLAGS="-fsanitize=address -fsanitize=leak" -DSTRICT=ON
in putty do make -j$(nproc) VERBOSE=1
in putty do python3 test/cryptsuite.py
enddelegate
delegate -
# Also, test-build the Windows tools using MinGW. This is important if
# we want the MinGW build to carry on working, partly because of the
# chance of compiler compatibility issues, but mostly because MinGW's
# linker uses Unix-style library search semantics (once down the
# library list), and no other Windows toolchain we build with is that
# picky. So this ensures the Windows library structure continues to
# work in the most difficult circumstance we expect it to encounter.
in putty do cmake . -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-mingw.cmake
in putty do make -j$(nproc) VERBOSE=1
enddelegate
# Windowsify LICENCE, since it's going in the Windows installers.
in putty do perl -i~ -pe 'y/\015//d;s/$$/\015/' LICENCE
@ -165,20 +165,20 @@ mkdir putty/windows/abuild64
#
# For the 32-bit ones, we set a subsystem version of 5.01, which
# allows the resulting files to still run on Windows XP.
in putty/windows with clangcl32 do Platform=x86 make -f Makefile.clangcl BUILDDIR=build32/ SUBSYSVER=,5.01 $(Makeargs) all -j$(nproc)
in putty/windows with clangcl64 do Platform=x64 make -f Makefile.clangcl BUILDDIR=build64/ $(Makeargs) all -j$(nproc)
in putty/windows/build32 with cmake_at_least_3.20 do cmake ../.. -DCMAKE_TOOLCHAIN_FILE=$(cmake_toolchain_clangcl32) -DCMAKE_BUILD_TYPE=Release -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DPUTTY_LINK_MAPS=ON
in putty/windows/build32 with cmake_at_least_3.20 do make -j$(nproc) VERBOSE=1
in putty/windows/build64 with cmake_at_least_3.20 do cmake ../.. -DCMAKE_TOOLCHAIN_FILE=$(cmake_toolchain_clangcl64) -DCMAKE_BUILD_TYPE=Release -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DPUTTY_LINK_MAPS=ON
in putty/windows/build64 with cmake_at_least_3.20 do make -j$(nproc) VERBOSE=1
# Build experimental Arm Windows binaries.
in putty/windows with clangcl_a32 do Platform=arm make -f Makefile.clangcl BUILDDIR=abuild32/ SUBSYSVER=,5.01 $(Makeargs) all -j$(nproc)
in putty/windows with clangcl_a64 do Platform=arm64 make -f Makefile.clangcl BUILDDIR=abuild64/ $(Makeargs) all -j$(nproc)
in putty/windows/abuild32 with cmake_at_least_3.20 do cmake ../.. -DCMAKE_TOOLCHAIN_FILE=$(cmake_toolchain_clangcl_a32) -DCMAKE_BUILD_TYPE=Release -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DPUTTY_LINK_MAPS=ON
in putty/windows/abuild32 with cmake_at_least_3.20 do make -j$(nproc) VERBOSE=1
in putty/windows/abuild64 with cmake_at_least_3.20 do cmake ../.. -DCMAKE_TOOLCHAIN_FILE=$(cmake_toolchain_clangcl_a64) -DCMAKE_BUILD_TYPE=Release -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DPUTTY_LINK_MAPS=ON
in putty/windows/abuild64 with cmake_at_least_3.20 do make -j$(nproc) VERBOSE=1
# Remove Windows binaries for the test programs we don't want to ship,
# like testcrypt.exe. (But we still _built_ them, to ensure the build
# worked.)
in putty/windows do make -f Makefile.clangcl BUILDDIR=build32/ cleantestprogs
in putty/windows do make -f Makefile.clangcl BUILDDIR=build64/ cleantestprogs
in putty/windows do make -f Makefile.clangcl BUILDDIR=abuild32/ cleantestprogs
in putty/windows do make -f Makefile.clangcl BUILDDIR=abuild64/ cleantestprogs
# Make a list of the Windows binaries we're going to ship, so that we
# can sign them.
in putty/windows do for subdir in build32 abuild32 build64 abuild64; do sed "s!^!$$subdir/!" $$subdir/shipped.txt; done > to-sign.txt
# Code-sign the Windows binaries, if the local bob config provides a
# script to do so in a cross-compiling way. We assume here that the
@ -187,7 +187,7 @@ in putty/windows do make -f Makefile.clangcl BUILDDIR=abuild64/ cleantestprogs
# take the program name from an .exe's version resource, and that it
# can accept multiple .exe or .msi filename arguments and sign them
# all in place.
ifneq "$(cross_winsigncode)" "" in putty/windows do $(cross_winsigncode) -N -i https://www.chiark.greenend.org.uk/~sgtatham/putty/ build*/*.exe abuild*/*.exe
ifneq "$(cross_winsigncode)" "" in putty/windows do $(cross_winsigncode) -N -i https://www.chiark.greenend.org.uk/~sgtatham/putty/ $$(cat to-sign.txt)
# Make a preliminary set of cryptographic checksums giving the hashes
# of these versions of the binaries. We'll make the rest below.
@ -217,19 +217,16 @@ in putty/windows do ./msifixup.py installera64.msi --dialog-bmp-width=123 --plat
# Sign the Windows installers.
ifneq "$(cross_winsigncode)" "" in putty/windows do $(cross_winsigncode) -i https://www.chiark.greenend.org.uk/~sgtatham/putty/ -n "PuTTY Installer" installer32.msi installer64.msi installera32.msi installera64.msi
# Delete the binaries and resource files from the build directories,
# so that we can rebuild them differently.
in putty/windows/build32 do rm -f *.exe *.res *.rcpp
in putty/windows/build64 do rm -f *.exe *.res *.rcpp
in putty/windows/abuild32 do rm -f *.exe *.res *.rcpp
in putty/windows/abuild64 do rm -f *.exe *.res *.rcpp
# Build the standalone binaries, in both 32- and 64-bit flavours.
# These differ from the previous set in that they embed the help file.
in putty/windows with clangcl32 do Platform=x86 make -f Makefile.clangcl BUILDDIR=build32/ RCFL=-DEMBED_CHM SUBSYSVER=,5.01 $(Makeargs) all -j$(nproc)
in putty/windows with clangcl64 do Platform=x64 make -f Makefile.clangcl BUILDDIR=build64/ RCFL=-DEMBED_CHM $(Makeargs) all -j$(nproc)
in putty/windows with clangcl_a32 do Platform=arm make -f Makefile.clangcl BUILDDIR=abuild32/ RCFL=-DEMBED_CHM SUBSYSVER=,5.01 $(Makeargs) all -j$(nproc)
in putty/windows with clangcl_a64 do Platform=arm64 make -f Makefile.clangcl BUILDDIR=abuild64/ RCFL=-DEMBED_CHM $(Makeargs) all -j$(nproc)
in putty/windows/build32 with cmake_at_least_3.20 do cmake . -DPUTTY_EMBEDDED_CHM_FILE=$$(realpath ../../doc/putty.chm)
in putty/windows/build32 with cmake_at_least_3.20 do make -j$(nproc) VERBOSE=1
in putty/windows/build64 with cmake_at_least_3.20 do cmake . -DPUTTY_EMBEDDED_CHM_FILE=$$(realpath ../../doc/putty.chm)
in putty/windows/build64 with cmake_at_least_3.20 do make -j$(nproc) VERBOSE=1
in putty/windows/abuild32 with cmake_at_least_3.20 do cmake . -DPUTTY_EMBEDDED_CHM_FILE=$$(realpath ../../doc/putty.chm)
in putty/windows/abuild32 with cmake_at_least_3.20 do make -j$(nproc) VERBOSE=1
in putty/windows/abuild64 with cmake_at_least_3.20 do cmake . -DPUTTY_EMBEDDED_CHM_FILE=$$(realpath ../../doc/putty.chm)
in putty/windows/abuild64 with cmake_at_least_3.20 do make -j$(nproc) VERBOSE=1
# Build the 'old' binaries, which should still run on all 32-bit
# versions of Windows back to Win95 (but not Win32s). These link
@ -241,42 +238,45 @@ in putty/windows with clangcl_a64 do Platform=arm64 make -f Makefile.clangcl BUI
#
# There's no installer to go with these, so they must also embed the
# help file.
in putty/windows with clangcl32_2003 do Platform=x86 make -f Makefile.clangcl BUILDDIR=buildold/ RCFL=-DEMBED_CHM $(Makeargs) CCTARGET=i386-pc-windows-msvc13.0.0 SUBSYSVER=,4.0 EXTRA_windows=wincrt0.obj EXTRA_console=crt0.obj EXTRA_libs=libcpmt.lib XFLAGS="/arch:IA32 -Wno-pragma-pack" all -j$(nproc)
in putty/windows/buildold with cmake_at_least_3.20 do cmake ../.. -DCMAKE_TOOLCHAIN_FILE=$(cmake_toolchain_clangcl32_2003) -DCMAKE_BUILD_TYPE=Release -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DPUTTY_LINK_MAPS=ON
in putty/windows/buildold with cmake_at_least_3.20 do make -j$(nproc) VERBOSE=1
# Remove test programs again.
in putty/windows do make -f Makefile.clangcl BUILDDIR=build32/ cleantestprogs
in putty/windows do make -f Makefile.clangcl BUILDDIR=build64/ cleantestprogs
in putty/windows do make -f Makefile.clangcl BUILDDIR=abuild32/ cleantestprogs
in putty/windows do make -f Makefile.clangcl BUILDDIR=abuild64/ cleantestprogs
in putty/windows do make -f Makefile.clangcl BUILDDIR=buildold/ cleantestprogs
# Regenerate to-sign.txt with the 'old' binaries included.
in putty/windows do for subdir in build32 abuild32 build64 abuild64 buildold; do sed "s!^!$$subdir/!" $$subdir/shipped.txt; done > to-sign.txt
# Code-sign the standalone versions of the binaries.
ifneq "$(cross_winsigncode)" "" in putty/windows do $(cross_winsigncode) -N -i https://www.chiark.greenend.org.uk/~sgtatham/putty/ build*/*.exe abuild*/*.exe
ifneq "$(cross_winsigncode)" "" in putty/windows do $(cross_winsigncode) -N -i https://www.chiark.greenend.org.uk/~sgtatham/putty/ $$(cat to-sign.txt)
# Move the shipped (and signed) binaries into another directory to
# deliver them from, so that we omit testcrypt and its ilk.
in putty/windows do mkdir deliver
in putty/windows do for subdir in build32 abuild32 build64 abuild64 buildold; do mkdir deliver/$$subdir; done
in putty/windows do while read x; do mv $$x deliver/$$x; mv $$x.map deliver/$$x.map; done < to-sign.txt
in putty/doc do make mostlyclean
in putty/doc do make $(Docmakever) -j$(nproc)
in putty/windows/buildold do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../doc/putty.chm
in putty/windows/build32 do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../doc/putty.chm
in putty/windows/build64 do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../doc/putty.chm
in putty/windows/abuild32 do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../doc/putty.chm
in putty/windows/abuild64 do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../doc/putty.chm
in putty/windows/deliver/buildold do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../doc/putty.chm
in putty/windows/deliver/build32 do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../doc/putty.chm
in putty/windows/deliver/build64 do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../doc/putty.chm
in putty/windows/deliver/abuild32 do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../doc/putty.chm
in putty/windows/deliver/abuild64 do zip -k -j putty.zip `ls *.exe | grep -v puttytel` ../../doc/putty.chm
in putty/doc do zip puttydoc.zip *.html
# Deliver the actual PuTTY release directory into a subdir `putty'.
deliver putty/windows/buildold/*.exe putty/w32old/$@
deliver putty/windows/buildold/putty.zip putty/w32old/$@
deliver putty/windows/build32/*.exe putty/w32/$@
deliver putty/windows/build32/putty.zip putty/w32/$@
deliver putty/windows/build64/*.exe putty/w64/$@
deliver putty/windows/build64/putty.zip putty/w64/$@
deliver putty/windows/deliver/buildold/*.exe putty/w32old/$@
deliver putty/windows/deliver/buildold/putty.zip putty/w32old/$@
deliver putty/windows/deliver/build32/*.exe putty/w32/$@
deliver putty/windows/deliver/build32/putty.zip putty/w32/$@
deliver putty/windows/deliver/build64/*.exe putty/w64/$@
deliver putty/windows/deliver/build64/putty.zip putty/w64/$@
deliver putty/windows/installer32.msi putty/w32/$(Ifilename32).msi
deliver putty/windows/installer64.msi putty/w64/$(Ifilename64).msi
deliver putty/windows/installera32.msi putty/wa32/$(Ifilenamea32).msi
deliver putty/windows/installera64.msi putty/wa64/$(Ifilenamea64).msi
deliver putty/windows/abuild32/*.exe putty/wa32/$@
deliver putty/windows/abuild32/putty.zip putty/wa32/$@
deliver putty/windows/abuild64/*.exe putty/wa64/$@
deliver putty/windows/abuild64/putty.zip putty/wa64/$@
deliver putty/windows/deliver/abuild32/*.exe putty/wa32/$@
deliver putty/windows/deliver/abuild32/putty.zip putty/wa32/$@
deliver putty/windows/deliver/abuild64/*.exe putty/wa64/$@
deliver putty/windows/deliver/abuild64/putty.zip putty/wa64/$@
deliver putty/doc/puttydoc.zip putty/$@
deliver putty/doc/putty.chm putty/$@
deliver putty/doc/puttydoc.txt putty/$@
@ -285,11 +285,11 @@ deliver putty/putty-src.zip putty/$@
deliver putty/*.tar.gz putty/$@
# Deliver the map files alongside the `proper' release deliverables.
deliver putty/windows/buildold/*.map maps/w32old/$@
deliver putty/windows/build32/*.map maps/w32/$@
deliver putty/windows/build64/*.map maps/w64/$@
deliver putty/windows/abuild32/*.map maps/wa32/$@
deliver putty/windows/abuild64/*.map maps/wa64/$@
deliver putty/windows/deliver/buildold/*.map maps/w32old/$@
deliver putty/windows/deliver/build32/*.map maps/w32/$@
deliver putty/windows/deliver/build64/*.map maps/w64/$@
deliver putty/windows/deliver/abuild32/*.map maps/wa32/$@
deliver putty/windows/deliver/abuild64/*.map maps/wa64/$@
# Deliver sign.sh, so that whoever has just built PuTTY (the
# snapshot scripts or me, depending) can conveniently sign it with

View File

@ -6,16 +6,12 @@
module putty
# Preparations.
in putty do ./mkfiles.pl
in putty do ./mkauto.sh
in putty/doc do make
# Scan the Unix build, on a 64-bit system to differentiate as much as
# possible from the other scan of the cross-platform files.
delegate covscan64
in putty do ./configure
in putty do cov-build --dir cov-int make
in putty do mkdir linbuild
in putty/linbuild do cmake ..
in putty/linbuild do cov-build --dir ../cov-int make -j$(nproc) VERBOSE=1
in putty do tar czvf cov-int.tar.gz cov-int
return putty/cov-int.tar.gz
enddelegate
@ -25,7 +21,9 @@ enddelegate
# Windows scanner for download).
delegate covscan32wine
in putty do tar xzvf cov-int.tar.gz
in putty/windows do cov-build --dir ../cov-int make -f Makefile.mgw CC=winegcc RC=wrc
in putty do mkdir winbuild
in putty/winbuild do cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-winegcc.cmake
in putty/winbuild do cov-build --dir ../cov-int make -j$(nproc) VERBOSE=1
in putty do tar czvf cov-int.tar.gz cov-int
return putty/cov-int.tar.gz
enddelegate

101
CMakeLists.txt Normal file
View File

@ -0,0 +1,101 @@
cmake_minimum_required(VERSION 3.12)
project(putty LANGUAGES C)
include(cmake/setup.cmake)
add_library(utils STATIC
memory.c marshal.c utils.c conf.c sshutils.c tree234.c version.c
wildcard.c wcwidth.c misc.c miscucs.c stripctrl.c sessprep.c
${GENERATED_COMMIT_C})
add_library(logging OBJECT
logging.c)
add_library(eventloop STATIC
callback.c timing.c)
add_library(console STATIC
clicons.c console.c)
add_library(settings STATIC
cmdline.c settings.c)
add_library(crypto STATIC
sshaes.c sshauxcrypt.c sshdes.c sshdss.c sshecc.c sshhmac.c sshmd5.c sshrsa.c
sshsh256.c sshsh512.c sshsha.c sshsha3.c
ecc.c mpint.c
sshprng.c
sshcrc.c
sshdh.c sshmac.c
ssharcf.c sshblowf.c sshccp.c
sshblake2.c sshargon2.c sshbcrypt.c
cproxy.c)
add_library(network STATIC
be_misc.c nullplug.c errsock.c proxy.c logging.c)
add_library(keygen STATIC
millerrabin.c mpunsafe.c pockle.c primecandidate.c smallprimes.c
sshdssg.c sshecdsag.c sshprime.c sshrsag.c
import.c)
add_library(agent STATIC
sshpubk.c pageant.c aqsync.c)
add_library(guiterminal STATIC
terminal.c ldisc.c minibidi.c config.c dialog.c
$<TARGET_OBJECTS:logging>)
add_library(noterminal STATIC
noterm.c ldisc.c)
add_library(sshcommon OBJECT
ssh1bpp.c ssh1censor.c
ssh1connection.c ssh1login.c ssh2bpp-bare.c ssh2bpp.c ssh2censor.c
ssh2connection.c ssh2transhk.c ssh2transport.c ssh2userauth.c
sshcommon.c sshcrcda.c sshgssc.c sshpubk.c sshrand.c
sshverstring.c sshzlib.c
pgssapi.c portfwd.c x11fwd.c)
add_library(sftpcommon OBJECT
sftpcommon.c)
add_library(all-backends OBJECT
pinger.c)
add_library(sshclient STATIC
ssh1connection-client.c ssh2connection-client.c ssh2kex-client.c
sshshare.c ssh.c
mainchan.c agentf.c
$<TARGET_OBJECTS:sshcommon>
$<TARGET_OBJECTS:all-backends>
$<TARGET_OBJECTS:logging>)
add_library(sshserver STATIC
ssh1connection-server.c ssh1login-server.c ssh2connection-server.c
ssh2kex-server.c ssh2userauth-server.c sshserver.c
sesschan.c
sftpserver.c
$<TARGET_OBJECTS:sftpcommon>
$<TARGET_OBJECTS:sshcommon>)
add_library(sftpclient STATIC
psftpcommon.c sftp.c $<TARGET_OBJECTS:sftpcommon>)
add_library(otherbackends STATIC
telnet.c rlogin.c raw.c supdup.c
$<TARGET_OBJECTS:all-backends>
$<TARGET_OBJECTS:logging>)
add_executable(testcrypt
testcrypt.c sshpubk.c sshcrcda.c)
target_link_libraries(testcrypt
keygen crypto utils ${platform_libraries})
add_compile_definitions(HAVE_CMAKE_H)
foreach(subdir ${PLATFORM_SUBDIRS})
add_subdirectory(${subdir})
endforeach()
configure_file(cmake/cmake.h.in ${GENERATED_SOURCES_DIR}/cmake.h)

125
README
View File

@ -1,123 +1,12 @@
This is the README for the source archive of PuTTY, a free Windows
and Unix Telnet and SSH client.
This is the README for PuTTY, a free Windows and Unix Telnet and SSH
client.
If you want to rebuild PuTTY from source, we provide a variety of
Makefiles and equivalents. (If you have fetched the source from
Git, you'll have to generate the Makefiles yourself -- see
below.)
PuTTY is built using CMake <https://cmake.org/>. To compile in the
simplest way (on any of Linux, Windows or Mac), run these commands in
the source directory:
There are various compile-time directives that you can use to
disable or modify certain features; it may be necessary to do this
in some environments. They are documented in `Recipe', and in
comments in many of the generated Makefiles.
For building on Windows:
- windows/Makefile.vc is for command-line builds on MS Visual C++
systems. Change into the `windows' subdirectory and type `nmake
-f Makefile.vc' to build all the PuTTY binaries.
As of 2017, we successfully compile PuTTY with both Visual Studio
7 (2003) and Visual Studio 14 (2015), so our guess is that it will
probably build with versions in between those as well.
(The binaries from Visual Studio 14 are only compatible with
Windows XP and up. Binaries from Visual Studio 7 ought to work
with anything from Windows 95 onward.)
- Inside the windows/MSVC subdirectory are MS Visual Studio project
files for doing GUI-based builds of the various PuTTY utilities.
These have been tested on Visual Studio 7 and 10.
You should be able to build each PuTTY utility by loading the
corresponding .dsp file in Visual Studio. For example,
MSVC/putty/putty.dsp builds PuTTY itself, MSVC/plink/plink.dsp
builds Plink, and so on.
- windows/Makefile.mgw is for MinGW / Cygwin installations. Type
`make -f Makefile.mgw' while in the `windows' subdirectory to
build all the PuTTY binaries.
MinGW and friends can lag behind other toolchains in their support
for the Windows API. Compile-time levers are provided to exclude
some features; the defaults are set appropriately for the
'mingw-w64' cross-compiler provided with Ubuntu 14.04. If you are
using an older toolchain, you may need to exclude more features;
alternatively, you may find that upgrading to a recent version of
the 'w32api' package helps.
- windows/Makefile.lcc is for lcc-win32. Type `make -f
Makefile.lcc' while in the `windows' subdirectory. (You will
probably need to specify COMPAT=-DNO_MULTIMON.)
- Inside the windows/DEVCPP subdirectory are Dev-C++ project
files for doing GUI-based builds of the various PuTTY utilities.
The PuTTY team actively use Makefile.vc (with VC7/10) and Makefile.mgw
(with mingw32), so we'll probably notice problems with those
toolchains fairly quickly. Please report any problems with the other
toolchains mentioned above.
For building on Unix:
- unix/configure is for Unix and GTK. If you don't have GTK, you
should still be able to build the command-line utilities (PSCP,
PSFTP, Plink, PuTTYgen) using this script. To use it, change into
the `unix' subdirectory, run `./configure' and then `make'. Or you
can do the same in the top-level directory (we provide a little
wrapper that invokes configure one level down), which is more like
a normal Unix source archive but doesn't do so well at keeping the
per-platform stuff in each platform's subdirectory; it's up to you.
- unix/Makefile.gtk and unix/Makefile.ux are for non-autoconfigured
builds. These makefiles expect you to change into the `unix'
subdirectory, then run `make -f Makefile.gtk' or `make -f
Makefile.ux' respectively. Makefile.gtk builds all the programs but
relies on Gtk, whereas Makefile.ux builds only the command-line
utilities and has no Gtk dependence.
- For the graphical utilities, any of Gtk+-1.2, Gtk+-2.0, and Gtk+-3.0
should be supported. If you have more than one installed, you can
manually specify which one you want by giving the option
'--with-gtk=N' to the configure script where N is 1, 2, or 3.
(The default is the newest available, of course.) In the absence
of any Gtk version, the configure script will automatically
construct a Makefile which builds only the command-line utilities;
you can manually create this condition by giving configure the
option '--without-gtk'.
- pterm would like to be setuid or setgid, as appropriate, to permit
it to write records of user logins to /var/run/utmp and
/var/log/wtmp. (Of course it will not use this privilege for
anything else, and in particular it will drop all privileges before
starting up complex subsystems like GTK.) By default the makefile
will not attempt to add privileges to the pterm executable at 'make
install' time, but you can ask it to do so by running configure
with the option '--enable-setuid=USER' or '--enable-setgid=GROUP'.
- The Unix Makefiles have an `install' target. Note that by default
it tries to install `man' pages; if you have fetched the source via
Git then you will need to have built these using Halibut
first - see below.
- It's also possible to build the Windows version of PuTTY to run
on Unix by using Winelib. To do this, change to the `windows'
directory and run `make -f Makefile.mgw CC=winegcc RC=wrc'.
All of the Makefiles are generated automatically from the file
`Recipe' by the Perl script `mkfiles.pl' (except for the Unix one,
which is generated by the `configure' script; mkfiles.pl only
generates the input to automake). Additions and corrections to Recipe,
mkfiles.pl and/or configure.ac are much more useful than additions and
corrections to the actual Makefiles, Makefile.am or Makefile.in.
The Unix `configure' script and its various requirements are generated
by the shell script `mkauto.sh', which requires GNU Autoconf, GNU
Automake, and Gtk; if you've got the source from Git rather
than using one of our source snapshots, you'll need to run this
yourself. The input file to Automake is generated by mkfiles.pl along
with all the rest of the makefiles, so you will need to run mkfiles.pl
and then mkauto.sh.
cmake .
cmake --build .
Documentation (in various formats including Windows Help and Unix
`man' pages) is built from the Halibut (`.but') files in the `doc'

431
Recipe
View File

@ -1,431 +0,0 @@
# -*- makefile -*-
#
# This file describes which PuTTY programs are made up from which
# object and resource files. It is processed into the various
# Makefiles by means of a Perl script. Makefile changes should
# really be made by editing this file and/or the Perl script, not
# by editing the actual Makefiles.
# ------------------------------------------------------------
# Top-level configuration.
# Overall project name.
!name putty
# Locations and types of output Makefiles.
!makefile clangcl windows/Makefile.clangcl
!makefile vc windows/Makefile.vc
!makefile vcproj windows/MSVC
!makefile cygwin windows/Makefile.mgw
!makefile lcc windows/Makefile.lcc
!makefile gtk unix/Makefile.gtk
!makefile unix unix/Makefile.ux
!makefile am Makefile.am
!makefile devcppproj windows/DEVCPP
!makefile vstudio10 windows/VS2010
!makefile vstudio12 windows/VS2012
# Source directories.
!srcdir charset/
!srcdir windows/
!srcdir unix/
# Help text added to the top of each Makefile, with /D converted
# into -D as appropriate for the particular Makefile.
!begin help
#
# Extra options you can set:
#
# - COMPAT=/DAUTO_WINSOCK (Windows only)
# Causes PuTTY to assume that <windows.h> includes its own WinSock
# header file, so that it won't try to include <winsock.h>.
#
# - COMPAT=/DWINSOCK_TWO (Windows only)
# Causes the PuTTY utilities to include <winsock2.h> instead of
# <winsock.h>, except Plink which _needs_ WinSock 2 so it already
# does this.
#
# - COMPAT=/DNO_SECURITY (Windows only)
# Disables use of <aclapi.h>, which is not available with some
# development environments (such as very old versions of the
# mingw/Cygwin GNU toolchain). This has the following effects:
# - Pageant won't care about the local user ID of processes
# accessing it; a version of Pageant built with this option
# will therefore refuse to run under NT-series OSes on
# security grounds (although it will run fine on Win95-series
# OSes where there is no access control anyway).
# - SSH connection sharing is disabled.
# - There is no support for restriction of the process ACLs.
#
# - COMPAT=/DNO_MULTIMON (Windows only)
# Disables PuTTY's use of <multimon.h>, which is not available
# with some development environments. This means that PuTTY's
# full-screen mode (configurable to work on Alt-Enter) will
# not behave usefully in a multi-monitor environment.
#
# - COMPAT=/DNO_HTMLHELP (Windows only)
# Disables PuTTY's use of <htmlhelp.h>, which is not available
# with some development environments.
#
# If you don't have this header, you may be able to use the copy
# supplied with HTML Help Workshop.
#
# - RCFL=/DNO_MANIFESTS (Windows only)
# Disables inclusion of XML application manifests in the PuTTY
# binaries. This may be necessary to build for 64-bit Windows;
# the manifests are only included to use the XP GUI style on
# Windows XP, and the architecture tags are a lie on 64-bit.
#
# - COMPAT=/DNO_IPV6
# Disables PuTTY's ability to make IPv6 connections, enabling
# it to compile under development environments which do not
# support IPv6 in their header files.
#
# - COMPAT=/DNO_GSSAPI
# Disables PuTTY's ability to use GSSAPI functions for
# authentication and key exchange.
#
# - COMPAT=/DSTATIC_GSSAPI
# Causes PuTTY to try to link statically against the GSSAPI
# library instead of the default of doing it at run time.
#
# - COMPAT=/DMSVC4 (Windows only)
# - RCFL=/DMSVC4
# Makes a couple of minor changes so that PuTTY compiles using
# MSVC 4. You will also need /DNO_SECURITY and /DNO_MULTIMON.
#
# - COMPAT=/DNO_SECUREZEROMEMORY (Windows only)
# Disables PuTTY's use of SecureZeroMemory(), which is missing
# from some environments' header files.
#
# - XFLAGS=/DDEBUG
# Causes PuTTY to enable internal debugging.
#
# - XFLAGS=/DMALLOC_LOG
# Causes PuTTY to emit a file called putty_mem.log, logging every
# memory allocation and free, so you can track memory leaks.
#
# - XFLAGS=/DMINEFIELD (Windows only)
# Causes PuTTY to use a custom memory allocator, similar in
# concept to Electric Fence, in place of regular malloc(). Wastes
# huge amounts of RAM, but should cause heap-corruption bugs to
# show up as GPFs at the point of failure rather than appearing
# later on as second-level damage.
#
# - XFLAGS=/DFUZZING
# Builds a version of PuTTY with some tweaks to make fuzz testing
# easier: the SSH random number generator is replaced by one that
# always returns the same thing. Note that this makes SSH
# completely insecure -- a FUZZING build should never be used to
# connect to a real server.
!end
# ------------------------------------------------------------
# Additional text added verbatim to each individual Makefile.
!cflags am version
!begin am
if AUTO_GIT_COMMIT
BUILT_SOURCES = empty.h
CLEANFILES = empty.h
libversion_a_CFLAGS += -DSOURCE_COMMIT=\"`git --git-dir=$(srcdir)/.git rev-parse HEAD 2>/dev/null`\"
empty.h: $(allsources)
echo '/* Empty file touched by automake makefile to force rebuild of version.o */' >$@
endif
# Run the cryptsuite tests as part of 'make check'. Override
# PUTTY_TESTCRYPT so that cryptsuite will take the testcrypt binary
# from the build directory instead of the source directory, in case
# this is an out-of-tree build.
check-local: testcrypt
PUTTY_TESTCRYPT=./testcrypt $(srcdir)/test/cryptsuite.py
!end
!begin >empty.h
/* Empty file touched by automake makefile to force rebuild of version.o */
!end
!begin vc vars
CFLAGS = $(CFLAGS) /DHAS_GSSAPI
!end
!begin clangcl vars
CFLAGS += /DHAS_GSSAPI
!end
# `make install' target for Unix.
!begin gtk
install:
mkdir -p $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir)
$(INSTALL_PROGRAM) -m 755 pageant $(DESTDIR)$(bindir)/pageant
$(INSTALL_PROGRAM) -m 755 plink $(DESTDIR)$(bindir)/plink
$(INSTALL_PROGRAM) -m 755 pscp $(DESTDIR)$(bindir)/pscp
$(INSTALL_PROGRAM) -m 755 psftp $(DESTDIR)$(bindir)/psftp
$(INSTALL_PROGRAM) -m 755 pterm $(DESTDIR)$(bindir)/pterm
if test -n "$(UTMP_GROUP)"; then \
chgrp $(UTMP_GROUP) $(DESTDIR)$(bindir)/pterm && \
chmod 2755 $(DESTDIR)$(bindir)/pterm; \
elif test -n "$(UTMP_USER)"; then \
chown $(UTMP_USER) $(DESTDIR)$(bindir)/pterm && \
chmod 4755 $(DESTDIR)$(bindir)/pterm; \
fi
$(INSTALL_PROGRAM) -m 755 putty $(DESTDIR)$(bindir)/putty
$(INSTALL_PROGRAM) -m 755 puttygen $(DESTDIR)$(bindir)/puttygen
$(INSTALL_PROGRAM) -m 755 puttytel $(DESTDIR)$(bindir)/puttytel
$(INSTALL_DATA) -m 644 ../doc/pageant.1 $(DESTDIR)$(man1dir)/pageant.1
$(INSTALL_DATA) -m 644 ../doc/plink.1 $(DESTDIR)$(man1dir)/plink.1
$(INSTALL_DATA) -m 644 ../doc/pscp.1 $(DESTDIR)$(man1dir)/pscp.1
$(INSTALL_DATA) -m 644 ../doc/psftp.1 $(DESTDIR)$(man1dir)/psftp.1
$(INSTALL_DATA) -m 644 ../doc/pterm.1 $(DESTDIR)$(man1dir)/pterm.1
$(INSTALL_DATA) -m 644 ../doc/putty.1 $(DESTDIR)$(man1dir)/putty.1
$(INSTALL_DATA) -m 644 ../doc/puttygen.1 $(DESTDIR)$(man1dir)/puttygen.1
$(INSTALL_DATA) -m 644 ../doc/puttytel.1 $(DESTDIR)$(man1dir)/puttytel.1
install-strip:
$(MAKE) install INSTALL_PROGRAM="$(INSTALL_PROGRAM) -s"
!end
# List the man pages for the automake makefile.
!begin am
if HAVE_GTK
man1_MANS = doc/plink.1 doc/pscp.1 doc/psftp.1 doc/puttygen.1 \
doc/pageant.1 doc/pterm.1 doc/putty.1 doc/puttytel.1
else
man1_MANS = doc/plink.1 doc/pscp.1 doc/psftp.1 doc/puttygen.1
endif
!end
# In automake, chgrp/chmod pterm after installation, if configured to.
!begin am
if HAVE_SETID_CMD
install-exec-local:
@SETID_CMD@ $(bindir)/pterm
chmod @SETID_MODE@ $(bindir)/pterm
endif
!end
# In automake makefile, build the OS X app bundle, if configured in
# Quartz mode.
!begin am
if HAVE_QUARTZ
noinst_SCRIPTS = unix/PuTTY.app unix/Pterm.app
unix/PuTTY.app: unix/putty.bundle puttyapp osxlaunch
rm -rf $@ && PUTTY_GTK_PREFIX_FROM_MAKEFILE=$$(pkg-config --variable=prefix gtk+-3.0) gtk-mac-bundler $<
unix/Pterm.app: unix/pterm.bundle ptermapp osxlaunch
rm -rf $@ && PUTTY_GTK_PREFIX_FROM_MAKEFILE=$$(pkg-config --variable=prefix gtk+-3.0) gtk-mac-bundler $<
endif
!end
# Random symbols.
!begin cygwin vars
# _WIN32_IE is required to expose identifiers that only make sense on
# systems with IE5+ installed, such as some arguments to SHGetFolderPath().
# WINVER etc perform a similar function for FlashWindowEx().
CFLAGS += -D_WIN32_IE=0x0500
CFLAGS += -DWINVER=0x0500 -D_WIN32_WINDOWS=0x0410 -D_WIN32_WINNT=0x0500
!end
# ------------------------------------------------------------
# Definitions of object groups. A group name, followed by an =,
# followed by any number of objects or other already-defined group
# names. A line beginning `+' is assumed to continue the previous
# line.
# conf.c and its dependencies.
CONF = conf marshal
# Terminal emulator and its (platform-independent) dependencies.
TERMINAL = terminal stripctrl wcwidth logging tree234 minibidi
+ config dialog CONF
# GUI front end and terminal emulator (putty, puttytel).
GUITERM = TERMINAL window windlg winctrls sizetip winprint winutils
+ wincfg winhelp winjump sessprep winselgui
# Same thing on Unix.
UXTERM = TERMINAL uxcfg uxucs uxprint timing callback miscucs
GTKTERM = UXTERM gtkwin gtkcfg gtkdlg gtkfont gtkcols gtkmisc xkeysym
+ x11misc gtkcomm sessprep
GTKMAIN = gtkmain cmdline
# Non-SSH back ends (putty, puttytel, plink).
NONSSH = telnet raw rlogin supdup ldisc pinger
# SSH back end (putty, plink, pscp, psftp).
ARITH = mpint ecc
SSHCRYPTO = ARITH sshmd5 sshsha sshsh256 sshsh512 sshsha3 sshblake2 sshargon2
+ sshrsa sshdss sshecc
+ sshdes sshblowf sshaes sshccp ssharcf
+ sshdh sshcrc sshcrcda sshauxcrypt
+ sshhmac
SSHCOMMON = sshcommon sshutils sshprng sshrand SSHCRYPTO
+ sshverstring
+ sshpubk sshzlib
+ sshmac marshal nullplug
+ sshgssc pgssapi wildcard ssh1censor ssh2censor ssh2bpp
+ ssh2transport ssh2transhk ssh2connection portfwd x11fwd
+ ssh1connection ssh1bpp ssh2bpp-bare
SSH = SSHCOMMON ssh
+ ssh1login ssh2userauth
+ pinger
+ sshshare aqsync agentf
+ mainchan ssh2kex-client ssh2connection-client ssh1connection-client
WINSSH = SSH winnoise wincapi winpgntc wingss winshare winnps winnpc
+ winhsock errsock
UXSSH = SSH uxnoise uxagentc uxgss uxshare
# SFTP implementation (pscp, psftp).
SFTP = psftpcommon sftp sftpcommon logging cmdline
# Components of the prime-generation system.
SSHPRIME = sshprime smallprimes primecandidate millerrabin pockle mpunsafe
# Miscellaneous objects appearing in all the utilities, or all the
# network ones, or the Unix or Windows subsets of those in turn.
MISC = misc utils marshal memory stripctrl wcwidth
MISCNETCOMMON = timing callback MISC version tree234 CONF
MISCNET = MISCNETCOMMON be_misc settings proxy
WINMISC = MISCNET winstore winnet winhandl cmdline windefs winmisc winproxy
+ wintime winhsock errsock winsecur winucs miscucs winmiscs
UXMISCCOMMON = MISCNETCOMMON uxstore uxsel uxpoll uxnet uxpeer uxmisc time
+ uxfdsock errsock
UXMISC = MISCNET UXMISCCOMMON uxproxy uxutils
# SSH server.
SSHSERVER = SSHCOMMON sshserver settings be_none logging ssh2kex-server
+ ssh2userauth-server sshrsag SSHPRIME ssh2connection-server
+ sesschan sftpcommon sftpserver proxy cproxy ssh1login-server
+ ssh1connection-server scpserver
# import.c and dependencies, for PuTTYgen-like utilities that have to
# load foreign key files.
IMPORT = import sshbcrypt sshblowf marshal
# Character set library, for use in pterm.
CHARSET = sbcsdat slookup sbcs utf8 toucs fromucs xenc mimeenc macenc localenc
# Standard libraries.
LIBS = advapi32.lib user32.lib gdi32.lib comdlg32.lib
+ shell32.lib imm32.lib ole32.lib
# Network backend sets. This also brings in the relevant attachment
# to proxy.c depending on whether we're crypto-avoidant or not.
BE_ALL = be_all cproxy
BE_NOSSH = be_nossh norand nocproxy
BE_SSH = be_ssh cproxy
BE_NONE = be_none nocproxy
# More backend sets, with the additional Windows serial-port module.
W_BE_ALL = be_all_s winser cproxy
W_BE_NOSSH = be_nos_s norand winser nocproxy
# And with the Unix serial-port module.
U_BE_ALL = be_all_s uxser cproxy
U_BE_NOSSH = be_nos_s norand uxser nocproxy
# Auxiliary crypto modules used by key generators.
KEYGEN = sshrsag sshdssg sshecdsag
# ------------------------------------------------------------
# Definitions of actual programs. The program name, followed by a
# colon, followed by a list of objects. Also in the list may be the
# keywords [G] for Windows GUI app, [C] for Console app, [X] for
# X/GTK Unix app, [U] for command-line Unix app.
putty : [G] GUITERM NONSSH WINSSH W_BE_ALL WINMISC winx11 putty.res LIBS
puttytel : [G] GUITERM NONSSH W_BE_NOSSH WINMISC puttytel.res nogss LIBS
plink : [C] winplink wincons console NONSSH WINSSH W_BE_ALL logging WINMISC
+ winx11 plink.res winnojmp sessprep noterm winnohlp winselcli
+ clicons wincliloop console LIBS
pscp : [C] pscp winsftp wincons WINSSH BE_SSH SFTP wildcard WINMISC
+ pscp.res winnojmp winnohlp winselcli clicons wincliloop
+ console LIBS
psftp : [C] psftp winsftp wincons WINSSH BE_SSH SFTP wildcard WINMISC
+ psftp.res winnojmp winnohlp winselcli clicons wincliloop
+ console LIBS
pageant : [G] winpgnt pageant sshrsa sshpubk sshdes ARITH sshmd5 version
+ tree234 MISC sshaes sshsha winsecur winpgntc aqsync sshdss sshsh256
+ sshsh512 winutils sshecc winmisc winmiscs winhelp conf pageant.res
+ sshauxcrypt sshhmac wincapi winnps winnpc winhsock errsock winnet
+ winhandl callback be_misc winselgui winhandl sshsha3 sshblake2
+ sshargon2 LIBS
puttygen : [G] winpgen KEYGEN SSHPRIME sshdes ARITH sshmd5 version
+ sshrand winnoise sshsha winstore MISC winctrls sshrsa sshdss winmisc
+ sshpubk sshaes sshsh256 sshsh512 IMPORT winutils puttygen.res
+ tree234 notiming winhelp winnojmp CONF LIBS wintime sshecc sshprng
+ sshauxcrypt sshhmac winsecur winmiscs sshsha3 sshblake2 sshargon2
pterm : [X] GTKTERM uxmisc misc ldisc settings uxpty uxsel BE_NONE uxstore
+ uxsignal CHARSET cmdline uxpterm version time xpmpterm xpmptcfg
+ nogss utils memory GTKMAIN
putty : [X] GTKTERM uxmisc misc ldisc settings uxsel U_BE_ALL uxstore
+ uxsignal CHARSET uxputty NONSSH UXSSH UXMISC ux_x11 xpmputty
+ xpmpucfg utils memory GTKMAIN
puttytel : [X] GTKTERM uxmisc misc ldisc settings uxsel U_BE_NOSSH
+ uxstore uxsignal CHARSET uxputty NONSSH UXMISC xpmputty xpmpucfg
+ nogss utils memory GTKMAIN
plink : [U] uxplink uxcons NONSSH UXSSH U_BE_ALL logging UXMISC uxsignal
+ ux_x11 noterm uxnogtk sessprep cmdline clicons uxcliloop console
PUTTYGEN_UNIX = KEYGEN SSHPRIME sshdes ARITH sshmd5 version sshprng
+ sshrand uxnoise sshsha MISC sshrsa sshdss uxcons uxstore uxmisc
+ sshpubk sshaes sshsh256 sshsh512 IMPORT puttygen.res time tree234
+ uxgen notiming CONF sshecc sshsha3 uxnogtk sshauxcrypt sshhmac
+ uxpoll uxutils sshblake2 sshargon2 console
puttygen : [U] cmdgen PUTTYGEN_UNIX
cgtest : [UT] cgtest PUTTYGEN_UNIX
pscp : [U] pscp uxsftp uxcons UXSSH BE_SSH SFTP wildcard UXMISC uxnogtk
+ clicons uxcliloop console
psftp : [U] psftp uxsftp uxcons UXSSH BE_SSH SFTP wildcard UXMISC uxnogtk
+ clicons uxcliloop console
pageant : [X] uxpgnt uxagentc aqsync pageant sshrsa sshpubk sshdes ARITH
+ sshmd5 version tree234 misc sshaes sshsha sshdss sshsh256 sshsh512
+ sshecc CONF uxsignal nocproxy nogss be_none x11fwd ux_x11 uxcons
+ gtkask gtkmisc nullplug logging UXMISC uxagentsock utils memory
+ sshauxcrypt sshhmac sshprng uxnoise uxcliloop sshsha3 sshblake2
+ sshargon2 console
ptermapp : [XT] GTKTERM uxmisc misc ldisc settings uxpty uxsel BE_NONE uxstore
+ uxsignal CHARSET uxpterm version time xpmpterm xpmptcfg
+ nogss gtkapp nocmdline utils memory
puttyapp : [XT] GTKTERM uxmisc misc ldisc settings uxsel U_BE_ALL uxstore
+ uxsignal CHARSET uxputty NONSSH UXSSH UXMISC ux_x11 xpmputty
+ xpmpucfg gtkapp nocmdline utils memory
osxlaunch : [UT] osxlaunch
fuzzterm : [UT] UXTERM CHARSET MISC version uxmisc uxucs fuzzterm time settings
+ uxstore be_none uxnogtk memory
testcrypt : [UT] testcrypt SSHCRYPTO sshprng SSHPRIME sshpubk marshal utils
+ memory tree234 uxutils KEYGEN
testcrypt : [C] testcrypt SSHCRYPTO sshprng SSHPRIME sshpubk marshal utils
+ memory tree234 winmiscs KEYGEN
testsc : [UT] testsc SSHCRYPTO marshal utils memory tree234 wildcard
+ sshmac uxutils sshpubk
testzlib : [UT] testzlib sshzlib utils marshal memory
uppity : [UT] uxserver SSHSERVER UXMISC uxsignal uxnoise uxgss uxnogtk
+ uxpty uxsftpserver ux_x11 uxagentsock procnet uxcliloop
psusan : [U] uxpsusan SSHSERVER UXMISC uxsignal uxnoise nogss uxnogtk
+ uxpty uxsftpserver ux_x11 uxagentsock procnet uxcliloop
PSOCKS = psocks portfwd conf sshutils logging proxy nocproxy timing callback
+ time tree234 version errsock be_misc norand MISC
psocks : [C] PSOCKS winsocks wincons winproxy winnet winmisc winselcli
+ winhsock winhandl winmiscs winnohlp wincliloop console LIBS
psocks : [UT] PSOCKS uxsocks uxcons uxproxy uxnet uxmisc uxpoll uxsel uxnogtk
+ uxpeer uxfdsock uxcliloop uxsignal console
# ----------------------------------------------------------------------
# On Windows, provide a means of removing local test binaries that we
# aren't going to actually ship. (I prefer this to not building them
# in the first place, so that we find out about build breakage early.)
!begin vc
cleantestprogs:
-del $(BUILDDIR)testcrypt.exe $(BUILDDIR)psocks.exe
!end
!begin clangcl
cleantestprogs:
-rm -f $(BUILDDIR)testcrypt.exe $(BUILDDIR)psocks.exe
!end

29
charset/CMakeLists.txt Normal file
View File

@ -0,0 +1,29 @@
include(FindPerl)
if(NOT PERL_EXECUTABLE)
message(FATAL_ERROR "Perl is required to autogenerate sbcsdat.c")
endif()
set(GENERATED_SBCSDAT_C ${GENERATED_SOURCES_DIR}/sbcsdat.c)
add_custom_command(OUTPUT ${GENERATED_SBCSDAT_C}.tmp
COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/charset/sbcsgen.pl
-o ${GENERATED_SBCSDAT_C}.tmp
DEPENDS ${CMAKE_SOURCE_DIR}/charset/sbcsgen.pl
${CMAKE_SOURCE_DIR}/charset/sbcs.dat)
add_custom_target(generated_sbcsdat_c
BYPRODUCTS ${GENERATED_SBCSDAT_C}
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${GENERATED_SBCSDAT_C}.tmp ${GENERATED_SBCSDAT_C}
DEPENDS ${GENERATED_SBCSDAT_C}.tmp
COMMENT "Updating sbcsdat.c")
add_library(charset STATIC
fromucs.c
localenc.c
macenc.c
mimeenc.c
sbcs.c
${GENERATED_SBCSDAT_C}
slookup.c
toucs.c
utf8.c
xenc.c)

12
charset/sbcsgen.pl Normal file → Executable file
View File

@ -1,11 +1,19 @@
#!/usr/bin/env perl -w
#!/usr/bin/env perl
# This script generates sbcsdat.c (the data for all the SBCSes) from its
# source form sbcs.dat.
$infile = "sbcs.dat";
use warnings;
use Getopt::Long;
use File::Basename;
$infile = (dirname __FILE__) . "/sbcs.dat";
$outfile = "sbcsdat.c";
my $usage = "usage: sbcsgen.pl [-o OUTFILE]\n";
GetOptions("o|output=s" => \$outfile)
or die $usage;
open FOO, $infile;
open BAR, ">$outfile";
select BAR;

35
cmake/cmake.h.in Normal file
View File

@ -0,0 +1,35 @@
#cmakedefine NO_IPV6
#cmakedefine NO_GSSAPI
#cmakedefine STATIC_GSSAPI
#cmakedefine NO_MULTIMON
#cmakedefine01 HAVE_WINRESRC_H
#cmakedefine01 HAVE_WINRES_H
#cmakedefine01 HAVE_WIN_H
#cmakedefine01 HAVE_NO_STDINT_H
#cmakedefine01 HAVE_GCP_RESULTSW
#cmakedefine01 HAVE_ADDDLLDIRECTORY
#cmakedefine01 HAVE_GETNAMEDPIPECLIENTPROCESSID
#cmakedefine01 HAVE_SETDEFAULTDLLDIRECTORIES
#cmakedefine01 HAVE_STRTOUMAX
#cmakedefine NOT_X_WINDOWS
#cmakedefine01 HAVE_FUTIMES
#cmakedefine01 HAVE_GETADDRINFO
#cmakedefine01 HAVE_POSIX_OPENPT
#cmakedefine01 HAVE_PTSNAME
#cmakedefine01 HAVE_SETRESUID
#cmakedefine01 HAVE_STRSIGNAL
#cmakedefine01 HAVE_UPDWTMPX
#cmakedefine01 HAVE_FSTATAT
#cmakedefine01 HAVE_DIRFD
#cmakedefine01 HAVE_SETPWENT
#cmakedefine01 HAVE_ENDPWENT
#cmakedefine01 HAVE_GETAUXVAL
#cmakedefine01 HAVE_CLOCK_MONOTONIC
#cmakedefine01 HAVE_CLOCK_GETTIME
#cmakedefine01 HAVE_SO_PEERCRED
#cmakedefine01 HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE
#cmakedefine01 HAVE_PANGO_FONT_MAP_LIST_FAMILIES

48
cmake/gitcommit.cmake Normal file
View File

@ -0,0 +1,48 @@
# Pure cmake script to write out cmake_commit.h
set(DEFAULT_COMMIT "unavailable")
set(commit "${DEFAULT_COMMIT}")
execute_process(
COMMAND ${GIT_EXECUTABLE} -C ${TOPLEVEL_SOURCE_DIR}
rev-parse --show-toplevel
OUTPUT_VARIABLE git_worktree
ERROR_VARIABLE stderr
RESULT_VARIABLE status)
string(REGEX REPLACE "\n$" "" git_worktree "${git_worktree}")
if(status EQUAL 0)
if(git_worktree STREQUAL TOPLEVEL_SOURCE_DIR)
execute_process(
COMMAND ${GIT_EXECUTABLE} -C ${TOPLEVEL_SOURCE_DIR}
rev-parse HEAD
OUTPUT_VARIABLE git_commit
ERROR_VARIABLE stderr
RESULT_VARIABLE status)
if(status EQUAL 0)
string(REGEX REPLACE "\n$" "" commit "${git_commit}")
else()
if(commit STREQUAL "unavailable")
message("Unable to determine git commit: 'git rev-parse HEAD' returned status ${status} and error output:\n${stderr}\n")
endif()
endif()
else()
if(commit STREQUAL "unavailable")
message("Unable to determine git commit: top-level source dir ${TOPLEVEL_SOURCE_DIR} is not the root of a repository")
endif()
endif()
else()
if(commit STREQUAL "unavailable")
message("Unable to determine git commit: 'git rev-parse --show-toplevel' returned status ${status} and error output:\n${stderr}\n")
endif()
endif()
file(WRITE "${OUTPUT_FILE}" "\
/*
* cmake_commit.h - string literal giving the source git commit, if known.
*
* Generated by cmake/gitcommit.cmake.
*/
const char commitid[] = \"${commit}\";
")

85
cmake/gtk.cmake Normal file
View File

@ -0,0 +1,85 @@
# Look for GTK, of any version.
set(PUTTY_GTK_VERSION "ANY"
CACHE STRING "Which major version of GTK to build with")
set_property(CACHE PUTTY_GTK_VERSION
PROPERTY STRINGS ANY 3 2 1)
set(GTK_FOUND FALSE)
macro(try_pkg_config_gtk VER PACKAGENAME)
if(NOT GTK_FOUND AND
(PUTTY_GTK_VERSION STREQUAL ANY OR PUTTY_GTK_VERSION STREQUAL ${VER}))
find_package(PkgConfig)
pkg_check_modules(GTK ${PACKAGENAME})
endif()
endmacro()
try_pkg_config_gtk(3 gtk+-3.0)
try_pkg_config_gtk(2 gtk+-2.0)
if(NOT GTK_FOUND AND
(PUTTY_GTK_VERSION STREQUAL ANY OR PUTTY_GTK_VERSION STREQUAL 1))
message("-- Checking for GTK1 (via gtk-config)")
find_program(GTK_CONFIG gtk-config)
if(GTK_CONFIG)
execute_process(COMMAND ${GTK_CONFIG} --cflags
OUTPUT_VARIABLE gtk_config_cflags
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE gtk_config_cflags_result)
execute_process(COMMAND ${GTK_CONFIG} --libs
OUTPUT_VARIABLE gtk_config_libs
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE gtk_config_libs_result)
if(gtk_config_cflags_result EQUAL 0 AND gtk_config_libs_result EQUAL 0)
set(GTK_INCLUDE_DIRS)
set(GTK_LIBRARY_DIRS)
set(GTK_LIBRARIES)
separate_arguments(gtk_config_cflags NATIVE_COMMAND
${gtk_config_cflags})
foreach(opt ${gtk_config_cflags})
string(REGEX MATCH "^-I" ok ${opt})
if(ok)
string(REGEX REPLACE "^-I" "" optval ${opt})
list(APPEND GTK_INCLUDE_DIRS ${optval})
endif()
endforeach()
separate_arguments(gtk_config_libs NATIVE_COMMAND
${gtk_config_libs})
foreach(opt ${gtk_config_libs})
string(REGEX MATCH "^-l" ok ${opt})
if(ok)
list(APPEND GTK_LIBRARIES ${opt})
endif()
string(REGEX MATCH "^-L" ok ${opt})
if(ok)
string(REGEX REPLACE "^-L" "" optval ${opt})
list(APPEND GTK_LIBRARY_DIRS ${optval})
endif()
endforeach()
message("-- Found GTK1")
set(GTK_FOUND TRUE)
endif()
endif()
endif()
if(GTK_FOUND)
# Check for some particular Pango functions.
function(pango_check_subscope)
set(CMAKE_REQUIRED_INCLUDES ${GTK_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${GTK_LIBRARIES})
check_symbol_exists(pango_font_family_is_monospace "pango/pango.h"
HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE)
check_symbol_exists(pango_font_map_list_families "pango/pango.h"
HAVE_PANGO_FONT_MAP_LIST_FAMILIES)
set(HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE
${HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE} PARENT_SCOPE)
set(HAVE_PANGO_FONT_MAP_LIST_FAMILIES
${HAVE_PANGO_FONT_MAP_LIST_FAMILIES} PARENT_SCOPE)
endfunction()
pango_check_subscope()
endif()

39
cmake/licence.cmake Normal file
View File

@ -0,0 +1,39 @@
# Pure cmake script to generate licence.h from LICENCE
file(READ "${LICENCE_FILE}" LICENCE_TEXT)
function(c_string_escape outvar value)
string(REPLACE "\\" "\\\\" value "${value}")
string(REPLACE "\"" "\\\"" value "${value}")
set("${outvar}" "${value}" PARENT_SCOPE)
endfunction()
set(copyright_regex "PuTTY is copyright ([0-9]+-[0-9]+ [^\n]*[^\n.])\\.?\n")
string(REGEX MATCH "${copyright_regex}" COPYRIGHT_NOTICE "${LICENCE_TEXT}")
string(REGEX REPLACE "${copyright_regex}" "\\1"
COPYRIGHT_NOTICE "${COPYRIGHT_NOTICE}")
c_string_escape(COPYRIGHT_NOTICE "${COPYRIGHT_NOTICE}")
string(REGEX REPLACE "\n$" "" LICENCE_TEXT "${LICENCE_TEXT}")
string(REPLACE "\r" "" LICENCE_TEXT "${LICENCE_TEXT}")
string(REPLACE "\n\n" "\r" LICENCE_TEXT "${LICENCE_TEXT}")
string(REPLACE "\n" " " LICENCE_TEXT "${LICENCE_TEXT}")
string(REPLACE "\r" "\n" LICENCE_TEXT "${LICENCE_TEXT}")
c_string_escape(LICENCE_TEXT "${LICENCE_TEXT}")
string(REPLACE "\n" "\" \\\n parsep \\\n \""
LICENCE_TEXT "${LICENCE_TEXT}")
file(WRITE "${OUTPUT_FILE}" "\
/*
* licence.h - macro definitions for the PuTTY licence.
*
* Generated by cmake/licence.cmake from ./LICENCE.
* You should edit those files rather than editing this one.
*/
#define LICENCE_TEXT(parsep) \\
\"${LICENCE_TEXT}\"
#define SHORT_COPYRIGHT_DETAILS \"${COPYRIGHT_NOTICE}\"
")

121
cmake/platforms/unix.cmake Normal file
View File

@ -0,0 +1,121 @@
set(PLATFORM_SUBDIRS charset unix)
set(PUTTY_GSSAPI DYNAMIC
CACHE STRING "Build PuTTY with dynamically or statically linked \
Kerberos / GSSAPI support, if possible")
set_property(CACHE PUTTY_GSSAPI
PROPERTY STRINGS DYNAMIC STATIC OFF)
include(CheckIncludeFile)
include(CheckLibraryExists)
include(CheckSymbolExists)
include(CheckCSourceCompiles)
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
-D_DEFAULT_SOURCE -D_GNU_SOURCE)
check_include_file(sys/auxv.h HAVE_SYS_AUXV_H)
check_include_file(asm/hwcap.h HAVE_ASM_HWCAP_H)
check_include_file(sys/sysctl.h HAVE_SYS_SYSCTL_H)
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(glob.h HAVE_GLOB_H)
check_symbol_exists(futimes "sys/time.h" HAVE_FUTIMES)
check_symbol_exists(getaddrinfo "sys/types.h;sys/socket.h;netdb.h"
HAVE_GETADDRINFO)
check_symbol_exists(posix_openpt "stdlib.h;fcntl.h" HAVE_POSIX_OPENPT)
check_symbol_exists(ptsname "stdlib.h" HAVE_PTSNAME)
check_symbol_exists(setresuid "unistd.h" HAVE_SETRESUID)
check_symbol_exists(setresgid "unistd.h" HAVE_SETRESGID)
check_symbol_exists(strsignal "string.h" HAVE_STRSIGNAL)
check_symbol_exists(updwtmpx "utmpx.h" HAVE_UPDWTMPX)
check_symbol_exists(fstatat "sys/types.h;sys/stat.h;unistd.h" HAVE_FSTATAT)
check_symbol_exists(dirfd "sys/types.h;dirent.h" HAVE_DIRFD)
check_symbol_exists(setpwent "sys/types.h;pwd.h" HAVE_SETPWENT)
check_symbol_exists(endpwent "sys/types.h;pwd.h" HAVE_ENDPWENT)
check_symbol_exists(getauxval "sys/auxv.h" HAVE_GETAUXVAL)
check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC)
check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
check_c_source_compiles("
#define _GNU_SOURCE
#include <features.h>
#include <sys/socket.h>
int main(int argc, char **argv) {
struct ucred cr;
socklen_t crlen = sizeof(cr);
return getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cr, &crlen) +
cr.pid + cr.uid + cr.gid;
}" HAVE_SO_PEERCRED)
if(HAVE_GETADDRINFO AND PUTTY_IPV6)
set(NO_IPV6 OFF)
else()
set(NO_IPV6 ON)
endif()
include(cmake/gtk.cmake)
find_package(X11)
if(NOT X11_FOUND)
set(NOT_X_WINDOWS ON)
else()
set(NOT_X_WINDOWS OFF)
endif()
include_directories(${CMAKE_SOURCE_DIR}/charset ${GTK_INCLUDE_DIRS} ${X11_INCLUDE_DIR})
link_directories(${GTK_LIBRARY_DIRS})
function(add_optional_system_lib library testfn)
check_library_exists(${library} ${testfn} "" HAVE_LIB${library})
if (HAVE_LIB${library})
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES};-l${library})
link_libraries(-l${library})
endif()
endfunction()
add_optional_system_lib(m pow)
add_optional_system_lib(rt clock_gettime)
add_optional_system_lib(xnet socket)
if(PUTTY_GSSAPI STREQUAL DYNAMIC)
add_optional_system_lib(dl dlopen)
if(HAVE_NO_LIBdl)
message(WARNING
"Could not find libdl -- cannot provide dynamic GSSAPI support")
set(NO_GSSAPI ON)
endif()
endif()
if(PUTTY_GSSAPI STREQUAL STATIC)
find_package(PkgConfig)
pkg_check_modules(KRB5 krb5-gssapi)
if(KRB5_FOUND)
include_directories(${KRB5_INCLUDE_DIRS})
link_directories(${KRB5_LIBRARY_DIRS})
link_libraries(${KRB5_LIBRARIES})
set(STATIC_GSSAPI ON)
else()
message(WARNING
"Could not find krb5 via pkg-config -- \
cannot provide static GSSAPI support")
set(NO_GSSAPI ON)
endif()
endif()
if(STRICT AND (CMAKE_C_COMPILER_ID MATCHES "GNU" OR
CMAKE_C_COMPILER_ID MATCHES "Clang"))
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wpointer-arith -Wvla")
endif()
function(installed_program target)
if(CMAKE_VERSION VERSION_LESS 3.14)
# CMake 3.13 and earlier required an explicit install destination.
install(TARGETS ${target} RUNTIME DESTINATION bin)
else()
# 3.14 and above selects a sensible default, which we should avoid
# overriding here so that end users can override it using
# CMAKE_INSTALL_BINDIR.
install(TARGETS ${target})
endif()
endfunction()

View File

@ -0,0 +1,171 @@
set(PLATFORM_SUBDIRS windows)
# I copied this over from the pre-CMake build system just to prove it
# still worked, but I should probably remove it now, together with all
# the #ifdefs that depend on it.
#
# Rationale: it was there so that you could do dev builds of PuTTY on
# compilers designed for the pre-NT single-user versions of Windows
# (Win95, Win98 etc). But we're not supporting those development
# environments any more!
set(PUTTY_NO_SECURITY OFF
CACHE BOOL "OBSOLETE AND DANGEROUS - DO NOT DEFINE! \
Build PuTTY without any use of the Windows security APIs.")
set(PUTTY_MINEFIELD OFF
CACHE BOOL "Build PuTTY with its built-in memory debugger 'Minefield'")
set(PUTTY_GSSAPI ON
CACHE BOOL "Build PuTTY with GSSAPI support")
set(PUTTY_LINK_MAPS OFF
CACHE BOOL "Attempt to generate link maps")
set(PUTTY_EMBEDDED_CHM_FILE ""
CACHE FILEPATH "Path to a .chm help file to embed in the binaries")
function(define_negation newvar oldvar)
if(${oldvar})
set(${newvar} OFF PARENT_SCOPE)
else()
set(${newvar} ON PARENT_SCOPE)
endif()
endfunction()
include(CheckIncludeFiles)
include(CheckSymbolExists)
include(CheckCSourceCompiles)
# Still needed for AArch32 Windows builds
set(CMAKE_REQUIRED_DEFINITIONS -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE)
check_include_files("windows.h;winresrc.h" HAVE_WINRESRC_H)
check_include_files("windows.h;winres.h" HAVE_WINRES_H)
check_include_files("windows.h;win.h" HAVE_WIN_H)
check_include_files("stdint.h" HAVE_STDINT_H)
define_negation(HAVE_NO_STDINT_H HAVE_STDINT_H)
check_include_files("windows.h;multimon.h" HAVE_MULTIMON_H)
define_negation(NO_MULTIMON HAVE_MULTIMON_H)
check_include_files("windows.h;htmlhelp.h" HAVE_HTMLHELP_H)
define_negation(NO_HTMLHELP HAVE_HTMLHELP_H)
check_symbol_exists(SecureZeroMemory "windows.h" HAVE_SECUREZEROMEMORY)
define_negation(NO_SECUREZEROMEMORY HAVE_SECUREZEROMEMORY)
check_symbol_exists(strtoumax "inttypes.h" HAVE_STRTOUMAX)
check_symbol_exists(AddDllDirectory "windows.h" HAVE_ADDDLLDIRECTORY)
check_symbol_exists(SetDefaultDllDirectories "windows.h"
HAVE_SETDEFAULTDLLDIRECTORIES)
check_symbol_exists(GetNamedPipeClientProcessId "windows.h"
HAVE_GETNAMEDPIPECLIENTPROCESSID)
check_c_source_compiles("
#include <windows.h>
GCP_RESULTSW gcpw;
int main(void) { return 0; }
" HAVE_GCP_RESULTSW)
set(NO_SECURITY ${PUTTY_NO_SECURITY})
add_compile_definitions(
_WINDOWS
_CRT_SECURE_NO_WARNINGS
_WINSOCK_DEPRECATED_NO_WARNINGS
_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE)
if(PUTTY_MINEFIELD)
add_compile_definitions(MINEFIELD)
endif()
if(NOT PUTTY_GSSAPI)
add_compile_definitions(NO_GSSAPI)
endif()
if(PUTTY_EMBEDDED_CHM_FILE)
add_compile_definitions("EMBEDDED_CHM_FILE=\"${PUTTY_EMBEDDED_CHM_FILE}\"")
endif()
if(WINELIB)
enable_language(RC)
set(LFLAG_MANIFEST_NO "")
elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC" OR
CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")
set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} /nologo /C1252")
set(LFLAG_MANIFEST_NO "/manifest:no")
else()
set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -c1252")
set(LFLAG_MANIFEST_NO "")
endif()
if(STRICT AND (CMAKE_C_COMPILER_ID MATCHES "GNU" OR
CMAKE_C_COMPILER_ID MATCHES "Clang"))
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wpointer-arith -Wvla")
endif()
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
# Turn off some warnings that I've just found too noisy.
#
# - 4244, 4267: "possible loss of data" when narrowing an integer
# type (separate warning numbers for initialisers and
# assignments). Every time I spot-check instances of this, they
# turn out to be sensible (e.g. something was already checked, or
# was assigned from a previous variable that must have been in
# range). I don't think putting a warning-suppression idiom at
# every one of these sites would improve code legibility.
#
# - 4018: "signed/unsigned mismatch" in integer comparison. Again,
# comes up a lot, and generally my spot checks make it look as if
# it's OK.
#
# - 4235: applying unary '-' to an unsigned type. We do that all
# the time in deliberate bit-twiddling code like mpint.c or
# crypto implementations.
#
# - 4293: warning about undefined behaviour if a shift count is too
# big. We often do this inside a ?: clause which doesn't evaluate
# the overlong shift unless the shift count _isn't_ too big. When
# the shift count is constant, MSVC spots the potential problem
# in one branch of the ?:, but doesn't also spot that that branch
# isn't ever taken, so it complains about a thing that's already
# guarded.
#
# - 4090: different 'const' qualifiers. It's a shame to suppress
# this one, because const mismatches really are a thing I'd
# normally like to be warned about. But MSVC (as of 2017 at
# least) seems to have a bug in which assigning a 'void *' into a
# 'const char **' thinks there's a const-qualifier mismatch.
# There isn't! Both are pointers to modifiable objects. The fact
# that in one case, the modifiable object is a pointer to
# something _else_ const should make no difference.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
/wd4244 /wd4267 /wd4018 /wd4146 /wd4293 /wd4090")
endif()
if(CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} /dynamicbase /nxcompat")
endif()
set(platform_libraries
advapi32.lib comdlg32.lib gdi32.lib imm32.lib
ole32.lib shell32.lib user32.lib ws2_32.lib kernel32.lib)
# Generate link maps
if(PUTTY_LINK_MAPS)
if(CMAKE_C_COMPILER_ID MATCHES "Clang" AND
"x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC")
set(CMAKE_C_LINK_EXECUTABLE
"${CMAKE_C_LINK_EXECUTABLE} /lldmap:<TARGET>.map")
elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_LINK_EXECUTABLE
"${CMAKE_C_LINK_EXECUTABLE} /map:<TARGET>.map")
else()
message(WARNING
"Don't know how to generate link maps on this toolchain")
endif()
endif()
# Write out a file in the cmake output directory listing the
# executables that are 'official' enough to want to code-sign and
# ship.
file(WRITE ${CMAKE_BINARY_DIR}/shipped.txt "")
function(installed_program target)
file(APPEND ${CMAKE_BINARY_DIR}/shipped.txt
"${target}${CMAKE_EXECUTABLE_SUFFIX}\n")
endfunction()

78
cmake/setup.cmake Normal file
View File

@ -0,0 +1,78 @@
# Forcibly re-enable assertions, even if we're building in release
# mode. This is a security project - assertions may be enforcing
# security-critical constraints. A backstop #ifdef in defs.h should
# give a #error if this manoeuvre doesn't do what it needs to.
string(REPLACE "/DNDEBUG" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
set(PUTTY_IPV6 ON
CACHE BOOL "Build PuTTY with IPv6 support if possible")
set(PUTTY_DEBUG OFF
CACHE BOOL "Build PuTTY with debug() statements enabled")
set(PUTTY_FUZZING OFF
CACHE BOOL "Build PuTTY binaries suitable for fuzzing, NOT FOR REAL USE")
set(STRICT OFF
CACHE BOOL "Enable extra compiler warnings and make them errors")
include(FindGit)
set(GENERATED_SOURCES_DIR ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY})
set(GENERATED_LICENCE_H ${GENERATED_SOURCES_DIR}/licence.h)
set(INTERMEDIATE_LICENCE_H ${GENERATED_LICENCE_H}.tmp)
add_custom_command(OUTPUT ${INTERMEDIATE_LICENCE_H}
COMMAND ${CMAKE_COMMAND}
-DLICENCE_FILE=${CMAKE_SOURCE_DIR}/LICENCE
-DOUTPUT_FILE=${INTERMEDIATE_LICENCE_H}
-P ${CMAKE_SOURCE_DIR}/cmake/licence.cmake
DEPENDS ${CMAKE_SOURCE_DIR}/cmake/licence.cmake ${CMAKE_SOURCE_DIR}/LICENCE)
add_custom_target(generated_licence_h
BYPRODUCTS ${GENERATED_LICENCE_H}
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${INTERMEDIATE_LICENCE_H} ${GENERATED_LICENCE_H}
DEPENDS ${INTERMEDIATE_LICENCE_H}
COMMENT "Updating licence.h")
set(GENERATED_COMMIT_C ${GENERATED_SOURCES_DIR}/cmake_commit.c)
set(INTERMEDIATE_COMMIT_C ${GENERATED_COMMIT_C}.tmp)
add_custom_target(check_git_commit
BYPRODUCTS ${INTERMEDIATE_COMMIT_C}
COMMAND ${CMAKE_COMMAND}
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
-DTOPLEVEL_SOURCE_DIR=${CMAKE_SOURCE_DIR}
-DOUTPUT_FILE=${INTERMEDIATE_COMMIT_C}
-P ${CMAKE_SOURCE_DIR}/cmake/gitcommit.cmake
DEPENDS ${CMAKE_SOURCE_DIR}/cmake/gitcommit.cmake
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Checking current git commit")
add_custom_target(cmake_commit_c
BYPRODUCTS ${GENERATED_COMMIT_C}
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${INTERMEDIATE_COMMIT_C} ${GENERATED_COMMIT_C}
DEPENDS check_git_commit ${INTERMEDIATE_COMMIT_C}
COMMENT "Updating cmake_commit.c")
function(add_platform_sources_to_library target)
set(sources ${ARGN})
list(TRANSFORM sources PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
target_sources(${target} PRIVATE ${sources})
endfunction()
if(CMAKE_SYSTEM_NAME MATCHES "Windows" OR WINELIB)
include(cmake/platforms/windows.cmake)
else()
include(cmake/platforms/unix.cmake)
endif()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${GENERATED_SOURCES_DIR}
${PLATFORM_SUBDIRS})
if(PUTTY_DEBUG)
add_compile_definitions(DEBUG)
endif()
if(PUTTY_FUZZING)
add_compile_definitions(FUZZING)
endif()

View File

@ -0,0 +1,10 @@
# Simple toolchain file for cross-building Windows PuTTY on Linux
# using MinGW (tested on Ubuntu).
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
set(CMAKE_AR x86_64-w64-mingw32-ar)
set(CMAKE_RANLIB x86_64-w64-mingw32-ranlib)

View File

@ -0,0 +1,33 @@
# Toolchain file for cross-building a Winelib version of Windows PuTTY
# on Linux, using winegcc (tested on Ubuntu).
# Winelib is weird because it's basically compiling ordinary Linux
# objects and executables, but we want to pretend to be Windows for
# purposes of (a) having resource files, and (b) selecting the Windows
# platform subdirectory.
#
# So, do we tag this as a weird kind of Windows build, or a weird kind
# of Linux build? Either way we have to do _something_ out of the
# ordinary.
#
# After some experimentation, it seems to make more sense to treat
# Winelib builds as basically Linux, and set a flag WINELIB that
# PuTTY's main build scripts will detect and handle specially.
# Specifically, that flag will cause cmake/setup.cmake to select the
# Windows platform (overriding the usual check of CMAKE_SYSTEM_NAME),
# and also trigger a call to enable_language(RC), which for some kind
# of cmake re-entrancy reason we can't do in this toolchain file
# itself.
set(CMAKE_SYSTEM_NAME Linux)
set(WINELIB ON)
# We need a wrapper script around winegcc proper, because cmake's link
# command lines will refer to system libraries as "-lkernel32.lib"
# rather than the required "-lkernel32". The winegcc script alongside
# this toolchain file bodges that command-line translation.
set(CMAKE_C_COMPILER ${CMAKE_SOURCE_DIR}/cmake/winegcc)
set(CMAKE_RC_COMPILER wrc)
set(CMAKE_RC_OUTPUT_EXTENSION .res.o)
set(CMAKE_RC_COMPILE_OBJECT
"<CMAKE_RC_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>")

29
cmake/winegcc Executable file
View File

@ -0,0 +1,29 @@
#!/bin/sh
# Wrapper for winegcc that allows it to be used in a build generated
# from PuTTY's CMakeLists.txt, by bodging around the command-line
# options that CMake gets wrong.
init=true
for arg in init "$@"; do
if $init; then
set --
init=false
continue
fi
case "$arg" in
# The Windows build definition for PuTTY specifies all the
# system API libraries by names like kernel32.lib. When CMake
# reads that file and thinks it's compiling for Linux, it will
# generate link options such as -lkernel32.lib. But in fact
# winegcc expects -lkernel32, so we need to strip the ".lib"
# suffix.
-l*.lib) set -- "$@" "${arg%.lib}";;
# Anything else, we leave unchanged.
*) set -- "$@" "$arg";;
esac
done
exec winegcc "$@"

View File

@ -1,264 +0,0 @@
# To compile this into a configure script, you need:
# * Autoconf 2.59c or newer
# * Gtk (for $prefix/share/aclocal/gtk.m4)
# * Automake (for aclocal)
# If you've got them, running "autoreconf" should work.
# Version number is substituted by Buildscr for releases, snapshots
# and custom builds out of svn; X.XX shows up in ad-hoc developer
# builds, which shouldn't matter
AC_INIT(putty, X.XX)
AC_CONFIG_FILES([Makefile])
AC_CONFIG_HEADERS([uxconfig.h:uxconfig.in])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_INSTALL
AC_PROG_RANLIB
ifdef([AM_PROG_AR],[AM_PROG_AR])
AM_PROG_CC_C_O
AC_PROG_CC_C99
# Mild abuse of the '--enable' option format to allow manual
# specification of setuid or setgid setup in pterm.
setidtype=none
AC_ARG_ENABLE([setuid],
[AS_HELP_STRING([--enable-setuid=USER],
[make pterm setuid to a given user])],
[case "$enableval" in
no) setidtype=none;;
*) setidtype=setuid; setidval="$enableval";;
esac])
AC_ARG_ENABLE([setgid],
[AS_HELP_STRING([--enable-setgid=GROUP],
[make pterm setgid to a given group])],
[case "$enableval" in
no) setidtype=none;;
*) setidtype=setgid; setidval="$enableval";;
esac])
AM_CONDITIONAL(HAVE_SETID_CMD, [test "$setidtype" != "none"])
AS_IF([test "x$setidtype" = "xsetuid"],
[SETID_CMD="chown $setidval"; SETID_MODE="4755"])
AS_IF([test "x$setidtype" = "xsetgid"],
[SETID_CMD="chgrp $setidval"; SETID_MODE="2755"])
AC_SUBST(SETID_CMD)
AC_SUBST(SETID_MODE)
AC_ARG_ENABLE([git-commit],
[AS_HELP_STRING([--disable-git-commit],
[disable embedding current git HEAD in binaries])],
[],
[if test -d "$srcdir/.git"; then
enable_git_commit=yes; else enable_git_commit=no; fi])
if test "x$enable_git_commit" = "xyes" -a ! -d "$srcdir/.git"; then
AC_ERROR([Cannot --enable-git-commit when source tree is not a git checkout])
fi
AM_CONDITIONAL(AUTO_GIT_COMMIT, [test "x$enable_git_commit" = "xyes"])
AC_ARG_WITH([gssapi],
[AS_HELP_STRING([--without-gssapi],
[disable GSSAPI support])],
[],
[with_gssapi=yes])
AC_ARG_WITH([quartz],
[AS_HELP_STRING([--with-quartz],
[build for the MacOS Quartz GTK back end])],
[AC_DEFINE([OSX_GTK], [1], [Define if building with GTK for MacOS.])
with_quartz=yes],
[with_quartz=no])
AM_CONDITIONAL([HAVE_QUARTZ],[test "x$with_quartz" = "xyes"])
WITH_GSSAPI=
AS_IF([test "x$with_gssapi" != xno],
[AC_DEFINE([WITH_GSSAPI], [1], [Define if building with GSSAPI support.])])
AC_ARG_WITH([gtk],
[AS_HELP_STRING([--with-gtk=VER],
[specify GTK version to use (`1', `2' or `3')])
AS_HELP_STRING([--without-gtk],
[do not use GTK (build command-line tools only)])],
[gtk_version_desired="$withval"],
[gtk_version_desired="any"])
case "$gtk_version_desired" in
1 | 2 | 3 | any | no) ;;
yes) gtk_version_desired="any" ;;
*) AC_ERROR([Invalid GTK version specified])
esac
AC_CHECK_HEADERS([utmpx.h],,,[
#include <sys/types.h>
#include <utmp.h>])
# Look for GTK 3, GTK 2 and GTK 1, in descending order of preference.
# If we can't find any, have the makefile only build the CLI programs.
gtk=none
case "$gtk_version_desired:$gtk" in
3:none | any:none)
ifdef([AM_PATH_GTK_3_0],[AM_PATH_GTK_3_0([3.0.0], [gtk=3], [])],
[AC_WARNING([generating configure script without GTK 3 autodetection])])
;;
esac
case "$gtk_version_desired:$gtk" in
2:none | any:none)
ifdef([AM_PATH_GTK_2_0],[AM_PATH_GTK_2_0([2.0.0], [gtk=2], [])],
[AC_WARNING([generating configure script without GTK 2 autodetection])])
;;
esac
case "$gtk_version_desired:$gtk" in
1:none | any:none)
ifdef([AM_PATH_GTK],[AM_PATH_GTK([1.2.0], [gtk=1], [])],[
# manual check for gtk1
AC_PATH_PROG(GTK1_CONFIG, gtk-config, absent)
if test "$GTK1_CONFIG" != "absent"; then
GTK_CFLAGS="`"$GTK1_CONFIG" --cflags`"
GTK_LIBS=`"$GTK1_CONFIG" --libs`
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
gtk=1
fi
])
;;
esac
case "$gtk" in
1)
# Add some manual #defines to make the GTK 1 headers work when
# compiling in C99 mode. Left to themselves, they'll expect the
# old-style pre-C99 GNU semantics of 'inline' and 'extern inline',
# with the effect that they'll end up defining out-of-line
# versions of the inlined functions in more than one translation
# unit and cause a link failure. Override them to 'static inline',
# which is safe.
GTK_CFLAGS="$GTK_CFLAGS -DG_INLINE_FUNC='static inline' -DG_CAN_INLINE=1"
esac
AM_CONDITIONAL(HAVE_GTK, [test "$gtk" != "none"])
if test "$gtk" = "2" -o "$gtk" = "3"; then
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $GTK_CFLAGS"
LIBS="$GTK_LIBS $LIBS"
AC_CHECK_FUNCS([pango_font_family_is_monospace pango_font_map_list_families])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
AC_SEARCH_LIBS([socket], [xnet])
AS_IF([test "x$with_gssapi" != xno],
[AC_SEARCH_LIBS(
[dlopen],[dl],
[],
[AC_DEFINE([NO_LIBDL], [1], [Define if we could not find libdl.])
AC_CHECK_HEADERS([gssapi/gssapi.h])
AC_SEARCH_LIBS(
[gss_init_sec_context],[gssapi gssapi_krb5 gss],
[],
[AC_DEFINE([NO_GSSAPI_LIB], [1], [Define if we could not find a gssapi library])])])])
AC_CHECK_LIB(X11, XOpenDisplay,
[GTK_LIBS="-lX11 $GTK_LIBS"
AC_DEFINE([HAVE_LIBX11],[],[Define if libX11.a is available])])
AC_CHECK_FUNCS([getaddrinfo posix_openpt ptsname setresuid strsignal updwtmpx fstatat dirfd futimes setpwent endpwent getauxval elf_aux_info sysctlbyname])
AC_CHECK_DECLS([CLOCK_MONOTONIC], [], [], [[#include <time.h>]])
AC_CHECK_HEADERS([sys/auxv.h asm/hwcap.h sys/sysctl.h sys/types.h glob.h])
AC_SEARCH_LIBS([clock_gettime], [rt], [AC_DEFINE([HAVE_CLOCK_GETTIME],[],[Define if clock_gettime() is available])])
AC_CACHE_CHECK([for SO_PEERCRED and dependencies], [x_cv_linux_so_peercred], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
#define _GNU_SOURCE
#include <features.h>
#include <sys/socket.h>
]],[[
struct ucred cr;
socklen_t crlen = sizeof(cr);
return getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cr, &crlen) +
cr.pid + cr.uid + cr.gid;
]]
)],
AS_VAR_SET(x_cv_linux_so_peercred, yes),
AS_VAR_SET(x_cv_linux_so_peercred, no)
)
])
AS_IF([test AS_VAR_GET(x_cv_linux_so_peercred) = yes],
[AC_DEFINE([HAVE_SO_PEERCRED], [1],
[Define if SO_PEERCRED works in the Linux fashion.])]
)
if test "x$GCC" = "xyes"; then
:
AC_SUBST(WARNINGOPTS, ['-Wall -Werror -Wpointer-arith -Wvla'])
else
:
AC_SUBST(WARNINGOPTS, [])
fi
AC_SEARCH_LIBS([pow], [m])
AC_OUTPUT
if test "$gtk_version_desired" = "no"; then cat <<EOF
'configure' was instructed not to build using GTK. Therefore, PuTTY
itself and the other GUI utilities will not be built by the generated
Makefile: only the command-line tools such as puttygen, plink and
psftp will be built.
EOF
elif test "$gtk" = "none"; then cat <<EOF
'configure' was unable to find any version of the GTK libraries on
your system. Therefore, PuTTY itself and the other GUI utilities will
not be built by the generated Makefile: only the command-line tools
such as puttygen, plink and psftp will be built.
EOF
fi
AH_BOTTOM([
/* Convert autoconf definitions to ones that PuTTY wants. */
#ifndef HAVE_GETADDRINFO
# define NO_IPV6
#endif
#ifndef HAVE_SETRESUID
# define HAVE_NO_SETRESUID
#endif
#ifndef HAVE_STRSIGNAL
# define HAVE_NO_STRSIGNAL
#endif
#if !defined(HAVE_UTMPX_H) || !defined(HAVE_UPDWTMPX)
# define OMIT_UTMP
#endif
#ifndef HAVE_PTSNAME
# define BSD_PTYS
#endif
#ifndef HAVE_SYS_SELECT_H
# define HAVE_NO_SYS_SELECT_H
#endif
#ifndef HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE
# define PANGO_PRE_1POINT4
#endif
#ifndef HAVE_PANGO_FONT_MAP_LIST_FAMILIES
# define PANGO_PRE_1POINT6
#endif
#if !defined(WITH_GSSAPI)
# define NO_GSSAPI
#endif
#if !defined(NO_GSSAPI) && defined(NO_LIBDL)
# if !defined(HAVE_GSSAPI_GSSAPI_H) || defined(NO_GSSAPI_LIB)
# define NO_GSSAPI
# endif
#endif
])

View File

@ -333,45 +333,6 @@ on a 640\u00D7{x}480 display. If you're adding controls to either of
these boxes and you find yourself wanting to increase the size of
the whole box, \e{don't}. Split it into more panels instead.
\H{udp-makefiles-auto} Automatically generated \cw{Makefile}s
PuTTY is intended to compile on multiple platforms, and with
multiple compilers. It would be horrifying to try to maintain a
single \cw{Makefile} which handled all possible situations, and just
as painful to try to directly maintain a set of matching
\cw{Makefile}s for each different compilation environment.
Therefore, we have moved the problem up by one level. In the PuTTY
source archive is a file called \c{Recipe}, which lists which source
files combine to produce which binaries; and there is also a script
called \cw{mkfiles.pl}, which reads \c{Recipe} and writes out the
real \cw{Makefile}s. (The script also reads all the source files and
analyses their dependencies on header files, so we get an extra
benefit from doing it this way, which is that we can supply correct
dependency information even in environments where it's difficult to
set up an automated \c{make depend} phase.)
You should \e{never} edit any of the PuTTY \cw{Makefile}s directly.
They are not stored in our source repository at all. They are
automatically generated by \cw{mkfiles.pl} from the file \c{Recipe}.
If you need to add a new object file to a particular binary, the
right thing to do is to edit \c{Recipe} and re-run \cw{mkfiles.pl}.
This will cause the new object file to be added in every tool that
requires it, on every platform where it matters, in every
\cw{Makefile} to which it is relevant, \e{and} to get all the
dependency data right.
If you send us a patch that modifies one of the \cw{Makefile}s, you
just waste our time, because we will have to convert it into a
change to \c{Recipe}. If you send us a patch that modifies \e{all}
of the \cw{Makefile}s, you will have wasted a lot of \e{your} time
as well!
(There is a comment at the top of every \cw{Makefile} in the PuTTY
source archive saying this, but many people don't seem to read it,
so it's worth repeating here.)
\H{udp-ssh-coroutines} Coroutines in the SSH code
Large parts of the code in the various SSH modules (in fact most of

View File

@ -1,11 +0,0 @@
#! /bin/sh
# This script makes the autoconf mechanism for the Unix port work.
# It's separate from mkfiles.pl because it won't work (and isn't needed)
# on a non-Unix system.
# It's nice to be able to run this from inside the unix subdir as
# well as from outside.
test -f unix.h && cd ..
# Run autoconf on our real configure.in.
autoreconf -i && rm -rf autom4te.cache

2095
mkfiles.pl

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,6 @@
set -e
perl mkfiles.pl
# These are text files.
text=`{ find . -name CVS -prune -o \
-name .cvsignore -prune -o \

View File

@ -3,15 +3,12 @@
# Build a Unix source distribution from the PuTTY CVS area.
#
# Expects the following arguments:
# - the version number to write into configure.ac
# - the suffix to put on the Unix source tarball
# - the options to put on the 'make' command line for the docs
autoconfver="$1"
arcsuffix="$2"
docver="$3"
arcsuffix="$1"
docver="$2"
perl mkfiles.pl
(cd doc && make -s ${docver:+"$docver"})
relver=`cat LATEST.VER`
@ -27,12 +24,9 @@ find . -name uxarc -prune -o \
-name CVS -prune -o \
-name .cvsignore -prune -o \
-name .svn -prune -o \
-name configure.ac -prune -o \
-name '*.zip' -prune -o \
-name '*.tar.gz' -prune -o \
-type f -exec ln -s $PWD/{} uxarc/$arcname/{} \;
sed "s/^AC_INIT(putty,.*/AC_INIT(putty, $autoconfver)/" configure.ac > uxarc/$arcname/configure.ac
(cd uxarc/$arcname && sh mkauto.sh) 2>errors || { cat errors >&2; exit 1; }
tar -C uxarc -chzof $arcname.tar.gz $arcname
rm -rf uxarc

View File

@ -34,10 +34,8 @@ if ($setver) {
my $builddir = tempdir(DIR => ".", CLEANUP => 1);
0 == system "git archive --format=tar HEAD | ( cd $builddir && tar xf - )"
or die;
0 == system "cd $builddir && ./mkfiles.pl" or die;
0 == system "cd $builddir && ./mkauto.sh" or die;
0 == system "cd $builddir && ./configure" or die;
0 == system "cd $builddir && make pscp plink RELEASE=${version}" or die;
0 == system "cd $builddir && cmake . -DCMAKE_C_FLAGS=-DRELEASE=${version}" or die;
0 == system "cd $builddir && cmake --build . -t pscp -t plink -j" or die;
our $pscp_transcript = `cd $builddir && ./pscp --help`;
$pscp_transcript =~ s/^Unidentified build/Release ${version}/m or die;
$pscp_transcript =~ s/^/\\c /mg;

204
unix/CMakeLists.txt Normal file
View File

@ -0,0 +1,204 @@
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
add_platform_sources_to_library(utils
uxutils.c uxsignal.c uxpoll.c xkeysym.c uxmisc.c xpmpucfg.c
xpmputty.c xpmptcfg.c xpmpterm.c x11misc.c ../time.c)
add_platform_sources_to_library(eventloop
uxcliloop.c uxsel.c)
add_platform_sources_to_library(console
uxcons.c)
add_platform_sources_to_library(settings
uxstore.c)
add_platform_sources_to_library(network
uxnet.c uxfdsock.c uxagentsock.c uxpeer.c uxproxy.c)
add_platform_sources_to_library(sshcommon
uxnoise.c ux_x11.c)
add_platform_sources_to_library(sshclient
uxgss.c uxagentc.c uxshare.c)
add_platform_sources_to_library(sshserver
uxsftpserver.c procnet.c)
add_platform_sources_to_library(sftpclient
uxsftp.c)
add_platform_sources_to_library(otherbackends
uxser.c)
add_platform_sources_to_library(agent
uxagentc.c)
add_executable(fuzzterm
${CMAKE_SOURCE_DIR}/fuzzterm.c
${CMAKE_SOURCE_DIR}/be_none.c
${CMAKE_SOURCE_DIR}/logging.c
${CMAKE_SOURCE_DIR}/noprint.c
uxucs.c
uxnogtk.c)
add_dependencies(fuzzterm generated_licence_h)
target_link_libraries(fuzzterm
guiterminal eventloop charset settings utils)
add_executable(osxlaunch
osxlaunch.c)
add_executable(plink
uxplink.c
${CMAKE_SOURCE_DIR}/be_all_s.c
uxnogtk.c)
target_link_libraries(plink
eventloop noterminal console sshclient otherbackends settings network crypto
utils)
installed_program(plink)
add_executable(pscp
${CMAKE_SOURCE_DIR}/pscp.c
${CMAKE_SOURCE_DIR}/be_ssh.c
uxnogtk.c)
target_link_libraries(pscp
sftpclient eventloop console sshclient settings network crypto utils)
installed_program(pscp)
add_executable(psftp
${CMAKE_SOURCE_DIR}/psftp.c
${CMAKE_SOURCE_DIR}/be_ssh.c
uxnogtk.c)
target_link_libraries(psftp
sftpclient eventloop console sshclient settings network crypto utils)
installed_program(psftp)
add_executable(psocks
uxsocks.c
${CMAKE_SOURCE_DIR}/psocks.c
${CMAKE_SOURCE_DIR}/norand.c
${CMAKE_SOURCE_DIR}/nocproxy.c
${CMAKE_SOURCE_DIR}/portfwd.c
uxnogtk.c)
target_link_libraries(psocks
eventloop console network utils)
add_executable(psusan
uxpsusan.c
${CMAKE_SOURCE_DIR}/be_none.c
${CMAKE_SOURCE_DIR}/nogss.c
${CMAKE_SOURCE_DIR}/scpserver.c
uxnogtk.c
uxpty.c)
target_link_libraries(psusan
eventloop sshserver keygen settings network crypto utils)
installed_program(psusan)
add_library(puttygen-common OBJECT
${CMAKE_SOURCE_DIR}/notiming.c
uxgen.c
uxnogtk.c
uxnoise.c
uxstore.c
${CMAKE_SOURCE_DIR}/sshpubk.c
${CMAKE_SOURCE_DIR}/sshrand.c)
add_executable(puttygen
${CMAKE_SOURCE_DIR}/cmdgen.c)
target_link_libraries(puttygen
puttygen-common keygen console crypto utils)
installed_program(puttygen)
add_executable(cgtest
${CMAKE_SOURCE_DIR}/cgtest.c)
target_link_libraries(cgtest
puttygen-common keygen console crypto utils)
add_executable(testsc
${CMAKE_SOURCE_DIR}/testsc.c)
target_link_libraries(testsc crypto utils)
add_executable(testzlib
${CMAKE_SOURCE_DIR}/testzlib.c
${CMAKE_SOURCE_DIR}/sshzlib.c)
target_link_libraries(testzlib utils)
add_executable(uppity
uxserver.c
${CMAKE_SOURCE_DIR}/be_none.c
${CMAKE_SOURCE_DIR}/scpserver.c
uxnogtk.c
uxpty.c
${CMAKE_SOURCE_DIR}/nogss.c)
target_link_libraries(uppity
eventloop sshserver keygen settings network crypto utils)
if(GTK_FOUND)
add_platform_sources_to_library(utils
gtkcols.c)
add_platform_sources_to_library(guiterminal
gtkwin.c gtkfont.c gtkdlg.c gtkcfg.c gtkcomm.c uxcfg.c uxucs.c uxprint.c)
add_dependencies(guiterminal generated_licence_h) # gtkdlg.c uses licence.h
add_library(guimisc STATIC
gtkmisc.c)
add_executable(pageant
uxpgnt.c
${CMAKE_SOURCE_DIR}/be_misc.c
${CMAKE_SOURCE_DIR}/be_none.c
${CMAKE_SOURCE_DIR}/nogss.c
gtkask.c
ux_x11.c
uxnoise.c
${CMAKE_SOURCE_DIR}/x11fwd.c)
target_link_libraries(pageant
guimisc eventloop console agent settings network crypto utils
${GTK_LIBRARIES})
installed_program(pageant)
add_executable(pterm
uxpterm.c
gtkmain.c
${CMAKE_SOURCE_DIR}/be_none.c
${CMAKE_SOURCE_DIR}/nogss.c
uxpty.c)
target_link_libraries(pterm
guiterminal guimisc eventloop settings charset utils
${GTK_LIBRARIES} ${X11_LIBRARIES})
installed_program(pterm)
add_executable(ptermapp
uxpterm.c
gtkapp.c
${CMAKE_SOURCE_DIR}/nocmdline.c
${CMAKE_SOURCE_DIR}/be_none.c
${CMAKE_SOURCE_DIR}/nogss.c
uxpty.c)
target_link_libraries(ptermapp
guiterminal guimisc eventloop settings charset utils
${GTK_LIBRARIES} ${X11_LIBRARIES})
add_executable(putty
uxputty.c
gtkmain.c
${CMAKE_SOURCE_DIR}/be_all_s.c)
target_link_libraries(putty
guiterminal guimisc eventloop sshclient otherbackends settings
network crypto charset utils
${GTK_LIBRARIES} ${X11_LIBRARIES})
set_target_properties(putty
PROPERTIES LINK_INTERFACE_MULTIPLICITY 2)
installed_program(putty)
add_executable(puttyapp
uxputty.c
gtkapp.c
${CMAKE_SOURCE_DIR}/nocmdline.c
${CMAKE_SOURCE_DIR}/be_all_s.c)
target_link_libraries(puttyapp
guiterminal guimisc eventloop sshclient otherbackends settings
network crypto charset utils
${GTK_LIBRARIES} ${X11_LIBRARIES})
add_executable(puttytel
uxputty.c
gtkmain.c
${CMAKE_SOURCE_DIR}/be_nos_s.c
${CMAKE_SOURCE_DIR}/nogss.c
${CMAKE_SOURCE_DIR}/norand.c
${CMAKE_SOURCE_DIR}/nocproxy.c)
target_link_libraries(puttytel
guiterminal guimisc eventloop otherbackends settings network charset utils
${GTK_LIBRARIES} ${X11_LIBRARIES})
endif()

3
unix/configure vendored
View File

@ -1,3 +0,0 @@
#!/bin/sh
$(echo "$0" | sed '$s!configure$!../configure!') "$@"

View File

@ -9,17 +9,10 @@
/*
To build on OS X, you will need a build environment with GTK 3 and
gtk-mac-bundler, and also Halibut on the path (to build the man pages,
without which the standard Makefile will complain). Then, from a clean
checkout, do this:
./mkfiles.pl -U --with-quartz
make -C icons icns
make -C doc
make
and you should get unix/PuTTY.app and unix/PTerm.app as output.
Building this for OS X is currently broken, because the new
CMake-based build system doesn't support it yet. Probably what needs
doing is to add it back in to unix/CMakeLists.txt under a condition
like if(CMAKE_SYSTEM_NAME MATCHES "Darwin").
*/

View File

@ -1,8 +1,8 @@
#ifndef PUTTY_UNIX_H
#define PUTTY_UNIX_H
#ifdef HAVE_CONFIG_H
# include "uxconfig.h" /* Space to hide it from mkfiles.pl */
#if HAVE_CMAKE_H
#include "cmake.h"
#endif
#include <stdio.h> /* for FILENAME_MAX */

View File

@ -6,7 +6,7 @@
/* Unix code to set up the GSSAPI library list. */
#if !defined NO_LIBDL && !defined NO_GSSAPI
#if !defined NO_LIBDL && !defined STATIC_GSSAPI && !defined NO_GSSAPI
const int ngsslibs = 4;
const char *const gsslibnames[4] = {

View File

@ -3,11 +3,11 @@
* appropriate autoconfery.
*/
#ifdef HAVE_CONFIG_H
# include "uxconfig.h" /* leading space prevents mkfiles.pl trying to follow */
#if HAVE_CMAKE_H
#include "cmake.h"
#endif
#ifdef HAVE_SO_PEERCRED
#if HAVE_SO_PEERCRED
#define _GNU_SOURCE
#include <features.h>
#endif
@ -18,7 +18,7 @@
bool so_peercred(int fd, int *pid, int *uid, int *gid)
{
#ifdef HAVE_SO_PEERCRED
#if HAVE_SO_PEERCRED
struct ucred cr;
socklen_t crlen = sizeof(cr);
if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cr, &crlen) == 0) {

View File

@ -198,7 +198,7 @@ static void pty_try_write(Pty *pty);
#ifndef OMIT_UTMP
static void setup_utmp(char *ttyname, char *location)
{
#ifdef HAVE_LASTLOG
#if HAVE_LASTLOG
struct lastlog lastlog_entry;
FILE *lastlog;
#endif
@ -235,9 +235,11 @@ static void setup_utmp(char *ttyname, char *location)
pututxline(&utmp_entry);
endutxent();
#if HAVE_UPDWTMPX
updwtmpx(WTMPX_FILE, &utmp_entry);
#endif
#ifdef HAVE_LASTLOG
#if HAVE_LASTLOG
memset(&lastlog_entry, 0, sizeof(lastlog_entry));
strncpy(lastlog_entry.ll_line, ttyname+5, lenof(lastlog_entry.ll_line));
strncpy(lastlog_entry.ll_host, location, lenof(lastlog_entry.ll_host));
@ -266,7 +268,9 @@ static void cleanup_utmp(void)
utmp_entry.ut_tv.tv_sec = tv.tv_sec;
utmp_entry.ut_tv.tv_usec = tv.tv_usec;
#if HAVE_UPDWTMPX
updwtmpx(WTMPX_FILE, &utmp_entry);
#endif
memset(utmp_entry.ut_line, 0, lenof(utmp_entry.ut_line));
utmp_entry.ut_tv.tv_sec = 0;
@ -371,7 +375,7 @@ static void pty_open_master(Pty *pty)
#endif
;
#ifdef HAVE_POSIX_OPENPT
#if HAVE_POSIX_OPENPT
#ifdef SET_NONBLOCK_VIA_OPENPT
/*
* OS X, as of 10.10 at least, doesn't permit me to set O_NONBLOCK
@ -567,7 +571,7 @@ void pty_pre_init(void)
/* Drop privs. */
{
#ifndef HAVE_NO_SETRESUID
#if HAVE_SETRESUID && HAVE_SETRESGID
int gid = getgid(), uid = getuid();
int setresgid(gid_t, gid_t, gid_t);
int setresuid(uid_t, uid_t, uid_t);
@ -717,7 +721,7 @@ static void pty_real_select_result(Pty *pty, int fd, int event, int status)
"\r\n[pterm: process terminated with exit code %d]\r\n",
WEXITSTATUS(pty->exit_code));
} else if (WIFSIGNALED(pty->exit_code)) {
#ifdef HAVE_NO_STRSIGNAL
#if !HAVE_STRSIGNAL
message = dupprintf(
"\r\n[pterm: process terminated on signal %d]\r\n",
WTERMSIG(pty->exit_code));

View File

@ -11,22 +11,22 @@
#define PUTTY_UXUTILS_H
#if defined __APPLE__
#ifdef HAVE_SYS_SYSCTL_H
#if HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h>
#endif
#endif /* defined __APPLE__ */
#if defined __arm__ || defined __aarch64__
#ifdef HAVE_SYS_TYPES_H
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_AUXV_H
#if HAVE_SYS_AUXV_H
#include <sys/auxv.h>
#endif
#ifdef HAVE_ASM_HWCAP_H
#if HAVE_ASM_HWCAP_H
#include <asm/hwcap.h>
#endif
@ -51,7 +51,7 @@ static inline u_long getauxval(int which) { return 0; }
#if defined __APPLE__
static inline bool test_sysctl_flag(const char *flagname)
{
#ifdef HAVE_SYSCTLBYNAME
#if HAVE_SYSCTLBYNAME
int value;
size_t size = sizeof(value);
return (sysctlbyname(flagname, &value, &size, NULL, 0) == 0 &&

View File

@ -11,15 +11,10 @@
#include "putty.h"
#include "ssh.h"
#ifdef SOURCE_COMMIT
#include "empty.h"
#endif
#include "version.h"
const char ver[] = TEXTVER;
const char sshver[] = SSHVER;
const char commitid[] = SOURCE_COMMIT;
/*
* SSH local version string MUST be under 40 characters. Here's a

View File

@ -11,25 +11,3 @@
#define TEXTVER "Unidentified build"
#define SSHVER "-Unidentified-Local-Build"
#define BINARY_VERSION 0,0,0,0
#ifndef SOURCE_COMMIT
/*
* git commit id from which this build was made. This is defined by
* Buildscr for official builds - both source archives and prebuilt
* binaries - in the course of overwriting this file as described
* above. But we put it here under ifdef, so that it can also be
* passed in on the command line for Unix local development builds,
* which I treat specially because Unix developers - e.g. me - are
* quite likely to run 'make install' straight out of their dev
* directory so as to use the bleeding-edge code for day-to-day
* running.
*
* Windows doesn't really need the same treatment, because the easiest
* way to install a build properly on Windows is to run the installer,
* and the easiest way to do that is to run Buildscr, which will
* populate this field its own way. It's only the Unix automake build
* where you might go straight from local 'make' to 'make install'
* without going through Buildscr.
*/
#define SOURCE_COMMIT "unavailable"
#endif

142
windows/CMakeLists.txt Normal file
View File

@ -0,0 +1,142 @@
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
add_platform_sources_to_library(utils
wincapi.c winutils.c winucs.c winmisc.c winmiscs.c wintime.c windefs.c
winsecur.c)
add_platform_sources_to_library(eventloop
wincliloop.c winhandl.c)
add_platform_sources_to_library(console
winselcli.c winnohlp.c wincons.c)
add_platform_sources_to_library(settings
winstore.c)
add_platform_sources_to_library(network
winnet.c winhsock.c winnpc.c winnps.c winproxy.c)
add_platform_sources_to_library(sshcommon
winnoise.c winx11.c)
add_platform_sources_to_library(sshclient
winpgntc.c wingss.c winshare.c)
add_platform_sources_to_library(sftpclient
winsftp.c)
add_platform_sources_to_library(otherbackends
winser.c)
add_platform_sources_to_library(agent
winpgntc.c)
add_platform_sources_to_library(guiterminal
windlg.c winctrls.c wincfg.c winprint.c winjump.c sizetip.c)
add_dependencies(guiterminal generated_licence_h) # windlg.c uses licence.h
add_library(guimisc STATIC
winselgui.c)
add_executable(pageant
winpgnt.c
winhelp.c
pageant.rc)
add_dependencies(pageant generated_licence_h)
target_link_libraries(pageant
guimisc eventloop agent network crypto utils
${platform_libraries})
set_target_properties(pageant PROPERTIES
WIN32_EXECUTABLE ON
LINK_FLAGS "${LFLAG_MANIFEST_NO}")
installed_program(pageant)
add_executable(plink
winplink.c
${CMAKE_SOURCE_DIR}/be_all_s.c
winnojmp.c
winnohlp.c
plink.rc)
add_dependencies(plink generated_licence_h)
target_link_libraries(plink
eventloop console noterminal sshclient otherbackends settings network crypto
utils
${platform_libraries})
installed_program(plink)
add_executable(pscp
${CMAKE_SOURCE_DIR}/pscp.c
${CMAKE_SOURCE_DIR}/be_ssh.c
winnojmp.c
winnohlp.c
pscp.rc)
add_dependencies(pscp generated_licence_h)
target_link_libraries(pscp
sftpclient eventloop console sshclient settings network crypto utils
${platform_libraries})
installed_program(pscp)
add_executable(psftp
${CMAKE_SOURCE_DIR}/psftp.c
${CMAKE_SOURCE_DIR}/be_ssh.c
winnojmp.c
winnohlp.c
psftp.rc)
add_dependencies(psftp generated_licence_h)
target_link_libraries(psftp
sftpclient eventloop console sshclient settings network crypto utils
${platform_libraries})
installed_program(psftp)
add_executable(psocks
winsocks.c
winnohlp.c
${CMAKE_SOURCE_DIR}/psocks.c
${CMAKE_SOURCE_DIR}/norand.c
${CMAKE_SOURCE_DIR}/nocproxy.c
${CMAKE_SOURCE_DIR}/portfwd.c)
target_link_libraries(psocks
eventloop console network utils
${platform_libraries})
add_executable(putty
window.c
winhelp.c
${CMAKE_SOURCE_DIR}/be_all_s.c
putty.rc)
add_dependencies(putty generated_licence_h)
target_link_libraries(putty
guiterminal guimisc eventloop sshclient otherbackends settings network crypto
utils
${platform_libraries})
set_target_properties(putty PROPERTIES
WIN32_EXECUTABLE ON
LINK_FLAGS "${LFLAG_MANIFEST_NO}")
installed_program(putty)
add_executable(puttytel
window.c
winhelp.c
${CMAKE_SOURCE_DIR}/be_nos_s.c
${CMAKE_SOURCE_DIR}/nogss.c
${CMAKE_SOURCE_DIR}/norand.c
${CMAKE_SOURCE_DIR}/nocproxy.c
puttytel.rc)
add_dependencies(puttytel generated_licence_h)
target_link_libraries(puttytel
guiterminal guimisc eventloop otherbackends settings network utils
${platform_libraries})
set_target_properties(puttytel PROPERTIES
WIN32_EXECUTABLE ON
LINK_FLAGS "${LFLAG_MANIFEST_NO}")
installed_program(puttytel)
add_executable(puttygen
winpgen.c
${CMAKE_SOURCE_DIR}/notiming.c
winnoise.c
winnojmp.c
winstore.c
winhelp.c
${CMAKE_SOURCE_DIR}/sshpubk.c
${CMAKE_SOURCE_DIR}/sshrand.c
winctrls.c
puttygen.rc)
add_dependencies(puttygen generated_licence_h)
target_link_libraries(puttygen
keygen guimisc crypto utils
${platform_libraries})
set_target_properties(puttygen PROPERTIES
WIN32_EXECUTABLE ON
LINK_FLAGS "${LFLAG_MANIFEST_NO}")
installed_program(puttygen)

View File

@ -5,20 +5,15 @@
#ifndef PUTTY_RCSTUFF_H
#define PUTTY_RCSTUFF_H
#ifdef __LCC__
#include <win.h>
#else
#ifdef HAVE_CMAKE_H
#include "cmake.h"
#endif
/* Some compilers don't have winresrc.h */
#ifndef NO_WINRESRC_H
#ifndef MSVC4
#if HAVE_WINRESRC_H
#include <winresrc.h>
#else
#elif HAVE_WINRES_H
#include <winres.h>
#endif
#endif
#endif /* end #ifdef __LCC__ */
/* Some systems don't define this, so I do it myself if necessary */
#ifndef TCS_MULTILINE

View File

@ -10,13 +10,7 @@
#include <limits.h>
#include <assert.h>
#ifdef __WINE__
#define NO_MULTIMON /* winelib doesn't have this */
#endif
#ifndef NO_MULTIMON
#define COMPILE_MULTIMON_STUBS
#endif
#include "putty.h"
#include "terminal.h"
@ -26,7 +20,7 @@
#include "winseat.h"
#include "tree234.h"
#ifndef NO_MULTIMON
#ifdef NO_MULTIMON
#include <multimon.h>
#endif
@ -1245,16 +1239,16 @@ static void exact_textout(HDC hdc, int x, int y, CONST RECT *lprc,
unsigned short *lpString, UINT cbCount,
CONST INT *lpDx, bool opaque)
{
#ifdef __LCC__
#if HAVE_GCP_RESULTSW
GCP_RESULTSW gcpr;
#else
/*
* The LCC include files apparently don't supply the
* GCP_RESULTSW type, but we can make do with GCP_RESULTS
* proper: the differences aren't important to us (the only
* variable-width string parameter is one we don't use anyway).
* If building against old enough headers that the GCP_RESULTSW
* type isn't available, we can make do with GCP_RESULTS proper:
* the differences aren't important to us (the only variable-width
* string parameter is one we don't use anyway).
*/
GCP_RESULTS gcpr;
#else
GCP_RESULTSW gcpr;
#endif
char *buffer = snewn(cbCount*2+2, char);
char *classbuffer = snewn(cbCount, char);

View File

@ -105,7 +105,7 @@ struct ssh_gss_liblist *ssh_gss_setup(Conf *conf)
if (!kernel32_module) {
kernel32_module = load_system32_dll("kernel32.dll");
}
#if defined _MSC_VER && _MSC_VER < 1900
#if !HAVE_ADDDLLDIRECTORY
/* Omit the type-check because older MSVCs don't have this function */
GET_WINDOWS_FUNCTION_NO_TYPECHECK(kernel32_module, AddDllDirectory);
#else

View File

@ -1,7 +1,7 @@
#include "win_res.h"
#ifdef EMBED_CHM
ID_CUSTOM_CHMFILE TYPE_CUSTOM_CHMFILE "../doc/putty.chm"
#ifdef EMBEDDED_CHM_FILE
ID_CUSTOM_CHMFILE TYPE_CUSTOM_CHMFILE EMBEDDED_CHM_FILE
#define HELPVER " (with embedded help)"
#else
#define HELPVER " (without embedded help)"

View File

@ -272,7 +272,7 @@ static SocketPeerInfo *sk_handle_peer_info(Socket *s)
if (!kernel32_module) {
kernel32_module = load_system32_dll("kernel32.dll");
#if (defined _MSC_VER && _MSC_VER < 1900) || defined __MINGW32__
#if !HAVE_GETNAMEDPIPECLIENTPROCESSID
/* For older Visual Studio, and MinGW too (at least as of
* Ubuntu 16.04), this function isn't available in the header
* files to type-check. Ditto the toolchain I use for

View File

@ -157,7 +157,7 @@ void dll_hijacking_protection(void)
if (!kernel32_module) {
kernel32_module = load_system32_dll("kernel32.dll");
#if (defined _MSC_VER && _MSC_VER < 1900)
#if !HAVE_SETDEFAULTDLLDIRECTORIES
/* For older Visual Studio, this function isn't available in
* the header files to type-check */
GET_WINDOWS_FUNCTION_NO_TYPECHECK(

View File

@ -237,7 +237,7 @@ void *minefield_c_realloc(void *p, size_t size)
#endif /* MINEFIELD */
#if defined _MSC_VER && _MSC_VER < 1800
#if !HAVE_STRTOUMAX
/*
* Work around lack of strtoumax in older MSVC libraries

View File

@ -5,21 +5,22 @@
#ifndef PUTTY_WINSTUFF_H
#define PUTTY_WINSTUFF_H
#ifndef AUTO_WINSOCK
#include <winsock2.h>
#if HAVE_CMAKE_H
#include "cmake.h"
#endif
#include <winsock2.h>
#include <windows.h>
#include <stdio.h> /* for FILENAME_MAX */
/* We use uintptr_t for Win32/Win64 portability, so we should in
* principle include stdint.h, which defines it according to the C
* standard. But older versions of Visual Studio - including the one
* used for official PuTTY builds as of 2015-09-28 - don't provide
* standard. But older versions of Visual Studio don't provide
* stdint.h at all, but do (non-standardly) define uintptr_t in
* stddef.h. So here we try to make sure _some_ standard header is
* included which defines uintptr_t. */
#include <stddef.h>
#if !defined _MSC_VER || _MSC_VER >= 1600 || defined __clang__
#if !HAVE_NO_STDINT_H
#include <stdint.h>
#endif