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