Add Joerg Mayer's macos-setup.sh script, modified to add an "x" after
[metze/wireshark/wip.git] / macosx-setup.sh
1 #!/bin/sh
2 # Setup development environment on Mac OS X (tested with 10.6.8 and Xcode 3.2.6)
3 #
4 # $Id$
5 #
6 # Trying to follow "Building Wireshark on SnowLeopard"
7 # given by Michael Tuexen at
8 # http://nplab.fh-muenster.de/groups/wiki/wiki/fb7a4/Building_Wireshark_on_SnowLeopard.html 
9 #
10
11 #
12 # Versions to download and install.
13 #
14 # These are required.
15 #
16 GETTEXT_VERSION=0.18.1.1
17 GLIB_VERSION=2.29.8
18 #
19 # pkg-config 0.26 appears to have broken the "we have our own GLib"
20 # stuff, even if you explicitly set GLIB_CFLAGS and GLIB_LIBS.
21 # Life's too short to work around the circular dependency in a script,
22 # so we use 0.25 instead.
23 #
24 PKG_CONFIG_VERSION=0.26
25 ATK_VERSION=2.0.1
26 PANGO_VERSION=1.29.3
27 GDK_PIXBUF_VERSION=2.23.4
28 GTK_VERSION=2.24.5
29
30 #
31 # These are optional.  Comment them out if you don't want them.
32 #
33 LIBSMI_VERSION=0.4.8
34 GEOIP_VERSION=1.4.5
35 #
36 # libgpg-error is required for libgcrypt.
37 #
38 LIBGPG_ERROR_VERSION=1.10
39 #
40 # libgcrypt is required for GnuTLS.
41 # XXX - the link for "Libgcrypt source code" at
42 # http://www.gnupg.org/download/#libgcrypt is for 1.5.0, and is a bzip2
43 # file, but http://directory.fsf.org/project/libgcrypt/ lists only
44 # 1.4.6.
45 #
46 LIBGCRYPT_VERSION=1.4.6
47 GNUTLS_VERSION=2.12.7
48 LUA_VERSION=5.1.4
49 PORTAUDIO_VERSION=pa_stable_v19_20110326
50 #
51 # XXX - they appear to have an unversioned gzipped tarball for the
52 # current version; should we just download that, with some other
53 # way of specifying whether to download the GeoIP API?
54 #
55 GEOIP_VERSION=1.4.8
56
57 #
58 # You need Xcode installed to get the compilers.
59 #
60 if [ ! -x /usr/bin/xcodebuild ]; then
61         echo "Please install Xcode first (should be available on DVD)."
62         exit 1
63 fi
64
65 #
66 # Do we have permission to write in /usr/local?
67 #
68 # If so, assume we have permission to write in its subdirectories.
69 # (If that's not the case, this test needs to check the subdirectories
70 # as well.)
71 #
72 # If not, do "make install" with sudo.
73 #
74 if [ -w /usr/local ]
75 then
76         DO_MAKE_INSTALL="make install"
77 else
78         DO_MAKE_INSTALL="sudo make install"
79 fi
80
81 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig
82
83 #
84 # Do all the downloads and untarring in a subdirectory, so all that
85 # stuff can be removed once we've installed the support libraries.
86 #
87 if [ ! -d macosx-support-libs ]
88 then
89         mkdir macosx-support-libs || exit 1
90 fi
91 cd macosx-support-libs
92
93 #
94 # Start with GNU gettext; GLib requires it, and OS X doesn't have it
95 # or a BSD-licensed replacement.
96 #
97 echo "Downloading, building, and installing GNU gettext:"
98 curl -O http://ftp.gnu.org/pub/gnu/gettext/gettext-$GETTEXT_VERSION.tar.gz || exit 1
99 tar xf gettext-$GETTEXT_VERSION.tar.gz || exit 1
100 cd gettext-$GETTEXT_VERSION
101 ./configure || exit 1
102 make -j 3 || exit 1
103 $DO_MAKE_INSTALL || exit 1
104 cd ..
105
106 echo "Downloading, building, and installing GLib:"
107 glib_dir=`expr $GLIB_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
108 curl -L -O http://ftp.gnome.org/pub/gnome/sources/glib/$glib_dir/glib-$GLIB_VERSION.tar.bz2 || exit 1
109 bzcat glib-$GLIB_VERSION.tar.bz2 | tar xf - || exit 1
110 cd glib-$GLIB_VERSION
111 #
112 # OS X ships with libffi, but doesn't provide its pkg-config file;
113 # explicitly specify LIBFFI_CFLAGS and LIBFFI_LIBS, so the configure
114 # script doesn't try to use pkg-config to get the appropriate
115 # CFLAGS and LIBS.
116 #
117 LIBFFI_CFLAGS="-I/usr/include/ffi" LIBFFI_LIBS="-L/usr/lib" ./configure || exit 1
118 #
119 # Mac OS X on 64-bit platforms provides libiconv, but in a form that
120 # confuses GLib.
121 #
122 patch -p1 < ../../macosx-support-lib-patches/glib-gconvert.patch || exit 1
123 make -j 3 || exit 1
124 # Apply patch: we depend on libffi, but pkg-config doesn't get told.
125 patch -p0 <../../macosx-support-lib-patches/glib-pkgconfig.patch || exit 1
126 $DO_MAKE_INSTALL || exit 1
127 cd ..
128
129 echo "Downloading, building, and installing pkg-config:"
130 curl -O http://pkgconfig.freedesktop.org/releases/pkg-config-$PKG_CONFIG_VERSION.tar.gz || exit 1
131 tar xf pkg-config-$PKG_CONFIG_VERSION.tar.gz || exit 1
132 cd pkg-config-$PKG_CONFIG_VERSION
133 # Avoid another pkgconfig call
134 GLIB_CFLAGS="-I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include" GLIB_LIBS="-L/usr/local/lib -lglib-2.0 -lintl" ./configure || exit 1
135 # ./configure || exit 1
136 make -j 3 || exit 1
137 $DO_MAKE_INSTALL || exit 1
138 cd ..
139
140 #
141 # Now we have reached a point where we can build everything but
142 # the GUI (Wireshark).
143 #
144
145 #
146 # Cairo is part of Mac OS X 10.6 (and, I think, 10.5).
147 # However, it's an X11 library; if we build with "native" GTK+ rather
148 # than X11 GTK+, we might have to build and install Cairo.
149 #
150 # echo "Downloading, building, and installing Cairo:"
151 # curl -O http://cairographics.org/releases/cairo-1.10.2.tar.gz || exit 1
152 # tar xvfz cairo-1.10.2.tar.gz || exit 1
153 # cd cairo-1.10.2
154 # ./configure --enable-quartz=no || exit 1
155 # make -j 3 || exit 1
156 # $DO_MAKE_INSTALL || exit 1
157 # cd ..
158
159 echo "Downloading, building, and installing ATK:"
160 atk_dir=`expr $ATK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
161 curl -O http://ftp.gnome.org/pub/gnome/sources/atk/$atk_dir/atk-$ATK_VERSION.tar.bz2 || exit 1
162 bzcat atk-$ATK_VERSION.tar.bz2 | tar xf - || exit 1
163 cd atk-$ATK_VERSION
164 ./configure || exit 1
165 make -j 3 || exit 1
166 $DO_MAKE_INSTALL || exit 1
167 cd ..
168
169 echo "Downloading, building, and installing Pango:"
170 pango_dir=`expr $PANGO_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
171 curl -L -O http://ftp.gnome.org/pub/gnome/sources/pango/$pango_dir/pango-$PANGO_VERSION.tar.bz2
172 bzcat pango-$PANGO_VERSION.tar.bz2 | tar xf - || exit 1
173 cd pango-$PANGO_VERSION
174 ./configure || exit 1
175 make -j 3 || exit 1
176 $DO_MAKE_INSTALL || exit 1
177 cd ..
178
179 echo "Downloading, building, and installing gdk-pixbuf:"
180 gdk_pixbuf_dir=`expr $GDK_PIXBUF_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
181 curl -L -O http://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/$gdk_pixbuf_dir/gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.bz2 || exit 1
182 bzcat gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.bz2 | tar xf - || exit 1
183 cd gdk-pixbuf-$GDK_PIXBUF_VERSION
184 ./configure --without-libtiff --without-libjpeg || exit 1
185 make -j 3 || exit 1
186 $DO_MAKE_INSTALL || exit 1
187 cd ..
188
189 echo "Downloading, building, and installing GTK+:"
190 gtk_dir=`expr $GTK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
191 curl -L -O http://ftp.gnome.org/pub/gnome/sources/gtk+/$gtk_dir/gtk+-$GTK_VERSION.tar.bz2
192 bzcat gtk+-$GTK_VERSION.tar.bz2 | tar xf - || exit 1
193 cd gtk+-$GTK_VERSION
194 ./configure || exit 1
195 make -j 3 || exit 1
196 $DO_MAKE_INSTALL || exit 1
197 cd ..
198
199 #
200 # Now we have reached a point where we can build everything including
201 # the GUI (Wireshark), but not with any optional features such as
202 # SNMP OID resolution, some forms of decryption, Lua scripting, playback
203 # of audio, or GeoIP mapping of IP addresses.
204 #
205 # We now conditionally download optional libraries to support them;
206 # the default is to download them all.
207 #
208
209 if [ ! -z $LIBSMI_VERSION ]
210 then
211         echo "Downloading, building, and installing libsmi:"
212         curl -L -O ftp://ftp.ibr.cs.tu-bs.de/pub/local/libsmi/libsmi-$LIBSMI_VERSION.tar.gz || exit 1
213         tar xf libsmi-$LIBSMI_VERSION.tar.gz || exit 1
214         cd libsmi-$LIBSMI_VERSION
215         ./configure || exit 1
216         make -j 3 || exit 1
217         $DO_MAKE_INSTALL || exit 1
218         cd ..
219 fi
220
221 if [ ! -z $LIBGPG_ERROR_VERSION ]
222 then
223         echo "Downloading, building, and installing libgpg-error:"
224         curl -L -O ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 || exit 1
225         bzcat libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 | tar xf - || exit 1
226         cd libgpg-error-$LIBGPG_ERROR_VERSION
227         ./configure || exit 1
228         make -j 3 || exit 1
229         $DO_MAKE_INSTALL || exit 1
230         cd ..
231 fi
232
233 if [ ! -z $LIBGCRYPT_VERSION ]
234 then
235         #
236         # libgpg-error is required for libgcrypt.
237         #
238         if [ -z $LIBGPG_ERROR_VERSION ]
239         then
240                 echo "libgcrypt requires libgpg-error, but you didn't install libgpg-error." 1>&2
241                 exit 1
242         fi
243
244         echo "Downloading, building, and installing libgcrypt:"
245         curl -L -O ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-$LIBGCRYPT_VERSION.tar.gz || exit 1
246         tar xf libgcrypt-$LIBGCRYPT_VERSION.tar.gz || exit 1
247         cd libgcrypt-$LIBGCRYPT_VERSION
248         #
249         # The assembler language code is not compatible with the OS X
250         # x86 assembler (or is it an x86-64 vs. x86-32 issue?).
251         #
252         ./configure --disable-asm || exit 1
253         make -j 3 || exit 1
254         $DO_MAKE_INSTALL || exit 1
255         cd ..
256 fi
257
258 if [ ! -z $GNUTLS_VERSION ]
259 then
260         #
261         # GnuTLS requires libgcrypt (or nettle, in newer versions).
262         #
263         if [ -z $LIBGCRYPT_VERSION ]
264         then
265                 echo "GnuTLS requires libgcrypt, but you didn't install libgcrypt" 1>&2
266                 exit 1
267         fi
268
269         echo "Downloading, building, and installing GnuTLS:"
270         curl -L -O http://ftp.gnu.org/gnu/gnutls/gnutls-$GNUTLS_VERSION.tar.bz2 || exit 1
271         bzcat gnutls-$GNUTLS_VERSION.tar.bz2 | tar xf - || exit 1
272         cd gnutls-$GNUTLS_VERSION
273         #
274         # Use libgcrypt, not nettle.
275         # XXX - is there some reason to prefer nettle?  Or does
276         # Wireshark directly use libgcrypt routines?
277         #
278         ./configure --with-libgcrypt || exit 1
279         make -j 3 || exit 1
280         $DO_MAKE_INSTALL || exit 1
281         cd ..
282 fi
283
284 if [ ! -z $LUA_VERSION ]
285 then
286         echo "Downloading, building, and installing Lua:"
287         curl -L -O http://www.lua.org/ftp/lua-$LUA_VERSION.tar.gz || exit 1
288         tar xf lua-$LUA_VERSION.tar.gz || exit 1
289         cd lua-$LUA_VERSION
290         make -j 3 macosx || exit 1
291         $DO_MAKE_INSTALL || exit 1
292         cd ..
293 fi
294
295 if [ ! -z $PORTAUDIO_VERSION ]
296 then
297         echo "Downloading, building, and installing PortAudio:"
298         curl -L -O http://www.portaudio.com/archives/$PORTAUDIO_VERSION.tgz || exit 1
299         tar xf $PORTAUDIO_VERSION.tgz || exit 1
300         cd portaudio
301         ./configure || exit 1
302         make -j 3 || exit 1
303         $DO_MAKE_INSTALL || exit 1
304         cd ..
305 fi
306
307 if [ ! -z $GEOIP_VERSION ]
308 then
309         echo "Downloading, building, and installing GeoIP API:"
310         curl -L -O http://geolite.maxmind.com/download/geoip/api/c/GeoIP-$GEOIP_VERSION.tar.gz || exit 1
311         tar xf GeoIP-$GEOIP_VERSION.tar.gz || exit 1
312         cd GeoIP-$GEOIP_VERSION
313         ./configure || exit 1
314         make -j 3 || exit 1
315         $DO_MAKE_INSTALL || exit 1
316         cd ..
317 fi
318
319 echo ""
320
321 echo "You are now prepared to build Wireshark. To do so do:"
322 echo "Download Wireshark source"
323 echo "./autogen.sh"
324 echo "./configure"
325 echo "make -j 3"
326 echo "make install"
327
328 echo ""
329
330 echo "Make sure you are allowed capture access to the network devices"
331 echo "See: http://wiki.wireshark.org/CaptureSetup/CapturePrivileges"
332
333 echo ""
334
335 exit 0