Remove a duplicate entry
[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.8
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
56 #
57 # You need Xcode installed to get the compilers.
58 #
59 if [ ! -x /usr/bin/xcodebuild ]; then
60         echo "Please install Xcode first (should be available on DVD or from http://developer.apple.com/xcode/index.php)."
61         exit 1
62 fi
63
64 #
65 # You also need the X11 SDK; with at least some versions of OS X and
66 # Xcode, that is, I think, an optional install.  (Or it might be
67 # installed with X11, but I think *that* is an optional install on
68 # at least some versions of OS X.)
69 #
70 if [ ! -d /usr/X11/include ]; then
71         echo "Please install X11 and the X11 SDK first."
72         exit 1
73 fi
74
75 #
76 # Do we have permission to write in /usr/local?
77 #
78 # If so, assume we have permission to write in its subdirectories.
79 # (If that's not the case, this test needs to check the subdirectories
80 # as well.)
81 #
82 # If not, do "make install" with sudo.
83 #
84 if [ -w /usr/local ]
85 then
86         DO_MAKE_INSTALL="make install"
87 else
88         DO_MAKE_INSTALL="sudo make install"
89 fi
90
91 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig
92
93 #
94 # Do all the downloads and untarring in a subdirectory, so all that
95 # stuff can be removed once we've installed the support libraries.
96 #
97 if [ ! -d macosx-support-libs ]
98 then
99         mkdir macosx-support-libs || exit 1
100 fi
101 cd macosx-support-libs
102
103 #
104 # Start with GNU gettext; GLib requires it, and OS X doesn't have it
105 # or a BSD-licensed replacement.
106 #
107 # At least on Lion with Xcode 4, _FORTIFY_SOURCE gets defined as 2
108 # by default, which causes, for example, stpncpy to be defined as
109 # a hairy macro that collides with the GNU gettext configure script's
110 # attempts to workaround AIX's lack of a declaration for stpncpy,
111 # with the result being a huge train wreck.  Define _FORTIFY_SOURCE
112 # as 0 in an attempt to keep the trains on separate tracks.
113 #
114 echo "Downloading, building, and installing GNU gettext:"
115 curl -O http://ftp.gnu.org/pub/gnu/gettext/gettext-$GETTEXT_VERSION.tar.gz || exit 1
116 tar xf gettext-$GETTEXT_VERSION.tar.gz || exit 1
117 cd gettext-$GETTEXT_VERSION
118 CFLAGS="-D_FORTIFY_SOURCE=0" ./configure || exit 1
119 make -j 3 || exit 1
120 $DO_MAKE_INSTALL || exit 1
121 cd ..
122
123 echo "Downloading, building, and installing GLib:"
124 glib_dir=`expr $GLIB_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
125 curl -L -O http://ftp.gnome.org/pub/gnome/sources/glib/$glib_dir/glib-$GLIB_VERSION.tar.bz2 || exit 1
126 bzcat glib-$GLIB_VERSION.tar.bz2 | tar xf - || exit 1
127 cd glib-$GLIB_VERSION
128 #
129 # OS X ships with libffi, but doesn't provide its pkg-config file;
130 # explicitly specify LIBFFI_CFLAGS and LIBFFI_LIBS, so the configure
131 # script doesn't try to use pkg-config to get the appropriate
132 # CFLAGS and LIBS.
133 #
134 LIBFFI_CFLAGS="-I/usr/include/ffi" LIBFFI_LIBS="-L/usr/lib" ./configure || exit 1
135 #
136 # Mac OS X on 64-bit platforms provides libiconv, but in a form that
137 # confuses GLib.
138 #
139 patch -p1 < ../../macosx-support-lib-patches/glib-gconvert.patch || exit 1
140 make -j 3 || exit 1
141 # Apply patch: we depend on libffi, but pkg-config doesn't get told.
142 patch -p0 <../../macosx-support-lib-patches/glib-pkgconfig.patch || exit 1
143 $DO_MAKE_INSTALL || exit 1
144 cd ..
145
146 echo "Downloading, building, and installing pkg-config:"
147 curl -O http://pkgconfig.freedesktop.org/releases/pkg-config-$PKG_CONFIG_VERSION.tar.gz || exit 1
148 tar xf pkg-config-$PKG_CONFIG_VERSION.tar.gz || exit 1
149 cd pkg-config-$PKG_CONFIG_VERSION
150 # Avoid another pkgconfig call
151 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
152 # ./configure || exit 1
153 make -j 3 || exit 1
154 $DO_MAKE_INSTALL || exit 1
155 cd ..
156
157 #
158 # Now we have reached a point where we can build everything but
159 # the GUI (Wireshark).
160 #
161
162 #
163 # Cairo is part of Mac OS X 10.6 (and, I think, 10.5).
164 # However, it's an X11 library; if we build with "native" GTK+ rather
165 # than X11 GTK+, we might have to build and install Cairo.
166 #
167 # echo "Downloading, building, and installing Cairo:"
168 # curl -O http://cairographics.org/releases/cairo-1.10.2.tar.gz || exit 1
169 # tar xvfz cairo-1.10.2.tar.gz || exit 1
170 # cd cairo-1.10.2
171 # ./configure --enable-quartz=no || exit 1
172 # make -j 3 || exit 1
173 # $DO_MAKE_INSTALL || exit 1
174 # cd ..
175
176 echo "Downloading, building, and installing ATK:"
177 atk_dir=`expr $ATK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
178 curl -O http://ftp.gnome.org/pub/gnome/sources/atk/$atk_dir/atk-$ATK_VERSION.tar.bz2 || exit 1
179 bzcat atk-$ATK_VERSION.tar.bz2 | tar xf - || exit 1
180 cd atk-$ATK_VERSION
181 ./configure || exit 1
182 make -j 3 || exit 1
183 $DO_MAKE_INSTALL || exit 1
184 cd ..
185
186 echo "Downloading, building, and installing Pango:"
187 pango_dir=`expr $PANGO_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
188 curl -L -O http://ftp.gnome.org/pub/gnome/sources/pango/$pango_dir/pango-$PANGO_VERSION.tar.bz2
189 bzcat pango-$PANGO_VERSION.tar.bz2 | tar xf - || exit 1
190 cd pango-$PANGO_VERSION
191 ./configure || exit 1
192 make -j 3 || exit 1
193 $DO_MAKE_INSTALL || exit 1
194 cd ..
195
196 echo "Downloading, building, and installing gdk-pixbuf:"
197 gdk_pixbuf_dir=`expr $GDK_PIXBUF_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
198 curl -L -O http://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/$gdk_pixbuf_dir/gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.bz2 || exit 1
199 bzcat gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.bz2 | tar xf - || exit 1
200 cd gdk-pixbuf-$GDK_PIXBUF_VERSION
201 ./configure --without-libtiff --without-libjpeg || exit 1
202 make -j 3 || exit 1
203 $DO_MAKE_INSTALL || exit 1
204 cd ..
205
206 echo "Downloading, building, and installing GTK+:"
207 gtk_dir=`expr $GTK_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'`
208 curl -L -O http://ftp.gnome.org/pub/gnome/sources/gtk+/$gtk_dir/gtk+-$GTK_VERSION.tar.bz2
209 bzcat gtk+-$GTK_VERSION.tar.bz2 | tar xf - || exit 1
210 cd gtk+-$GTK_VERSION
211 ./configure || exit 1
212 make -j 3 || exit 1
213 $DO_MAKE_INSTALL || exit 1
214 cd ..
215
216 #
217 # Now we have reached a point where we can build everything including
218 # the GUI (Wireshark), but not with any optional features such as
219 # SNMP OID resolution, some forms of decryption, Lua scripting, playback
220 # of audio, or GeoIP mapping of IP addresses.
221 #
222 # We now conditionally download optional libraries to support them;
223 # the default is to download them all.
224 #
225
226 if [ ! -z $LIBSMI_VERSION ]
227 then
228         echo "Downloading, building, and installing libsmi:"
229         curl -L -O ftp://ftp.ibr.cs.tu-bs.de/pub/local/libsmi/libsmi-$LIBSMI_VERSION.tar.gz || exit 1
230         tar xf libsmi-$LIBSMI_VERSION.tar.gz || exit 1
231         cd libsmi-$LIBSMI_VERSION
232         ./configure || exit 1
233         make -j 3 || exit 1
234         $DO_MAKE_INSTALL || exit 1
235         cd ..
236 fi
237
238 if [ ! -z $LIBGPG_ERROR_VERSION ]
239 then
240         echo "Downloading, building, and installing libgpg-error:"
241         curl -L -O ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 || exit 1
242         bzcat libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 | tar xf - || exit 1
243         cd libgpg-error-$LIBGPG_ERROR_VERSION
244         ./configure || exit 1
245         make -j 3 || exit 1
246         $DO_MAKE_INSTALL || exit 1
247         cd ..
248 fi
249
250 if [ ! -z $LIBGCRYPT_VERSION ]
251 then
252         #
253         # libgpg-error is required for libgcrypt.
254         #
255         if [ -z $LIBGPG_ERROR_VERSION ]
256         then
257                 echo "libgcrypt requires libgpg-error, but you didn't install libgpg-error." 1>&2
258                 exit 1
259         fi
260
261         echo "Downloading, building, and installing libgcrypt:"
262         curl -L -O ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-$LIBGCRYPT_VERSION.tar.gz || exit 1
263         tar xf libgcrypt-$LIBGCRYPT_VERSION.tar.gz || exit 1
264         cd libgcrypt-$LIBGCRYPT_VERSION
265         #
266         # The assembler language code is not compatible with the OS X
267         # x86 assembler (or is it an x86-64 vs. x86-32 issue?).
268         #
269         ./configure --disable-asm || exit 1
270         make -j 3 || exit 1
271         $DO_MAKE_INSTALL || exit 1
272         cd ..
273 fi
274
275 if [ ! -z $GNUTLS_VERSION ]
276 then
277         #
278         # GnuTLS requires libgcrypt (or nettle, in newer versions).
279         #
280         if [ -z $LIBGCRYPT_VERSION ]
281         then
282                 echo "GnuTLS requires libgcrypt, but you didn't install libgcrypt" 1>&2
283                 exit 1
284         fi
285
286         echo "Downloading, building, and installing GnuTLS:"
287         curl -L -O http://ftp.gnu.org/gnu/gnutls/gnutls-$GNUTLS_VERSION.tar.bz2 || exit 1
288         bzcat gnutls-$GNUTLS_VERSION.tar.bz2 | tar xf - || exit 1
289         cd gnutls-$GNUTLS_VERSION
290         #
291         # Use libgcrypt, not nettle.
292         # XXX - is there some reason to prefer nettle?  Or does
293         # Wireshark directly use libgcrypt routines?
294         #
295         ./configure --with-libgcrypt || exit 1
296         make -j 3 || exit 1
297         #
298         # The pkgconfig file for GnuTLS says "requires zlib", but OS X,
299         # while it supplies zlib, doesn't supply a pkgconfig file for
300         # it.
301         #
302         # Patch the GnuTLS pkgconfig file not to require zlib.
303         #
304         patch -p0 lib/gnutls.pc <../../macosx-support-lib-patches/gnutls-pkgconfig.patch || exit 1
305         $DO_MAKE_INSTALL || exit 1
306         cd ..
307 fi
308
309 if [ ! -z $LUA_VERSION ]
310 then
311         echo "Downloading, building, and installing Lua:"
312         curl -L -O http://www.lua.org/ftp/lua-$LUA_VERSION.tar.gz || exit 1
313         tar xf lua-$LUA_VERSION.tar.gz || exit 1
314         cd lua-$LUA_VERSION
315         make -j 3 macosx || exit 1
316         $DO_MAKE_INSTALL || exit 1
317         cd ..
318 fi
319
320 if [ ! -z $PORTAUDIO_VERSION ]
321 then
322         echo "Downloading, building, and installing PortAudio:"
323         curl -L -O http://www.portaudio.com/archives/$PORTAUDIO_VERSION.tgz || exit 1
324         tar xf $PORTAUDIO_VERSION.tgz || exit 1
325         cd portaudio
326         ./configure || exit 1
327         make -j 3 || exit 1
328         $DO_MAKE_INSTALL || exit 1
329         cd ..
330 fi
331
332 if [ ! -z $GEOIP_VERSION ]
333 then
334         echo "Downloading, building, and installing GeoIP API:"
335         curl -L -O http://geolite.maxmind.com/download/geoip/api/c/GeoIP-$GEOIP_VERSION.tar.gz || exit 1
336         tar xf GeoIP-$GEOIP_VERSION.tar.gz || exit 1
337         cd GeoIP-$GEOIP_VERSION
338         ./configure || exit 1
339         make -j 3 || exit 1
340         $DO_MAKE_INSTALL || exit 1
341         cd ..
342 fi
343
344 echo ""
345
346 echo "You are now prepared to build Wireshark. To do so do:"
347 echo "./autogen.sh"
348 echo "./configure"
349 echo "make -j 3"
350 echo "make install"
351
352 echo ""
353
354 echo "Make sure you are allowed capture access to the network devices"
355 echo "See: http://wiki.wireshark.org/CaptureSetup/CapturePrivileges"
356
357 echo ""
358
359 exit 0