Skip to content

jado4810/emacs-dmg-build

Repository files navigation

emacs-dmg-build: DMG Package Builder of Gnu Emacs

Emacs 30 Ready Emacs 29 Ready macOS26 Ready Intel Universal Binary arm Universal Binary

EN|JA

Overview

A build script to make a dmg package of Gnu Emacs for macOS. It will generate the universal binaries with Apple Silicon running macOS26 Tahoe or prior.

It works without any dependefncies on external libraries; supporting treesit available since Emacs29 with several language grammar rules, having GnuTLS runtimes for SSL/TLS connections, and handling images by standard ns GUI functions.

Applies some patches from Emacs Plus. Also, inline patch would be available useful for CJK environment.

And more, modern high resolution icons set delivered from Emacs MacPort is available.

How to build

1. Get sources

Fetch below and store under sources. It will recognize both .tar.gz and .tar.xz formats automatically.

a. Source of Gnu Emacs

Available on Gnu mirror (https://ftpmirror.gnu.org/emacs/).

b. Source of nettle

Implementation of cryptographic algorithm, required for GnuTLS.

Available on Gnu mirror (https://ftpmirror.gnu.org/nettle/).

c. Source of GnuTLS

Implementation of SSL/TLS. Emacs requires GnuTLS, not OpenSSL coming with macOS.

Available on official site (https://www.gnutls.org/download.html).

Note

We checked the versions specified in the build script, but newer ones should work, especially for required libraries. In that case, set versions in the script to match retrieved ones.

d. Source of tree-sitter

Implementation of parsing algorithm used by treesit.

Available on releases page (https://github.com/tree-sitter/tree-sitter/releases) under GitHub project site.

Note

We get sources of required grammar rules automatically with git.

2. Setup build environment

Edit the build script (emacs-dmg-build.sh) to modify the following variables near the top.

a. Versions of each sources

Set EMACSVER, NETTLEVER, GNUTLSVER and TREESITVER values to match those of retrieved ones.

b. Path where site-lisp will be stored

Set SITELISP value to site-lisp path, where the lisps available system-wide will be stored.

The default value is /Library/Application Support/Emacs/site-lisp, and recommended such path outside the package.

c. Whether to activate the inline patch

To apply inline patch which Ishikawa Takaaki coordinates at https://github.com/takaxp/ns-inline-patch , set USEINLINE to yes.

Although, in recent versions of Emacsen, the inline (on the spot) input via OS-native input method is available, activate it if necessary because of some useful extentions, such as changing input modes with toggle-input-method, or hooks when changing input modes.

d. Whether to apply high resolution icons

To use high resolution icons by Emacs MacPort, set USEHRICON to yes.

If enabled, the images from those icons will be used for application icons and toolbar.

e. Whether to customize application icons

To customize application icons as you like, set USEAPPICON to yes.

It would be useful when using icons which the EmacsPlus project coordinates to be available in their build options. If enabled, Emacs.icns and document.icns are preferred to those of Emacs MacPort.

f. Whether to customize splash images

To customize splash images as you like, set USESPLASH to yes.

If enabled, splash.png, splash.xpm and splash.pbm are overridden, and the default SVG splash image is disabled.

It seems that only PNG images are actually used in the macOS environment, but XPM or PBM images might be used in the environment with low color depth.

g. Language rules to be included

Set TSGRAMMARS to language and source information to be included.

By default, we specify those that has been confirmed to work with Emacs30, so select them as appropriate.

The format of each line is like below; to build at the subdirectory, specify the third element.

'language;url-of-git-repository-to-get-source[;subdirectory]'

h. Target architectures

Set ARCHES as an array of target architectures names. Defined ARCHES=(arm64) by default, to build the uni-arch binaries for Apple Silicon. Set ARCHES=(x86_64) in Intel environments.

On Apple Silicon running macOS26 Tahoe or prior, set ARCHES=(arm64 x86_64) to build the universal binaries. Or ARCHES=(x86_64) to cross-build the Intel binaries.

i. Number of cores to use on build

Set CORES to the number of parallel processes on build. It will be an argument of -j option for make.

The default value is 4, and it works fine in the recent mac environments.

Note

In the environment with more than 4 performance cores, it will reduce a little on build time to set it to the number of those cores. However, since over half of build time is spent in executing configure, it seems to be within the variability.

3. Store custom images

When setting USEAPPICON or USESPLASH to yes, store corresponding images under custom-images. It is not necessary to store all of image files since only the found files would be replaced.

  • In the case of USEAPPICON=yes - Emacs.icns and document.icns
  • In the case of USESPLASH=yes - splash.png, splash.xpm and splash.pbm

4. Prepare the required tools

Install the tools required to build if not installed yet. These would be used only when building and have no dependencies from the dmg package contents to be built.

a. Compiler sets (make, clang/gcc and ld)

Install the Xcode command line tools.

$ xcode-select --install

b. Texinfo

Install it via homebrew and so on.

$ brew install texinfo

c. Automake

Requires only if set USEINLINE=yes. Install it via homebrew and so on.

$ brew install automake

d. pkgconf

Requires for GnuTLS 3.8.9 or later. Install it via homebrew and so on.

$ brew install pkgconf

5. Execute the build script

Execute the build script to create the dmg package under build.

First, it gets required sources of grammar rules for treesit. It tries to update to the current version with "git pull" if already got; -n available to disable updating.

It takes about 3 minutes in the environment of Apple M5, excluding getting or updating of sources of grammar rules. For universal binaries, it takes about 6 minutes.

$ sh emacs-dmg-build.sh [-n]

The source packages are expanded under build. You can delete them if not necessary.

LICENSE

The script and the patches under patches/custom are provided under CC0.

External patches under patches/plus, patches/inline, and icon resources under icons are provided under other licenses: refer to the LICENSE or README files under each directories for detail.

Distributors of included resources

About

DMG Package Builder of Gnu Emacs

Topics

Resources

License

Stars

Watchers

Forks

Contributors