1#!/bin/bash 2 3# Git repo information 4fork="lmms" # i.e. "lmms" or "tobydox" 5branch="master" # i.e. "master" or "stable-1.2" 6 7# Console colors 8red="\\x1B[1;31m" 9green="\\x1B[1;32m" 10yellow="\\x1B[1;33m" 11plain="\\x1B[0m" 12 13function info() { echo -e "\n${green}$1${plain}"; } 14function warn() { echo -e "\n${yellow}$1${plain}"; } 15function err() { echo -e "\n${red}$1${plain}"; exit 1;} 16 17info "Checking for mingw environment" 18env |grep MINGW 19if [ $? -ne 0 ]; then 20 err " - Failed. Please relaunch using MinGW shell" 21fi 22 23info "Preparing the git directory..." 24mkdir $HOME/.git; touch $HOME/.git/config > /dev/null &2>1 25git config --global http.sslverify false 26 27info "Cloning the repository..." 28if [ -d ./lmms ]; then 29 warn " - Skipping, ./lmms already exists" 30else 31 git clone -b $branch https://github.com/$fork/lmms.git 32fi 33 34 35info "Fetching ppa using cmake/msys/fetch_ppas.sh..." 36if [ -d $HOME/ppa ]; then 37 warn " - Skipping, $HOME/ppa already exists" 38else 39 ./lmms/cmake/msys/fetch_ppa.sh 40fi 41 42 43info "Extracting debs to $HOME/ppa/opt/, etc..." 44if [ -d $HOME/ppa/opt ]; then 45 warn " - Skipping, $HOME/ppa/opt already exists" 46else 47 ./lmms/cmake/msys/extract_debs.sh 48fi 49 50info "Preparing library merge, making all qt headers writable..." 51chmod u+w /mingw64/include/qt4 -R 52chmod u+w /mingw32/include/qt4 -R 53 54info "Merging mingw headers and libraries from ppa over existing system libraries..." 55find /mingw64 |grep sndfile.h 56 57if [ $? -ne 0 ]; then 58 \cp -r $HOME/ppa/opt/mingw* / 59else 60 warn " - Skipping, sndfile.h has already been merged" 61fi 62 63fltkver="1.3.3" 64oggver="1.3.2" 65vorbisver="1.3.5" 66flacver="1.3.2" 67gigver="4.0.0" 68stkver="4.5.1" 69 70info "Downloading and building fltk $fltkver" 71 72mingw_root="/$(echo $MSYSTEM|tr '[:upper:]' '[:lower:]')" 73which fluid 74if [ $? -ne 0 ]; then 75 wget http://fltk.org/pub/fltk/$fltkver/fltk-$fltkver-source.tar.gz -O $HOME/fltk-source.tar.gz 76 if [ $? -ne 0 ]; then 77 err "ERROR: Could not download fltk. Exiting." 78 fi 79 tar zxf $HOME/fltk-source.tar.gz -C $HOME/ 80 pushd $HOME/fltk-$fltkver 81 82 info " - Compiling fltk $fltkver..." 83 ./configure --prefix=$mingw_root --enable-shared 84 85 make 86 87 info " - Installing fltk..." 88 make install 89 90 if [ $? -ne 0 ]; then 91 err "ERROR: Could not build/install fltk -- Zyn needs this. Exiting." 92 fi 93 94# ln -s $mingw_root/usr/local/bin/fluid.exe $mingw_root/bin/fluid.exe 95 popd 96else 97 warn " - Skipping, fluid binary already exists" 98fi 99 100info "Downloading and building libogg $oggver" 101 102if [ ! -e $mingw_root/lib/libogg.dll.a ]; then 103 wget http://downloads.xiph.org/releases/ogg/libogg-$oggver.tar.xz -O $HOME/libogg-source.tar.xz 104 if [ $? -ne 0 ]; then 105 err "ERROR: Could not download libogg. Exiting." 106 fi 107 tar xf $HOME/libogg-source.tar.xz -C $HOME/ 108 pushd $HOME/libogg-$oggver 109 110 info " - Compiling libogg $oggver..." 111 ./configure --prefix=$mingw_root 112 113 make 114 115 info " - Installing libogg..." 116 make install 117 118 # for some reason libgig needs this 119 ./configure --prefix=/opt$mingw_root 120 121 make 122 123 info " - Installing libogg..." 124 make install 125 126 if [ $? -ne 0 ]; then 127 err "ERROR: Could not build/install fltk -- lmms needs this. Exiting." 128 fi 129 130 popd 131else 132 warn " - Skipping, libogg binary already exists" 133fi 134 135 136info "Downloading and building libvorbis $vorbisver" 137 138if [ ! -e $mingw_root/lib/libvorbis.dll.a ]; then 139 wget http://downloads.xiph.org/releases/vorbis/libvorbis-$vorbisver.tar.xz -O $HOME/libvorbis-source.tar.xz 140 if [ $? -ne 0 ]; then 141 err "ERROR: Could not download libogg. Exiting." 142 fi 143 tar xf $HOME/libvorbis-source.tar.xz -C $HOME/ 144 pushd $HOME/libvorbis-$vorbisver 145 146 info " - Compiling libvorbis $vorbisver..." 147 ./configure --prefix=$mingw_root 148 149 make 150 151 info " - Installing libvorbis..." 152 make install 153 154 # for some reason libgig needs this 155 ./configure --prefix=/opt$mingw_root 156 157 make 158 159 info " - Installing libvorbis..." 160 make install 161 162 if [ $? -ne 0 ]; then 163 err "ERROR: Could not build/install libvorbis -- lmms needs this. Exiting." 164 fi 165 166 popd 167else 168 warn " - Skipping, libvorbis binary already exists" 169fi 170 171info "Downloading and building flac $flacver" 172 173if [ ! -e $mingw_root/lib/libFLAC.dll.a ]; then 174 wget http://downloads.xiph.org/releases/flac/flac-$flacver.tar.xz -O $HOME/flac-source.tar.xz 175 if [ $? -ne 0 ]; then 176 err "ERROR: Could not download flac. Exiting." 177 fi 178 tar xf $HOME/flac-source.tar.xz -C $HOME/ 179 pushd $HOME/flac-$flacver 180 181 info " - Compiling flac $flacver..." 182 ./configure --prefix=$mingw_root 183 184 make 185 186 info " - Installing flac..." 187 make install 188 189 # for some reason libgig needs this 190 ./configure --prefix=/opt$mingw_root 191 192 make 193 194 info " - Installing flac..." 195 make install 196 197 if [ $? -ne 0 ]; then 198 err "ERROR: Could not build/install flac -- lmms needs this. Exiting." 199 fi 200 201 popd 202else 203 warn " - Skipping, libvorbis flac already exists" 204fi 205 206info "Downloading and building libgig $gigver" 207 208if [ ! -e $mingw_root/lib/libgig/libgig.dll.a ]; then 209 wget http://download.linuxsampler.org/packages/libgig-$gigver.tar.bz2 -O $HOME/gig-source.tar.xz 210 if [ $? -ne 0 ]; then 211 err "ERROR: Could not download libgig. Exiting." 212 fi 213 tar xf $HOME/gig-source.tar.xz -C $HOME/ 214 pushd $HOME/libgig-$gigver 215 216 info " - Compiling libgig $gigver..." 217 ./configure --prefix=$mingw_root 218 219 make 220 221 info " - Installing libgig..." 222 make install 223 224 mv $mingw_root/lib/bin/libakai-0.dll $mingw_root/bin 225 mv $mingw_root/lib/bin/libgig-7.dll $mingw_root/bin 226 227 if [ $? -ne 0 ]; then 228 err "ERROR: Could not build/install libgig -- gigplayer needs this. Exiting." 229 fi 230 231 popd 232else 233 warn " - Skipping, libgig binary already exists" 234fi 235 236info "Downloading and building stk $stkver" 237 238if [ ! -e $mingw_root/lib/libstk.dll ]; then 239 wget http://ccrma.stanford.edu/software/stk/release/stk-$stkver.tar.gz -O $HOME/stk-source.tar.xz 240 if [ $? -ne 0 ]; then 241 err "ERROR: Could not download stk. Exiting." 242 fi 243 tar xf $HOME/stk-source.tar.xz -C $HOME/ 244 pushd $HOME/stk-$stkver 245 246 info " - Compiling stk $stkver..." 247 ./configure --prefix=$mingw_root 248 249 make 250 251 info " - Installing stk..." 252 make install 253 254 if [ $? -ne 0 ]; then 255 err "ERROR: Could not build/install stk -- mallotstk needs this. Exiting." 256 fi 257 258 mv $mingw_root/lib/libstk.so $mingw_root/lib/libstk.dll 259 mv $mingw_root/lib/libstk-$stkver.so $mingw_root/lib/libstk-$stkver.dll 260 261 popd 262else 263 warn " - Skipping, stk binary already exists" 264fi 265 266# make a symlink to make cmake happy 267if [ $mingw_root = "/mingw64" ]; then 268 if [ ! -e /opt/mingw64/bin/x86_64-w64-mingw32-pkg-config ]; then 269 ln -s /usr/bin/pkg-config /opt/mingw64/bin/x86_64-w64-mingw32-pkg-config 270 fi 271fi 272if [ $mingw_root = "/mingw32" ]; then 273 274 if [ ! -e /opt/mingw32/bin/i686-w64-mingw32-pkg-config ]; then 275 ln -s /usr/bin/pkg-config /opt/mingw32/bin/i686-w64-mingw32-pkg-config 276 fi 277fi 278 279info "Cleaning up..." 280rm -rf $HOME/fltk-$fltkver 281rm -rf $HOME/libogg-$oggver 282rm -rf $HOME/libvorbis-$vorbisver 283rm -rf $HOME/flac-$flacver 284rm -rf $HOME/libgig-$gigver 285rm -rf $HOME/stk-$stkver 286info "Done." 287