doc/build-macos.md
author Damiano Boppart <damiano@pep-security.net>
Tue, 29 Aug 2017 16:40:43 +0200
branchENGINE-237
changeset 2019 6c2b325f2056
parent 2015 eefffcd9f781
child 2039 b88e62c9ea72
permissions -rw-r--r--
Remove fixme, add Python bug documentation
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@2014
     6
# Build instructions for macOS Sierra and iOS
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@2014
    68
It's of course possible to skip MacPort's version, and use a self-compiled GPGME/GPG.
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@2014
    79
For an explanation of the mechanics of `PLATFORM_OVERRIDE`, see the inline comments in `Makefile.conf`.
damiano@2014
    80
In this guide, the platform-specific configuration will be called `local`.
damiano@2014
    81
The installation directory will be a subdirectory of the repository.
damiano@2014
    82
This is useful for testing only.
Damiano@1681
    83
damiano@2014
    84
~~~
damiano@2014
    85
export PLATFORM_OVERRIDE=local
damiano@2014
    86
~~~
dirk@821
    87
damiano@2014
    88
`./build-config/local.conf`:
dirk@821
    89
damiano@2014
    90
~~~
damiano@2014
    91
PREFIX=$(HOME)/code/pep-engine/build
damiano@2014
    92
SYSTEM_DB=$(PREFIX)/share/pEp/system.db
dirk@821
    93
damiano@2014
    94
YML2_PATH=$(HOME)/code/yml2
damiano@2014
    95
damiano@2014
    96
ETPAN_LIB=-L$(HOME)/code/libetpan/build/lib
damiano@2014
    97
ETPAN_INC=-I$(HOME)/code/libetpan/build/include
damiano@2014
    98
damiano@2014
    99
GPGME_LIB=-L$(HOME)/code/gpgme/build/lib
damiano@2014
   100
GPGME_INC=-I$(HOME)/code/gpgme/build/include
damiano@2014
   101
~~~
damiano@2014
   102
damiano@2014
   103
The engine is built as follows:
damiano@2014
   104
damiano@2014
   105
~~~
dirk@821
   106
make all
dirk@821
   107
make db
damiano@2014
   108
~~~
dirk@821
   109
damiano@2019
   110
If your build fails with an error message similar to the following:
damiano@2019
   111
damiano@2019
   112
~~~
damiano@2019
   113
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 477, in _parse_localename
damiano@2019
   114
    raise ValueError, 'unknown locale: %s' % localename
damiano@2019
   115
ValueError: unknown locale: UTF-8
damiano@2019
   116
~~~
damiano@2019
   117
damiano@2019
   118
or any other locale-related Python error, make sure Python does not have any locale-related environment variables set.
damiano@2019
   119
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
   120
This is a bug in Python, see [https://bugs.python.org/issue18378#msg215215](https://bugs.python.org/issue18378#msg215215).
damiano@2019
   121
damiano@2015
   122
The unit tests can be run without the engine library being installed, however `system.db` must be installed:
dirk@821
   123
damiano@2014
   124
~~~
damiano@2014
   125
make -C db install
damiano@2014
   126
~~~
dirk@821
   127
damiano@2014
   128
Since `system.db` rarely changes, its installation is not needed for every build.
dirk@821
   129
damiano@2014
   130
Tests can be compiled and executed with the following commands:
dirk@821
   131
damiano@2014
   132
~~~
damiano@2014
   133
make -C test compile
dirk@821
   134
make test
damiano@2014
   135
~~~