## Building a library for Windows

For building you need x64 Windows 7 or newer.

### Dependencies

* Microsoft Visual C 2013 or newer
* git, cmake, cygwin (installed in "C:/cygwin") with flex and bison preinstalled, MSYS2
* MATLAB (optional), Code::Blocks (optional), Java (optional), Python (optional).

#### General

Used for building dependencies and the library itself.

* Download and install GIT from https://git-scm.com in C:\Program Files\Git (should be the default).
* Download and install CMake https://cmake.org in C:\Program Files (x86)\CMake. 
* Download and install Microsoft Visual Studio 2013.
* Install custom cygwin with preinstalled packages: flex, bison, etc. Unpack the archive in C:\cygwin and add C:\cygwin\bin to the PATH.

#### Wrappers' dependencies

Used for building wrappers such as java wrapper or matlab wrapper.

* Install .NET Framework SP1 (for C# wrapper)
* Install JDK 7-9 64 bits if not installed (for Java).
  > A proven Java distribution can be downloaded 
    https://sourceforge.net/projects/javaclientmsiinstallers/files/Java%20JDK%209%20Update%20464/jdk9.0.464.zip/download
    or https://www.oracle.com/java/technologies/javase/javase9-archive-downloads.html. Authorization is required to download from the second link.
    Prescribe the variable JDK_PATH
    Example: JDK is installed in C:\Program Files\Java\jdk-9.0.4 
    => Start -> PC Software Computer -> Properties -> Additional system parameters -> Environment Variables -> System variables,
    there we create a variable JDK_HOME and JDK32_HOME with the value C:\Program Files\Java\jdk-9.0.4
* Install MATLAB R2014b x64 (for MATLAB wrapper)

#### Examples' dependencies

* Download and install MSYS2 into C:\MSYS2 (for C examples, CodeBlocks).
  > In MSYS2 shell install two packages: mingw-w64-i686-toolchain and mingw-w64-x86_64-toolchain:
  > ```shell
  > pacman -S mingw-w64-i686-toolchain
  > pacman -S mingw-w64-x86_64-toolchain
  > ```
* Download and install CodeBlocks in C:\Program Files (x86)\CodeBlocks
* Make sure JDK is installed (for Java examples, see Wrappers' dependencies)
* Make sure .NET Framework is installed (for C# and VB.NET examples, see Wrappers' dependencies)

To build, use the build system via build.bat. A help menu is available via: build.bat --help.

Build system usage example (building the library):
```cmd
    # Build the dependencies
    build.bat deps
    
    # Build the source code using templates and the protocol file
    build.bat gen-libximc-sources

    # Build the library
    build.bat libximc
```

## Building a library for Ubuntu (Debian based)

For building you need Debian-based Linux

#### General

The following instruction has been tested on Ubuntu 18.04.

I. Install dependencies
```shell
    # 1. Install dependencies
    sudo apt install lsb-release

    # 2. Install build essentials:
    sudo apt install build-essential

    # 3. Install git:
    sudo apt install git

    # 4. Install make and cmake:
    sudo apt install make
    sudo apt install cmake

    # 5. Install autotools:
    sudo apt install autoconf autotools-dev libtool libglib2.0-dev

    # 6. Install flex and bison:
    sudo apt install flex bison

    # 7. Install doxygen and latex:
    sudo apt install doxygen
    sudo apt install texlive texlive-latex-extra texlive-fonts-extra texlive-lang-cyrillic

    # 8. Install Java:
    #    8.1. Install Java 8:
    sudo apt install openjdk-8-jdk
	
    #8.2. Or in case Java 8 is unavailable, install Java 7:
    # "sudo apt install openjdk-7-jdk"

    #    Note: You should use Java 7 or 8. So in case your system use another version, after installation
    #    of Java 7(8) one extra action may be needed -- set default Java version to 7 (or 8) using
    #    "update-alternatives --config java".
```

II. Build

```shell
    # Build dependencies
    ./build.sh deps
    
    # Generate libximc sources
    ./build.sh gen-libximc-sources

    # Build the library
    ./build.sh libximc

    # Build wrappers
    ./build.sh wrappers

    # Build examples
    ./build.sh examples

    # Build documentation
    ./build.sh docs

    # Build deb-packages
    ./build.sh debs
```

## Building a library for macOS

For building library you need macOS 10.15 or newer.

### Dependencies

* brew, XCode 4 or newer, autotools (autoconf, autoheader, aclocal, automake, autoreconf, libtool), pkg-config
* Java (опционально), doxygen (опционально)

### Build

To build use the following commands:

```shell
    # Build dependencies
    ./build.sh deps
    
    # Generate libximc sources
    ./build.sh gen-libximc-sources

    # Build the library
    ./build.sh libximc

    # Build wrappers
    ./build.sh wrappers

    # Build examples
    ./build.sh examples

    # Build documentation
    ./build.sh docs

    # Build deb-packages
    ./build.sh debs
```
