<chapter id="install">
<title>Download and installation</title>

<para>
You can download the easy-to-install packages for pev that we call pre-compiled binaries. This is the easiest way to start using pev, although you may want to compile it in your environment if you feel comfortable but that will require you to install dependencies, some libraries headers and some programs too.
</para>

<para>
If you choose to use the pre-compiled binaries (recommended for beginners), you just need to download its package from our download page. There are pre-compiled binaries for Windows and DEB and RPM packages for Linux. OS X users can use MacPorts to install pev, while Linux users can also opt out for using the native package manager.
</para>

<section id="binary">
<title>Using the pre-compiled binaries</title>

<section id="binlinux">
<title>On GNU/Linux</title>

<para>
We recommend you to use your package manager for that, but in case pev is outdated or
not present in your package manager repositories, you can still use it by compiling it
from the sources.
</para>

</section>

<section id="binwin">
<title>On Windows</title>
<para>
Just download the ZIP package and uncompress it in any directory you want. There is a handy script called run.bat that you can use to open a Command Prompt window in pev's directory. This script also configures the environment for proper working of pev toolkit. You can also consider adding the pev's directory to PATH variable to make use of pev tools even easier.
</para>

<para>After running the script you should see a window like this:</para>
<imageobject>
	<imagedata fileref="figures/runbat.png" format="PNG" />
</imageobject>

<tip><para>You DON'T need to install Cygwin to run pev in Windows. Cygwin is only needed if you want to compile pev toolkit by your own.</para></tip>

</section>

<section id="binmac">
<title>On Mac OS X</title>
<para>
If you haven't, please install either <ulink url="http://brew.sh/">Homebrew</ulink> or <ulink url="http://www.macports.org/">MacPorts</ulink> first, then open a Terminal window and run one of the following commands:
</para>

<screen>
<prompt>$ </prompt><command>brew install pev</command>
</screen>

<screen>
<prompt>$ </prompt><command>sudo port install pev</command>
</screen>

</section>

</section>

<section id="source">
<title>From the sources</title>

<para>
Go to <ulink url="http://pev.sourceforge.net" />, and download the tarball
named pev-x.xx.tar.gz, where x.xx is the version number you want.
</para>

<para>You can have the most up to date source code from the
<ulink url="https://github.com/mentebinaria/readpe">pev repository on GitHub</ulink> (recommended).
If you have git installed, run the following:</para>

<prompt>$ </prompt> <command>git clone --recursive git://github.com/mentebinaria/readpe.git</command>

<para>
Even without git installed, you can download a ZIP or tarball file from project web page
on GitHub.
</para>

<section id="complinux">
<title>Compiling on GNU/Linux</title>

<para>
Make sure you have the following dependencies installed and working properly:
</para>

<simplelist>
<member><ulink url="https://github.com/mentebinaria/readpe">libpe</ulink> (included with in the repository under lib/libpe)</member>
<member>libssl (used by pehash and pesec)</member>
<member>gcc</member>
<member>make</member>
</simplelist>

<para>If you have downloaded the tarball, uncompress it with tar command:</para>

<screen>
<prompt>$ </prompt><command>tar xf pev-x.xx.tar.gz</command>
<prompt>$ </prompt><command>cd pev-x.xx</command>
</screen>
<para>If you've cloned the git repository, it's time to compile pev and its libraries:</para>

<screen>
<prompt>$ </prompt><command>make</command>
<prompt># </prompt><command>make install</command> (root privileges needed)
</screen>

<para>
If your Linux distribution does not set /usr/local/lib as one of default locations for libraries, you may need to create a symlink like this:
<screen>
<prompt># </prompt><command>ln -s /usr/local/lib/libpe.so.1.0 /usr/lib/libpe.so.1</command>
</screen>
</para>

<para>
The commands above will compile libpe and all pev binaries. You can set
DEST and PREFIX variables if you need. For compiling libpe only, enter in its directory
and issue make command, as this:
</para>

<screen>
<prompt>$ </prompt><command>cd lib/libpe</command>
<prompt>$ </prompt><command>make</command>
</screen>

<para>To compile individual pev binaries, use:</para>
<screen>
<prompt>$ </prompt><command>cd src/</command>
<prompt>$ </prompt><command>make <replaceable>program</replaceable></command>
</screen>

<note>
<para>
In order to use any pev binary you should compile and install libpe first.
</para>
</note>

</section>

<section id="compwin">
<title>Compiling in Windows (via Cygwin)</title>

<para>The first step is to download and install <ulink
url="http://cygwin.com/">Cygwin</ulink>. During the installation process,
you must select at minimum the following packages:</para>

<simplelist>
<member>gcc-core</member>
<member>binutils</member>
<member>make</member>
<member>zip</member>
<member>openssl-devel</member>
<member>git (just to clone the repository and make things easier)</member>
</simplelist>

<para>
You should follow the same compilation steps for GNU/Linux, replacing
"make install" by "make zip" at the end:
</para>

<screen>
<prompt>$ </prompt><command>make zip</command>
</screen>

<para>A file <emphasis>pev-x.xx.zip</emphasis> will be created and can be
extracted in any directory you choose. All pev tools can be called directly from
Windows Command Prompt (<emphasis>cmd.exe</emphasis>). You can add the pev's directory
in %PATH% environment variable in order to call pev tools from anywhere.</para>

<warning><para>You can't call "make install" under Cygwin.</para></warning>

</section>

<section id="composx">
<title>Compiling in OS X</title>
<para>We recommend you use one of the following package managers to install dependencies first when
compiling in OS X:</para>

<simplelist>
<member>Homebrew - http://brew.sh/</member>
<member>MacPorts - http://www.macports.org</member>
</simplelist>

<para>For Homebrew, use:</para>

<screen>
<prompt>$ </prompt><command>brew install &lt;pkgname&gt;</command>
<prompt>$ </prompt><command>make CFLAGS="-I/opt/local/include"</command>
</screen>


<para>For MacPorts, use:</para>

<screen>
<prompt>$ </prompt><command>sudo port install &lt;pkgname&gt;</command>
<prompt>$ </prompt><command>make CFLAGS="-I/opt/local/include"</command>
</screen>

<para>The directories above may change depending on your package manager installation settings.</para>

</section>

<section id="compother">
<title>Compiling in other platforms</title>

<para>
As pev is written in standard C language, we encourage you to compile it in
different platforms and let us know about that. We believe pev can be compiled
in many different platforms with just a few or no patches, but you may face some
dependencies challenges. Anyway, we encourage you to <ulink url="http://pev.sourceforge.net/#support">
get in touch</ulink> to discuss.
</para>

<para>
Previous versions were compiled for Android, Solaris and other systems. If you want to give it
a try, go ahead! ;)
</para>
</section>

<section id="compat">
<title>Output retro-compatibility</title>
<para>
As of version 0.70 the output format of pev programs changed. If you have some
scripts calling pev and parsing the old 0.60 output format, you can define
a macro called LIBPE_ENABLE_OUTPUT_COMPAT_WITH_V06 before compilation, just like this:</para>

<screen>
<prompt>$ </prompt><command>DFLAGS+=-DLIBPE_ENABLE_OUTPUT_COMPAT_WITH_V06 make readpe</command>
</screen>

<para>This retrocompatibility will be removed in the next release, so please consider updating
your scripts as soon as possible.
</para>

</section>

</section>

</chapter>
