Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build-deps.sh 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. #!/bin/bash
  2. # apt-get install build-essential autoconf libtool cmake libglib2.0-dev libgl1-mesa-dev
  3. # ---------------------------------------------------------------------------------------------------------------------
  4. # stop on error
  5. set -e
  6. # ---------------------------------------------------------------------------------------------------------------------
  7. # cd to correct path
  8. cd $(dirname $0)
  9. # ---------------------------------------------------------------------------------------------------------------------
  10. # set variables
  11. source common.env
  12. # ---------------------------------------------------------------------------------------------------------------------
  13. # function to remove old stuff
  14. cleanup()
  15. {
  16. rm -rf ${TARGETDIR}/carla32/ ${TARGETDIR}/carla64/
  17. rm -rf file-*
  18. rm -rf flac-*
  19. rm -rf fltk-*
  20. rm -rf fluidsynth-*
  21. rm -rf liblo-*
  22. rm -rf libogg-*
  23. rm -rf libsndfile-*
  24. rm -rf libvorbis-*
  25. rm -rf pkg-config-*
  26. rm -rf zlib-*
  27. }
  28. # ---------------------------------------------------------------------------------------------------------------------
  29. # function to build base libs
  30. build_base()
  31. {
  32. export CC=gcc
  33. export CXX=g++
  34. export PREFIX=${TARGETDIR}/carla${ARCH}
  35. export PATH=${PREFIX}/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
  36. export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
  37. export CFLAGS="-O3 -mtune=generic -msse -msse2 -mfpmath=sse -fvisibility=hidden -fdata-sections -ffunction-sections"
  38. export CFLAGS="${CFLAGS} -fPIC -DPIC -DNDEBUG -I${PREFIX}/include -m${ARCH}"
  39. export CXXFLAGS="${CFLAGS} -fvisibility-inlines-hidden"
  40. export LDFLAGS="-fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-O1 -Wl,--as-needed -Wl,--strip-all"
  41. export LDFLAGS="${LDFLAGS} -L${PREFIX}/lib -m${ARCH}"
  42. # ---------------------------------------------------------------------------------------------------------------------
  43. # pkgconfig
  44. if [ ! -d pkg-config-${PKG_CONFIG_VERSION} ]; then
  45. aria2c https://pkg-config.freedesktop.org/releases/pkg-config-${PKG_CONFIG_VERSION}.tar.gz
  46. tar -xf pkg-config-${PKG_CONFIG_VERSION}.tar.gz
  47. fi
  48. if [ ! -f pkg-config-${PKG_CONFIG_VERSION}_$ARCH/build-done ]; then
  49. cp -r pkg-config-${PKG_CONFIG_VERSION} pkg-config-${PKG_CONFIG_VERSION}_$ARCH
  50. cd pkg-config-${PKG_CONFIG_VERSION}_$ARCH
  51. ./configure --enable-indirect-deps --with-internal-glib --with-pc-path=$PKG_CONFIG_PATH --prefix=${PREFIX}
  52. make ${MAKE_ARGS}
  53. make install
  54. touch build-done
  55. cd ..
  56. fi
  57. # ---------------------------------------------------------------------------------------------------------------------
  58. # liblo
  59. if [ ! -d liblo-${LIBLO_VERSION} ]; then
  60. aria2c https://download.sourceforge.net/liblo/liblo-${LIBLO_VERSION}.tar.gz
  61. tar -xf liblo-${LIBLO_VERSION}.tar.gz
  62. fi
  63. if [ ! -f liblo-${LIBLO_VERSION}_$ARCH/build-done ]; then
  64. cp -r liblo-${LIBLO_VERSION} liblo-${LIBLO_VERSION}_$ARCH
  65. cd liblo-${LIBLO_VERSION}_$ARCH
  66. ./configure --enable-static --disable-shared --prefix=${PREFIX} \
  67. --enable-threads \
  68. --disable-examples --disable-tools
  69. make ${MAKE_ARGS}
  70. make install
  71. touch build-done
  72. cd ..
  73. fi
  74. # ---------------------------------------------------------------------------------------------------------------------
  75. if [ x"${ARCH}" = x"32" ] && [ x"${TARGET}" != x"32" ]; then
  76. return
  77. fi
  78. # ---------------------------------------------------------------------------------------------------------------------
  79. # zlib
  80. if [ ! -d zlib-${ZLIB_VERSION} ]; then
  81. aria2c https://github.com/madler/zlib/archive/v${ZLIB_VERSION}.tar.gz
  82. tar -xf zlib-${ZLIB_VERSION}.tar.gz
  83. fi
  84. if [ ! -f zlib-${ZLIB_VERSION}/build-done ]; then
  85. cd zlib-${ZLIB_VERSION}
  86. ./configure --static --prefix=${PREFIX}
  87. make ${MAKE_ARGS}
  88. make install
  89. touch build-done
  90. cd ..
  91. fi
  92. # ---------------------------------------------------------------------------------------------------------------------
  93. # file/magic
  94. if [ ! -d file-${FILE_VERSION} ]; then
  95. wget ftp://ftp.astron.com/pub/file/file-${FILE_VERSION}.tar.gz
  96. tar -xf file-${FILE_VERSION}.tar.gz
  97. fi
  98. if [ ! -f file-${FILE_VERSION}/build-done ]; then
  99. cd file-${FILE_VERSION}
  100. ./configure --enable-static --disable-shared --prefix=${PREFIX}
  101. make ${MAKE_ARGS}
  102. make install
  103. touch build-done
  104. cd ..
  105. fi
  106. # ---------------------------------------------------------------------------------------------------------------------
  107. # libogg
  108. if [ ! -d libogg-${LIBOGG_VERSION} ]; then
  109. aria2c https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-${LIBOGG_VERSION}.tar.gz
  110. tar -xf libogg-${LIBOGG_VERSION}.tar.gz
  111. fi
  112. if [ ! -f libogg-${LIBOGG_VERSION}/build-done ]; then
  113. cd libogg-${LIBOGG_VERSION}
  114. ./configure --enable-static --disable-shared --prefix=${PREFIX}
  115. make ${MAKE_ARGS}
  116. make install
  117. touch build-done
  118. cd ..
  119. fi
  120. # ---------------------------------------------------------------------------------------------------------------------
  121. # libvorbis
  122. if [ ! -d libvorbis-${LIBVORBIS_VERSION} ]; then
  123. aria2c https://ftp.osuosl.org/pub/xiph/releases/vorbis/libvorbis-${LIBVORBIS_VERSION}.tar.gz
  124. tar -xf libvorbis-${LIBVORBIS_VERSION}.tar.gz
  125. fi
  126. if [ ! -f libvorbis-${LIBVORBIS_VERSION}/build-done ]; then
  127. cd libvorbis-${LIBVORBIS_VERSION}
  128. ./configure --enable-static --disable-shared --prefix=${PREFIX}
  129. make ${MAKE_ARGS}
  130. make install
  131. touch build-done
  132. cd ..
  133. fi
  134. # ---------------------------------------------------------------------------------------------------------------------
  135. # flac
  136. if [ ! -d flac-${FLAC_VERSION} ]; then
  137. aria2c https://ftp.osuosl.org/pub/xiph/releases/flac/flac-${FLAC_VERSION}.tar.xz
  138. tar -xf flac-${FLAC_VERSION}.tar.xz
  139. fi
  140. if [ ! -f flac-${FLAC_VERSION}/build-done ]; then
  141. cd flac-${FLAC_VERSION}
  142. chmod +x configure install-sh
  143. ./configure --enable-static --disable-shared --prefix=${PREFIX} \
  144. --disable-cpplibs
  145. make ${MAKE_ARGS}
  146. make install
  147. touch build-done
  148. cd ..
  149. fi
  150. # ---------------------------------------------------------------------------------------------------------------------
  151. # libsndfile
  152. if [ ! -d libsndfile-${LIBSNDFILE_VERSION} ]; then
  153. wget http://www.mega-nerd.com/libsndfile/files/libsndfile-${LIBSNDFILE_VERSION}.tar.gz
  154. tar -xf libsndfile-${LIBSNDFILE_VERSION}.tar.gz
  155. fi
  156. if [ ! -f libsndfile-${LIBSNDFILE_VERSION}/build-done ]; then
  157. cd libsndfile-${LIBSNDFILE_VERSION}
  158. ./configure --enable-static --disable-shared --prefix=${PREFIX} \
  159. --disable-full-suite --disable-alsa --disable-sqlite
  160. make ${MAKE_ARGS}
  161. make install
  162. touch build-done
  163. cd ..
  164. fi
  165. # ---------------------------------------------------------------------------------------------------------------------
  166. # glib
  167. if [ ! -d ${PREFIX}/include/glib-2.0 ]; then
  168. cp -r /usr/include/glib-2.0 ${PREFIX}/include/
  169. fi
  170. if [ ! -f ${PREFIX}/lib/pkgconfig/glib-2.0.pc ]; then
  171. if [ -f /usr/lib/x86_64-linux-gnu/pkgconfig/glib-2.0.pc ]; then
  172. cp /usr/lib/x86_64-linux-gnu/pkgconfig/glib-2.0.pc ${PREFIX}/lib/pkgconfig/
  173. cp /usr/lib/x86_64-linux-gnu/pkgconfig/gthread-2.0.pc ${PREFIX}/lib/pkgconfig/
  174. cp /usr/lib/x86_64-linux-gnu/pkgconfig/libpcre.pc ${PREFIX}/lib/pkgconfig/
  175. else
  176. cp /usr/lib/pkgconfig/glib-2.0.pc ${PREFIX}/lib/pkgconfig/
  177. cp /usr/lib/pkgconfig/gthread-2.0.pc ${PREFIX}/lib/pkgconfig/
  178. fi
  179. fi
  180. # ---------------------------------------------------------------------------------------------------------------------
  181. # fluidsynth
  182. if [ ! -d fluidsynth-${FLUIDSYNTH_VERSION} ]; then
  183. aria2c https://github.com/FluidSynth/fluidsynth/archive/v${FLUIDSYNTH_VERSION}.tar.gz
  184. tar -xf fluidsynth-${FLUIDSYNTH_VERSION}.tar.gz
  185. fi
  186. if [ ! -f fluidsynth-${FLUIDSYNTH_VERSION}/build-done ]; then
  187. cd fluidsynth-${FLUIDSYNTH_VERSION}
  188. if [ ! -f patched ]; then
  189. patch -p1 -i ../../patches/fluidsynth-skip-drivers-build.patch
  190. touch patched
  191. fi
  192. sed -i "s/3.0.2/2.8.0/" CMakeLists.txt
  193. sed -i 's/_init_lib_suffix "64"/_init_lib_suffix ""/' CMakeLists.txt
  194. cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${PREFIX} -DBUILD_SHARED_LIBS=OFF \
  195. -Denable-debug=OFF -Denable-profiling=OFF -Denable-ladspa=OFF -Denable-fpe-check=OFF -Denable-portaudio=OFF \
  196. -Denable-trap-on-fpe=OFF -Denable-aufile=OFF -Denable-dbus=OFF -Denable-ipv6=OFF -Denable-jack=OFF \
  197. -Denable-midishare=OFF -Denable-oss=OFF -Denable-pulseaudio=OFF -Denable-readline=OFF -Denable-ladcca=OFF \
  198. -Denable-lash=OFF -Denable-alsa=OFF -Denable-coreaudio=OFF -Denable-coremidi=OFF -Denable-framework=OFF \
  199. -Denable-floats=ON
  200. make ${MAKE_ARGS}
  201. make install
  202. sed -i -e "s|-lfluidsynth|-lfluidsynth -lglib-2.0 -lgthread-2.0 -lsndfile -lFLAC -lvorbisenc -lvorbis -logg -lpthread -lm|" ${PREFIX}/lib/pkgconfig/fluidsynth.pc
  203. touch build-done
  204. cd ..
  205. fi
  206. # ---------------------------------------------------------------------------------------------------------------------
  207. # mxml
  208. if [ ! -d mxml-${MXML_VERSION} ]; then
  209. aria2c https://github.com/michaelrsweet/mxml/releases/download/v${MXML_VERSION}/mxml-${MXML_VERSION}.tar.gz
  210. mkdir mxml-${MXML_VERSION}
  211. cd mxml-${MXML_VERSION}
  212. tar -xf ../mxml-${MXML_VERSION}.tar.gz
  213. cd ..
  214. fi
  215. if [ ! -f mxml-${MXML_VERSION}/build-done ]; then
  216. cd mxml-${MXML_VERSION}
  217. ./configure --disable-shared --prefix=$PREFIX
  218. make libmxml.a
  219. cp *.a $PREFIX/lib/
  220. cp *.pc $PREFIX/lib/pkgconfig/
  221. cp mxml.h $PREFIX/include/
  222. touch build-done
  223. cd ..
  224. fi
  225. # ---------------------------------------------------------------------------------------------------------------------
  226. # fftw3 (needs to be last as it modifies C[XX]FLAGS)
  227. if [ ! -d fftw-${FFTW3_VERSION} ]; then
  228. aria2c http://www.fftw.org/fftw-${FFTW3_VERSION}.tar.gz
  229. tar -xf fftw-${FFTW3_VERSION}.tar.gz
  230. fi
  231. if [ ! -f fftw-${FFTW3_VERSION}/build-done ]; then
  232. export CFLAGS="${CFLAGS} -ffast-math"
  233. export CXXFLAGS="${CXXFLAGS} -ffast-math"
  234. cd fftw-${FFTW3_VERSION}
  235. ./configure --enable-static --disable-shared --prefix=${PREFIX} \
  236. --enable-sse2 \
  237. --disable-debug --disable-alloca --disable-fortran \
  238. --with-our-malloc
  239. make
  240. make install
  241. make clean
  242. ./configure --enable-static --disable-shared --prefix=${PREFIX} \
  243. --enable-sse2 --enable-sse --enable-single \
  244. --disable-debug --disable-alloca --disable-fortran \
  245. --with-our-malloc
  246. make
  247. make install
  248. make clean
  249. touch build-done
  250. cd ..
  251. fi
  252. }
  253. # ---------------------------------------------------------------------------------------------------------------------
  254. # build base libs
  255. export ARCH=32
  256. export TARGET="${1}"
  257. build_base
  258. if [ x"${TARGET}" != x"32" ]; then
  259. export ARCH=64
  260. build_base
  261. fi
  262. # ---------------------------------------------------------------------------------------------------------------------