
-------------------------------------------------------------------------------
Compiling GNU TeXmacs
-------------------------------------------------------------------------------

1. Check dependencies.
   Before you compile GNU TeXmacs on your system, you have to make
   sure that the other programs on which GNU TeXmacs depends,
   namely TeX and Guile Scheme (from the Gnome project)
   have been installed correctly. You can do this by checking
   whether the latex and guile binaries exists in your path

	which latex
	which guile

   If one of these commands yields an error message,
   then look at the webpage doc/html/web/Dependencies.html.

2. Compile, install and run.
   GNU TeXmacs supports the standard GNU compilation and
   installation procedure. Assuming that you logged yourself
   in as root, cd into the installation directory and type

	./configure
	make
	make install

   The first command examines your particular system configuration.
   The second command launches the compilation.
   Actually, it will first build the generic preprocessors
   'gencc' and 'gendep'. Next the main source will be built.
   The last command installs GNU TeXmacs in /usr/local.

   If everything works fine, then you should be able to run the program by

	texmacs &

   If this does not work, you should make sure that /usr/local/bin
   is in your PATH. Depending on your shell, you can ensure this by typing

	export PATH=/usr/local/bin:$PATH
   or
	setenv PATH /usr/local/bin:$PATH

3. Configuration options.
   If you cannot log yourself in as root, or if you want to install
   TeXmacs elsewhere than in /usr/local, then you should use

	./configure --prefix=[target directory]

   instead of ./configure. In this case, TeXmacs will be installed in
   [target directory] and you will have to set your PATH accordingly,
   as to contain [target directory]/bin. Other options supported
   by configure are

   * --bindir=[binary directory]:
     sets the directory where the TeXmacs binaries should be installed
     ([target directory]/bin, by default).

   * --datadir=[data directory]:
     sets the directory where other TeXmacs data should be installed
     ([target directory]/share, by default).

4. 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,
   then you should first clean up some makefiles,
   libraries and binaries, and type

	make OTHER
	make STATIC_TEXMACS

   Yet another alternative (except for sun and dec)
   is to build TeXmacs using

	make MIXED_TEXMACS

   In this case, all extern libraries will be linked dynamically,
   but all proper TeXmacs libraries will be linked statically.
   This alternative may be useful when including TeXmacs
   in a distribution with other programs.

5. Problems:

   * Your system is not yet supported.
     Solution: add it by modifying the file 'gencc/src/gg_system.cc'

   * You have problems with compiling or linking with X Window.
     Solution: modify some include paths in the file 'gencc/src/gg_system.cc'

   * You have the impression that some of the modifications that you
     made in the source are not taken into account by 'gencc' and 'gendep'.
     Solution: type 'make OTHER' in order to be sure that all makefiles
     are built again  and/or  'rm src/Objects/*' in order to be sure that
     the object files are rebuilt.

   * You get a segmentation fault when running.
     Solution: check that the macros 'WORD_LENGTH', 'WORD_LENGTH_INC'
     and 'WORD_MASK' in 'src/fast_alloc.gen.h' are OK for your system.

   * You have problems with the font system from TeX when running.
     Solution: get a version of TeX with 'kpsepath',
     'MakeTeXPK' and 'MakeTeXTFM'.

   * For other problems, contact me...

-------------------------------------------------------------------------------
Optimization and debugging
-------------------------------------------------------------------------------

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 on a PC/Linux system:

	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

	CXX: the compiler
	CXXFLAGS: extra compilation flags
	CXXXWINDOW: extra flags for compilation of X Window programs
	CXXGUILE: flags for finding guile header files
	LD: the linker (for libraries)
	LDFLAGS: linker flags
	LDSTATIC: flags for static linking
	LDSHARED: flags for shared linking
	LDPATH: extra linking paths
	LDXWINDOW: options for linking with X
	LDDL: options for dynamic linking
	LDGUILE: options for linking with guile
	LDB: the linker (for binaries)
	LDBFLAGS:
	LDBSTATIC:
	LDBSHARED:
	LDBPATH:
	LDBXWINDOW:
	LDBDL:
	LDBGUILE: similar options for linking binaries instead of libraries
	AR: archive program
	ARFLAGS: flags for archive program
	RM: remove without messages
	GENCC: the gencc preprocessor

-------------------------------------------------------------------------------
Important note for compilation 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.

A typical examples 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);
	}

More recently, I have been tring to compile using gcc/g++ 3.0.
Even in non optimized mode, this compiler contains severe new bugs,
which make it impossible to build a working version of TeXmacs.
We therefore recommend you to use older versions of
the gcc/g++ compiler. One particular bug
I completely tracked down is in the function

	void
	edit_interface_rep::set_main_menu (scheme_tree p) {
	  main_menu= p;
	  notify_change (THE_DECORATIONS);
	}

in <Edit/Interface/edit_interface.gen.cc.
In the code generated by the compiler,
the destructor for p is called twice on exit...
