How to build the TeXmacs SDK


1 Overview 
Building TeXmacs on your own machine can be quiet challenging, depending on what libraries are offered by the OS. The tmSDK aims to ease this process.
You can build the tmSDK on Windows (7 and upper), Linux, MacOS (6 and upper).
The SDK builds the static version of libraries, in oder to make TeXmacs statically linked with them. That avoids libraries version conflicts in some OSes.
As they are located in a specific location, the newly built libraries wont conflict with the original ones. They are only accessible in the tmSDK environment or during TeXmacs build.
2 Prerequisites 
1 Common 
wget, tar, make, autoconf, pkg-config, gcc, g++, patch, aclocal, libtool
gcc versions >=4 are preferred. llvm or clang are also suitable.
No need to be root to construct the SDK
2 Linux 
(g)libc-devel is required.
Qt requires libX11-devel and libXext-devel
3 MacOs 
If you intend to build a package, install the right Apple SDK in /Developer/SDKs/ directory.
4 Windows 
An unix like environment is needed to build TeXmacs. We advise to install the msys2 environment (https://www.msys2.org/) which can be install in a freely  choose directory. To build TeXmacs and the SDK use the mingw32 environment. you can run it with the mingw32 command located in the install directory.
Update the installation by running pacman -Syu
3 Getting the SDK 
•  Fetch from our ftp site ftp://ftp.texmacs.org
•  TeXmacs/dev/SDK/tmSDK.tar
•  TeXmacs/dev/SDK/tmTAR.tar 
•  Unpack the tmSDK.tar tar ball in a empty directory you choiced (i.e DEV, avoid spaces in the name) or in / for Windows.
•   Unpack the tmTAR.tar tar ball in the same directory. Once it is done you must have two subdirectories : SDKsrc and TAR
•  Go into the SDKsrc source directory and run ./setenv.sh -c to check the environment.
•  run ./setenv.sh -c to check your installation correctness and do the final adjustments for some OSes. 
4 Build the SDK 
4.1 Libraries location 
The SDK tree is located in a subdirectory “SDK” ( or “SDKg” for the debug version) where  libraries, includes, binaries lay in their usual locations.
If you intend to build texmacs with some dynamics libraries offered by you operating system, simply do not build the SDK matching package. So use the manual build mode.
4.2 Automatic build 
On MacOS, if you attend to build a dmg package, it is better to specify what OS level you target with the -l option of the setenv.sh command.
•  Run ./setsdk.sh -a [-l X] for example -l 6 for MacOS 10.6
•  Check carefully the SDK status at the end or with the command ./setenv.sh -s [-l X] 
4.3 Manual build 
•  Go in the SDK environment with /setsdk.sh -m [-l OsXversion] for example -l 6 for MacOS 10.6 . that forks a shell in the SDK environment.
•  extract the libraries packages with ./mksrc.sh. The command ignores already extracted sources.
•  Use ./mkbasic.sh to build the basics libraries. Give the libraries list in parameters to install a subset. The list can be obtained by ./mkbasic.sh -l
•  Use ./mkguile.sh to build Guile 1.8
•  Use ./mkgs.sh to use ghostcript. If you build it, this version will be embedded in TeXmacs packages.
•  Use ./mkqt.sh to build the QT 4.8 librairies. Just the necessary libraries are built, that speed up the building process
•  At the end, exit from the SDK environment by “exit” in order not to propagate the SDK environment flags to TeXmacs building. 
4.4 Troubleshooting 
Although we carefully test the tmSDK building process on different platforms, it may happen the build fails for several packages. In this case you must act as you do usually, looking in the config.log file of the package. After having corrected the problem, (for example add a missing prerequisite), you can use the manual mode or delete the package directory en use the auto mode. Only the missing or failing packages are rebuilt
4.5 Debug version 
Simply add the -d option to the setsdk.sh command line. The debug version of the SDK goes in a new subdirectory without overwritten the regular version  