Compilation of TeXmacs



1. Download the source code

Download the latest version of the source code.

2. Unpack the package

cd into the directory where you wish to compile TeXmacs and type

    tar -zxvf TeXmacs-[source version].tar.gz
  
All files will be unpacked into the directory TeXmacs-[version], which is the 'installation directory'; its subdirectory TeXmacs-[version] is the main 'TeXmacs directory'.

3. Prepare compilation

cd into the installation directory and set the environment variables by

    source SETUP
  
Actually, it is a good idea to include these definitions in your .bash_profile or another personal boot script.

4. Build TeXmacs

Build 'TeXmacs' using

    make
  
First, this will build the generic preprocessors 'gencc' and 'gendep'. Next the main source will be built.

By default, we build TeXmacs using dynamically linked libraries. If you rather want to build the static version, use

    make STATIC_TEXMACS
  
If you have already built a dynamic version of TeXmacs and if you want to replace it by a static version, you should first clean up some makefiles, libraries and binaries, and type
    make OTHER
    make STATIC_TEXMACS
  

5. Problems



Optimized compilation

Using recent versions of the egcs compiler, it is possible to considerably speed up TeXmacs by optimizing the compilation. I personally use the following options:

    export CXXFLAGS="-O3 -fexpensive-optimizations -malign-loops=2 -malign-jumps=2 -malign-functions=2"
  
In order to build TeXmacs using these optimization flags, just type
    make -e
  
Notice that you might want to separate the compilation of the gencc preprocessor and the actual editor. In order to build the preprocessor only, type
    make GENCC
  
In a similar fashion, you may compile the editor with debugging information. In this case, you have to use the following flags:
    export CXXFLAGS=-g
  
Other environment variables recognized during the compilation of TeXmacs are

Problems when compiling with egcs

Unfortunately, several bugs seem to persist in the egcs compiler. In order to compile TeXmacs using egcs 2.95.2, optimization and redhat linux, I had to change correct source at three places in order to avoid segmentation faults. On a SuSE linux system, I even had to change one line in order to get the non optimized program working, and I still don't manage to correctly compile the program using optimization.

A typical example of the kind of changes needed to get things working is avoiding nested expressions :

    SI
    TER::get_length (string name) {
      string s= get (name)->label;
      return decode_length (s);
    }
  
instead of
    SI
    TER::get_length (string name) {
      return decode_length (get (name)->label);
    }