Documenting macOS build, using MacPorts
authorDirk Zimmermann <dirk@pep-project.org>
Sat, 09 Jul 2016 10:49:10 +0200
changeset 821a0907c429673
parent 820 03e6929fe32b
child 823 8f3cb6e834f9
Documenting macOS build, using MacPorts
Makefile.conf
README-OSX.md
macports_env.sh
src/Makefile
     1.1 --- a/Makefile.conf	Sun Jul 10 08:56:19 2016 +0200
     1.2 +++ b/Makefile.conf	Sat Jul 09 10:49:10 2016 +0200
     1.3 @@ -11,9 +11,6 @@
     1.4  YML_PATH=$(HOME)/yml2
     1.5  ASN1C=asn1c
     1.6  
     1.7 -# TODO: For brew this is /usr/local/share/asn1c
     1.8 -# On BSDs, it might be that as well. How to check?
     1.9 -# For now, it just works, even when it doesn't exist.
    1.10  ASN1C_INCLUDE=/opt/local/share/asn1c
    1.11  
    1.12  # C makros (not environment variables) to overwrite:
     2.1 --- a/README-OSX.md	Sun Jul 10 08:56:19 2016 +0200
     2.2 +++ b/README-OSX.md	Sat Jul 09 10:49:10 2016 +0200
     2.3 @@ -1,23 +1,119 @@
     2.4 -# Dependencies
     2.5 +# Building for OS X/macOS
     2.6  
     2.7 -You need a working [asn1c](https://lionet.info/asn1c/blog/).
     2.8 +See also README.txt for general information.
     2.9 +
    2.10 +## Dependencies
    2.11 +
    2.12 +### MacPorts
    2.13 +
    2.14 +Install [MacPorts](https://www.macports.org/) for your
    2.15 +[version of OS X/macOS](https://www.macports.org/install.php).
    2.16 +
    2.17 +Note that you need [Xcode installed](https://www.macports.org/install.php)
    2.18 +for MacPorts, and for building the engine. You also need to accept Xcode's EULA.
    2.19 +
    2.20 +*Note*: Use the script `macports_env.sh` (or a similar one) to set up a clean build environment
    2.21 +before building the engine:
    2.22  
    2.23  ```
    2.24 -brew install asn1c
    2.25 +. macports_env.sh
    2.26  ```
    2.27  
    2.28 -# Building for OS X
    2.29 +If you don't use that environment, please make sure you've set up all search paths correctly.
    2.30  
    2.31 -* TODO: which dependencies can be fetched via "brew" and which have to be compiled manually?
    2.32 -
    2.33 -## Build libetpan
    2.34 +#### MacPorts dependencies
    2.35  
    2.36  ```
    2.37 -cd pEpEngine   <--- huh? to build libetpan???
    2.38 -autoreconf -vfi
    2.39 -./configure
    2.40 +sudo port install mercurial
    2.41 +sudo port install py27-lxml
    2.42 +sudo port install gpgme
    2.43 +sudo port install autoconf
    2.44 +sudo port install asn1c
    2.45 +sudo port install zlib
    2.46 +```
    2.47 +
    2.48 +### Other dependecies
    2.49 +
    2.50 +#### [yml2](https://fdik.org/yml/toolchain)
    2.51 +
    2.52 +Install into your home directory:
    2.53 +
    2.54 +```
    2.55 +pushd ~
    2.56 +curl -LO http://fdik.org/yml2.tar.bz2
    2.57 +tar xf yml2.tar.bz2
    2.58 +rm yml2.tar.bz2*
    2.59 +popd
    2.60 +```
    2.61 +
    2.62 +#### libetpan
    2.63 +
    2.64 +Note: libetpan needs libz and libiconv, but the libiconv from MacPorts is not compatible, some
    2.65 +functions seem to have been renamed there. Therefore the dynlib from OS X is used.
    2.66 +
    2.67 +```
    2.68 +git clone https://github.com/fdik/libetpan libetpan-osx
    2.69 +cd libetpan-osx/
    2.70 +./autogen.sh
    2.71  make
    2.72 +cp ./src/.libs/libetpan.a ~/lib/
    2.73 +```
    2.74 +
    2.75 +##### libetpan with xcodebuild
    2.76 +
    2.77 +The build with autoconf (see previous section) is preferred. This is just for completeness.
    2.78 +*Don't actually build libetpan with xcodebuild.*
    2.79 +
    2.80 +```
    2.81 +git clone https://github.com/fdik/libetpan libetpan-osx
    2.82 +cd libetpan-osx/build-mac
    2.83 +xcodebuild -project libetpan.xcodeproj/ -target "static libetpan"
    2.84 +mkdir ~/lib
    2.85 +cp build/Release/libetpan.a ~/lib/
    2.86 +```
    2.87 +
    2.88 +### Configuration
    2.89 +
    2.90 +You can change some defaults by editing `Makefile.conf`. But this readme assumes you don't.
    2.91 +
    2.92 +### Build
    2.93 +
    2.94 +```
    2.95 +make clean
    2.96 +make all
    2.97 +make db
    2.98 +```
    2.99 +
   2.100 +Done! The result should be (among others):
   2.101 +
   2.102 +```
   2.103 +./src/libpEpEngine.a
   2.104 +./src/libpEpEngine.dylib
   2.105 +```
   2.106 +
   2.107 +### Install
   2.108 +
   2.109 +Install (you might need sudo for some commands, depending on how your system is set up):
   2.110 +
   2.111 +```
   2.112  make install
   2.113 +make -C db install
   2.114 +```
   2.115 +
   2.116 +Since the `system.db` rarely changes, `make -C db install` is not needed for every build.
   2.117 +
   2.118 +### Run tests
   2.119 +
   2.120 +Make sure that you add `/opt/local/lib` to each definition of `LD_LIBRARY_PATH`
   2.121 +in `test/Makefile`. This ensures that libgpgme will be found:
   2.122 +
   2.123 +```
   2.124 +test: pEpEngineTest
   2.125 +        LD_LIBRARY_PATH=/opt/local/lib:~/lib:../src ./pEpEngineTest
   2.126 +```
   2.127 +
   2.128 +```
   2.129 +make test
   2.130  ```
   2.131  
   2.132  # Building for iOS
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/macports_env.sh	Sat Jul 09 10:49:10 2016 +0200
     3.3 @@ -0,0 +1,14 @@
     3.4 +# Typical pure MacPorts environment
     3.5 +
     3.6 +# Restrict to MacPorts
     3.7 +export PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
     3.8 +
     3.9 +# Make sure the Apple python (which will be triggered by the makefile)
    3.10 +# has access to the Python libs installed for MacPorts
    3.11 +export PYTHONPATH=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/
    3.12 +
    3.13 +# YML processing might complain about that. Make sure the locale exists (locale -a)
    3.14 +export LC_ALL=en_US.UTF-8
    3.15 +
    3.16 +# Search paths for includes used when doing YML processing
    3.17 +export YML_PATH=~/yml2/
     4.1 --- a/src/Makefile	Sun Jul 10 08:56:19 2016 +0200
     4.2 +++ b/src/Makefile	Sat Jul 09 10:49:10 2016 +0200
     4.3 @@ -14,7 +14,7 @@
     4.4  CFLAGS?=-I$(GPGME_IN)/include -I$(HOME)/include -I/opt/local/include $(OPTIMIZE) -pedantic \
     4.5  	-DSYSTEM_DB=\"$(SYSTEM_DB)\" -DLIBGPGME=\"$(LIBGPGME)\" -I../asn.1
     4.6  LDFLAGS?=-lc -shared -arch x86_64 \
     4.7 -	-L$(HOME)/lib -L/opt/local/lib -letpan -lsqlite3 -L../asn.1 -lasn1
     4.8 +	-L$(HOME)/lib -L/usr/lib -L/opt/local/lib -letpan -lsqlite3 -L../asn.1 -lasn1 -lz -liconv
     4.9  
    4.10  else
    4.11  $(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))