---
layout: page
title: How To
permalink: /how-to/
---

* toc
{:toc}

# How to Get the Sources
This step should be simple:

{% highlight bash %}
git clone https://github.com/Samsung/jerryscript.git
cd jerryscript
{% endhighlight %}

# How to Setup Recommended Prerequisites

Currently, we are using Ubuntu Linux 14.04+ as our development environment, so this tutorial was written based on this assumption. Additionaly, it'll be useful to read [Prerequisites]({{ site.baseurl }}/wiki/Prerequisites) wiki page, also.

There are dependencies, that should be installed manually. The following list is required for building:

- `gcc` or `g++` higher than `4.8.2`
  - native
  - arm-none-eabi
- `cmake` higher than `2.8.12.2`
- `make` higher than `3.81`
- `bash` higher than `4.3.11`

These tools are required for development:

- `cppcheck` requires `libpcre`
- `vera++` requires `tcl`, `tk` and `boost`

{% highlight bash %}
sudo apt-get install gcc g++
sudo apt-get install gcc-arm-none-eabi
sudo apt-get install cmake
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install tcl8.6 tcl8.6-dev tk8.6-dev libboost-all-dev
{% endhighlight %}

To make our scripts run correctly, several shell utilities should be available on the system:

- `find`
- `bc`
- `awk`
- `sed`
- `sha256sum`
- `wget`

# How to Build

After setting up prerequisites, let's built the engine:

{% highlight bash %}
make
{% endhighlight %}

Upon first build, `make` would try to setup prerequisites, required for further development and pre-commit testing:
- stm32f3 and stm32f4 libraries
- nuttx's headers
- cppcheck 1.66
- vera++ 1.2.1

It may take time, so go grab some coffee:

{% highlight bash %}
Setting up prerequisites... (log file: ./build/prerequisites/prerequisites.log)
{% endhighlight %}

# How to Build Debug Version
To build debug version for Linux:

{% highlight bash %}
make debug.linux
{% endhighlight %}

To build debug version for Linux without LTO (Link Time Optimization):

{% highlight bash %}
LTO=off make debug.linux
{% endhighlight %}

# How to Run Unittests
{% highlight bash %}
make unittests
{% endhighlight %}

# How to Check the Patch
{% highlight bash %}
make precommit -j
{% endhighlight %}

Sometimes pre-commit testing fails, in that case you'll see message like that:

{% highlight bash %}
Build failed. See ./build/bin/unittests/make.log for details.
{% endhighlight %}
