README-OSX.md
author Dirk Zimmermann <dirk@pep-project.org>
Sat, 09 Jul 2016 10:49:10 +0200
changeset 821 a0907c429673
parent 805 f026ae414feb
child 1082 9ed6c2829271
permissions -rw-r--r--
Documenting macOS build, using MacPorts
dirk@821
     1
# Building for OS X/macOS
dirk@707
     2
dirk@821
     3
See also README.txt for general information.
dirk@821
     4
dirk@821
     5
## Dependencies
dirk@821
     6
dirk@821
     7
### MacPorts
dirk@821
     8
dirk@821
     9
Install [MacPorts](https://www.macports.org/) for your
dirk@821
    10
[version of OS X/macOS](https://www.macports.org/install.php).
dirk@821
    11
dirk@821
    12
Note that you need [Xcode installed](https://www.macports.org/install.php)
dirk@821
    13
for MacPorts, and for building the engine. You also need to accept Xcode's EULA.
dirk@821
    14
dirk@821
    15
*Note*: Use the script `macports_env.sh` (or a similar one) to set up a clean build environment
dirk@821
    16
before building the engine:
dirk@707
    17
dirk@707
    18
```
dirk@821
    19
. macports_env.sh
dirk@707
    20
```
dirk@707
    21
dirk@821
    22
If you don't use that environment, please make sure you've set up all search paths correctly.
dirk@706
    23
dirk@821
    24
#### MacPorts dependencies
dirk@706
    25
dirk@706
    26
```
dirk@821
    27
sudo port install mercurial
dirk@821
    28
sudo port install py27-lxml
dirk@821
    29
sudo port install gpgme
dirk@821
    30
sudo port install autoconf
dirk@821
    31
sudo port install asn1c
dirk@821
    32
sudo port install zlib
dirk@821
    33
```
dirk@821
    34
dirk@821
    35
### Other dependecies
dirk@821
    36
dirk@821
    37
#### [yml2](https://fdik.org/yml/toolchain)
dirk@821
    38
dirk@821
    39
Install into your home directory:
dirk@821
    40
dirk@821
    41
```
dirk@821
    42
pushd ~
dirk@821
    43
curl -LO http://fdik.org/yml2.tar.bz2
dirk@821
    44
tar xf yml2.tar.bz2
dirk@821
    45
rm yml2.tar.bz2*
dirk@821
    46
popd
dirk@821
    47
```
dirk@821
    48
dirk@821
    49
#### libetpan
dirk@821
    50
dirk@821
    51
Note: libetpan needs libz and libiconv, but the libiconv from MacPorts is not compatible, some
dirk@821
    52
functions seem to have been renamed there. Therefore the dynlib from OS X is used.
dirk@821
    53
dirk@821
    54
```
dirk@821
    55
git clone https://github.com/fdik/libetpan libetpan-osx
dirk@821
    56
cd libetpan-osx/
dirk@821
    57
./autogen.sh
dirk@706
    58
make
dirk@821
    59
cp ./src/.libs/libetpan.a ~/lib/
dirk@821
    60
```
dirk@821
    61
dirk@821
    62
##### libetpan with xcodebuild
dirk@821
    63
dirk@821
    64
The build with autoconf (see previous section) is preferred. This is just for completeness.
dirk@821
    65
*Don't actually build libetpan with xcodebuild.*
dirk@821
    66
dirk@821
    67
```
dirk@821
    68
git clone https://github.com/fdik/libetpan libetpan-osx
dirk@821
    69
cd libetpan-osx/build-mac
dirk@821
    70
xcodebuild -project libetpan.xcodeproj/ -target "static libetpan"
dirk@821
    71
mkdir ~/lib
dirk@821
    72
cp build/Release/libetpan.a ~/lib/
dirk@821
    73
```
dirk@821
    74
dirk@821
    75
### Configuration
dirk@821
    76
dirk@821
    77
You can change some defaults by editing `Makefile.conf`. But this readme assumes you don't.
dirk@821
    78
dirk@821
    79
### Build
dirk@821
    80
dirk@821
    81
```
dirk@821
    82
make clean
dirk@821
    83
make all
dirk@821
    84
make db
dirk@821
    85
```
dirk@821
    86
dirk@821
    87
Done! The result should be (among others):
dirk@821
    88
dirk@821
    89
```
dirk@821
    90
./src/libpEpEngine.a
dirk@821
    91
./src/libpEpEngine.dylib
dirk@821
    92
```
dirk@821
    93
dirk@821
    94
### Install
dirk@821
    95
dirk@821
    96
Install (you might need sudo for some commands, depending on how your system is set up):
dirk@821
    97
dirk@821
    98
```
dirk@706
    99
make install
dirk@821
   100
make -C db install
dirk@821
   101
```
dirk@821
   102
dirk@821
   103
Since the `system.db` rarely changes, `make -C db install` is not needed for every build.
dirk@821
   104
dirk@821
   105
### Run tests
dirk@821
   106
dirk@821
   107
Make sure that you add `/opt/local/lib` to each definition of `LD_LIBRARY_PATH`
dirk@821
   108
in `test/Makefile`. This ensures that libgpgme will be found:
dirk@821
   109
dirk@821
   110
```
dirk@821
   111
test: pEpEngineTest
dirk@821
   112
        LD_LIBRARY_PATH=/opt/local/lib:~/lib:../src ./pEpEngineTest
dirk@821
   113
```
dirk@821
   114
dirk@821
   115
```
dirk@821
   116
make test
dirk@706
   117
```
dirk@706
   118
dirk@670
   119
# Building for iOS
dirk@670
   120
dirk@670
   121
This is done with Xcode. Simply add `pEpEngine.xcodeproj` to
dirk@670
   122
your project and add a dependency to the target `pEpEngine`
dirk@670
   123
(in `Target Dependencies` in your `Build Phases`.
dirk@670
   124
dirk@670
   125
Usually you just integrate `pEpiOSAdapter.xcodeproj`.