doc/build-macos.md
author Damiano Boppart <damiano@pep-security.net>
Fri, 27 Oct 2017 17:21:25 +0200
branchdiphoton_M1
changeset 2258 340598e126a2
parent 2218 da5d2c04cd94
child 2296 1a12f577ac71
permissions -rw-r--r--
Update documentation to reflect the changes to Makefile.conf
damiano@2014
     1
<!-- Copyright 2015-2017, pEp foundation, Switzerland
damiano@2014
     2
This file is part of the pEp Engine
damiano@2014
     3
This file may be used under the terms of the Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) License
damiano@2014
     4
See CC_BY-SA.txt -->
vb@1513
     5
damiano@2039
     6
# Build instructions for macOS Sierra
dirk@821
     7
damiano@2014
     8
# Installing packaged dependencies
dirk@1415
     9
damiano@2014
    10
## MacPorts
vb@1425
    11
damiano@2014
    12
MacPorts is needed to install some compile-time dependencies.
damiano@2014
    13
Install MacPorts according to the instructions found [here](https://www.macports.org/install.php).
damiano@2014
    14
Ensure that Macports' binary paths (`/opt/local/bin` and `/opt/local/sbin`) are in your `PATH` environment variable.
dirk@821
    15
damiano@2014
    16
~~~
damiano@2014
    17
# general
damiano@2014
    18
sudo port install mercurial
damiano@2014
    19
# YML2
damiano@2014
    20
sudo port install py27-lxml
damiano@2014
    21
# libetpan
damiano@2014
    22
sudo port install git autoconf automake libtool
damiano@2014
    23
# asn1c
damiano@2014
    24
sudo port install asn1c
damiano@2014
    25
# engine
damiano@2014
    26
sudo port install gpgme
damiano@2014
    27
~~~
dirk@821
    28
damiano@2014
    29
Ensure that `python` is Python 2.7:
dirk@821
    30
damiano@2014
    31
~~~
damiano@2014
    32
sudo port select python python27
damiano@2014
    33
~~~
Damiano@1681
    34
damiano@2014
    35
# Installing unpackaged dependencies
damiano@2014
    36
## YML2
dirk@1414
    37
damiano@2014
    38
~~~
damiano@2014
    39
mkdir -p ~/code/yml2
damiano@2014
    40
hg clone https://cacert.pep.foundation/dev/repos/yml2/ ~/code/yml2
damiano@2014
    41
~~~
dirk@1414
    42
damiano@2014
    43
## libetpan
damiano@2014
    44
pEp Engine requires libetpan with a set of patches that have not been upstreamed yet.
dirk@1414
    45
damiano@2014
    46
~~~
damiano@2014
    47
mkdir -p ~/code/libetpan
damiano@2014
    48
git clone https://github.com/fdik/libetpan ~/code/libetpan
damiano@2014
    49
cd ~/code/libetpan
damiano@2014
    50
mkdir ~/code/libetpan/build
damiano@2014
    51
./autogen.sh --prefix="$HOME/code/libetpan/build"
edouard@1682
    52
make
edouard@1682
    53
make install
damiano@2014
    54
~~~
edouard@1682
    55
damiano@2014
    56
## GPGME
damiano@2014
    57
The MacPorts-packaged GPGME links to a version of GNU libiconv that has files in the same include/library paths as GPGME. This version of libiconv must not be visible to the linker when the pEp Engine is build or run.
dirk@821
    58
damiano@2014
    59
Thus the files of the GPGME distribution will have to be manually copied to separate include/library folders, so that no include or library paths used for building the pEp Engine contains files of MacPorts' libiconv distribution.
dirk@821
    60
damiano@2014
    61
~~~
damiano@2014
    62
mkdir -p ~/code/gpgme/build/include
damiano@2014
    63
cp /opt/local/include/gpg*.h ~/code/gpgme/build/include
damiano@2014
    64
mkdir -p ~/code/gpgme/build/lib
damiano@2014
    65
cp -r /opt/local/lib/libgpg* ~/code/gpgme/build/lib
damiano@2014
    66
~~~
dirk@821
    67
damiano@2042
    68
It's of course possible to skip MacPort's version, and use a self-compiled GPGME/GPG. The default build configuration assumes this case, and assumes you have installed your GPGME with `$(HOME)` as your prefix.
dirk@821
    69
damiano@2014
    70
# pEp Engine
dirk@821
    71
damiano@2014
    72
~~~
damiano@2014
    73
mkdir -p ~/code/pep-engine
damiano@2014
    74
hg clone https://cacert.pep.foundation/dev/repos/pEpEngine/ ~/code/pep-engine
damiano@2014
    75
cd ~/code/pep-engine
damiano@2014
    76
mkdir ~/code/pep-engine/build
damiano@2014
    77
~~~
dirk@821
    78
damiano@2218
    79
Edit the build configuration to your needs in `Makefile.conf`, or create a `local.conf` that sets any of the make variables documented in `Makefile.conf`. All the default values for the build configuration variables on each platform are documented in `default.conf`.
damiano@2082
    80
damiano@2218
    81
If a dependency is not found in your system's default include or library paths, you will have to specify the according paths in a make variable. Typically, this has to be done at least for YML2, and libetpan.
damiano@2210
    82
damiano@2218
    83
For a more detailed explanation of the mechanics of these build configuration files, and overriding defaults, see the comments in `default.conf`.
damiano@2218
    84
damiano@2218
    85
Below is a sample `./local.conf` file, for orientation.
Damiano@1681
    86
damiano@2014
    87
~~~
damiano@2218
    88
PREFIX=$(HOME)/code/engine/build
damiano@2014
    89
SYSTEM_DB=$(PREFIX)/share/pEp/system.db
dirk@821
    90
damiano@2014
    91
YML2_PATH=$(HOME)/code/yml2
damiano@2014
    92
damiano@2014
    93
ETPAN_LIB=-L$(HOME)/code/libetpan/build/lib
damiano@2014
    94
ETPAN_INC=-I$(HOME)/code/libetpan/build/include
damiano@2014
    95
damiano@2218
    96
GPGME_LIB=-L$(HOME)/lib
damiano@2218
    97
GPGME_INC=-I$(HOME)/include
damiano@2014
    98
~~~
damiano@2014
    99
damiano@2014
   100
The engine is built as follows:
damiano@2014
   101
damiano@2014
   102
~~~
dirk@821
   103
make all
dirk@821
   104
make db
damiano@2014
   105
~~~
dirk@821
   106
damiano@2019
   107
If your build fails with an error message similar to the following:
damiano@2019
   108
damiano@2019
   109
~~~
damiano@2019
   110
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 477, in _parse_localename
damiano@2019
   111
    raise ValueError, 'unknown locale: %s' % localename
damiano@2019
   112
ValueError: unknown locale: UTF-8
damiano@2019
   113
~~~
damiano@2019
   114
damiano@2019
   115
or any other locale-related Python error, make sure Python does not have any locale-related environment variables set.
damiano@2019
   116
Usually, `unset LC_CTYPE` is sufficient to take care of the problem, but it depends on your macOS's regional and language settings and which terminal emulator you use.
damiano@2019
   117
This is a bug in Python, see [https://bugs.python.org/issue18378#msg215215](https://bugs.python.org/issue18378#msg215215).
damiano@2019
   118
damiano@2015
   119
The unit tests can be run without the engine library being installed, however `system.db` must be installed:
dirk@821
   120
damiano@2014
   121
~~~
damiano@2014
   122
make -C db install
damiano@2014
   123
~~~
dirk@821
   124
damiano@2014
   125
Since `system.db` rarely changes, its installation is not needed for every build.
dirk@821
   126
damiano@2014
   127
Tests can be compiled and executed with the following commands:
dirk@821
   128
damiano@2014
   129
~~~
damiano@2014
   130
make -C test compile
dirk@821
   131
make test
damiano@2014
   132
~~~