1#!/bin/bash
2# Bootstrapper to semi-automatically build avidemux from source on OSX
3# (c) Mean 2009
4
5# Specify the the directory where you want to install avidemux (a.k.a. the cmake_install_prefix)
6# like export BASE_INSTALL_DIR="<full_path_to_installation>". This can be /usr/local or /opt/local (macports) or /sw (Fink)
7export BASE_INSTALL_DIR="/boot/apps/Avidemux";
8
9packages_ext=""
10do_core=1
11do_cli=0
12do_gtk=0   # Note that gtk is no fully longer supported on OSX. You are on your own here
13do_qt4=1
14do_plugins=1
15debug=0
16fail()
17{
18        echo "** Failed at $1**"
19        exit 1
20}
21
22
23Process()
24{
25        export BUILDDIR=$1
26        export SOURCEDIR=$2
27        export EXTRA=$3
28        export DEBUG=""
29        BUILDER="Unix Makefiles"
30        if [ "x$debug" = "x1" ] ; then
31                DEBUG="-DVERBOSE=1 -DCMAKE_BUILD_TYPE=Debug  "
32                BUILDDIR="${BUILDDIR}_debug"
33                BUILDER="CodeBlocks - Unix Makefiles"
34        fi
35
36        echo "Building $BUILDDIR from $SOURCEDIR with EXTRA=<$EXTRA>, DEBUG=<$DEBUG>"
37        rm -Rf ./$BUILDDIR
38        mkdir $BUILDDIR || fail mkdir
39        cd $BUILDDIR
40        cmake $PKG -DCMAKE_EDIT_COMMAND=mcedit -DCMAKE_CXX_FLAGS="-D__STDC_CONSTANT_MACROS" -DPTHREAD_INCLUDE_DIR=/boot/develop/headers/posix -DAVIDEMUX_SOURCE_DIR=$TOP -DCMAKE_INSTALL_PREFIX="$BASE_INSTALL_DIR" $EXTRA $DEBUG -G "$BUILDER" $SOURCEDIR || fail cmakeZ
41        make -j 2 > /tmp/log$BUILDDIR || fail make
42}
43printModule()
44{
45        value=$1
46        name=$2
47        if [ "x$value" = "x1" ]; then echo "    $name will be built"
48        else echo "     $name will be skipped"
49        fi
50
51
52}
53config()
54{
55        echo "Build configuration :"
56        echo "******************* :"
57        echo "Build type :"
58        if [ "x$debug" = "x1" ] ; then echo   "Debug build"
59        else echo   "Release build"
60        fi
61        printModule $do_core Core
62        printModule $do_gtk Gtk
63        printModule $do_qt4 Qt4
64        printModule $do_cli Cli
65        printModule $do_plugins Plugins
66}
67usage()
68{
69        echo "Bootstrap avidemux 2.6:"
70        echo "***********************"
71        echo "  --help            : Print usage"
72        echo "  --tgz             : Build tgz packages"
73        echo "  --debug           : Switch debugging on"
74        echo "  --with-core       : Build core"
75        echo "  --without-core    : Dont build core"
76        echo "  --with-cli        : Build cli"
77        echo "  --without-cli     : Dont build cli"
78        echo "  --with-gtk        : Build gtk"
79        echo "  --without-gtk     : Dont build gtk"
80        echo "  --with-core       : Build core"
81        echo "  --without-qt4     : Dont build qt4"
82        echo "  --with-plugins    : Build plugins"
83        echo "  --without-plugins : Dont build plugins"
84        config
85
86}
87# Could probably do it with getopts...
88while [ $# != 0 ] ;do
89        case "$1" in
90         -h|--help)
91             usage
92             exit 1
93             ;;
94         --debug)
95                debug=1
96                ;;
97         --pause)
98                pause_script=true
99                ;;
100         --tgz)
101                packages_ext=tar.gz
102                PKG="$PKG -DAVIDEMUX_PACKAGER=tgz"
103                ;;
104         --without-qt4)
105                do_qt4=0
106             ;;
107         --without-cli)
108                do_cli=0
109             ;;
110         --without-gtk)
111                do_gtk=0
112             ;;
113         --without-plugins)
114                do_plugins=0
115             ;;
116         --without-core)
117                do_core=0
118             ;;
119         --with-qt4)
120                do_qt4=1
121             ;;
122         --with-cli)
123                do_cli=1
124             ;;
125         --with-gtk)
126                do_gtk=1
127             ;;
128         --with-plugins)
129                do_plugins=1
130             ;;
131         --with-core)
132                do_core=1
133             ;;
134        *)
135                echo "unknown parameter $1"
136                usage
137                exit 1
138                ;;
139     esac
140     shift
141done
142config
143echo "**BootStrapping avidemux **"
144export TOP=$PWD
145export POSTFIX=""
146echo "Top dir : $TOP"
147if [ "x$debug" = "x1" ] ; then echo
148POSTFIX="_debug"
149fi
150
151if [ "x$do_core" = "x1" ] ; then
152        echo "** CORE **"
153        cd $TOP
154        Process buildCore ../avidemux_core
155        echo " Core needs to be installed, installing through  make install ...."
156        cd $TOP/buildCore${POSTFIX} &&  make install
157fi
158if [ "x$do_qt4" = "x1" ] ; then
159        echo "** QT4 **"
160        cd $TOP
161        Process buildQt4 ../avidemux/qt4
162        echo " Qt4 needs to be installed, installing through  make install ...."
163        cd $TOP/buildQt4${POSTFIX} &&  make install
164fi
165if [ "x$do_cli" = "x1" ] ; then
166        echo "** CLI **"
167        cd $TOP
168        Process buildCli ../avidemux/cli
169        echo " Cli needs to be installed, installing through  make install ...."
170        cd $TOP/buildCli${POSTFIX} &&  make install
171fi
172if [ "x$do_gtk" = "x1" ] ; then
173        echo "** GTK **"
174        cd $TOP
175        Process buildGtk ../avidemux/gtk
176        echo " Gtk needs to be installed, installing through  make install ...."
177        cd $TOP/buildGtk${POSTFIX} &&  make install
178fi
179if [ "x$do_plugins" = "x1" ] ; then
180        echo "** Plugins **"
181        cd $TOP
182        Process buildPluginsCommon ../avidemux_plugins -DPLUGIN_UI=COMMON
183fi
184if [ "x$do_plugins" = "x1" -a "x$do_qt4" = "x1" ] ; then
185        echo "** Plugins Qt4 **"
186        cd $TOP
187        Process buildPluginsQt4 ../avidemux_plugins -DPLUGIN_UI=QT4
188fi
189if [ "x$do_plugins" = "x1" -a "x$do_gtk" = "x1" ] ; then
190        echo "** Plugins Gtk **"
191        cd $TOP
192        Process buildPluginsGtk ../avidemux_plugins -DPLUGIN_UI=GTK
193fi
194if [ "x$do_plugins" = "x1" -a "x$do_cli" = "x1" ] ; then
195        echo "** Plugins CLI **"
196        cd $TOP
197        Process buildPluginsCLI ../avidemux_plugins -DPLUGIN_UI=CLI
198fi
199
200echo "** Preparing debs **"
201cd $TOP
202if [ "x$packages_ext" = "x" ]; then
203        echo "No packaging"
204else
205        echo "Preparing packages"
206        rm -Rf debs
207        mkdir debs
208        find . -name "*.$packages_ext" | grep -vi cpa | xargs cp -t debs
209        echo "** debs directory ready **"
210        ls -l debs
211fi
212echo "** ALL DONE **"
213