README-OSX.md
author Krista Bennett <krista@pep-project.org>
Fri, 01 Jun 2018 10:30:20 +0200
branchENGINE-238
changeset 2728 01f1da97c547
parent 1704 8147e7b101fd
permissions -rw-r--r--
close branch
Damiano@1681
     1
This file is under Creative Commons License 3.0 cc-by-sa
vb@1513
     2
dirk@821
     3
# Building for OS X/macOS
dirk@821
     4
See also README.txt for general information.
dirk@821
     5
Damiano@1681
     6
For compiling pEp Engine and its dependencies, make sure you have the LANG variable set. Some source files contain unicode characters, and python (assuming files are ascii) will fail.
dirk@1415
     7
Damiano@1681
     8
```
Damiano@1681
     9
export LANG=en_US.UTF-8
Damiano@1681
    10
```
vb@1425
    11
dirk@821
    12
## Dependencies
dirk@821
    13
dirk@821
    14
### MacPorts
Damiano@1681
    15
[Install MacPorts](https://www.macports.org/install.php) for your version of OS X/macOS.
dirk@821
    16
Damiano@1681
    17
If MacPorts is already installed on your machine, but was installed by a different user, make sure your `PATH` variable is set as follows in `~/.profile`:
dirk@706
    18
dirk@706
    19
```
Damiano@1681
    20
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
dirk@821
    21
```
dirk@821
    22
Damiano@1681
    23
Install dependencies packaged with MacPorts as follows.
Damiano@1681
    24
Damiano@1681
    25
```
Damiano@1703
    26
sudo port install mercurial py27-lxml gpgme autoconf automake libtool asn1c zlib openssl libiconv cyrus-sasl2
Damiano@1681
    27
```
dirk@1414
    28
dirk@1414
    29
Make sure that `python` is a version 2 one:
dirk@1414
    30
dirk@1414
    31
```
dirk@1414
    32
sudo port select python python27
dirk@1414
    33
```
dirk@1414
    34
edouard@1682
    35
### NetPGP (if not GPGME)
edouard@1682
    36
edouard@1682
    37
#### Prepare :
edouard@1682
    38
edouard@1682
    39
Get OpenSSL and build/install it as shared library.
edouard@1682
    40
edouard@1682
    41
```
edouard@1682
    42
wget https://www.openssl.org/source/old/1.0.1/openssl-1.0.1u.tar.gz
edouard@1682
    43
tar xvfz openssl-1.0.1u.tar.gz
edouard@1682
    44
cd openssl-1.0.1u
edouard@1682
    45
./Configure darwin64-x86_64-cc --prefix=$HOME shared
edouard@1682
    46
make install
edouard@1682
    47
```
edouard@1682
    48
edouard@1682
    49
Get and autoconf NetPGP
edouard@1682
    50
edouard@1682
    51
```
edouard@1682
    52
cd $SRC
edouard@1682
    53
hg clone https://cacert.pep.foundation/dev/repos/netpgp-et/
edouard@1682
    54
cd netpgp-et
edouard@1682
    55
autoreconf -i
edouard@1682
    56
```
edouard@1682
    57
edouard@1682
    58
#### Build
edouard@1682
    59
edouard@1682
    60
Important : LDFLAGS is set to help finding OpenSSL shared lib. If not set,
edouard@1682
    61
system's default libcrypto may silently be used instead, causing memory
edouard@1682
    62
corruption or crash at runtime.
edouard@1682
    63
edouard@1682
    64
```
edouard@1682
    65
mkdir netpgp_debug
edouard@1682
    66
cd netpgp_debug
edouard@1682
    67
$SRC/netpgp-et/configure --with-openssl=$HOME --prefix=$HOME CPPFLAGS=-DDEBUG CXXFLAGS="-g -O0" LDFLAGS="-L${HOME}/lib"
edouard@1682
    68
make
edouard@1682
    69
make install
edouard@1682
    70
```
edouard@1682
    71
Damiano@1681
    72
### Other Dependecies
dirk@821
    73
dirk@821
    74
#### [yml2](https://fdik.org/yml/toolchain)
dirk@821
    75
Install into your home directory:
dirk@821
    76
dirk@821
    77
```
dirk@821
    78
pushd ~
dirk@1082
    79
hg clone https://cacert.pep.foundation/dev/repos/yml2/
dirk@821
    80
popd
dirk@821
    81
```
dirk@821
    82
dirk@821
    83
#### libetpan
dirk@821
    84
dirk@821
    85
Note: libetpan needs libz and libiconv, but the libiconv from MacPorts is not compatible, some
dirk@821
    86
functions seem to have been renamed there. Therefore the dynlib from OS X is used.
dirk@821
    87
dirk@821
    88
```
Damiano@1681
    89
git clone https://github.com/fdik/libetpan
Damiano@1681
    90
cd libetpan
Damiano@1681
    91
./autogen.sh --prefix "$HOME"
dirk@706
    92
make
Damiano@1681
    93
make install
dirk@821
    94
```
dirk@821
    95
Damiano@1681
    96
## Building pEp Engine
Damiano@1681
    97
dirk@821
    98
### Configuration
Damiano@1681
    99
You can change some defaults by editing `Makefile.conf`. The following variable needs to be set appropriately:
dirk@821
   100
Damiano@1681
   101
```
Damiano@1681
   102
LIBGPGME=/opt/local/lib/libgpgme.11.dylib
Damiano@1681
   103
```
dirk@821
   104
dirk@821
   105
### Build
dirk@821
   106
dirk@821
   107
```
dirk@821
   108
make clean
dirk@821
   109
make all
dirk@821
   110
make db
dirk@821
   111
```
dirk@821
   112
Damiano@1681
   113
### Installation
dirk@821
   114
dirk@821
   115
```
dirk@706
   116
make install
Damiano@1681
   117
sudo make -C db install
dirk@821
   118
```
dirk@821
   119
Damiano@1681
   120
Since the `system.db` rarely changes, the last step is not needed for every build. If you would like to be able to install the engine without `sudo`, ensure that your user can write the file `/usr/local/share/pEp/system.db`. This is not recommended for production machines.
dirk@821
   121
dirk@821
   122
### Run tests
dirk@821
   123
Damiano@1681
   124
If you installed the test keys in your keyring (see: README.txt), this should just work:
dirk@821
   125
dirk@821
   126
```
Damiano@1704
   127
cd test
dirk@821
   128
make test
dirk@706
   129
```
dirk@706
   130
dirk@670
   131
# Building for iOS
dirk@670
   132
dirk@670
   133
This is done with Xcode. Simply add `pEpEngine.xcodeproj` to
dirk@670
   134
your project and add a dependency to the target `pEpEngine`
dirk@670
   135
(in `Target Dependencies` in your `Build Phases`.
dirk@670
   136
dirk@670
   137
Usually you just integrate `pEpiOSAdapter.xcodeproj`.