Code

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