Subject: bug#22240: Build instructions for 64-bit Windows?

From: Brian Burns <[email-masked]>
Date: Tue, 29 Dec 2015 01:12:51 -0600

Okay thanks, here's a rough draft for the instructions - it's also in a
Gist at
https://gist.github.com/bburns/43c9f170361aecee3b71 if anyone wants to make
any
changes that way.

I did wind up writing more than I thought I would, but I sent in my signed
paperwork last week in case I needed it.

> The "configure; make; make install" section should avoid showing
> non-essential switches to configure, except as an example: users
> should decide by themselves what switches to use.

Okay, I made it more clear that they were examples.

> the --host, --target, and --build switches should not be needed

I tried running configure without the '--host=x86_64-w64-mingw32' etc
switches
but got an error:

    configure: error: Emacs does not support 'x86_64-pc-msys' systems.
    If you think it should, please send a report to [email-masked].
    Check 'etc/MACHINES' for recognized configuration names.

but the MACHINES file says to see the nt/INSTALL document, which doesn't
cover
the 64-bit options. So I left them in for the moment - I can file a bug
report
for that also if needed.

> . the --with-wide-int switch is a no-op in a 64-bit build
> . the --with-png and other similar switches should not be used at
> all, since configure will detect whatever libraries are
> available by default (only the corresponding --without-FOO
> switches should ever be used to _disable_ a package that would
> otherwise be detected)

Okay, removed those.

> the --prefix should be on the configure command, and it should
> NOT advise any particular location (there's a discussion in
> nt/INSTALL where PREFIX should be, and I suggest to either
> repeat it or point to it, because I believe the same
> considerations are valid for a MinGW64 build; if MinGW64 has a
> popular location of the root of its tree, the preferred PREFIX
> should use it)

Okay, I put the --prefix on the configure command, but I think it would be
good
if the instructions included a simple example, and refer the user to the
INSTALL
instructions for more options - part of the reason I think my earlier
attempts
at building Emacs failed were because the instructions in INSTALL didn't
have an
example to follow, and coming from Windows I'm not very familiar with
building
from source, so having the example in Chris's instructions to follow were
very
helpful.

> the 'cp' commands I don't understand at all: if PREFIX is chosen
> correctly, the Emacs's bin/ directory and the MinGW64's bin/
> directory should be the same, so there's no need to copy; and
> even if these two bin/ directories are different, the directory
> with DLLs should be on PATH.  this sounds like some workaround
> for some misconfiguration, so we had better not repeated that.

I think this was in part because MSYS2 doesn't add its folders to the PATH,
and
if you use the PATH variable there might be both 32-bit and 64-bit DLLs on
it,
so in that case it's better to have the DLLs in the directory with the
executable - they're only about 32MB. But I removed this section and just
said
to add the folders to the PATH, and if there's a conflict to copy the DLLs
to
the bin folder.

> The "Run" section doesn't belong in installation instructions.

I think it might be good to include a simple Test section that just says to
run emacs with

      ./bin/runemacs.exe -Q

to check that it works - mainly because a Windows user might tend to launch
Emacs from a shortcut on the desktop and might be unused to launching it
from the console, so a simple line like that might be helpful.

Any corrections or additions are welcome - I'm a novice at building things
like this so am not sure what a more advanced user might want to see.

Brian

---------------------

               Building and Installing Emacs on 64-bit MS-Windows
                           using MSYS2 and MinGW-w64

               Copyright (c) 2015 Free Software Foundation, Inc.
                See the end of the file for license conditions.

This document describes how to compile a 64-bit GNU Emacs using MSYS2 and
MinGW-w64.  For more detailed information on the build process, and
instructions
for building a 32-bit Emacs using MSYS and MinGW, see the INSTALL document
in
this directory.

Do not use this recipe with Cygwin.  For building on Cygwin, use the normal
installation instructions in ../INSTALL.

* Requirements

  The total time to download all tools and build Emacs is approximately 90
  minutes on an Intel i3 processor, and 3GB of free space is required
(1.8GB for
  MSYS2 / MinGW-w64 and 1.2GB for Emacs with the full repository).

  Approximate times for the first pass through each step are given - to time
  them yourself you can precede any BASH command with 'time'.

* Set up the MinGW-w64 / MSYS2 build environment                       [25
mins]

  MinGW-w64 provides a complete runtime for projects built with gcc for
64-bit
  Windows - it's located at https://sourceforge.net/projects/mingw-w64/.

  MSYS2 is a Cygwin-derived software distribution for Windows which provides
  build tools for MinGW-w64 - see https://sourceforge.net/projects/msys2/.

** Download and install MinGW-w64 and MSYS2                             [5
mins]

  You can download the x86_64 version of MSYS2 (i.e.
msys2-x86_64-<date>.exe)
  from

      https://sourceforge.net/projects/msys2/files/Base/x86_64

  Run this file to install MSYS2 in your preferred directory, e.g. the
default
  C:\msys64 - this will install MinGW-w64 also.  Note that a path containing
  spaces may cause problems.

  Then you'll need to add the following directories to your Windows PATH
  environment variable -

      c:\msys64\usr\bin;c:\msys64\mingw64\bin

  you can do this through the usual Control Panel / System and Security /
  System / Advanced system settings / Environment Variables / Edit path.

  Note: If you've already installed a 32-bit MinGW and have it on your path
  you might need to either remove it from the path, or after building the
  Emacs executable, copy the MinGW-w64 DLLs in /mingw64/bin/ to the new
  Emacs bin folder - they're about 32MB.

** Download and install the necessary packages                         [20
mins]

  Run msys2_shell.bat in your MSYS2 directory and you will see a BASH window
  opened.

  In the BASH prompt, use the following command to install the necessary
  packages (you can copy and paste it into the shell with Shift + Insert):

      pacman -S base-devel \
      mingw-w64-x86_64-toolchain \
      mingw-w64-x86_64-xpm-nox \
      mingw-w64-x86_64-libtiff \
      mingw-w64-x86_64-giflib \
      mingw-w64-x86_64-libpng \
      mingw-w64-x86_64-libjpeg-turbo \
      mingw-w64-x86_64-librsvg \
      mingw-w64-x86_64-libxml2 \
      mingw-w64-x86_64-gnutls

  The packages include the base developer tools (autoconf, automake, grep,
make,
  etc.), the compiler toolchain (gcc, gdb, etc.), several image libraries,
an
  xml library, and the GnuTLS (transport layer security) library.

  You now have a complete build environment for Emacs.

* Install git (optional) and disable autocrlf                           [2
mins]

  If you don't already have git on your system, you can install it in your
MSYS2
  environment with:

      pacman -S git

  The autocrlf feature of Git may interfere with the configure file, so it
is
  best to disable this feature by running the command:

      git config core.autocrlf false

* Get the Emacs source code                                            [15
mins]

  Now you can either get an existing release version of the Emacs source
code
  from the GNU ftp site, or get the more current version and history from
the
  git repository.

  You can always find the most recent information on these sources from the
GNU
  Savannah Emacs site, https://savannah.gnu.org/projects/emacs.

** From the FTP site                                                     [1
min]

  The Emacs ftp site is located at http://ftp.gnu.org/gnu/emacs/ - download
the
  version you want to build and put the file into a location like C:\emacs\,
  then uncompress it with tar and cd into the folder. This will put the
Emacs
  source into a folder like C:\emacs\emacs-24.5:

      cd /c/emacs
      tar xf emacs-24.5.tar.xz
      cd emacs-24.5

** From the git repository                                             [15
mins]

  To download the git repository, do something like the following - this
will
  put the Emacs source into C:\emacs\emacs-25:

      mkdir /c/emacs
      cd /c/emacs
      git clone git://git.sv.gnu.org/emacs.git emacs-25
      cd emacs-25

* Build Emacs                                                          [45
mins]

  Now you're ready to build and install Emacs with autogen, configure,
make,
  and make install.

** Run autogen                                                           [1
min]

  Run autogen to generate the configure script (note: this step is not
necessary
  if you are using a release source tarball, as the configure file is
included):

      ./autogen.sh

** Run configure                                                        [4
mins]

  Now you can run configure, which will build the various Makefiles.  The
  following is a simple example for some configure options - see the INSTALL
  file in this directory for more information on the options available.

  Note that the --prefix option specifies a location for the resulting
binary
  files, which 'make install' will use - if a prefix is not specified the
files
  will be put in the standard MinGW-w64 directories.

  Note also that we need to disable Imagemagick because Emacs does not yet
  support it in Windows.

      PKG_CONFIG_PATH=/mingw64/lib/pkgconfig \
      ./configure \
      --prefix=/c/emacs/emacs-25 \
      --host=x86_64-w64-mingw32 \
      --target=x86_64-w64-mingw32 \
      --build=x86_64-w64-mingw32 \
      --without-imagemagick

** Run make                                                            [30
mins]

  This will compile Emacs and build the executables, putting them in the src
  directory:

      make

** Run make install                                                     [6
mins]

  Now you can run make install, which will copy the executable and other
files
  to the location specified in the configure step:

      make install

* Test Emacs

  To test it out, run

      ./bin/runemacs.exe -Q

  and if all went well, you will have a new 64-bit version of Emacs.

* Credits

  Thanks to Chris Zheng <[email-masked]> for the original build
outline
  as used by the emacsbinw64 project, located at:

https://sourceforge.net/p/emacsbinw64/wiki/Build%20guideline%20for%20MSYS2-MinGW-w64%20system/

* License

  This file is part of GNU Emacs.

  GNU Emacs 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.

  GNU Emacs 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 GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.

* Emacs settings

Local Variables:
mode: org
sentence-end-double-space: t
End:

On Sat, Dec 26, 2015 at 2:30 AM, Eli Zaretskii <[email-masked]> wrote: