This is the GUI Installer Builder for Claws Mail for Windows.

Instructions:
=============

1. Download the source and binary packages that are required to build the installer:

   $ cd packages
   $ ./download.sh
   $ cd ..

2. Configure the source tree for cross compilation, for either
   32-bit or 64-bit release. The default, with no parameter, builds
   the 64-bit version:

   $ ./autogen.sh
	 or
   $ ./autogen.sh --build-w32
	 or
   $ ./autogen.sh --build-w64

3. Build the installer:

   $ make

The installer will be made available in:

src/claws-mail-X.Y.Z-R.exe

4. Build the source tarball:

   $ make dist

The source tarball will be made available in:

claws-mail-win32-X.Y.Z-R.tar.xz

To collect files with debug symbols:

$ find src/playground/install/pkgs/ -name '*.debug' | grep /bin/ | xargs zip -j debug-files.zip


Build options
==================
If no parameters are passed to autogen.sh, it will prep the 64-bit build in the
official configuration.

If any parameters are passed to autogen.sh, the first must be either
--build-w32 or --build-w64.  All remaining parameters are passed on to the
configure script.


The configure script has four parameters for developers:

--disable-fancy-plugin will skip building the fancy plugin and its dependencies

--disable-strip will skip stripping the debug symbols from the build binaries
into separate .debug files

--enable-bzip2 will use faster bzip2 compression in the nsis installer instead
of smaller lzma

--enable-debug will build packages with debug CFLAGS and configure options


The configure script looks for five environment variables:

CFLAGS and CXXFLAGS are respected and passed down when building the packages.
If CFLAGS is specified but CXXFLAGS isn't, CXXFLAGS will use the CFLAGS value.

EXTRA_MAKENSIS_FLAGS will be added to the makensis command line.

WEBKITGTK_BISON sets a custom path to bison for building webkitgtk-2.4.11.  See below.

MAKE_JOBS sets the make -j parameter for building in parallel.  It defaults to
the number of CPUs on the system.  It doesn't build multiple packages in
parallel; it sets the parallelism in each package.


Build examples
==================
 # Build the 64-bit installer in the official configuration
 $ ./autogen.sh

 # Build the 32-bit installer in the official configuration
 $ ./autogen.sh --build-w32

 # Build an unstripped, 64-bit debug build suitable for use with cv2pdb
 # cv2pdb will generate PDB symbols for use with native Microsoft tools
 $ ./autogen.sh --build-w64 --disable-strip --enable-debug


Basic requirements
==================

A decent POSIX system is required for building this software as well
as GNU make.  We are using Debian GNU/Linux 11 (Bullseye), any other
POSIX system should work as well but you may run into problems due to
different mingw-w64 versions.

To finish the build, following packages need to be installed on a
Debian Bullseye system.

build-essential
automake
autoconf
mingw-w64
mingw-w64-tools
nsis
stow
unzip
docbook-utils
libglib2.0-bin
libglib2.0-dev-bin
git
cmake
bison ***
flex
gperf
intltool
libtool
libgettextpo-dev
meson
python3-distutils
wget
curl
ruby *
python-is-python3 *
gtk-3-examples **

* only needed for webkitgtk on gtk2 builds
** only needed for gtk3 builds
*** webkitgtk-2.4.11 fails to build with bison-3.7 but
    works with bison-3.6.4.  See below.


Fancy / WebkitGTK / GTK2
========================

Due to a lack of upstream support, webkitgtk and therefore the Claws Fancy plugin
are only available with the GTK2 build.  The latest version of webkitgtk that can
be built for Windows is 2.4.11, which is quite old.  Several packages needed by
Claws have since broken compatibility with the old version of webkitgtk.  Currently,
they are:
	glib
	glib-networking
	icu

In order to keep some Fancy support, the GTK2 build of Claws also builds with
old versions of those packages.

Additionally, webkitgtk-2.4.11 needs bison-3.6.4 to build.  If bison-3.6.4 isn't
available from your distro:

1. Build and install bison-3.6.4
	wget http://mirrors.kernel.org/gnu/bison/bison-3.6.4.tar.xz
	tar xf bison-3.6.4.tar.xz
	cd bison-3.6.4
	./configure --prefix=/opt/bison-3.6.4
	make && sudo make install

2. Call autogen.sh with the path to bison
	./autogen.sh --build-w64 WEBKITGTK_BISON=/opt/bison-3.6.4/bin/bison


Building in a Docker container
==============================

A good way to create an isolated environment for the build is to
use a Docker container. An image built from following Dockerfile
is sufficient:

--------8<---------8<---------8<--------
FROM debian:bullseye
RUN apt-get update && apt-get -y install build-essential automake autoconf mingw-w64 mingw-w64-tools nsis stow unzip docbook-utils libglib2.0-bin libglib2.0-dev-bin git cmake bison flex gperf intltool libtool libgettextpo-dev meson python3-distutils python-is-python3 wget curl ruby gtk-3-examples & apt-get clean
--------8<---------8<---------8<--------

To build the image locally (run in the directory with Dockerfile
with above content:
# docker image build -t claws-win32-builder:0.1 .

To launch a container based on the image, with the claws-win32-installer
cloned repository mounted inside it:
# docker run -ti --name mybuilder \
  -v /path/to/claws-win32-installer:/build \
	claws-win32-builder:0.1

In the shell inside the running container, switch to /build directory
and build the Claws Mail package according to the instructions above
in this README files.


Adding new packages to the installer:
=====================================

This requires editing a couple of files.

1. Add package to toplevel configure.ac, stating its dependencies.
  The CM_BPKG macro is for pre-built binaries
  The CM_MPKG macro is for packages that only use a makefile
  The CM_SPKG macro is for autotools, cmake, or meson packages

2. Add download information to packages/packages.current.

3. Add variables to src/Makefile.am
  cm_pkg_<pkg>_cmake if the package uses cmake
  cm_pkg_<pkg>_meson if the package uses meson
  cm_pkg_<pkg>_configure is the arguments passed to the configure script (or cmake/meson equivalent)
  cm_pkg_<pkg>_make_dir if make should be invoked from a directory besides the top-level directory
  cm_pkg_<pkg>_make_dir_inst if make install should be invoked from a directory besides the top-level directory
  cm_pkg_<pkg>_meson_cppflags are appended to -Dc_args and -Dcpp_args for meson setup
  cm_pkg_<pkg>_meson_ldflags are appended to -Dc_link_args and -Dcpp_link_args for meson setup
  cm_pkg_<pkg>_make_args if the package needs special arguments to make
  cm_pkg_<pkg>_make_args_inst if the package needs special arguments to make install

4. Add a cm_pkg_<pkg>_version entry to src/config.nsi.in

5. Specify what files from the built package should be included in
the installation (and uninstallation) in src/sections-(un)installer.nsi.

Then follow the standard build instructions listed above.


SASL and unofficial patches
===========================

In order for libsasl2 to find its plugins (which we install into
$INSTDIR\lib\sasl2), I've had to add a new API function to libetpan,
mailsasl_set_plugin_path(), which in turn calls sasl_set_path().

We call this new function from Claws Mail's main() during initialization.

This is done via patches held in this repository, since this stuff can
not go upstream - or at least the Claws Mail patch shouldn't, until
libetpan provides some way to set the SASL plugin path. I'll consider
submitting the libetpan patch upstream later.


Copyright
=========

The entire Claws Mail package is

  Copyright (C) 1999-2021 the Claws Mail Team and Hiroyuki Yamamoto

  Claws Mail is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 3 of the License, or
  (at your option) any later version.

  Claws Mail is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  02110-1301, USA


This file
=========

This README file is based on README file from GPG4Win installer package:

Copyright 2005, 2006, 2008 g10 Code GmbH

This file is free software; as a special exception the author gives
unlimited permission to copy and/or distribute it, with or without
modifications, as long as this notice is preserved.

This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
