1 #!/bin/sh
2 #
3 # Based on the Imendio 'build-gtk.sh' script.
4 #
5 # Inkscape build additions by Michael Wybrow <mjwybrow@users.sf.net>
6 #
7 # See the following page for build instructions:
8 # http://developer.imendio.com/projects/gtk-macosx/build-instructions
9 #
10 # Usage:
11 # export PREFIX=/your/install/prefix
12 # ./build-gtk bootstrap
13 # ./build-gtk build inkscape
14 #
17 version=1.2-inkscape
19 export PREFIX=${PREFIX-/opt/gtk}
20 export PATH=$PREFIX/bin:$PATH
21 #export PATH=$PREFIX/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:
22 export LIBTOOLIZE=$PREFIX/bin/libtoolize
24 # FIXME: We might need some more intelligent way to get the path here.
25 export PYTHONPATH=$PREFIX/lib/python2.3/site-packages
27 # Needed for glib etc to pick up gettext
28 export LDFLAGS=-L$PREFIX/lib
29 export CPPFLAGS=-I$PREFIX/include
31 export XDG_DATA_DIRS=$PREFIX/share
33 # Support install-check from jhbuild to speed up compilation
34 if [ -x $PREFIX/bin/install-check ]; then
35 export INSTALL=$PREFIX/bin/install-check
36 fi
38 COMMON_OPTIONS="--prefix=$PREFIX --disable-static --enable-shared \
39 --disable-gtk-doc --disable-scrollkeeper"
41 SOURCE=${SOURCE-$HOME/Source/gtk}
42 GNOMECVSROOT=${GNOMECVSROOT-:pserver:anonymous@anoncvs.gnome.org:/cvs/gnome}
43 CAIROCVSROOT=${CAIROCVSROOT-:pserver:anoncvs@cvs.freedesktop.org:/cvs/cairo}
44 INKSCAPEREPURL="https://svn.sourceforge.net/svnroot/inkscape/inkscape/trunk"
46 if [ x$1 = xrun ]; then
47 cmd="$2"
48 shift 2
49 exec $cmd $*
50 fi
52 if [ $# -eq 0 -o "x`echo "$*" | grep shell`" = xshell ]; then
53 # Can be used in .bashrc to set a fancy prompt...
54 export INSIDE_GTK_BUILD=1
55 bash
56 exit 0
57 fi
59 CORE_MODULES="cairo gnome-common glib pango atk gtk+"
60 EXTRA_MODULES="libxml2 libxslt loudmouth libglade gossip gtk-engines"
61 PYGTK_MODULES=" pycairo pygobject pygtk"
62 INKSCAPE_MODULES="$CORE_MODULES libxml2 libxslt gc lcms libsig++ doxygen glibmm cairomm gtkmm popt inkscape"
64 # Could add those (orbit requires popt though)
65 MORE_MODULES="libIDL ORBit2 gconf"
67 function print_usage
68 {
69 echo
70 echo "GTK+ on Mac OS X build script version $version."
71 echo
72 echo "Usage:"
73 echo "`basename $0` [bootstrap|[shell]|run <cmd>|build [<modules>]], modules are:"
74 echo " Core: $CORE_MODULES"
75 echo " Extra: $EXTRA_MODULES"
76 echo " Python: $PYGTK_MODULES"
77 echo " Inkscape: $INKSCAPE_MODULES"
78 echo
79 echo "Setup: This script defaults to downloading source to ~/Source/gtk and"
80 echo "installing in /opt/gtk. Make sure your user has write access to the"
81 echo "latter directory. You can override those directories by setting the"
82 echo "SOURCE and PREFIX environment variables. Anoncvs is used by default"
83 echo "for access to GNOME CVS, if you wish to override, set the environment"
84 echo "variable GNOMECVSROOT to your own account."
85 echo
86 echo "While in the shell that this script provides, the environment variable"
87 echo "INSIDE_GTK_BUILD is set, which makes it possible to put something like"
88 echo "the following in ~/.bashrc:"
89 echo
90 echo " if [ x\$INSIDE_GTK_BUILD != x ]; then"
91 echo " PS1=\"[GTK] \u@\h \W $ \""
92 echo " fi"
93 echo
94 echo "Start by bootstrapping. This will install the necessary build tools."
95 echo "Then build GTK+ & co by using the \"build\" command. If no modules are"
96 echo "specified, only the ones needed for GTK+ will be built. The special"
97 echo "modules \"core\" and \"all\" can be used to build just the core or all"
98 echo "modules."
99 echo
100 echo "If you want to build something manually or run something, use the "
101 echo "\"shell\" command (or no command) to get a shell with the environment"
102 echo "properly setup."
103 echo
104 echo "Tip: if you build and install \"install-check\" from jhbuild into your"
105 echo "PREFIX, recompiling when hacking on GTK+ & co will be a lot faster."
106 echo
107 }
109 function download
110 {
111 BASENAME=`basename $1`
113 if [ -s $BASENAME ]; then
114 echo "Already downloaded"
115 return 0
116 fi
118 curl $1 > $BASENAME || return 1
120 return 0
121 }
123 function should_build
124 {
125 if [ -f $1/BUILT ]; then
126 echo "Already built"
127 return 1
128 fi
130 return 0
131 }
133 function tarball_get_and_build
134 {
135 BASENAME=`basename $1`
136 DIRNAME=`echo $BASENAME | sed -e s,.src.,., | sed -e s,.tar.*,,`
137 INSTCMD="make install"
138 PREFIXARG="--prefix=$PREFIX"
139 COMMONOPTS="$COMMON_OPTIONS"
141 echo
142 echo "Building $DIRNAME"
143 echo -ne "\033]0;Building $DIRNAME\007"
145 # Special case jpeg... :/
146 if [ x`echo $DIRNAME | grep jpeg` != x ]; then
147 INSTCMD="make install-lib"
148 fi
150 if [ x`echo $BASENAME | grep bz2` != x ]; then
151 COMP="j"
152 else
153 COMP="z"
154 fi
156 # Doxygen doesn't have a standard configure script.
157 if [ x`echo $BASENAME | grep doxygen` != x ]; then
158 PREFIXARG="--prefix $PREFIX"
159 COMMONOPTS="--shared"
160 fi
162 cd $SOURCE || return 1
163 download $1 || return 1
164 should_build $DIRNAME || return 0
165 tar ${COMP}xf $BASENAME && \
166 cd $DIRNAME && \
167 echo "./configure $PREFIXARG $COMMONOPTS $2" && \
168 ./configure $PREFIXARG $COMMONOPTS $2 && make && $INSTCMD && touch BUILT
169 }
171 function cpan_get_and_build
172 {
173 BASENAME=`basename $1`
174 DIRNAME=`echo $BASENAME | sed -e s,.tar.*,,`
176 echo
177 echo "Building $DIRNAME"
178 echo -ne "\033]0;Building $DIRNAME\007"
180 if [ x`echo $BASENAME | grep bz2` != x ]; then
181 COMP="j"
182 else
183 COMP="z"
184 fi
186 cd $SOURCE || return 1
187 download $1 || return 1
188 should_build $DIRNAME || return 0
189 tar ${COMP}xf $BASENAME && \
190 cd $DIRNAME && \
191 perl Makefile.PL $2 && \
192 make && \
193 (echo "Enter your password to istall $BASENAME"; make install) && \
194 touch BUILT
195 }
197 function git_get_and_build
198 {
199 if !(echo "$MODULES" | grep -w $2) >/dev/null; then
200 return 0
201 fi
203 echo
204 echo "Building $2"
205 echo -ne "\033]0;Building $2\007"
207 cd $SOURCE
208 if [ -d $2 ]; then
209 cd $2
210 cg-update || return
211 else
212 cg-clone $1/$2 || return
213 cd $2
214 fi
216 echo "./autogen.sh $COMMON_OPTIONS $3"
217 (./autogen.sh $COMMON_OPTIONS $3 && make && make install)
218 }
220 function cvs_get_and_build
221 {
222 if !(echo "$MODULES" | grep -w $2) >/dev/null; then
223 return 0
224 fi
226 echo
227 echo "Building $2"
228 echo -ne "\033]0;Building $2\007"
230 cd $SOURCE
231 if [ -d $2 ]; then
232 cd $2
233 cvs up -dP || return
234 else
235 cvs -d $1 co -P $2 || return
236 cd $2
237 fi
239 echo "./autogen.sh $COMMON_OPTIONS $3"
240 (./autogen.sh $COMMON_OPTIONS $3 && make && make install)
241 }
243 function svn_get_and_build
244 {
245 if !(echo "$MODULES" | grep -w $2) >/dev/null; then
246 return 0
247 fi
249 echo
250 echo "Building $2"
251 echo -ne "\033]0;Building $2\007"
253 cd $SOURCE
254 if [ -d $2 ]; then
255 cd $2
256 svn up || return
257 else
258 svn co $1 $2 || return
259 cd $2
260 fi
262 echo "./autogen.sh $COMMON_OPTIONS $3"
263 (./autogen.sh $COMMON_OPTIONS $3 && ./configure --prefix=$PREFIX $COMMON_OPTIONS $3 && make && make install)
264 }
266 function set_automake
267 {
268 old_AUTOMAKE=$AUTOMAKE
269 old_ACLOCAL=$ACLOCAL
271 export AUTOMAKE=automake-$1
272 export ACLOCAL=aclocal-$1
273 }
275 function restore_automake
276 {
277 if [ x$old_AUTOMAKE != x ]; then
278 export AUTOMAKE=$old_AUTOMAKE
279 else
280 unset AUTOMAKE
281 fi
283 if [ x$old_ACLOCAL != x ]; then
284 export ACLOCAL=$old_ACLOCAL
285 else
286 unset ACLOCAL
287 fi
288 }
290 function do_exit
291 {
292 echo -ne "\033]0;\007"
293 exit
294 }
296 # Make sure to restore the title when done.
297 trap do_exit EXIT SIGINT SIGTERM
299 if (echo "$*" | grep bootstrap) >/dev/null; then
300 if [ "x`cg-version 2>/dev/null`" == "x" ]; then
301 echo "You need the cogito to get cairo from git. It's available e.g. in Darwin ports."
302 exit 1
303 fi
304 if [ "x`which svn 2>/dev/null`" == "x" ]; then
305 echo "You need the svn client to get inkscape."
306 exit 1
307 fi
309 mkdir -p $SOURCE 2>/dev/null || (echo "Error: Couldn't create source checkout dir $SOURCE"; exit 1)
310 mkdir -p $PREFIX/bin 2>/dev/null || (echo "Error: Couldn't create bin dir $PREFIX/bin"; exit 1)
312 echo "Building bootstrap packages."
314 PACKAGES=" \
315 http://pkgconfig.freedesktop.org/releases/pkg-config-0.20.tar.gz \
316 http://ftp.gnu.org/gnu/libtool/libtool-1.5.22.tar.gz \
317 http://ftp.gnu.org/gnu/autoconf/autoconf-2.59.tar.bz2 \
318 http://ftp.gnu.org/pub/gnu/automake/automake-1.7.9.tar.bz2 \
319 http://ftp.gnu.org/gnu/automake/automake-1.9.6.tar.bz2 \
320 http://heanet.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.12.tar.bz2 \
321 ftp://ftp.remotesensing.org/pub/libtiff/tiff-3.8.2.tar.gz \
322 http://people.imendio.com/richard/gtk-osx/files/jpeg-6b.tar.gz \
323 http://ftp.gnu.org/gnu/gettext/gettext-0.14.5.tar.gz \
324 http://heanet.dl.sourceforge.net/sourceforge/expat/expat-2.0.0.tar.gz \
325 http://heanet.dl.sourceforge.net/sourceforge/freetype/freetype-2.1.10.tar.bz2 \
326 http://fontconfig.org/release/fontconfig-2.3.2.tar.gz \
327 http://people.imendio.com/richard/gtk-osx/files/docbook-files-1.tar.gz \
328 http://www.cs.mu.oz.au/~mjwybrow/gtk-osx/gnome-doc-utils-fake-1.tar.gz \
329 "
331 #http://people.imendio.com/richard/gtk-osx/files/popt-1.7.tar.gz
333 for PACKAGE in $PACKAGES; do
334 tarball_get_and_build $PACKAGE || exit 1
335 done
337 PACKAGE=http://ftp.gnome.org/pub/GNOME/sources/gtk-doc/1.6/gtk-doc-1.6.tar.bz2
338 tarball_get_and_build $PACKAGE "--with-xml-catalog=$PREFIX/etc/xml/catalog" || exit 1
340 PACKAGE=ftp://ftp4.freebsd.org/pub/FreeBSD/ports/distfiles/XML-Parser-2.34.tar.gz
341 cpan_get_and_build $PACKAGE "PREFIX=$PREFIX INSTALLDIRS=perl EXPATLIBPATH=$PREFIX/lib EXPATINCPATH=$PREFIX/include" || exit 1
343 PACKAGES=" \
344 http://ftp.gnome.org/pub/GNOME/sources/intltool/0.35/intltool-0.35.0.tar.bz2 \
345 http://icon-theme.freedesktop.org/releases/hicolor-icon-theme-0.9.tar.gz \
346 http://ftp.gnome.org/pub/GNOME/sources/gnome-icon-theme/2.14/gnome-icon-theme-2.14.2.tar.bz2 \
347 "
349 for PACKAGE in $PACKAGES; do
350 tarball_get_and_build $PACKAGE || exit 1
351 done
353 # Setup glibtool* links since some stuff expects them to be named like that on OSX
354 if [ -z $PREFIX/bin/glibtoolize ]; then
355 ln -s $PREFIX/bin/libtoolize $PREFIX/bin/glibtoolize
356 ln -s $PREFIX/bin/libtool $PREFIX/bin/glibtool
357 fi
359 echo
360 echo "Done bootstrapping. Continue with \"build\" or \"shell\"."
361 exit 0
362 fi
364 if [ "x$1" != xbuild ]; then
365 print_usage
366 exit 1
367 fi
369 shift
371 MODULES=$*
372 if [ $# -eq 0 ]; then
373 echo "Building core modules."
374 MODULES="$CORE_MODULES"
375 elif [ "x$1" = xcore ]; then
376 echo "Building core modules."
377 MODULES="$CORE_MODULES"
378 elif [ "x$1" = xpython ]; then
379 echo "Building python modules."
380 MODULES="$PYGTK_MODULES"
381 elif [ "x$1" = xall ]; then
382 echo "Building core+extra+python modules."
383 MODULES="$CORE_MODULES $EXTRA_MODULES $PYGTK_MODULES"
384 elif [ "x$1" = xinkscape ]; then
385 echo "Building inkscape modules."
386 MODULES="$INKSCAPE_MODULES"
387 fi
389 git_get_and_build git://git.cairographics.org/git cairo "--enable-pdf --enable-atsui --enable-quartz --disable-xlib" || exit 1
391 tarball_get_and_build http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gc6.7.tar.gz || exit 1
392 tarball_get_and_build http://www.littlecms.com/lcms-1.15.tar.gz || exit 1
393 tarball_get_and_build ftp://ftp.gnome.org/mirror/gnome.org/sources/libsigc++/2.0/libsigc++-2.0.17.tar.gz || exit 1
394 tarball_get_and_build http://ftp.stack.nl/pub/users/dimitri/doxygen-1.5.1.src.tar.gz || exit 1
395 tarball_get_and_build ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.1.x/popt-1.7.tar.gz || exit 1
397 cvs_get_and_build $GNOMECVSROOT libxml2 || exit 1
398 cvs_get_and_build $GNOMECVSROOT libxslt || exit 1
399 cvs_get_and_build $GNOMECVSROOT gnome-common || exit 1
400 cvs_get_and_build $GNOMECVSROOT glib || exit 1
401 cvs_get_and_build $GNOMECVSROOT atk || exit 1
402 cvs_get_and_build $GNOMECVSROOT pango "--without-x" || exit 1
403 cvs_get_and_build $GNOMECVSROOT gtk+ "--with-gdktarget=quartz" || exit 1
404 cvs_get_and_build $GNOMECVSROOT gtk-engines || exit 1
405 cvs_get_and_build $GNOMECVSROOT loudmouth "--with-ssl=openssl" || exit 1
406 cvs_get_and_build $GNOMECVSROOT libglade || exit 1
407 # gossip needs xml2po from gnome-doc-utils.
408 cvs_get_and_build $GNOMECVSROOT gossip "--with-backend=cocoa" || exit 1
409 cvs_get_and_build $CAIROCVSROOT pycairo || exit 1
410 cvs_get_and_build $GNOMECVSROOT pygobject "--disable-docs" || exit 1
411 cvs_get_and_build $GNOMECVSROOT pygtk "--disable-docs" || exit 1
413 cvs_get_and_build $GNOMECVSROOT glibmm "--disable-docs --disable-fulldocs" || exit 1
414 cvs_get_and_build $CAIROCVSROOT cairomm || exit 1
415 cvs_get_and_build $GNOMECVSROOT gtkmm "--disable-docs --disable-examples --disable-demos" || exit 1
417 svn_get_and_build $INKSCAPEREPURL inkscape || exit 1
419 #cvs_get_and_build $GNOMECVSROOT gimp || exit 1
420 # For gimp:
421 # libart_lgpl, needs automake 1.4 and doesn't run libtoolize
422 # gtkhtml2 (optional)
423 # libpoppler (optional)
424 # ./autogen.sh --prefix=/opt/gimp --disable-gtk-doc
426 echo "Done."