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