root/tags/release-0.7.3/bootstrap-libs.sh

Revision 646, 6.2 kB (checked in by olivier, 10 months ago)

fix bootstrap-libs script minor issues and update osx bundle Makefile to 0.7.3rc1

  • Property svn:executable set to *
Line 
1#!/bin/bash
2
3# This script downloads, builds and install Jackbeat's dependencies 
4# into ./local-libs or into ./local-libs-mingw if you pass "mingw" as first
5# argument. When bootstraping for mingw, gtk is downloaded automatically,
6# but on other targets you must install gtk manually.
7
8if [ "$1" == "mingw" ]
9then
10    TARGET=mingw
11    TARGET_DIR=$(pwd)/local-libs-mingw
12else
13    TARGET=posix
14    TARGET_DIR=$(pwd)/local-libs
15fi
16
17if [ -n "$2" ]
18then
19    ONLY="$2"
20else
21    ONLY=""
22fi
23
24if wget --version 2> /dev/null | grep Wget > /dev/null
25then
26    DOWNLOAD="wget -O"
27else
28    DOWNLOAD="curl -o"
29fi
30
31ROOT=$(pwd)
32
33function cleanup
34{
35    rm -f $TARGET_DIR/download/*
36}
37
38function info
39{
40    printf "\n\x1B[32m$1\x1B[0m\n\n"
41}
42
43function error
44{
45    printf "\n\x1B[31mERROR: $1\x1B[0m\n\n"
46    cleanup
47    exit 1
48}
49
50function init_dir
51{
52    if ! [ -f $1 ]
53    then
54        mkdir -p $1 || error "Can't create directory $1"
55    fi
56}
57
58function install_package
59{
60    pkg=$1
61
62    if [ -z $ONLY ] || echo "$pkg" | grep "$ONLY" > /dev/null
63    then
64        remote=$2
65        src_dir="$3"
66        opts="$4"
67        if [ -z "$src_dir" ]
68        then
69            src_dir=$pkg
70        fi
71        file=$pkg.tar.gz
72        prefix=$TARGET_DIR/build
73        info "Downloading $pkg"
74        $DOWNLOAD $TARGET_DIR/download/$file $remote/$file || error "Failed to download $pkg"
75        tar -xzvf $TARGET_DIR/download/$file -C $TARGET_DIR/src
76        cd $TARGET_DIR/src/$src_dir || error "Couldn't change to directory $TARGET_DIR/src/$src_dir"
77        info "Configuring $pkg"
78        if [ $TARGET == "mingw" ]
79        then
80            host="--host=i586-mingw32msvc"
81        else
82            host=""
83        fi
84        ./configure --prefix=$prefix $host $opts || error "Failed to configure $pkg"
85        info "Building $pkg"
86        make -j2 || error "Failed to build $pkg"
87        make install || error "Failed to install $pkg (prefix: $prefix)"
88    else
89        info "Skipping $pkg"
90    fi
91}
92
93function install_portaudio
94{
95    if [ -z $ONLY ] || [ $ONLY == "portaudio" ]
96    then
97        if [ $TARGET != "mingw" ]
98        then
99            if [ $ONLY == "portaudio" ]; then ONLY=pa_stable; fi
100            install_package pa_stable_v19_20071207  http://www.portaudio.com/archives portaudio
101        else
102            info "Building Asio"
103            cd $ROOT
104            asio_dir=$TARGET_DIR/src/ASIOSDK2
105            cp mingw/Makefile.asio $asio_dir/Makefile
106            cd $asio_dir
107            make
108
109            info "Downloading DirectX"
110            $DOWNLOAD $TARGET_DIR/download/DirectX90c.DevPak http://www.g-productions.net/files/devpak/DirectX90c.DevPak
111            tar -xjvf $TARGET_DIR/download/DirectX90c.DevPak -C $TARGET_DIR/src
112            rmdir $TARGET_DIR/src/DirectX90c\\# To delete some created windows style dirs
113
114            info "Downloading Portaudio"
115            $DOWNLOAD $TARGET_DIR/download/pa_stable_v19_061121.tar.gz http://www.portaudio.com/archives/pa_stable_v19_061121.tar.gz
116            rm -rf $TARGET_DIR/src/portaudio
117            tar -xzvf $TARGET_DIR/download/pa_stable_v19_061121.tar.gz -C $TARGET_DIR/src
118
119            info "Patching Portaudio"
120            cd $TARGET_DIR/src/portaudio
121            patch -p1 < ../../../mingw/portaudio-v19_061121.diff
122
123            info "Preparing Portaudio SConstruct'ion"
124            cd $ROOT
125            cp mingw/portaudio.SConstruct $TARGET_DIR/src/portaudio/SConstruct.crossmingw
126            cd $TARGET_DIR/src/portaudio
127            $DOWNLOAD crossmingw.py http://iua-share.upf.edu/svn/clam/trunk/CLAM/scons/sconstools/crossmingw.py
128
129            info "Building Portaudio"
130            scons -f SConstruct.crossmingw install prefix=$TARGET_DIR/build
131
132            info "Generating Portaudio .pc file"
133            pc=$TARGET_DIR/build/lib/pkgconfig/portaudio-2.0.pc
134            cp "portaudio-2.0.pc.in" $pc
135            sed -i "s#@prefix@#$TARGET_DIR/build#" $pc
136            sed -i 's#@exec_prefix@#${prefix}#' $pc
137            sed -i 's#@libdir@#${exec_prefix}/lib#' $pc
138            sed -i 's#@includedir@#${prefix}/include#' $pc
139            sed -i 's#@.*@##' $pc
140        fi
141    else
142        info "Skipping portaudio"
143    fi
144}
145
146init_dir $TARGET_DIR/download
147init_dir $TARGET_DIR/src
148init_dir $TARGET_DIR/build/lib
149init_dir $TARGET_DIR/build/include
150
151cleanup
152
153if [ "$TARGET" != "mingw" ]
154then
155        install_package pkg-config-0.23 http://pkgconfig.freedesktop.org/releases
156        export PATH=$PATH:$TARGET_DIR/build/bin
157else
158    if [ -z $ONLY ] || [ $ONLY == "pthread" ]
159    then
160        info "Downloading pthreads-win32"
161        $DOWNLOAD $TARGET_DIR/build/lib/libpthread.a ftp://sourceware.org/pub/pthreads-win32/dll-latest/lib/libpthreadGC2.a
162            $DOWNLOAD $TARGET_DIR/build/bin/pthreadGC2.dll ftp://sourceware.org/pub/pthreads-win32/dll-latest/lib/pthreadGC2.dll
163        $DOWNLOAD $TARGET_DIR/build/include/pthread.h ftp://sourceware.org/pub/pthreads-win32/dll-latest/include/pthread.h
164        $DOWNLOAD $TARGET_DIR/build/include/semaphore.h ftp://sourceware.org/pub/pthreads-win32/dll-latest/include/semaphore.h
165        $DOWNLOAD $TARGET_DIR/build/include/sched.h ftp://sourceware.org/pub/pthreads-win32/dll-latest/include/sched.h
166    else
167        info "Skipping pthreads-win32"
168    fi
169
170    if [ -z $ONLY ] || [ $ONLY == "gtk" ]
171    then
172        info "Downloading GTK"
173        $DOWNLOAD $TARGET_DIR/download/gtk+-2.16.zip http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.16/gtk+-bundle_2.16.2-20090601_win32.zip
174        init_dir $TARGET_DIR/gtk
175        cd $TARGET_DIR/gtk
176        unzip $TARGET_DIR/download/gtk+-2.16.zip
177        info "Fixing GTK .pc files"
178        sed -i "s#^prefix=.*#prefix=$TARGET_DIR/gtk#" lib/pkgconfig/*.pc
179    else
180        info "Skipping GTK"
181    fi
182
183    export PKG_CONFIG_LIBDIR="/tmp/junk"
184fi
185
186install_package libsndfile-1.0.19       http://www.mega-nerd.com/libsndfile
187install_package libsamplerate-0.1.7     http://www.mega-nerd.com/SRC
188
189if [ "$TARGET" == "mingw" ]
190then
191        CFLAGS="-I$TARGET_DIR/build/include $CFLAGS" LDFLAGS="-L$TARGET_DIR/build/lib $LDFLAGS" \
192        install_package liblo-0.26              http://ovh.dl.sourceforge.net/project/liblo/liblo/0.26
193else
194        install_package liblo-0.26              http://ovh.dl.sourceforge.net/project/liblo/liblo/0.26
195fi
196
197install_package libxml2-2.7.3           ftp://xmlsoft.org/libxml2 "" "--without-python"
198install_portaudio
199
200cleanup
201
202info "Done bootstrapping"
Note: See TracBrowser for help on using the browser.