msys_helper.sh 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. #!/bin/bash
  2. set -eu
  3. # Git repo information
  4. fork="lmms" # i.e. "lmms" or "tobydox"
  5. branch="master" # i.e. "master" or "stable-1.2"
  6. # Console colors
  7. red="\\x1B[1;31m"
  8. green="\\x1B[1;32m"
  9. yellow="\\x1B[1;33m"
  10. plain="\\x1B[0m"
  11. function info() { echo -e "\n${green}$1${plain}"; }
  12. function warn() { echo -e "\n${yellow}$1${plain}"; }
  13. function err() { echo -e "\n${red}$1${plain}"; exit 1;}
  14. info "Checking for mingw environment"
  15. if ! env | grep MINGW; then
  16. err " - Failed. Please relaunch using MinGW shell"
  17. fi
  18. info "Preparing the git directory..."
  19. mkdir "$HOME/.git" || true
  20. touch "$HOME/.git/config" > /dev/null 2>&1
  21. git config --global http.sslverify false
  22. info "Cloning the repository..."
  23. if [ -d ./lmms ]; then
  24. warn " - Skipping, ./lmms already exists"
  25. else
  26. git clone -b $branch https://github.com/$fork/lmms.git
  27. fi
  28. info "Fetching ppa using cmake/msys/fetch_ppas.sh..."
  29. if [ -d "$HOME/ppa" ]; then
  30. warn " - Skipping, $HOME/ppa already exists"
  31. else
  32. lmms/cmake/msys/fetch_ppa.sh
  33. fi
  34. info "Extracting debs to $HOME/ppa/opt/, etc..."
  35. if [ -d "$HOME/ppa/opt" ]; then
  36. warn " - Skipping, $HOME/ppa/opt already exists"
  37. else
  38. lmms/cmake/msys/extract_debs.sh
  39. fi
  40. info "Preparing library merge, making all qt headers writable..."
  41. chmod u+w /mingw64/include/qt4 -R
  42. chmod u+w /mingw32/include/qt4 -R
  43. info "Merging mingw headers and libraries from ppa over existing system libraries..."
  44. if ! find /mingw64 | grep sndfile.h; then
  45. command cp -r "$HOME/ppa/opt/mingw"* /
  46. else
  47. warn " - Skipping, sndfile.h has already been merged"
  48. fi
  49. fltkver="1.3.3"
  50. oggver="1.3.2"
  51. vorbisver="1.3.5"
  52. flacver="1.3.2"
  53. gigver="4.0.0"
  54. stkver="4.5.1"
  55. mingw_root="/$(echo "$MSYSTEM"|tr '[:upper:]' '[:lower:]')"
  56. info "Downloading and building fltk $fltkver"
  57. if ! command -v fluid; then
  58. wget http://fltk.org/pub/fltk/$fltkver/fltk-$fltkver-source.tar.gz -O "$HOME/fltk-source.tar.gz"
  59. tar zxf "$HOME/fltk-source.tar.gz" -C "$HOME/"
  60. pushd "$HOME/fltk-$fltkver"
  61. info " - Compiling fltk $fltkver..."
  62. ./configure --prefix="$mingw_root" --enable-shared
  63. make
  64. info " - Installing fltk..."
  65. make install
  66. # ln -s $mingw_root/usr/local/bin/fluid.exe $mingw_root/bin/fluid.exe
  67. popd
  68. else
  69. warn " - Skipping, fluid binary already exists"
  70. fi
  71. info "Downloading and building libogg $oggver"
  72. if [ ! -e "$mingw_root/lib/libogg.dll.a" ]; then
  73. wget http://downloads.xiph.org/releases/ogg/libogg-$oggver.tar.xz -O "$HOME/libogg-source.tar.xz"
  74. tar xf "$HOME/libogg-source.tar.xz" -C "$HOME/"
  75. pushd "$HOME/libogg-$oggver"
  76. info " - Compiling libogg $oggver..."
  77. ./configure --prefix="$mingw_root"
  78. make
  79. info " - Installing libogg..."
  80. make install
  81. # for some reason libgig needs this
  82. ./configure --prefix="/opt$mingw_root"
  83. make
  84. info " - Installing libogg..."
  85. make install
  86. popd
  87. else
  88. warn " - Skipping, libogg binary already exists"
  89. fi
  90. info "Downloading and building libvorbis $vorbisver"
  91. if [ ! -e "$mingw_root/lib/libvorbis.dll.a" ]; then
  92. wget http://downloads.xiph.org/releases/vorbis/libvorbis-$vorbisver.tar.xz -O "$HOME/libvorbis-source.tar.xz"
  93. tar xf "$HOME/libvorbis-source.tar.xz" -C "$HOME/"
  94. pushd "$HOME/libvorbis-$vorbisver"
  95. info " - Compiling libvorbis $vorbisver..."
  96. ./configure --prefix="$mingw_root"
  97. make
  98. info " - Installing libvorbis..."
  99. make install
  100. # for some reason libgig needs this
  101. ./configure --prefix="/opt$mingw_root"
  102. make
  103. info " - Installing libvorbis..."
  104. make install
  105. popd
  106. else
  107. warn " - Skipping, libvorbis binary already exists"
  108. fi
  109. info "Downloading and building flac $flacver"
  110. if [ ! -e "$mingw_root/lib/libFLAC.dll.a" ]; then
  111. wget http://downloads.xiph.org/releases/flac/flac-$flacver.tar.xz -O "$HOME/flac-source.tar.xz"
  112. tar xf "$HOME/flac-source.tar.xz" -C "$HOME/"
  113. pushd "$HOME/flac-$flacver"
  114. info " - Compiling flac $flacver..."
  115. ./configure --prefix="$mingw_root"
  116. make
  117. info " - Installing flac..."
  118. make install
  119. # for some reason libgig needs this
  120. ./configure --prefix="/opt$mingw_root"
  121. make
  122. info " - Installing flac..."
  123. make install
  124. popd
  125. else
  126. warn " - Skipping, libvorbis flac already exists"
  127. fi
  128. info "Downloading and building libgig $gigver"
  129. if [ ! -e "$mingw_root/lib/libgig/libgig.dll.a" ]; then
  130. wget http://download.linuxsampler.org/packages/libgig-$gigver.tar.bz2 -O "$HOME/gig-source.tar.xz"
  131. tar xf "$HOME/gig-source.tar.xz" -C "$HOME/"
  132. pushd "$HOME/libgig-$gigver"
  133. info " - Compiling libgig $gigver..."
  134. ./configure --prefix="$mingw_root"
  135. make
  136. info " - Installing libgig..."
  137. make install
  138. mv "$mingw_root/lib/bin/libakai-0.dll" "$mingw_root/bin"
  139. mv "$mingw_root/lib/bin/libgig-7.dll" "$mingw_root/bin"
  140. popd
  141. else
  142. warn " - Skipping, libgig binary already exists"
  143. fi
  144. info "Downloading and building stk $stkver"
  145. if [ ! -e "$mingw_root/lib/libstk.dll" ]; then
  146. wget http://ccrma.stanford.edu/software/stk/release/stk-$stkver.tar.gz -O "$HOME/stk-source.tar.xz"
  147. tar xf "$HOME/stk-source.tar.xz" -C "$HOME/"
  148. pushd "$HOME/stk-$stkver"
  149. info " - Compiling stk $stkver..."
  150. ./configure --prefix="$mingw_root"
  151. make
  152. info " - Installing stk..."
  153. make install
  154. mv "$mingw_root/lib/libstk.so" "$mingw_root/lib/libstk.dll"
  155. mv "$mingw_root/lib/libstk-$stkver.so" "$mingw_root/lib/libstk-$stkver.dll"
  156. popd
  157. else
  158. warn " - Skipping, stk binary already exists"
  159. fi
  160. # make a symlink to make cmake happy
  161. if [ "$mingw_root" = "/mingw64" ]; then
  162. if [ ! -e /opt/mingw64/bin/x86_64-w64-mingw32-pkg-config ]; then
  163. ln -s /usr/bin/pkg-config /opt/mingw64/bin/x86_64-w64-mingw32-pkg-config
  164. fi
  165. elif [ "$mingw_root" = "/mingw32" ]; then
  166. if [ ! -e /opt/mingw32/bin/i686-w64-mingw32-pkg-config ]; then
  167. ln -s /usr/bin/pkg-config /opt/mingw32/bin/i686-w64-mingw32-pkg-config
  168. fi
  169. fi
  170. info "Cleaning up..."
  171. rm -rf "$HOME/fltk-$fltkver"
  172. rm -rf "$HOME/libogg-$oggver"
  173. rm -rf "$HOME/libvorbis-$vorbisver"
  174. rm -rf "$HOME/flac-$flacver"
  175. rm -rf "$HOME/libgig-$gigver"
  176. rm -rf "$HOME/stk-$stkver"
  177. info "Done."