README.macos.md 6.89 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
# Compiling Linphone on MacOS X

## Dependencies

* Xcode (download from apple or using appstore application)
* Java SE
* [HomeBrew](http://brew.sh) or [Macports](http://www.macports.org/).

### Multiple MacOS version support

In order to enable generation of bundle for multiple MacOS version and 32 bit processors, it is recommended to:

1. Edit `/opt/local/etc/macports/macports.conf` to add the following line:

 > macosx_deployment_target 10.6

2. Edit `/opt/local/etc/macports/variants.conf` to add the following line:

 > +universal

### Build time dependencies

#### Using MacPorts

* Linphone core dependencies
26 27 28 29

        sudo port install automake autoconf libtool intltool wget cunit \
        antlr3 speex libvpx readline sqlite3 libsoup openldap libupnp \
        ffmpeg-devel -gpl2
30 31 32

* UI dependencies: install `GTK`. It is recommended to use the `quartz` backend for better integration.

33 34 35
        sudo port install gtk2 +quartz +no_x11
        sudo port install gtk-osx-application -python27
        sudo port install hicolor-icon-theme
36 37 38

 #### Using HomeBrew

39 40 41 42 43
        brew install automake intltool libtool pkg-config coreutils \
        yasm nasm wget imagemagick gettext gtk+ speex ffmpeg pygtk
        brew link gettext --force
        # readline is required from linphonec.c otherwise compilation will fail
        brew link readline --force
44

45 46 47 48
        # then you have to install antlr3 from a tap.
        wget https://gist.githubusercontent.com/Gui13/f5cf103f50d34c28c7be/raw/f50242f5e0c3a6d25ed7fca1462bce3a7b738971/antlr3.rb
        mv antlr3.rb /usr/local/Library/Formula/
        brew install antlr3
49

50 51
        brew tap marekjelen/gtk
        brew install gtk+-quartz
52

53 54 55 56
        # gtk-mac-integration is not available in main repository or Brew yet.
        wget https://gist.github.com/Gui13/cdcad37faa6b8ffa0588/raw/bf2277d45e261ad48ae1344c4c97f2684974ed87/gtk-mac-integration.rb
        mv gtk-mac-integration.rb /usr/local/Library/Formula/
        brew install gtk-mac-integration
57

58
### Building Linphone
59 60 61 62 63

The next pieces need to be compiled manually.

* To ensure compatibility with multiple MacOS versions it is recommended to do:

64 65 66 67 68
        export MACOSX_DEPLOYMENT_TARGET=10.6
        export CFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=10.5"
        export OBJCFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=10.5"
        export CXXFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=10.5"
        export LDFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=10.5 -Wl,-headerpad_max_install_names -Wl,-read_only_relocs -Wl,suppress"
69 70 71

* Install libantlr3c (library used by belle-sip for parsing)

72 73 74 75 76
        git clone -b linphone git://git.linphone.org/antlr3.git
        cd antlr3/runtime/C
        ./autogen.sh
        ./configure --disable-static --prefix=/opt/local && make
        sudo make install
77 78

* Install polarssl (encryption library used by belle-sip)
79 80 81 82 83

        git clone git://git.linphone.org/polarssl.git -b linphone
        cd polarssl
        ./autogen.sh && ./configure --prefix=/opt/local && make
        sudo make install
84 85 86

* Install belle-sip (sip stack)

87 88 89 90
        git clone git://git.linphone.org/belle-sip.git
        cd belle-sip
        ./autogen.sh && ./configure --prefix=/opt/local && make
        sudo make install
91 92 93

* (Optional) Install srtp for call encryption

94 95 96
        git clone git://git.linphone.org/srtp.git
        cd srtp && autoconf && ./configure --prefix=/opt/local && make libsrtp.a
        sudo make install
97

98
* (Optional) Install zrtp, for unbreakable call encryption
99

100 101 102
        git clone git://git.linphone.org:bzrtp
        cd bzrtp && ./autogen.sh && ./configure --prefix=/opt/local && make
        sudo make install
103 104 105

* (Optional) Install gsm codec

106 107 108 109
        git clone git://git.linphone.org/gsm.git
        cd gsm
        make CCFLAGS="$CFLAGS -c -O2 -DNeedFunctionPrototypes=1"
        sudo make install INSTALL_ROOT=/opt/local GSM_INSTALL_INC=/opt/local/include
110 111 112 113 114 115 116 117 118

* (Optional) libvpx-1.2 has a bug on MacOS resulting in ugly video. It is recommended to upgrade it manually to 1.3 from source.
The libvpx build isn't able to produce dual architecture files. To workaround this, configure libvpx twice and use lipo to create a dual architecture `libvpx.a`.

* (Optional, proprietary extension only) Compile and install the tunnel library

 If you got the source code from git, run `./autogen.sh` first.
 Then or otherwise, do:

119
        ./configure --prefix=/opt/local && make && sudo make install
120 121 122 123 124 125 126

* Compile Linphone

 If you got the source code from git, run `./autogen.sh` first.

 Then or otherwise, do:

127
        PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure --prefix=/opt/local --with-readline=/opt/local --disable-x11 --with-srtp=/opt/local --with-gsm=/opt/local --enable-zrtp --disable-strict && make
128 129 130

* Install on the system

131
        sudo make install
132 133 134 135 136 137 138

You are done.

### Generate portable bundle

If you want to generate a portable bundle, then install `gtk-mac-bundler`:

139 140 141 142 143
        git clone https://github.com/jralls/gtk-mac-bundler.git
        cd gtk-mac-bundler && make install
        export PATH=$PATH:~/.local/bin
        #make this dummy charset.alias file for the bundler to be happy:
        sudo touch /opt/local/lib/charset.alias
144 145 146 147

The bundler file in `build/MacOS/linphone.bundle` expects some plugins to be installed in `/opt/local/lib/mediastreamer/plugins`.
If you don't need plugins, remove or comment out this line from the bundler file:

148 149 150
        <binary>
        ${prefix:ms2plugins}/lib/mediastreamer/plugins/*.*.so
        </binary>
151 152 153

Then run, inside Linphone source tree configure as told before but with `--enable-relativeprefix` appended.

154
        make && make bundle
155 156 157 158 159

The resulting bundle is located in Linphone build directory, together with a zipped version.

* For a better appearance, you can install `gtk-quartz-engine` (a GTK theme) that makes GTK application more similar to other Mac applications (but not perfect).

160 161 162 163 164
        git clone https://github.com/jralls/gtk-quartz-engine.git
        cd gtk-quartz-engine
        autoreconf -i
        ./configure --prefix=/opt/local CFLAGS="$CFLAGS -Wno-error" && make
        sudo make install
165 166 167 168 169 170 171 172 173

Generate a new bundle to have it included.

### libiconv hack

The `Makefile.am` rules used to generate the bundle fetch a `libiconv.2.dylib` from a Linphone download page.
This library adds some additional symbols so that dependencies requiring the `iconv` from `/usr/lib` and the ones requiring from the bundle are both satisfied.
In case this library needs to generated, here are the commands:

174 175 176 177 178
        wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
        cd libiconv-1.14
        patch -p1 < ../linphone/build/MacOS/libiconv-MacOS.patch
        ./configure --prefix=/opt/local --disable-static 'CFLAGS=-arch i386 -arch x86_64 -mmacosx-version-min=10.5' 'LDFLAGS=-arch i386 -arch x86_64 -mmacosx-version-min=10.5'  CXXFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=10.5" && make
        make install DESTDIR=/tmp
179 180 181 182 183 184

The resulted library can be found in `/tmp/opt/local/lib`.