[main]Notes on TeXmacs

Build TeXmacs using CMake and Homebrew

This article serves as a guide for TeXmacs contributors and developers on macOS. We talk about how to build and test GNU TeXmacs on macOS using CMake and Homebrew.

Here is a detailed guide to build GNU TeXmacs using CMake and Homebrew.

Install build tools and necessary dependencies

Install Homebrew and build essentials

Homebrew is a package manger for macOS. Typically, we install Homebrew first, and then use the brew command line to install build tools and dependencies to build TeXmacs.

Xcode Command Line Tools provide the C/C++ compiler. It is required. TeXmacs can not be built without a C/C++ compiler. And TeXmacs is designed to be customizable using Scheme. If you want to be a power user of TeXmacs but not want to compile TeXmacs, please browse the built-in documents under HelpScheme extensions.

The rest part of this guide is maintained in a Shell session (InsertSessionShell). Yes, if you are browsing this guide using TeXmacs, the commands can be executed.

Global Variables

Shell]

GROUP_DIR=$HOME/texmacs

Shell]

T_HOMEBREW_DIR=$GROUP_DIR/homebrew

Shell]

T_TEXMACS_DIR=$GROUP_DIR/texmacs

Shell]

These global variables should be executed manually every time you use this note.

Check Homebrew installation

Shell]

brew –version

Homebrew 2.5.10-18-ge945b1c

Homebrew/homebrew-core (git revision b86ad9; last commit 2020-08-01)

Homebrew/homebrew-cask (git revision c4d66; last commit 2020-11-14)

Shell]

Check Xcode Command Line Tools installation

Shell]

$(xcode-select –print-path)/usr/bin/cc –version

Apple clang version 11.0.0 (clang-1100.0.33.8)

Target: x86_64-apple-darwin19.2.0

Thread model: posix

InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Shell]

Install CMake and check

Shell]

cmake –version || brew install cmake

cmake version 3.18.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Shell]

Install GNU Guile 1.8

Clone texmacs/homebrew

Shell]

[[ -d "$T_HOMEBREW_DIR" ]] && echo "texmacs/homebrew is cloned" || echo "Please clone texmacs/homebrew first"

texmacs/homebrew is cloned

Shell]

[[ ! -d $T_HOMEBREW_DIR ]] && git clone git@github.com:texmacs/homebrew.git $T_HOMEBREW_DIR

Shell]

[[ ! -d $T_HOMEBREW_DIR ]] && git clone https://github.com/texmacs/guile.git $T_HOMEBREW_DIR

Shell]

[[ -d $T_HOMEBREW_DIR ]] && echo "texmacs/homebrew is cloned"

texmacs/homebrew is cloned

Shell]

Install guile 1.8 using brew

Shell]

cd $T_HOMEBREW_DIR && brew install guile@1.8.rb

Install Qt

Install Qt 4

For GNU TeXmacs 1.99.15, please use Qt 4 if you want to build and package TeXmacs by yourself. Qt 4 has been removed in the official homebrew repo. We need extra steps to install Qt 4 via brew:

Shell]

brew tap cartr/qt4

Shell]

brew tap-pin cartr/qt4

Shell]

brew install qt@4 # will link qt

brew install qt@4 # will link qt

Updating Homebrew…

[33mWarning:[0m cartr/qt4/qt@4 4.8.7_6 is already installed and up-to-date

To reinstall 4.8.7_6, run ‘brew reinstall qt@4‘

Shell]

/usr/local/Cellar/qt@4/4.8.7_6/bin/qmake –version

/usr/local/Cellar/qt@4/4.8.7_6/bin/qmake –version

QMake version 2.01a

Using Qt version 4.8.7 in /usr/local/lib

Shell]

Switch between Qt 4 and Qt 5

Sometimes, we need to keep both Qt 4 and Qt 5 installed by homebrew. To switch between Qt 4 and Qt 5:

Shell]

qmake –version

qmake –version

QMake version 2.01a

Using Qt version 4.8.7 in /usr/local/lib

Shell]

brew unlink qt@4 && brew link qt –force

brew unlink qt@4 && brew link qt –force

Unlinking /usr/local/Cellar/qt@4/4.8.7_6… 666 symlinks removed

Linking /usr/local/Cellar/qt/5.15.0… 510 symlinks created

If you need to have this software first in your PATH instead consider running:

echo 'export PATH="/usr/local/opt/qt/bin:$PATH"' >> ~/.zshrc

Shell]

qmake –version

brew link qt –force

Linking /usr/local/Cellar/qt/5.15.0… 510 symlinks created

If you need to have this software first in your PATH instead consider running:

echo 'export PATH="/usr/local/opt/qt/bin:$PATH"' >> ~/.zshrc

Shell]

brew unlink qt && brew link qt@4

brew unlink qt && brew link qt@4

Unlinking /usr/local/Cellar/qt/5.15.0… 510 symlinks removed

Linking /usr/local/Cellar/qt@4/4.8.7_6… 666 symlinks created

Shell]

qmake –version

QMake version 2.01a

Using Qt version 4.8.7 in /usr/local/lib

Shell]

If you have trouble on brew link qt –force and brew unlink qt. Make sure that you have installed Qt before using homebrew:

Shell]

brew install qt

Install Ghostscript

Shell]

gs –version || brew install ghostscript

gs –version

9.52

Shell]

Missing dependencies

Please create PRs to update this note for any missing dependencies.

Build

Clone texmacs/texmacs and build it

Shell]

[[ ! -d $T_TEXMACS_DIR ]] && git clone git@github.com:texmacs/texmacs.git $T_TEXMACS_DIR

Shell]

mkdir -p $T_TEXMACS_DIR/build

Shell]

cd $T_TEXMACS_DIR/build && cmake -DQT_QMAKE_EXECUTABLE=/usr/local/Cellar/qt@4/4.8.7_6/bin/qmake -DCMAKE_INSTALL_PREFIX=./TeXmacs.app/Contents/Resources ..

Shell]

cd $T_TEXMACS_DIR/build && make -j8 install

Use ccache for faster build

Toggle the menu entry FocusOutput optionsShow timings as checked.

Shell]

sleep 2

2.015 sec

Shell]

Execute the sleep command, and you will find the timings are listed on the right side.

Compile TeXmacs without or with ccache, the elapse time should be reduced with ccache.

Shell]

cd $T_TEXMACS_DIR/build && make -j8

Shell]

ccache –version || brew install ccache

ccache version 3.7.11

Copyright (C) 2002-2007 Andrew Tridgell

Copyright (C) 2009-2020 Joel Rosdahl

This program 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.

40 msec

Shell]

cd $T_TEXMACS_DIR/build && make -j8

As long as ccache is available, CMake will use it to boost the compilation.

Testing

Running the C++ Unit Tests

Shell]

cd $T_TEXMACS_DIR/build && ctest

Shell]

Testing the binary

Shell]

$T_TEXMACS_DIR/build/TeXmacs.app/Contents/MacOS/TeXmacs –version

TeXmacs version 1.99.16

SVN version 1.99.16

(c) 1999-2020 by Joris van der Hoeven and others

Shell]

$T_TEXMACS_DIR/build/TeXmacs.app/Contents/MacOS/TeXmacs –help

Options for TeXmacs:

-b [file] Specify scheme buffers initialization file

-c [i] [o] Convert file 'i' into file 'o'

-d For debugging purposes

-fn [font] Set the default TeX font

-g [geom] Set geometry of window in pixels

-h Display this help message

-i [file] Specify scheme initialization file

-p Get the TeXmacs path

-q Shortcut for -x "(quit-TeXmacs)"

-r Reverse video mode

-s Suppress information messages

-S Rerun TeXmacs setup program before starting

-v Display current TeXmacs version

-V Show some informative messages

-x [cmd] Execute scheme command

-Oc TeX characters bitmap clipping off

+Oc TeX characters bitmap clipping on (default)

Please report bugs to <bugs@texmacs.org>

Shell]

Testing the App

Shell]

open $T_TEXMACS_DIR/build # click the app to test it as a user

Shell]