Cleanup
[carla.git] / data / linux / build-deps.sh
blobd5e772140c3caeee303478f1d125366d2873dbc2
1 #!/bin/bash
3 # apt-get install build-essential autoconf libtool cmake libglib2.0-dev libgl1-mesa-dev
5 # ---------------------------------------------------------------------------------------------------------------------
6 # stop on error
8 set -e
10 # ---------------------------------------------------------------------------------------------------------------------
11 # cd to correct path
13 cd $(dirname $0)
15 # ---------------------------------------------------------------------------------------------------------------------
16 # set variables
18 source common.env
20 # ---------------------------------------------------------------------------------------------------------------------
21 # function to remove old stuff
23 cleanup()
26 rm -rf ${TARGETDIR}/carla32/ ${TARGETDIR}/carla64/
27 rm -rf file-*
28 rm -rf flac-*
29 rm -rf fltk-*
30 rm -rf fluidsynth-*
31 rm -rf liblo-*
32 rm -rf libogg-*
33 rm -rf libsndfile-*
34 rm -rf libvorbis-*
35 rm -rf pkg-config-*
36 rm -rf qtbase-*
37 rm -rf qtsvg-*
38 rm -rf zlib-*
42 # ---------------------------------------------------------------------------------------------------------------------
43 # function to build base libs
45 build_base()
48 export CC=gcc
49 export CXX=g++
51 export PREFIX=${TARGETDIR}/carla${ARCH}
52 export PATH=${PREFIX}/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
53 export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
55 export CFLAGS="-O3 -mtune=generic -msse -msse2 -mfpmath=sse -fvisibility=hidden -fdata-sections -ffunction-sections"
56 export CFLAGS="${CFLAGS} -fPIC -DPIC -DNDEBUG -I${PREFIX}/include -m${ARCH}"
57 export CXXFLAGS="${CFLAGS} -fvisibility-inlines-hidden"
59 export LDFLAGS="-fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-O1 -Wl,--as-needed -Wl,--strip-all"
60 export LDFLAGS="${LDFLAGS} -L${PREFIX}/lib -m${ARCH}"
62 # ---------------------------------------------------------------------------------------------------------------------
63 # pkgconfig
65 if [ ! -d pkg-config-${PKG_CONFIG_VERSION} ]; then
66 aria2c https://pkg-config.freedesktop.org/releases/pkg-config-${PKG_CONFIG_VERSION}.tar.gz
67 tar -xf pkg-config-${PKG_CONFIG_VERSION}.tar.gz
70 if [ ! -f pkg-config-${PKG_CONFIG_VERSION}_$ARCH/build-done ]; then
71 cp -r pkg-config-${PKG_CONFIG_VERSION} pkg-config-${PKG_CONFIG_VERSION}_$ARCH
72 cd pkg-config-${PKG_CONFIG_VERSION}_$ARCH
73 ./configure --enable-indirect-deps --with-internal-glib --with-pc-path=$PKG_CONFIG_PATH --prefix=${PREFIX}
74 make ${MAKE_ARGS}
75 make install
76 touch build-done
77 cd ..
80 # ---------------------------------------------------------------------------------------------------------------------
81 # liblo
83 if [ ! -d liblo-${LIBLO_VERSION} ]; then
84 aria2c https://download.sourceforge.net/liblo/liblo-${LIBLO_VERSION}.tar.gz
85 tar -xf liblo-${LIBLO_VERSION}.tar.gz
88 if [ ! -f liblo-${LIBLO_VERSION}_$ARCH/build-done ]; then
89 cp -r liblo-${LIBLO_VERSION} liblo-${LIBLO_VERSION}_$ARCH
90 cd liblo-${LIBLO_VERSION}_$ARCH
91 ./configure --enable-static --disable-shared --prefix=${PREFIX} \
92 --enable-threads \
93 --disable-examples --disable-tools
94 make ${MAKE_ARGS}
95 make install
96 touch build-done
97 cd ..
100 # ---------------------------------------------------------------------------------------------------------------------
102 if [ x"${ARCH}" = x"32" ] && [ x"${TARGET}" != x"32" ]; then
103 return
106 # ---------------------------------------------------------------------------------------------------------------------
107 # qt
109 if [ ! -d qtbase-opensource-src-${QT5_VERSION} ]; then
110 aria2c http://download.qt.io/archive/qt/${QT5_MVERSION}/${QT5_VERSION}/submodules/qtbase-opensource-src-${QT5_VERSION}.tar.xz
111 tar xf qtbase-opensource-src-${QT5_VERSION}.tar.xz
114 if [ ! -f qtbase-opensource-src-${QT5_VERSION}/build-done ]; then
115 cd qtbase-opensource-src-${QT5_VERSION}
116 if [ ! -f configured ]; then
117 ./configure -release -strip -silent \
118 -sse2 \
119 -no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 \
120 -no-avx -no-avx2 -no-avx512 \
121 -prefix ${PREFIX} \
122 -opensource -confirm-license \
123 -optimize-size -optimized-qmake \
124 -qt-freetype \
125 -qt-harfbuzz \
126 -qt-libjpeg \
127 -qt-libpng \
128 -qt-pcre \
129 -qt-sqlite \
130 -qt-xcb \
131 -qt-zlib \
132 -opengl desktop \
133 -no-cups \
134 -no-gtk \
135 -no-icu \
136 -no-openssl \
137 -make libs \
138 -make tools \
139 -nomake examples \
140 -nomake tests
141 touch configured
143 make ${MAKE_ARGS}
144 make install
145 touch build-done
146 cd ..
149 # ---------------------------------------------------------------------------------------------------------------------
150 # qt5-svg
152 if [ ! -d qtsvg-opensource-src-${QT5_VERSION} ]; then
153 aria2c http://download.qt.io/archive/qt/${QT5_MVERSION}/${QT5_VERSION}/submodules/qtsvg-opensource-src-${QT5_VERSION}.tar.xz
154 tar xf qtsvg-opensource-src-${QT5_VERSION}.tar.xz
157 if [ ! -f qtsvg-opensource-src-${QT5_VERSION}/build-done ]; then
158 cd qtsvg-opensource-src-${QT5_VERSION}
159 qmake
160 make ${MAKE_ARGS}
161 make install
162 touch build-done
163 cd ..
166 # ---------------------------------------------------------------------------------------------------------------------
167 # zlib
169 if [ ! -d zlib-${ZLIB_VERSION} ]; then
170 aria2c https://github.com/madler/zlib/archive/v${ZLIB_VERSION}.tar.gz
171 tar -xf zlib-${ZLIB_VERSION}.tar.gz
174 if [ ! -f zlib-${ZLIB_VERSION}/build-done ]; then
175 cd zlib-${ZLIB_VERSION}
176 ./configure --static --prefix=${PREFIX}
177 make ${MAKE_ARGS}
178 make install
179 touch build-done
180 cd ..
183 # ---------------------------------------------------------------------------------------------------------------------
184 # file/magic
186 if [ ! -d file-${FILE_VERSION} ]; then
187 wget ftp://ftp.astron.com/pub/file/file-${FILE_VERSION}.tar.gz
188 tar -xf file-${FILE_VERSION}.tar.gz
191 if [ ! -f file-${FILE_VERSION}/build-done ]; then
192 cd file-${FILE_VERSION}
193 ./configure --enable-static --disable-shared --prefix=${PREFIX}
194 make ${MAKE_ARGS}
195 make install
196 touch build-done
197 cd ..
200 # ---------------------------------------------------------------------------------------------------------------------
201 # libogg
203 if [ ! -d libogg-${LIBOGG_VERSION} ]; then
204 aria2c https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-${LIBOGG_VERSION}.tar.gz
205 tar -xf libogg-${LIBOGG_VERSION}.tar.gz
208 if [ ! -f libogg-${LIBOGG_VERSION}/build-done ]; then
209 cd libogg-${LIBOGG_VERSION}
210 ./configure --enable-static --disable-shared --prefix=${PREFIX}
211 make ${MAKE_ARGS}
212 make install
213 touch build-done
214 cd ..
217 # ---------------------------------------------------------------------------------------------------------------------
218 # libvorbis
220 if [ ! -d libvorbis-${LIBVORBIS_VERSION} ]; then
221 aria2c https://ftp.osuosl.org/pub/xiph/releases/vorbis/libvorbis-${LIBVORBIS_VERSION}.tar.gz
222 tar -xf libvorbis-${LIBVORBIS_VERSION}.tar.gz
225 if [ ! -f libvorbis-${LIBVORBIS_VERSION}/build-done ]; then
226 cd libvorbis-${LIBVORBIS_VERSION}
227 ./configure --enable-static --disable-shared --prefix=${PREFIX}
228 make ${MAKE_ARGS}
229 make install
230 touch build-done
231 cd ..
234 # ---------------------------------------------------------------------------------------------------------------------
235 # flac
237 if [ ! -d flac-${FLAC_VERSION} ]; then
238 aria2c https://ftp.osuosl.org/pub/xiph/releases/flac/flac-${FLAC_VERSION}.tar.xz
239 tar -xf flac-${FLAC_VERSION}.tar.xz
242 if [ ! -f flac-${FLAC_VERSION}/build-done ]; then
243 cd flac-${FLAC_VERSION}
244 chmod +x configure install-sh
245 ./configure --enable-static --disable-shared --prefix=${PREFIX} \
246 --disable-cpplibs
247 make ${MAKE_ARGS}
248 make install
249 touch build-done
250 cd ..
253 # ---------------------------------------------------------------------------------------------------------------------
254 # libsndfile
256 if [ ! -d libsndfile-${LIBSNDFILE_VERSION} ]; then
257 wget http://www.mega-nerd.com/libsndfile/files/libsndfile-${LIBSNDFILE_VERSION}.tar.gz
258 tar -xf libsndfile-${LIBSNDFILE_VERSION}.tar.gz
261 if [ ! -f libsndfile-${LIBSNDFILE_VERSION}/build-done ]; then
262 cd libsndfile-${LIBSNDFILE_VERSION}
263 ./configure --enable-static --disable-shared --prefix=${PREFIX} \
264 --disable-full-suite --disable-alsa --disable-sqlite
265 make ${MAKE_ARGS}
266 make install
267 touch build-done
268 cd ..
271 # ---------------------------------------------------------------------------------------------------------------------
272 # glib
274 if [ ! -d ${PREFIX}/include/glib-2.0 ]; then
275 cp -r /usr/include/glib-2.0 ${PREFIX}/include/
278 if [ ! -f ${PREFIX}/lib/pkgconfig/glib-2.0.pc ]; then
279 if [ -f /usr/lib/x86_64-linux-gnu/pkgconfig/glib-2.0.pc ]; then
280 cp /usr/lib/x86_64-linux-gnu/pkgconfig/glib-2.0.pc ${PREFIX}/lib/pkgconfig/
281 cp /usr/lib/x86_64-linux-gnu/pkgconfig/gthread-2.0.pc ${PREFIX}/lib/pkgconfig/
282 cp /usr/lib/x86_64-linux-gnu/pkgconfig/libpcre.pc ${PREFIX}/lib/pkgconfig/
283 else
284 cp /usr/lib/pkgconfig/glib-2.0.pc ${PREFIX}/lib/pkgconfig/
285 cp /usr/lib/pkgconfig/gthread-2.0.pc ${PREFIX}/lib/pkgconfig/
289 # ---------------------------------------------------------------------------------------------------------------------
290 # fluidsynth
292 if [ ! -d fluidsynth-${FLUIDSYNTH_VERSION} ]; then
293 aria2c https://github.com/FluidSynth/fluidsynth/archive/v${FLUIDSYNTH_VERSION}.tar.gz
294 tar -xf fluidsynth-${FLUIDSYNTH_VERSION}.tar.gz
297 if [ ! -f fluidsynth-${FLUIDSYNTH_VERSION}/build-done ]; then
298 cd fluidsynth-${FLUIDSYNTH_VERSION}
299 if [ ! -f patched ]; then
300 patch -p1 -i ../../patches/fluidsynth-skip-drivers-build.patch
301 touch patched
303 sed -i "s/3.0.2/2.8.0/" CMakeLists.txt
304 sed -i 's/_init_lib_suffix "64"/_init_lib_suffix ""/' CMakeLists.txt
305 cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${PREFIX} -DBUILD_SHARED_LIBS=OFF \
306 -Denable-debug=OFF -Denable-profiling=OFF -Denable-ladspa=OFF -Denable-fpe-check=OFF -Denable-portaudio=OFF \
307 -Denable-trap-on-fpe=OFF -Denable-aufile=OFF -Denable-dbus=OFF -Denable-ipv6=OFF -Denable-jack=OFF \
308 -Denable-midishare=OFF -Denable-oss=OFF -Denable-pulseaudio=OFF -Denable-readline=OFF -Denable-ladcca=OFF \
309 -Denable-lash=OFF -Denable-alsa=OFF -Denable-coreaudio=OFF -Denable-coremidi=OFF -Denable-framework=OFF \
310 -Denable-floats=ON
311 make ${MAKE_ARGS}
312 make install
313 sed -i -e "s|-lfluidsynth|-lfluidsynth -lglib-2.0 -lgthread-2.0 -lsndfile -lFLAC -lvorbisenc -lvorbis -logg -pthread -lm|" ${PREFIX}/lib/pkgconfig/fluidsynth.pc
314 touch build-done
315 cd ..
318 # ---------------------------------------------------------------------------------------------------------------------
319 # mxml
321 if [ ! -d mxml-${MXML_VERSION} ]; then
322 aria2c https://github.com/michaelrsweet/mxml/releases/download/v${MXML_VERSION}/mxml-${MXML_VERSION}.tar.gz
323 tar -xf mxml-${MXML_VERSION}.tar.gz
326 if [ ! -f mxml-${MXML_VERSION}/build-done ]; then
327 cd mxml-${MXML_VERSION}
328 ./configure --disable-shared --prefix=$PREFIX
329 make libmxml.a
330 cp *.a $PREFIX/lib/
331 cp *.pc $PREFIX/lib/pkgconfig/
332 cp mxml.h $PREFIX/include/
333 touch build-done
334 cd ..
337 # ---------------------------------------------------------------------------------------------------------------------
338 # fftw3 (needs to be last as it modifies C[XX]FLAGS)
340 if [ ! -d fftw-${FFTW3_VERSION} ]; then
341 aria2c http://www.fftw.org/fftw-${FFTW3_VERSION}.tar.gz
342 tar -xf fftw-${FFTW3_VERSION}.tar.gz
345 if [ ! -f fftw-${FFTW3_VERSION}/build-done ]; then
346 export CFLAGS="${CFLAGS} -ffast-math"
347 export CXXFLAGS="${CXXFLAGS} -ffast-math"
348 cd fftw-${FFTW3_VERSION}
349 ./configure --enable-static --disable-shared --prefix=${PREFIX} \
350 --enable-sse2 \
351 --disable-debug --disable-alloca --disable-fortran \
352 --with-our-malloc
353 make
354 make install
355 make clean
356 ./configure --enable-static --disable-shared --prefix=${PREFIX} \
357 --enable-sse2 --enable-sse --enable-single \
358 --disable-debug --disable-alloca --disable-fortran \
359 --with-our-malloc
360 make
361 make install
362 make clean
363 touch build-done
364 cd ..
369 # ---------------------------------------------------------------------------------------------------------------------
370 # build base libs
372 export ARCH=32
373 export TARGET="${1}"
374 build_base
376 if [ x"${TARGET}" != x"32" ]; then
377 export ARCH=64
378 build_base
381 # ---------------------------------------------------------------------------------------------------------------------