4eb951f573d9e9fad66579a4e03eada8e55d69fe
[synfig.git] / synfigstudio-linux-build.sh
1 #!/bin/bash
2 #
3 # SynfigStudio build script
4 # Copyright (c) 2008-2010 Konstantin Dmitriev
5 #
6 # This package is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation; either version 2 of
9 # the License, or (at your option) any later version.
10 #
11 # This package is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
15
16 # = Usage: =
17 #    ./synfigstudio-linux-build.sh [mode] [revision]
18 #
19 # where:
20 #   - [mode] is full|quick|package
21 #   - [revision] - commit id, branch or tag (package mode only)
22 #
23 # To build packages it's required to run this script as root.
24 #
25 # = Examples: =
26 #
27 # == Standart mode ==
28 # Configure and (re)build synfigstudio into your homedir:
29 #    ./synfigstudio-linux-build.sh
30 # Configure and make clean build synfigstudio into your homedir:
31 #    ./synfigstudio-linux-build.sh full
32 # Quick rebuild of synfig (without configure) into your homedir:
33 #    ./synfigstudio-linux-build.sh quick
34 #
35 # == Package mode ==
36 # Build package from "master" branch:
37 #    ./synfigstudio-linux-build.sh package
38 # Build package from "genete_setup_dialog" branch
39 #    ./synfigstudio-linux-build.sh package origin/genete_setup_dialog
40 # Build package from commit with "synfigstudio-0.62.00" tag
41 #    ./synfigstudio-linux-build.sh package synfigstudio-0.62.00
42 #
43 # = TODO =
44 # - debuginfo packages
45
46 RELEASE=1
47 PREFIX=$HOME/synfig/
48
49 PACKAGES_PATH=$HOME/synfig-packages             # path where to write packages files
50 PACKAGES_BUILDROOT=/tmp/synfig-buildroot        # path of for build infrastructure
51
52 # full = clean, configure, make
53 # standart = configure, make
54 # quick = make
55 # package = chroot, clean, configure, make
56 MODE='standart'
57 OPENGL=0
58 DEBUG=0
59 BREED=
60
61 LIBSIGCPP=2.0.17
62 GLEW=1.5.1
63 CAIROMM=1.2.4
64 IMAGEMAGICK=6.4.0
65 #GTKMM=2.10.9
66 GTKMM=2.8.12
67 FTGL=2.1.2
68 FREEGLUT=2.4.0
69 GTKGLEXT=1.2.0
70 GTKGLEXTMM=1.2.0
71 #LIBXMLPP=2.14.0
72 LIBXMLPP=2.20.0
73 #LIBXMLPP=2.23.2
74 GLIBMM=2.12.8
75 #GLIBMM=2.18.1
76 GITVERSION=1.7.0   # git version for chroot environment
77
78 SYNFIG_REPO_DIR=''
79 WORKDIR_IS_REPO=0
80
81 # Allow overriding PREFIX and/or BREED
82 if [ -f "./synfigstudio-build.conf" ] ; then
83         . "./synfigstudio-build.conf"
84 fi
85
86 set -e
87
88 if (test "$2"); then
89         SELECTEDREVISION=$2
90 else
91         SELECTEDREVISION=origin/master
92 fi
93
94 mklibsigcpp()
95 {
96 if [ ! -d ${PREFIX}/include/sigc++-2.0 ]; then
97         pushd /source
98         [ ! -d libsigc++-${LIBSIGCPP} ] && tar -xjf libsigc++-${LIBSIGCPP}.tar.bz2
99         cd libsigc++-${LIBSIGCPP}
100         #make clean || true
101         ./configure --prefix=${PREFIX}/ --includedir=${PREFIX}/include --disable-static --enable-shared 
102         make -j2 
103         make install
104         cd ..
105         popd
106 fi
107 }
108
109 mkglibmm()
110 {
111 if [ ! -d ${PREFIX}/include/glibmm-2.4 ]; then
112         pushd /source
113         [ ! -d glibmm-${GLIBMM} ] && tar -xjf glibmm-${GLIBMM}.tar.bz2
114         cd glibmm-${GLIBMM}
115         #[[ $DOCLEAN == 1 ]] && make clean || true
116         ./configure --prefix=${PREFIX} --includedir=${PREFIX}/include --disable-static --enable-shared --disable-fulldocs 
117         make -j2 
118         make install
119         cd ..
120         popd
121 fi
122 }
123
124 mklibxmlpp()
125 {
126 if [ ! -d ${PREFIX}/include/libxml++-2.6 ]; then
127         pushd /source
128         [ ! -d libxml++-${LIBXMLPP} ] && tar -xjf libxml++-${LIBXMLPP}.tar.bz2
129         cd libxml++-${LIBXMLPP}
130         #[[ $DOCLEAN == 1 ]] && make clean || true
131         ./configure --prefix=${PREFIX} --includedir=${PREFIX}/include --disable-static --enable-shared 
132         make -j2 
133         make install
134         cd ..
135         popd
136 fi
137 }
138
139 mkimagemagick()
140 {
141 if [ ! -d ${PREFIX}/include/ImageMagick ]; then
142         pushd /source
143         [ ! -d ImageMagick-${IMAGEMAGICK} ] && tar -xjf ImageMagick-${IMAGEMAGICK}-10.tar.bz2 && cd ImageMagick-${IMAGEMAGICK} && patch -p1 < ../ImageMagick-6.4.0-multilib.patch && cd ..
144         cd ImageMagick-${IMAGEMAGICK}
145         #[[ $DOCLEAN == 1 ]] && make clean || true
146         ./configure --prefix=${PREFIX} --includedir=${PREFIX}/include --disable-static --enable-shared \
147                 --with-modules \
148                 --without-perl \
149                 --without-x \
150                 --with-threads \
151                 --with-magick_plus_plus \
152                 --without-gslib \
153                 --without-wmf \
154                 --without-lcms \
155                 --without-rsvg \
156                 --without-xml \
157                 --without-windows-font-dir \
158                 --without-dps \
159                 --without-djvu \
160                 --without-fpx \
161                 --without-jbig \
162                 --without-jp2 \
163                 --without-tiff \
164                 --without-fontconfig \
165                 --without-freetype \
166                 --without-png \
167                 --without-gvc \
168                 --without-openexr
169         sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
170         sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
171         make -j2 
172         make install
173         cd ..
174         popd
175 fi
176 }
177
178 mkglew()
179 {
180 [ ! -d glew-${GLEW} ] && tar -xzf glew-${GLEW}.tar.gz && cd glew && patch -p1 < glew-${GLEW}-makefile.patch && cd ..
181         pushd /source
182         cd glew
183         #[[ $DOCLEAN == 1 ]] && make clean || true
184         sed -i -e 's/\r//g' config/config.guess
185         make -j2
186         make install GLEW_DEST=${PREFIX} libdir=/lib bindir=/bin  includedir=/include
187         cd ..
188         popd
189 }
190
191 mkcairomm()
192 {
193 if [ ! -d ${PREFIX}/include/cairomm-1.0 ]; then
194         pushd /source
195         [ ! -d cairomm-${CAIROMM} ] && tar -xzf cairomm-${CAIROMM}.tar.gz
196         cd cairomm-${CAIROMM}
197         #[[ $DOCLEAN == 1 ]] && make clean || true
198         ./configure --prefix=${PREFIX} --includedir=${PREFIX}/include --disable-static --enable-shared --enable-docs=no
199         make -j2 
200         make install
201         cd ..
202 fi
203 }
204
205 mkgtkmm()
206 {
207 if [ ! -d ${PREFIX}/include/gtkmm-2.4 ]; then
208         pushd /source
209         [ ! -d gtkmm-${GTKMM} ] && tar -xjf gtkmm-${GTKMM}.tar.bz2
210         cd gtkmm-${GTKMM}
211         #[[ $DOCLEAN == 1 ]] && make clean || true
212         ./configure --prefix=${PREFIX} --includedir=${PREFIX}/include --disable-static --enable-shared --disable-examples --disable-demos --disable-docs
213         make -j2
214         make install
215         cd ..
216         popd
217 fi
218 }
219
220 mkfreeglut()
221 {
222         pushd /source
223         [ ! -d freeglut-${FREEGLUT} ] && tar -xzf freeglut-${FREEGLUT}.tar.gz
224         cd freeglut-${FREEGLUT}
225         #[[ $DOCLEAN == 1 ]] && make clean || true
226         ./configure --prefix=${PREFIX} --includedir=${PREFIX}/include --disable-static  --disable-warnings --enable-shared 
227         make -j2
228         make install
229         cd ..
230         popd
231 }
232
233 mkftgl()
234 {
235         pushd /source
236         if [ ! -d ftgl-${FTGL} ]; then
237                 tar -xjf ftgl-${FTGL}.tar.bz2
238                 cd FTGL
239                 patch -p1 -b < ftgl-2.1.2-destdir.patch
240                 patch -p1 -b < ftgl-2.1.2-Glyph-g++_41.patch
241                 patch -p1 -b < ftgl-2.1.2-pc_req.patch
242                 patch -p1 -b < ftgl-2.1.2-rpath_FTGLDemo.patch
243                 patch -p1 -b < ftgl-2.1.2-ttf_font.patch
244                 sed -i.fixed_version -e 's|2.0.5|%{version}|g' unix/configure.ac unix/configure
245                 cd ..
246         fi
247         cd FTGL
248         cd unix
249         #[[ $DOCLEAN == 1 ]] && make clean || true
250         ./configure --prefix=${PREFIX} --includedir=${PREFIX}/include --disable-static --enable-shared --with-gl-inc=${PREFIX}/include  --with-gl-lib=${PREFIX}/lib  --with-glut-inc=${PREFIX}/include  --with-glut-lib=${PREFIX}/lib  --with-x 
251         make all -j2
252         make install
253         cd ..
254         popd
255 }
256
257 mkgtkglext()
258 {
259         pushd /source
260         [ ! -d gtkglext-${GTKGLEXT} ] && tar -xjf gtkglext-${GTKGLEXT}.tar.bz2
261         cd gtkglext-${GTKGLEXT}
262         #[[ $DOCLEAN == 1 ]] && make clean || true
263         ./configure --prefix=${PREFIX} --includedir=${PREFIX}/include  --disable-gtk-doc --disable-static  --enable-shared 
264         make -j2 
265         make install
266         cd ..
267         popd
268 }
269
270 mkgtkglextmm()
271 {
272         pushd /source
273         [ ! -d gtkglextmm-${GTKGLEXTMM} ] && tar -xjf gtkglextmm-${GTKGLEXTMM}.tar.bz2 && cd gtkglextmm-${GTKGLEXTMM} && patch -p1 < gtkglextmm-1.2.0-aclocal.diff && cd ..
274         cd gtkglextmm-${GTKGLEXTMM}
275         #[[ $DOCLEAN == 1 ]] && make clean || true
276         ./configure --prefix=${PREFIX} --includedir=${PREFIX}/include  --disable-dependency-tracking --disable-static  --enable-shared 
277         make -j2 
278         make install
279         popd
280 cd ..
281 }
282
283 mkgit()
284 {
285         pushd /source
286         [ ! -d git-${GITVERSION} ] && tar -xjf git-${GITVERSION}.tar.bz2
287         cd git-${GITVERSION}
288         ./configure
289         make -j2
290         make install
291         cd ..
292         popd
293 }
294
295 mkETL()
296 {
297 if [ -d ${SYNFIG_REPO_DIR}/ETL/trunk ]; then
298         pushd ${SYNFIG_REPO_DIR}/ETL/trunk
299 else
300         pushd ${SYNFIG_REPO_DIR}/ETL
301 fi
302
303
304 if ( [[ $MODE == 'package' ]] || [[ $MODE == 'full' ]] ); then
305         echo "Cleaning source tree..."
306         make clean || true
307 fi
308
309
310 if [[ $MODE != 'quick' ]]; then
311         echo "Going to configure..."
312         rm -f aclocal.m4
313         autoreconf --install --force
314         bash ./configure --prefix=${PREFIX} --includedir=${PREFIX}/include $DEBUG 
315 fi
316
317 make -j2
318 make install
319
320 popd
321 }
322
323 mksynfig()
324 {
325 if [ -d ${SYNFIG_REPO_DIR}/synfig-core/trunk ]; then
326         pushd ${SYNFIG_REPO_DIR}/synfig-core/trunk
327 else
328         pushd ${SYNFIG_REPO_DIR}/synfig-core
329 fi
330
331 export CXXFLAGS=-I${PREFIX}/include/ImageMagick
332
333 ( [[ $MODE == 'package' ]] || [[ $MODE == 'full' ]] ) && make clean || true
334
335 if [[ $MODE != 'quick' ]]; then
336         libtoolize --ltdl --copy --force
337         sed -i 's/^AC_CONFIG_SUBDIRS(libltdl)$/m4_ifdef([_AC_SEEN_TAG(libltdl)], [], [AC_CONFIG_SUBDIRS(libltdl)])/' configure.ac || true
338         sed -i 's/^# AC_CONFIG_SUBDIRS(libltdl)$/m4_ifdef([_AC_SEEN_TAG(libltdl)], [], [AC_CONFIG_SUBDIRS(libltdl)])/' configure.ac || true
339         autoreconf --install --force
340         bash ./configure --prefix=${PREFIX} --includedir=${PREFIX}/include --disable-static --enable-shared --with-magickpp --without-libavcodec $DEBUG  
341 fi
342
343 #It looks like mod_libavcodec causes segfault on synfig-core when rendering to png.
344 #Tested on: ffmpeg-0.4.9-0.52.20080908.fc10.x86_64.
345
346 #if [[ $GIT == 1 ]]; then
347 #       export CFLAGS=-I/opt/synfig/include/GL/
348 #       export LDFLAGS=-L/opt/synfig/lib/
349 #else
350 #       export CFLAGS=''
351 #       export LDFLAGS=''
352 #fi
353
354 make -j2
355 make install
356
357 popd
358 }
359
360 mksynfigstudio()
361 {
362 if [ -d ${SYNFIG_REPO_DIR}/synfig-studio/trunk ]; then
363         pushd ${SYNFIG_REPO_DIR}/synfig-studio/trunk
364 else
365         pushd ${SYNFIG_REPO_DIR}/synfig-studio
366 fi
367
368 ( [[ $MODE == 'package' ]] || [[ $MODE == 'full' ]] ) && make clean || true
369
370 if [[ $MODE != 'quick' ]]; then
371         autoreconf --install --force
372         bash ./configure --prefix=${PREFIX} --includedir=${PREFIX}/include --disable-static --enable-shared $DEBUG
373 fi
374
375 make -j2
376 make install
377
378 for n in AUTHORS COPYING NEWS README
379 do
380         cp -f $n ${PREFIX}
381 done
382
383 if [ -e synfigstudio-cph-monitor ]; then
384         cp -f synfigstudio-cph-monitor ${PREFIX}/bin/
385         chmod a+x ${PREFIX}/bin/synfigstudio-cph-monitor
386 fi
387
388 popd
389 }
390
391 mkpack()
392 {
393         [ -d /packages ] || mkdir /packages
394         
395         #== tar.bz2 ==
396         TBZPREFIX=/tmp/synfigstudio-${VERSION}-${REVISION}.$BREED.$RELEASE.${ARCH}
397         rm -rf $TBZPREFIX
398         mkdir -p $TBZPREFIX
399         cp -r  ${PREFIX}/* $TBZPREFIX
400         
401         if [[ $DEBUG == '--enable-debug' ]]; then
402                 GDB="which gdb && xterm -e  gdb -ex run -ex quit \$PREFIX/bin/synfig \$@ || "
403         else
404                 GDB=''
405         fi
406         
407         #binaries
408         cat > $TBZPREFIX/synfig <<EOF
409 #!/bin/sh
410
411 PREFIX=\`dirname \$0\`
412 PREFIX=\`cd \$PREFIX; pwd\`
413 export LD_LIBRARY_PATH=\${PREFIX}/lib:\$LD_LIBRARY_PATH
414 export SYNFIG_ROOT=\${PREFIX}/
415 export SYNFIG_MODULE_LIST=\${PREFIX}/etc/synfig_modules.cfg
416
417 $GDB\$PREFIX/bin/synfig \$@
418 EOF
419         if [[ $DEBUG == '--enable-debug' ]]; then
420                 GDB="which gdb && xterm -e  gdb -ex run -ex quit \$PREFIX/bin/synfigstudio \$@ || "
421         else
422                 GDB=''
423         fi
424         cat > $TBZPREFIX/synfigstudio <<EOF
425 #!/bin/sh
426
427 PREFIX=\`dirname \$0\`
428 PREFIX=\`cd \$PREFIX; pwd\`
429 export LD_LIBRARY_PATH=\${PREFIX}/lib:\$LD_LIBRARY_PATH
430 export SYNFIG_ROOT=\${PREFIX}/
431 export SYNFIG_MODULE_LIST=\${PREFIX}/etc/synfig_modules.cfg
432
433 $GDB\$PREFIX/bin/synfigstudio \$@
434 EOF
435         chmod a+x $TBZPREFIX/synfig
436         chmod a+x $TBZPREFIX/synfigstudio
437         
438         #cleaning devel stuff
439         mkdir $TBZPREFIX/bin.tmp
440         mv $TBZPREFIX/bin/synfig $TBZPREFIX/bin.tmp/synfig
441         mv $TBZPREFIX/bin/synfigstudio $TBZPREFIX/bin.tmp/synfigstudio
442         rm -rf $TBZPREFIX/bin
443         mv $TBZPREFIX/bin.tmp $TBZPREFIX/bin
444         
445         rm -f $TBZPREFIX/lib/*.la
446         rm -f $TBZPREFIX/lib/*.a
447         rm -rf $TBZPREFIX/include
448         rm -rf $TBZPREFIX/lib/gdkmm-2.4
449         rm -rf $TBZPREFIX/lib/libxml++-2.6
450         rm -rf $TBZPREFIX/lib/glibmm-2.4
451         rm -rf $TBZPREFIX/lib/gtkmm-2.4
452         rm -rf $TBZPREFIX/lib/pkgconfig
453         rm -rf $TBZPREFIX/lib/sigc++-2.0
454         rm -rf $TBZPREFIX/share/doc
455         rm -rf $TBZPREFIX/share/aclocal
456         rm -rf $TBZPREFIX/share/ImageMagick-6.4.0
457         rm -rf $TBZPREFIX/share/man
458         
459         rm -f /packages/synfigstudio-${VERSION}-${REVISION}.$BREED.$RELEASE.${ARCH}.tar.bz2
460         pushd $TBZPREFIX/../
461         tar cjf /packages/synfigstudio-${VERSION}-${REVISION}.$BREED.$RELEASE.${ARCH}.tar.bz2 synfigstudio-${VERSION}-${REVISION}.$BREED.$RELEASE.${ARCH}
462         popd
463         rm -rf $TBZPREFIX
464         
465         #== rpm ==
466         RPMREVISION=`echo $REVISION.$BREED | sed s/-/_/`
467     cat > synfigstudio.spec << EOF
468 %define __spec_install_post /bin/true
469
470 Name:           synfigstudio
471 Version:        ${VERSION}
472 Release:        ${RPMREVISION}.${RELEASE}
473 Summary:        Film-Quality 2D Vector Animation package
474 Group:          Applications/Graphics
475 License:        GPL
476 URL:            http://www.synfig.org/
477 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
478 Obsoletes:       synfig ETL
479 AutoReqProv: no
480
481
482 %description
483 Synfig Animation Studio is a powerful, industrial-strength vector-based
484 2D animation software, designed from the ground-up for producing
485 feature-film quality animation with fewer people and resources.
486 It is designed to be capable of producing feature-film quality
487 animation. It eliminates the need for tweening, preventing the
488 need to hand-draw each frame. Synfig features spatial and temporal
489 resolution independence (sharp and smoothat any resolution or framerate),
490 high dynamic range images, and a flexible plugin system.
491
492
493 %prep
494
495
496 %build
497
498 %install
499 rm -rf \$RPM_BUILD_ROOT
500 mkdir -p \$RPM_BUILD_ROOT/${PREFIX}
501 cp -r  ${PREFIX}/* \$RPM_BUILD_ROOT/${PREFIX}
502 mkdir -p \$RPM_BUILD_ROOT/usr/share
503 mv \$RPM_BUILD_ROOT/${PREFIX}/share/applications \$RPM_BUILD_ROOT/usr/share
504 mv \$RPM_BUILD_ROOT/${PREFIX}/share/icons \$RPM_BUILD_ROOT/usr/share
505 mkdir -p \$RPM_BUILD_ROOT/usr/share/mime-info
506 ln -sf ${PREFIX}/share/mime-info/synfigstudio.keys \$RPM_BUILD_ROOT/usr/share/mime-info/synfigstudio.keys
507 ln -sf ${PREFIX}/share/mime-info/synfigstudio.mime \$RPM_BUILD_ROOT/usr/share/mime-info/synfigstudio.mime
508 mkdir -p \$RPM_BUILD_ROOT/usr/share/pixmaps
509 ln -sf ${PREFIX}/share/pixmaps/sif_icon.png \$RPM_BUILD_ROOT/usr/share/pixmaps/sif_icon.png
510 ln -sf ${PREFIX}/share/pixmaps/synfig_icon.png \$RPM_BUILD_ROOT/usr/share/pixmaps/synfig_icon.png
511 mkdir -p \$RPM_BUILD_ROOT/usr/bin
512 mv \$RPM_BUILD_ROOT/${PREFIX}/bin/synfig \$RPM_BUILD_ROOT/usr/bin/
513 mv \$RPM_BUILD_ROOT/${PREFIX}/bin/synfigstudio \$RPM_BUILD_ROOT/usr/bin/
514
515 if [ -e \$RPM_BUILD_ROOT/${PREFIX}/bin/synfigstudio-cph-monitor ]; then
516 mv \$RPM_BUILD_ROOT/${PREFIX}/bin/synfigstudio-cph-monitor \$RPM_BUILD_ROOT/usr/bin/
517 cat > \$RPM_BUILD_ROOT/usr/share/applications/synfigstudio-cph-monitor.desktop << EOD
518 [Desktop Entry]
519 Encoding=UTF-8
520 Name=Synfig Studio CPH monitor
521 Comment=This application collecting statistics about synfig crashes
522 Exec=synfigstudio-cph-monitor
523 Icon=terminal.png
524 Terminal=true
525 Type=Application
526 Categories=Graphics;Application;
527 X-Desktop-File-Install-Version=0.15
528 EOD
529 fi
530
531 #cleaning devel stuff
532 rm -f \$RPM_BUILD_ROOT/${PREFIX}/lib/*.la
533 rm -f \$RPM_BUILD_ROOT/${PREFIX}/lib/*.a
534 rm -rf \$RPM_BUILD_ROOT/${PREFIX}/bin
535 rm -rf \$RPM_BUILD_ROOT/${PREFIX}/include
536 rm -rf \$RPM_BUILD_ROOT/${PREFIX}/lib/gdkmm-2.4
537 rm -rf \$RPM_BUILD_ROOT/${PREFIX}/lib/libxml++-2.6
538 rm -rf \$RPM_BUILD_ROOT/${PREFIX}/lib/glibmm-2.4
539 rm -rf \$RPM_BUILD_ROOT/${PREFIX}/lib/gtkmm-2.4
540 rm -rf \$RPM_BUILD_ROOT/${PREFIX}/lib/pkgconfig
541 rm -rf \$RPM_BUILD_ROOT/${PREFIX}/lib/sigc++-2.0
542 rm -rf \$RPM_BUILD_ROOT/${PREFIX}/share/doc
543 rm -rf \$RPM_BUILD_ROOT/${PREFIX}/share/aclocal
544 rm -rf \$RPM_BUILD_ROOT/${PREFIX}/share/ImageMagick-6.4.0
545 rm -rf \$RPM_BUILD_ROOT/${PREFIX}/share/man
546
547
548 %clean
549 rm -rf \$RPM_BUILD_ROOT
550
551 %post
552
553 %postun
554
555 %files
556 %defattr(-,root,root,-)
557 $PREFIX
558 /usr/share/*
559 /usr/bin/*
560
561 %changelog
562 * Sat Mar 21 2009 Konstantin Dmitriev <ksee.zelgadis@gmail.com> - 0.61.09-2354.morevnapackage.1
563 - Update to SVN2354
564 - Include ImageMagick-c++
565
566 * Wed Jan 14 2009 Konstantin Dmitriev <ksee.zelgadis@gmail.com> - 0.61.09-2316.morevnapackage.1
567 - First release
568
569 EOF
570     rpmbuild -bb synfigstudio.spec
571     
572     #cp /usr/src/redhat/RPMS/$ARCH/synfigstudio-${VERSION}-${RPMREVISION}.$RELEASE.${ARCH}.rpm ../
573     cp /usr/src/rpm/RPMS/$ARCH/synfigstudio-${VERSION}-${RPMREVISION}.$RELEASE.${ARCH}.rpm /packages/
574     pushd /packages/
575     alien -k synfigstudio-${VERSION}-${RPMREVISION}.$RELEASE.${ARCH}.rpm
576     rm -rf synfigstudio-${VERSION}
577     popd
578 }
579
580 initialize()
581 {
582         # Make sure we have all dependencies installed
583         echo "Checking dependencies..."
584         DEB_LIST_MINIMAL="build-essential autoconf automake libltdl3-dev libtool gettext cvs libpng12-dev libjpeg62-dev libfreetype6-dev libfontconfig1-dev libgtk2.0-dev libxml2-dev bzip2"
585         if which yum >/dev/null; then
586                 PKG_LIST="git"
587                 if [[ $MODE == 'package' ]]; then
588                         PKG_LIST="${PKG_LIST} debootstrap rsync"
589                 else
590                         PKG_LIST="${PKG_LIST} libpng-devel libjpeg-devel freetype-devel fontconfig-devel atk-devel pango-devel cairo-devel gtk2-devel gettext-devel libxml2-devel libxml++-devel gcc-c++ autoconf automake libtool libtool-ltdl-devel cvs"
591                         PKG_LIST="${PKG_LIST} OpenEXR-devel libmng-devel ImageMagick-c++-devel gtkmm24-devel glibmm24-devel"
592                 fi
593                 if ! ( rpm -qv $PKG_LIST ); then
594                         echo "Running yum (you need root privelegies to do that)..."
595                         su -c "yum install $PKG_LIST"
596                 fi
597         elif which apt-get >/dev/null; then
598                 PKG_LIST="git-core"
599                 if [[ $MODE == 'package' ]]; then
600                         if [[ `cat /etc/chroot.id` == "Synfig Packages Buildroot" ]]; then
601                                 #we are inside of chroot
602                                 PKG_LIST="$DEB_LIST_MINIMAL rpm alien xsltproc wget python"
603                         else
604                                 #we have to prepare chroot
605                                 PKG_LIST="${PKG_LIST} debootstrap rsync"
606                         fi
607                 else
608                         PKG_LIST="${PKG_LIST} ${DEB_LIST_MINIMAL} libmng-dev libgtkmm-2.4-dev libglibmm-2.4-dev libsigc++-2.0-dev"
609                 fi
610                 if ! ( dpkg -s $PKG_LIST >/dev/null ); then
611                         echo "Running apt-get (you need root privelegies to do that)..."
612                         echo 
613                         #echo "http_proxy =====" $http_proxy
614                         #env
615                         sudo apt-get update
616                         sudo apt-get install -y $PKG_LIST
617                 fi
618         else
619                 if [[ $MODE == 'package' ]]; then
620                         if ! ( which git && which debootstrap ) ; then
621                                 echo "ERROR: Please install 'git' and 'debootstrap'."
622                                 exit;
623                         fi
624                 else
625                         echo "WARNING: This build script does not works with package mangement systems other than rpm/yum or apt/dpkg! You should install dependent packages manually."
626                         read
627                 fi
628         fi
629         echo "Done."
630         
631         if [[ $DEBUG == 1 ]]; then
632                 DEBUG='--enable-debug'
633         else
634                 DEBUG=''
635         fi
636         
637         
638         
639         if [[ $MODE == 'package' ]] && [[ `cat /etc/chroot.id` == "Synfig Packages Buildroot" ]]; then
640                 SYNFIG_REPO_DIR="/source/synfig.git"
641                 PREFIX="/opt/synfig"
642                 
643                 which git || mkgit
644                 
645                 pushd $SYNFIG_REPO_DIR
646                 git fetch
647                 git reset --hard HEAD
648                 #we can't switch directly to specified commit wit old git, so let's create temporary branch:
649                 #git checkout master || ( git branch -f master && git checkout master )
650                 #git branch -f __build $SELECTEDREVISION
651                 #git checkout __build
652                 git checkout $SELECTEDREVISION
653                 VERSION=`cat synfig-core/configure.ac |egrep "AC_INIT\(\[Synfig Core\],"| sed "s|.*Core\],\[||" | sed "s|\],\[.*||"`
654                 if [ -z $BREED ]; then
655                         BREED="`git branch -a --no-color --contains HEAD | sed -e s/\*\ // | sed -e s/\(no\ branch\)// | tr '\n' ' ' | tr -s ' ' | sed s/^' '//`"
656                         if ( echo $BREED | egrep origin/master > /dev/null ); then
657                                 #give a priority to master branch
658                                 BREED='master'
659                         else
660                                 BREED=`echo $BREED | cut -d ' ' -f 1`
661                                 BREED=${BREED##*/}
662                         fi
663                         BREED=${BREED%_master}
664                 fi
665                 [[ $DEBUG == 1 ]] && BREED=${BREED}_debug
666                 REVISION=`git show --pretty=medium $SELECTEDREVISION | head -n 3 |tail -n 1 | sed 's/Date: *//' | sed 's/ +.*//'`
667                 REVISION=`date --date="${REVISION}" +%Y%m%d`
668                 echo
669                 echo
670                 echo "BUILDING synfigstudio-$VERSION-$REVISION.$BREED.$RELEASE"
671                 echo
672                 echo
673                 sleep 5
674                 popd
675                 
676                 #Trick to detect arch under chroot
677                 #ARCH=`rpm -q --queryformat='%{arch}\n' e2fsprogs`
678                 MACHINE_TYPE=`uname -m`
679                 case ${MACHINE_TYPE} in
680                         i586)
681                         ARCH=i386;;
682                         i686)
683                         ARCH=i386;;
684                         *)
685                         ARCH=${MACHINE_TYPE};;
686                 esac
687         else
688                 #detecting repo
689                 if git rev-parse --git-dir >/dev/null; then
690                         SYNFIG_REPO_DIR=$(dirname `git rev-parse --git-dir`)
691                         WORKDIR_IS_REPO=1
692                 fi
693         fi
694         
695         export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
696         export PATH=${PREFIX}/bin:$PATH
697         export LD_LIBRARY_PATH=${PREFIX}/lib:$LD_LIBRARY_PATH
698         export LDFLAGS="-Wl,-rpath -Wl,\\\$\$ORIGIN/lib"
699 }
700
701 mk()
702 {
703         if [[ WORKDIR_IS_REPO == 0 ]]; then
704                 SYNFIG_REPO_DIR=`pwd`/synfig.git/
705                 git clone git://synfig.git.sourceforge.net/gitroot/synfig/synfig ${SYNFIG_REPO_DIR}
706         fi
707         
708         mkETL
709         mksynfig
710         mksynfigstudio
711 }
712
713 mkpackage()
714 {
715         #check if we already in chroot
716         if [[ `cat /etc/chroot.id` == "Synfig Packages Buildroot" ]]; then
717                 echo "We are in chroot now."
718                 
719                 echo "[user]"  > $HOME/.gitconfig
720                 echo "email = packages@synfig.org"  >> $HOME/.gitconfig
721                 echo "name = Synfig Packager" >> $HOME/.gitconfig
722                 
723                 
724                 
725                 #synfig-core deps
726                 mklibsigcpp
727                 mkglibmm
728                 mklibxmlpp
729                 if [[ $OPENGL == 1 ]]; then
730                         mkglew
731                 fi
732                 mkimagemagick
733                 #synfig-studio deps
734                 mkcairomm
735                 mkgtkmm
736                 if [[ $OPENGL == 1 ]]; then
737                         mkfreeglut
738                         mkftgl
739                         mkgtkglext
740                         mkgtkglextmm
741                 fi
742                 
743                 mkETL
744                 mksynfig
745                 mksynfigstudio
746                 
747                 mkpack
748         else
749                 [ -d $HOME/synfig-packages ] || mkdir -p $HOME/synfig-packages
750                 #DEB_LIST="build-essential,autoconf,automake,libltdl3-dev,libtool,gettext,cvs,libpng12-dev,libjpeg62-dev,libfreetype6-dev,libfontconfig1-dev,libgtk2.0-dev,libxml2-dev,bzip2,rpm,alien,xsltproc"
751                 for ARCH in i386 amd64; do
752                 if [[ $ARCH == 'i386' ]];then
753                         SETARCH='linux32'
754                 else
755                         SETARCH='linux64'
756                 fi
757                 if ! [ -e $PACKAGES_BUILDROOT.$ARCH/etc/chroot.id ]; then
758                         debootstrap --arch=$ARCH --variant=buildd  --include=sudo etch $PACKAGES_BUILDROOT.$ARCH http://ftp.us.debian.org/debian
759                 fi
760                 #set chroot ID
761                 echo "Synfig Packages Buildroot" > $PACKAGES_BUILDROOT.$ARCH/etc/chroot.id
762                 cp -f $0 $PACKAGES_BUILDROOT.$ARCH/build.sh
763                 #keep proxy settings
764                 if ! [ -z $http_proxy ]; then 
765                         #echo "export http_proxy=\"$http_proxy\";" >> $PACKAGES_BUILDROOT.$ARCH/root/.bashrc
766                         #echo "echo 'proxy export done';" >> $PACKAGES_BUILDROOT.$ARCH/root/.bashrc
767                         echo "Acquire::http::Proxy \"$http_proxy\";" > $PACKAGES_BUILDROOT.$ARCH/etc/apt/apt.conf
768                 fi
769                 #fetch sources to cache
770                 [ -d $PACKAGES_BUILDROOT.$ARCH/source ] && rm -rf $PACKAGES_BUILDROOT.$ARCH/source || true
771                 if ! [ -d $PACKAGES_BUILDROOT/synfig.git ]; then
772                         if [[ $WORKDIR_IS_REPO == 1 ]]; then
773                                 git clone $SYNFIG_REPO_DIR $PACKAGES_BUILDROOT/synfig.git
774                                 sed -i 's|url = .*|url = git://synfig.git.sourceforge.net/gitroot/synfig/synfig|' $PACKAGES_BUILDROOT/synfig.git/.git/config
775                         else
776                                 git clone git://synfig.git.sourceforge.net/gitroot/synfig/synfig $PACKAGES_BUILDROOT/synfig.git
777                         fi
778                 fi
779                 pushd $PACKAGES_BUILDROOT
780                 cd synfig.git && git fetch && cd ..
781                 [ ! -e git-$GITVERSION.tar.bz2 ] && wget -c http://kernel.org/pub/software/scm/git/git-$GITVERSION.tar.bz2
782                 for FILE in \
783                         cairomm-${CAIROMM}.tar.gz \
784                         glibmm-${GLIBMM}.tar.bz2 \
785                         gtkmm-${GTKMM}.tar.bz2 \
786                         libsigc++-${LIBSIGCPP}.tar.bz2 \
787                         libxml++-${LIBXMLPP}.tar.bz2 \
788                         ImageMagick-6.3.8-invalid-gerror-use.patch \
789                         ImageMagick-${IMAGEMAGICK}-10.tar.bz2 \
790                         ImageMagick-${IMAGEMAGICK}-multilib.patch \
791                         ImageMagick-${IMAGEMAGICK}-xdg-open.patch
792                 do
793                         #[ ! -e $FILE ] && wget -c http://download.tuxfamily.org/morevna/morevnapackage/sources/$FILE
794                         rsync -av rsync://download.tuxfamily.org/pub/synfig/packages/sources/$FILE ./
795                 done
796                 if [[ $OPENGL == 1 ]]; then
797                 for FILE in \
798                         glew-${GLEW}.tar.gz\
799                         glew-${GLEW}-makefile.patch \
800                         freeglut-${FREEGLUT}.tar.gz \
801                         ftgl-${FTGL}.tar.gz \
802                         ftgl-${FTGL}-destdir.patch \
803                         ftgl-${FTGL}-Glyph-g++_41.patch \
804                         ftgl-${FTGL}-pc_req.patch \
805                         ftgl-${FTGL}-rpath_FTGLDemo.patch \
806                         ftgl-${FTGL}-ttf_font.patch \
807                         gtkglext-${GTKGLEXT}.tar.bz2 \
808                         gtkglextmm-${GTKGLEXTMM}.tar.bz2 \
809                         gtkglextmm-${GTKGLEXTMM}-aclocal.diff
810                 do
811                         #[ ! -e $FILE ] && wget -c http://download.tuxfamily.org/morevna/morevnapackage/sources/$FILE
812                         rsync -av rsync://download.tuxfamily.org/pub/synfig/packages/sources/$FILE ./
813                 done
814                 fi
815                 popd
816                 #copy sources
817                 [ -d $PACKAGES_BUILDROOT.$ARCH/source ] || mkdir -p $PACKAGES_BUILDROOT.$ARCH/source
818                 cp -rf $PACKAGES_BUILDROOT/* $PACKAGES_BUILDROOT.$ARCH/source/
819                 #go to chroot
820                 $SETARCH chroot $PACKAGES_BUILDROOT.$ARCH env http_proxy=$http_proxy bash /build.sh package $SELECTEDREVISION
821                 mv -f $PACKAGES_BUILDROOT.$ARCH/packages/* $PACKAGES_PATH
822                 done
823                 echo
824                 echo
825                 find $PACKAGES_PATH/synfigstudio* -maxdepth 1
826                 echo "     DONE BUILDING PACKAGES INTO $HOME/synfig-packages"
827                 echo
828         fi
829 }
830
831 ###=================================== MAIN ======================================
832
833 if [ -z $1 ]; then
834         ARG='standart'
835 else
836         ARG=$1
837 fi
838
839 case $ARG in
840         full)
841                 MODE='full'
842                 initialize
843                 mk
844                 exit;;
845         standart)
846                 MODE='standart'
847                 initialize
848                 mk
849                 exit;;
850         quick)
851                 MODE='quick'
852                 initialize
853                 mk
854                 exit;;
855         package)
856                 MODE='package'
857                 initialize
858                 mk$ARG
859                 exit;;
860         *)
861                 MODE='package'
862                 initialize
863                 mk$ARG
864                 exit;;
865 esac