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