Scripts to build a distribution of Emacs from sources, using MSYS2 and Mingw64(32)
I wanted a script to build Emacs from sources, package it and install it on different computers, with the following conditions
The script supports two way of being invoked:
emacs-build.cmd
assumes nothing about your system, except for an existing installation of PowerShell. It will download and install a minimal MSYS/MINGW64 environment and build Emacs and all other requested components. This allows for a more deterministic build, without perturbing your computer.emacs-build.sh
is meant to be ran from an existing MSYS/MINGW64 environment, which will be modified to allow building Emacs and all tools. Use this version at your own risk..\emacs-build.cmd --clone --deps --build --pack-emacs
zips
folder for the products of the scriptUsage:
emacs-build [--version] [--help] [--features]
[--branch b] [--clone] [--build] [--deps]
[--slim] [--[no-]compress] [--[no-]strip]
[--with-all] [--without-X] [--with-X]
[--pdf-tools] [--aspell] [--hunspell] [--mu] [--isync]
[--pack-emacs] [--pack-all]
Actions:
--build Configure and build Emacs from sources.
--clean Remove all directories except sources and zip files.
--clone Download Savannah's git repository for Emacs.
--deps Create a ZIP file with all the Mingw64/32 dependencies.
--help Output this help message, --features and exit.
--pack-emacs Package an Emacs previously built with the --build option.
--pack-all Package an Emacs previously built, with all the Mingw64/32
dependencies, as well as all extensions (see Extensions below).
--features Shows all active and inactive features for the selected options.
--version Output emacs-build version number and exit.
Multiple actions can be selected. The default is to run them all in a logical
order: clone, build, deps and pack-all.
Build options:
--branch b Select Emacs branch (or tag) 'b' for the remaining operations.
--compress Ship Emacs with gunzip and compress documentation and Emacs
script files.
--debug Output all statements run by the script.
--debug-dependencies
Describe which MSYS/MINGW packages depend on which, and
which files are discarded from the ZIP files.
--no-strip Disable the --strip option.
--no-compress Disable the --compress option.
--slim Remove Cairo, SVG and TIFF support for a slimmer build.
Remove also documentation files and other support files
from the dependencies file. Activate --compress and
--strip. (Default configuration)
--strip Strip executables and DLL's from debug information.
--with-all Add all Emacs features.
--with-* Add requested feature in the dependencies and build
* is any of the known features for emacs in Windows/Mingw
(see --features).
--without-* Remove requested feature in the dependencies and build.
Options are processed in order. Thus --slim followed by --with-cairo
would enable Cairo, even though --slim removes it.
Extensions:
--pdf-tools Build and package PDF-TOOLS.
--hunspell Install Hunspell spell checker.
--aspell Install Aspell spell checker.
--mu Mail search system and supporting Emacs mu4e libraries.
--isync Synchronize email from IMAP/POP to Maildir format (mbsync).
Assume you invoke this script as follows
.\emacs-build.cmd --slim --clone --deps --build --pdf-tools --hunspell --mu --isync --pack-all
It will take care of the following tasks
The script, just like its creator, is a bit opinionated. The default build (without arguments), assumes --slim and performs takes some extra steps to reduce the size of the distribution
There are implicit dependencies in the various actions:
--clone
is required to get the sources--build
is assumed to be run before --pack-all
or --pack-emacs
, and also before the extensions.Note that --clean
or --clean-all
do not remove the msys64
directory, because it is very time consuming to create and update it.
The tool produces zip files that are stored in ./zips
and can be uncompressed wherever you want:
emacs-xx-xxxx-deps.zips
is the file with optional libraries (png, jpeg, etc) used by Emacs.emacs-xx-xxxx-nodeps.zip
is a bare Emacs installation. It runs even if the 'deps' file is not usedemacs-xx-xxxx-full.zip
is a complete Emacs installation, with the optional libraries and all extensions (pdf-tools, mu, etc) you mentioned in the command line.pdf-tools-xxxx.zip
and others are the Zip files for the extensions. They can be unpacked inside an Emacs installation, but may assume that 'deps' have also been unpacked.Regarding the extensions to Emacs and third-party utilities:
c:\emacs
is where you unpacked the full installation, some extensions will reside in c:\emacs\bin
(e.g. pdftools) and some others in c:\emacs\usr\bin
(e.g. mu and mbsync).site-start.el
that activates the directories for MSYS2 extensions.