Граф коммитов

152 Коммитов

Автор SHA1 Сообщение Дата
Simon Tatham 37aca556ce Makefile.clangcl: permit building for Windows on Arm.
Now we don't have to worry about which windres we're using (or whether
another target architecture's windres will do just as well), this is
very easy - just test for a couple of extra values of $(Platform).

To build on Arm with VS2017 includes and libraries, various blog posts
and websites explain that you have to #define a cumbersome macro
called _ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE, without which the
headers will #error at you. But if you do that, then everything seems
to compile fine and I actually tested it on an Arm Windows machine
today.

Also, I had to disable stack protection (/GS-), because clang-cl
doesn't yet support the particular form of it for which the VS2017 Arm
C library provides the runtime support. Unfortunate in a security
application, of course, but there we go.
2018-05-31 18:50:15 +01:00
Simon Tatham bf0cf984cd Makefile.clangcl: use llvm-rc instead of windres.
Previously I was using clang-cl as my compiler, lld as my linker, and
GNU windres as my resource compiler, which made a confusing hybrid of
the LLVM and GNU toolchains. This was because llvm-rc had about four
missing features that stopped it being able to handle PuTTY's resource
files. (Some dialog control types; dialog class names; handling
preprocessor output without getting confused by line markers and
snippets of stray C; not complaining about the DISCARDABLE keyword.
Although admittedly I could have dealt with the last of those by just
removing it from my .rc files, because it's pointless anyway.)

In the past month, the llvm-rc developers have been hard at work, and
now it has _all_ those features! So now I can switch over to a purely
LLVM-based toolchain for my Windows builds, which is easier to set up
(and easier to tell other people how to set up, since they get it for
free with the rest of LLVM); doesn't have a nominal architecture
dependency (windres has to built against a particular flavour of
binutils); and produces bit-identical output to Visual Studio's
resource compiler as far as I can see (whereas windres is more in the
'close enough' area).

This needed a small makefile restructuring, because unlike windres,
llvm-rc doesn't have a built-in option to run the resource file
through the preprocessor. So now Makefile.clangcl has separate rules
to preprocess $tool.rc into $tool.rcpp and then compile the latter
into $tool.res.
2018-05-31 18:21:04 +01:00
Simon Tatham 1a02274272 Fix a Perl warning when mkfiles.pl gets bad input.
If you forget the '+' at the start of a continuation line with only
one word on it, then Perl would test $_[1] before checking that it
even existed to test. The test would give the right answer anyway, but
the warning was annoying.
2018-05-25 14:08:24 +01:00
Simon Tatham c05fdb7d61 A small pile of Windows compiler-warning fixes.
These include an unused variable left over from the command-line
refactoring; an explicit referencing of the module handle for
sspicli.dll which we really do deliberately load and then don't
(directly) use; a missing pointer-type cast in the Windows handle
socket code; and two 32/64 bit integer size mismatches in the types of
functions I was importing from system API DLLs.

The last of those are a bit worrying, and suggest to me that after
going to all that trouble to add type-checking of those runtime
imports in commit 49fb598b0, I might have only checked the resulting
compiler output in a 32-bit build and not a 64-bit one. Oops!
2017-12-10 09:22:22 +00:00
Simon Tatham 4ec2791945 Remove Makefile.bor.
After a conversation this week with a user who tried to use it, it's
clear that Borland C can't build the up-to-date PuTTY without having
to make too many compromises of functionality (unsupported API
details, no 'long long' type), even above the issues that could be
worked round with extra porting ifdefs.
2017-09-13 19:26:28 +01:00
Simon Tatham a459fc58e8 Switch to producing .res files, not .res.o.
I've just upgraded my build process to a version of lld-link
that knows how to read .res, and I think it's a slightly more
commonly found format, so less confusing to encounter.
2017-08-26 15:23:56 +01:00
Simon Tatham f02587f7ac Makefile.clangcl: provide a way to tell lld-link about crt0.obj.
I've been experimenting with using clang-cl with older versions of the
Visual Studio libraries and headers, and found that the older VS
libraries have a quirk which can cause link failure in a way that
doesn't happen with the newer one. I assume the corresponding old VS
linker must be doing some kind of special-case handling that lld isn't
mimicking.

The quirk arises because lld tries to pull in more than one of the
*crt0.obj startup objects which set things up before calling main or
WinMain (or whatever), and those objects define some of the same
symbols as each other. The fix is to explicitly ask for the right one
of those objects on the link command line, so that it's already been
loaded _before_ the linker starts searching libraries for unresolved
symbols; then the disputed symbols are never unresolved in the first
place during the library search phase.

But this means you have to pick your crt0 object differently depending
on which subsystem you're compiling for. Accordingly, here's an extra
feature in Makefile.clangcl to make that possible by means of the
right definitions on the make command line.
2017-05-25 08:21:19 +01:00
Simon Tatham ad694a4941 mkfiles.pl: fix regex syntax error.
Thanks to Brian K. White for spotting this straight-up syntax error of
a missing ), in the regex handling the special case of &splitlines
when it findss a word in its input string too long to fit in the
specified output line width. Apparently in all my own uses of
&splitline I'd never exercised that special-case code path before.
2017-05-01 06:53:06 +01:00
klemens 89fff90de7 Spelling fixes (just in comments).
As found by a bot ( http://www.misfix.org,
https://github.com/ka7/misspell_fixer ).
2017-04-15 17:47:10 +01:00
Simon Tatham 826c52144a Fix the '--without-gtk' mode in configure.
I had accidentally included the experimental "XT" app class (the
GtkApplication-based packaging of Unix PuTTY/pterm for OS X) among the
things that should still be built even when GTK is absent. That's
definitely wrong.
2017-02-18 17:09:38 +00:00
Simon Tatham 2e229cb179 New makefile, for Windows cross-builds with clang-cl.
This was very strange to write, because it's a bizarre combination of
the GNU-make-isms and rc commands of Makefile.mgw with the cl and link
commands of Makefile.vc (but also the latter thankfully doesn't need
those horrible response files).

I've added a big comment in mkfiles.pl about what the build
requirements for this makefile actually are, which _hopefully_ will be
usable by people other than me.
2017-02-05 11:53:58 +00:00
Simon Tatham 35d6c97dd7 Fix Makefile warning about circular empty.h dependency.
In commit be586d53b I made empty.h depend on $(allsources), which
unfortunately was defined so as to include empty.h. This was harmless,
because make just ignored the circular dependency, but annoying,
because it constantly mentioned that it was ignoring it.
2017-01-29 19:44:17 +00:00
Simon Tatham 23a9d5608c Fix PE header of the VS2015 builds so they run on Windows XP.
By default the VS2015 linker produces binaries with the minimum
version fields in the PE header set to 06.00, which causes XP not to
recognise them as valid binaries at all. But there's no other reason
VS2015-built binaries _can't_ run on versions of Windows as old as XP;
so here I add the link option to set those fields to 05.01 which makes
XP like them again.

This only applies to the 32-bit build, because the VS2015 64-bit
linker refuses to lower the min version field to under 06.00.
2017-01-21 14:55:53 +00:00
Simon Tatham 27e58f826f Reinstate the ASLR and DEP linker flags on Windows.
Originally added in commit 0014ffb70, and promptly reverted in
6bea4b250 when we realised that VS2003 didn't actually understand
them. But now we're building with VS2015, which does understand them,
it's actually useful to put them back in again.

Looking more closely, it turns out that VS2003 didn't actually _fail
to build_ if you passed these flags on the linker command line - it
just printed a warning and ignored them. (So there was no actual need
to revert the original change, except that it would have caused
confusion.) But that means I can add them unconditionally now, without
breaking even the legacy VS2003 build.
2017-01-21 14:55:53 +00:00
Simon Tatham ccf25c0849 Add explicit "./" in mkfiles.pl's require statements.
I've just tried for the first time to run mkfiles.pl on a system where
plain 'require "sbcsgen.pl"' does not search the cwd by default.
2016-09-19 14:14:54 +01:00
Jacob Nevins b3c3871745 Enable various features in MinGW builds.
I've reset the baseline to be the version of mingw-w64 that comes with
Ubuntu 14.04. Right now, that means no features need to be omitted; all
you need to do is set TOOLPATH to i686-w64-mingw32- .

I've removed -mno-cygwin without comment. Toolchains which don't support
this flag have been around since at least 2012, so we can probably
assume that no-one cares about older toolchains by now.
2016-04-10 15:27:16 +01:00
Jacob Nevins 371c68e355 Rename Makefile.cyg to Makefile.mgw.
It's really only useful with MinGW rather than a Cygwin toolchain these
days, as recent versions of the latter insist against linking with the
Cygwin DLL.

(I think it may no longer be possible to build with Cygwin out of the
box at all these days, but I'm not going to say so without having
actually checked that's the case. Settle for listing MinGW first in
various comments and docs.)
2016-04-10 15:10:45 +01:00
Simon Tatham c0a57d0b9e Fix semantics of empty string in mkfiles.pl "!cflags".
Previously, if you tried to set the special cflags for an object file
to the empty string, mkfiles.pl would normalise that to the string
"1". I'm not entirely sure why - that line of code was added without
explanation in commit 64150a5ef which brought in that directive in the
first place - but I have to guess that it was left over from some
earlier design iteration in which I hadn't quite decided whether I was
going to need a string or a boolean to separate version.o from other
objects.

Of course, setting an object's cflags to "" is a bit of a weird thing
to want to do anyway - why not just leave them unset? But in fact I've
now thought of something useful for it to do: this commit arranges
that setting cflags="" has the effect (in the 'am' makefile type) of
separating the object out into its own little automake library but not
actually giving that library any separate cflags. And the point of
_that_, in turn, will be that then you can add cflags to it
_conditionally_ in a "!begin am" snippet, e.g. conditionalised on
something in configure.
2016-04-07 07:52:01 +01:00
Simon Tatham 8730ed5297 Windows: compile with /D_CRT_SECURE_NO_WARNINGS.
With all due respect to Microsoft, a cross-platform program simply
cannot switch to using MS's assorted 'secure' versions of standard C
functions if it wants to continue compiling on platforms other than
Windows. So I might as well squash the warnings, so that any other
more interesting compiler warnings can avoid being swamped in the
mess.
2016-04-02 14:21:54 +01:00
Simon Tatham 5e884cfc27 Make Makefile.gtk default to GTK 3. 2016-03-25 09:11:01 +00:00
Simon Tatham 68b1933326 Fix Makefile.gtk in the wake of the new [XT] program type.
It's not the recommended makefile any more, but it's not too hard
to keep it working for the moment.
2016-03-25 09:10:50 +00:00
Simon Tatham 1af3bd927f New program type [XT] in Recipe.
This is to [X] what [UT] is to [U]: that is, it's a program linked
against the GTK libraries, but one which doesn't become part of the
'make install' set. I'll use this for the individual binaries that
will go in the OS X application bundles, and then have another
makefile rule pick those up in turn.
2016-03-23 22:01:10 +00:00
Simon Tatham 9ddd071ec2 Stop copying the licence text into C source code.
Now all the uses of the licence text or the short copyright notice get
it from a new header "licence.h", which in turn is built by a Perl
script licence.pl invoked by mkfiles.pl, using LICENCE itself as the
source.

Hence, I can completely remove a whole section from the list of
licence locations in CHECKLST.txt :-)
2015-12-22 13:33:42 +00:00
Simon Tatham 50ea866e4c Fix build breakage on Unix.
Occurred as a side effect of commit 198bca233, in which I wrote a Perl
loop of the form 'foreach $srcdir (@srcdirs)' inside which I modified
$srcdir - forgetting the Perl gotcha that if you do that, $srcdir
temporarily aliases the actual array element, so you end up modifying
the array you iterated over. Hence, a set of transformations intended
to convert the source directory list into a special form for the nmake
batch-mode inference rule syntax in particular ended up back in
@srcdirs to be reflected in unrelated makefiles output later in the
run.
2015-12-17 09:06:53 +00:00
Simon Tatham d3db17f3e1 Introduce a BUILDDIR parameter in Makefile.vc.
Now you can run a command like "nmake /f Makefile.vc BUILDDIR=foo\",
which will cause all the generated files to appear in a subdirectory
of putty\windows. This is immediately useful for testing multiple
build configurations against each other by hand; later on I hope it
will also be a convenient way to run multiple build configurations in
the proper bob build.
2015-12-16 18:52:15 +00:00
Simon Tatham 198bca233a Switch Makefile.vc to using batch-mode inference rules.
This enables it to combine the compilation of multiple source files
into a single 'cl' command with multiple input file arguments, which
speeds up the build noticeably.

(I think nmake could be doing a lot more to improve this - for a
start, I haven't found any way to let it aggregate compilations of
source files in more than one directory, and also, it seems to me that
it really ought to be able to reduce down to just _one_ invocation of
cl by choosing the best topological sort of its build operations,
whereas in fact it looks as if it's sorting the operations _before_
doing the aggregation. But even so, it's a big improvement on the
previous build time.)
2015-12-16 18:49:07 +00:00
Simon Tatham 7f95ebc0bf Use nmake's inline file creation to automate .rsp files.
This is noticeably faster than a sequence of 'echo' commands, because
the file gets created all in one go. The most natural approach to this
job would also hide the file's contents, but doing it this way with a
'type' command lets me see the file on nmake's standard output, so
that the build log should still contain everything useful for
debugging build problems.
2015-12-16 18:46:38 +00:00
Owen Dunn 6bea4b2502 Put ASLR and DEP flags back until the nightly build linker is new enough! 2015-11-27 19:55:52 +00:00
Owen Dunn 0014ffb70c Enable DEP and ASLR flags on VC++ linker command line
/dynamicbase and /nxcompat on the VC linker command line should
enable DEP and ASLR according to this MSDN article.
https://msdn.microsoft.com/en-us/library/bb430720.aspx
2015-11-24 22:57:46 +00:00
Simon Tatham f14382ccce Make 'make install' ignore the new 'fuzzterm' binary.
It's for regression testing and fuzzing, so there's no use for it if
you're not a developer working on the source.

Leaving it out of the 'make install' target in Makefile.gtk is no
trouble because that's already handled manually in Recipe by inserting
a giant hairy Makefile fragment to do the installation. But
Makefile.am was just setting bin_PROGRAMS to the full set of binaries
built, so for that one, I had to invent a new Recipe program category
[UT] which moves a particular binary into noinst_PROGRAMS.

While I was at it, I've retired the [M] program category, which has
been lying around unused since Ben's old Mac OS pre-X port.
2015-11-07 14:54:36 +00:00
Simon Tatham 6903e761d5 Consistently use &def for %makefile_extra pieces.
mkfiles.pl was giving a couple of annoying perl warnings, because some
makefile_extra strings were never set by Recipe. We already have the
&def function to convert undefs into "" for this reason, but weren't
using it everywhere. Now I think we are.
2014-11-22 16:30:29 +00:00
Simon Tatham 04caa872fe Move definition of SECURITY_WIN32 from makefiles into source.
This makes it easier for people to recompile the source in other
contexts or other makefiles.
2014-11-01 15:39:35 +00:00
Simon Tatham 4d8782e74f Rework versioning system to not depend on Subversion.
I've shifted away from using the SVN revision number as a monotonic
version identifier (replacing it in the Windows version resource with
a count of days since an arbitrary epoch), and I've removed all uses
of SVN keyword expansion (replacing them with version information
written out by Buildscr).

While I'm at it, I've done a major rewrite of the affected code which
centralises all the computation of the assorted version numbers and
strings into Buildscr, so that they're all more or less alongside each
other rather than scattered across multiple source files.

I've also retired the MD5-based manifest file system. A long time ago,
it seemed like a good idea to arrange that binaries of PuTTY would
automatically cease to identify themselves as a particular upstream
version number if any changes were made to the source code, so that if
someone made a local tweak and distributed the result then I wouldn't
get blamed for the results. Since then I've decided the whole idea is
more trouble than it's worth, so now distribution tarballs will have
version information baked in and people can just cope with that.

[originally from svn r10262]
2014-09-24 10:33:13 +00:00
Simon Tatham 0da2258292 Add the 'subdir-objects' option in the automake makefile.
This rearranges the object files so that they each live alongside
their original source file, instead of all being in the same
directory. To my way of thinking this is a more or less neutral change
(perhaps marginally less tidy), but autotools is apparently beginning
to think it's the One True Way and 1.14 will give a warning if you
don't have it enabled.

[originally from svn r10142]
2014-02-22 18:02:06 +00:00
Simon Tatham a947c49bec Move the Unix configure script up to the top level.
Previously, 'configure' and its assorted machinery lived in the 'unix'
subdir, because that seemed like a clean place to keep it given that
all the other per-platform Makefiles live in their platform
directories. However, this never sat all that happily with autotools,
and even less so now that it likes to have object file pathnames
parallel source file pathnames: if you have Makefile.am refer to
source files outside its subdir as "../terminal.c" and enable
subdir-objects then any out-of-tree build calls the corresponding
object file "../terminal.o" and so your build products mostly end up
at the directory above your build dir! And as of autotools 1.14 my
previous compensatory bodge of prefixing every source file path in
Makefile.am with "$(srcdir)" has stopped working too.

So I'm giving in to necessity, and changing policy by moving the
configure machinery up to the top level of the source tree where
autotools will be less confused by it. This should not be taken as any
indication of the primacy of the Unix port, only of the recalcitrance
of autotools.

Whereas before we had a trivial script called 'configure' at the top
level that invoked unix/configure to effectively do an 'out-of-tree
build' (for make purposes) at the top level of the source tree, we now
have a similar script in unix/configure. So this _should_ make very
little difference: people who were previously running configure from
the top level should still be able to, and likewise people who were
running it from the unix subdir.

[originally from svn r10141]
2014-02-22 18:01:32 +00:00
Simon Tatham 8d5ff561a3 Generate IDE project files for Visual Studio 2010 and 2012.
Thanks to Mike Edenfield for the initial version of this patch; I've
polished it up a bit (in particular inventing a more overengineered
GUID generation strategy) but most of it is his.

[originally from svn r10112]
2014-01-11 11:23:12 +00:00
Simon Tatham 293af847b5 sbcsgen.pl uses 'select' to point Perl at a different default output
handle. Revert that when we hackily call it from mkfiles.pl, so that
if I have a need to insert diagnostics in the latter they won't go
into the end of sbcsdat.c.

[originally from svn r10013]
2013-08-08 17:22:07 +00:00
Simon Tatham 4f457ff7f2 Add '.so' to the list of file extensions cleared up by 'make clean' in
Makefile.cyg, since if you're building against Winelib it will
generate one of those alongside each .exe file.

[originally from svn r9952]
2013-07-21 09:16:37 +00:00
Simon Tatham ac115f9082 Move the -I options for all our source subdirectories out of AM_CFLAGS
and into AM_CPPFLAGS. This is more conceptually sensible according to
my reading of the automake manual, and also has the specific desirable
effect that they move to the front of the command line, ahead of any
'system' type -I options that autoconf might have felt a need for.

A user reported that autoconf had added -I/usr/local/include to their
command line for the sake of a required header file, but their
/usr/local/include also turned out to include a thing called 'proxy.h'
(from libproxy, nothing to do with us) which shadowed our own proxy.h
and caused a build failure. This should fix that.

[originally from svn r9736]
2013-01-07 19:08:33 +00:00
Ben Harris 65290ced76 Better document the various environments with which Makefile.cyg works.
[originally from svn r9670]
2012-09-18 23:07:42 +00:00
Ben Harris 580103fca2 Add a new COMPAT option for environments lacking SecureZeroMemory(),
rather than explicitly checking for Winelib.  It seems that w32api is
lacking it as well.

[originally from svn r9669]
2012-09-18 23:05:29 +00:00
Ben Harris 5415b82930 In the cygwin Makefile, use "-o" on the windres command line to specify
the output file.  This appears to be supported by windres, and is
required by wrc (the Winelib resource compiler).

[originally from svn r9661]
2012-09-13 21:53:47 +00:00
Simon Tatham 3d3052f680 Add '-Wall -Werror' to the compile options in the autotools makefile,
having just noticed that Makefile.gtk had it and this one doesn't. (Of
course, this being autoconf, we can easily enough make it conditional
on the compiler actually being gcc.)

[originally from svn r9583]
2012-07-19 04:42:34 +00:00
Simon Tatham a4424bfd85 Create empty.h (used to force rebuilds of version.o by the automake
makefile) as a side effect of running mkfiles.pl.

The automake docs observe that the BUILT_SOURCES list is only
automatically built by plain 'make' or 'make all' or a couple of other
targets, so the sequence './configure && make plink' from a freshly
unpacked tar file would previously fail for lack of empty.h.

If empty.h had important _content_ that needed to be built at compile
time, of course, I wouldn't be able to fix it like this; but since the
only important thing is the timestamp, I can just make sure it already
exists at the time of first build.

[originally from svn r9288]
2011-09-14 15:54:26 +00:00
Simon Tatham 5a2e957525 Add a -U option to mkfiles.pl, which is just like -u except that it
runs configure at the top level rather than the unix subdirectory. I'm
getting into the idea of even doing it that way myself, because then I
can do VPATH builds from the same source tree elsewhere.

(Autoconf seems to be fine with doing multiple VPATH builds from the
same source tree in different build directories, but gets upset if you
try to do a VPATH build when you've done a normal build in the real
configure directory. So this way I do what autoconf sees as _only_
VPATH builds.)

[originally from svn r9269]
2011-08-20 07:56:19 +00:00
Simon Tatham 53be75b0cb Add a convenience option to mkfiles.pl for Unix users. If you run
'mkfiles.pl -u', it will do its normal processing, then run mkauto.sh
to regenerate configure and Makefile.in, then run configure in the
Unix subdirectory to regenerate unix/Makefile. So it's a handy
one-stop shop for going all the way from a modified Recipe to the
end-product Unix makefile, if you're adding source files during
development.

[originally from svn r9242]
2011-07-23 11:58:37 +00:00
Simon Tatham 64150a5ef2 Switch to using automake for the Unix autoconfigured build.
mkfiles.pl no longer generates a Makefile.in, but instead generates a
Makefile.am on which mkauto.sh runs automake. This means that the
autoconfigured makefile now does build-time dependency tracking (a
standard feature of automake-generated makefiles), and is generally
more like what Unix people will expect.

Some of the old-style make command-line settings (VER=-DRELEASE=foo,
XFLAGS=-DDEBUG) will still work; the COMPAT settings are better done
by autoconfiguration, and my habitual 'XFLAGS="-g -O0"' for an easily
debuggable build will actually not work any more because CFLAGS is
specified _after_ XFLAGS, so I should instead write 'make CFLAGS=-O0'
(-g is the default in automake, removed at 'make install' time).

The new makefile will automatically degrade into one that builds the
command-line tools only, in the case where GTK could not be found. In
principle, therefore, it should be an adequate replacement for _both_
the static Unix makefiles, Makefile.gtk and Makefile.ux. I haven't
actually retired those in this commit, but I'm pretty tempted.

[originally from svn r9239]
2011-07-23 11:33:29 +00:00
Simon Tatham d31d1f4bb5 Add an 'XLFLAGS' make variable to Makefile.vc, permitting user-
supplied extra link flags. This makes it reasonably convenient to
compile for Visual Studio debugging: just build using

  nmake /f Makefile.vc XFLAGS="/Zi /Od" XLFLAGS="/debug"

then load the resulting executable into Visual Studio (using 'Open
Project' rather than 'Open File') and the debugger should be able to
access the source.

[originally from svn r9038]
2010-12-20 13:04:34 +00:00
Simon Tatham ffe40202a4 Oops: r9004 should have removed various pieces from the Makefile and
header file setup too.

[originally from svn r9005]
[r9004 == 7ac1f17aab]
2010-09-25 08:37:30 +00:00
Simon Tatham 9f52d6c905 Move '-w' in the #! line into 'use warnings;' in the Perl code, to
simplify the #! line.

[originally from svn r8967]
2010-05-30 22:50:18 +00:00