summaryrefslogtreecommitdiff
path: root/tools/macos/build-dg.sh
blob: bd799b8e542d3c5661d9aeca7ebf2d4afda466b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#!/bin/bash

# ---------------------------------------------------------------------------------------------------------------------
# stop on error

set -e

# ---------------------------------------------------------------------------------------------------------------------
# stop on error

TARGETDIR=$PWD/builds/drumgizmo

DOWNLOADS=$PWD/downloads

PKG_CONFIG_VERSION=0.28
LIBOGG_VERSION=1.3.3
LIBVORBIS_VERSION=1.3.6
FLAC_VERSION=1.3.2
LIBSNDFILE_VERSION=1.0.28
ZITA_RESAMPLER_VERSION=1.6.2

DRUMGIZMO_VERSION=0.9.20

# ---------------------------------------------------------------------------------------------------------------------
# function to remove old stuff

cleanup()
{

rm -rf $TARGETDIR
rm -rf flac-*
rm -rf libogg-*
rm -rf libsndfile-*
rm -rf libvorbis-*
rm -rf pkg-config-*
exit 0

}

# ---------------------------------------------------------------------------------------------------------------------
# setup build vars

export CC=clang
export CXX=clang++

export PREFIX=${TARGETDIR}
export PATH=${PREFIX}/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig

export CFLAGS="-O3 -mtune=generic -msse -msse2 -fvisibility=hidden"
export CFLAGS="${CFLAGS} -fPIC -DPIC -DNDEBUG -I${PREFIX}/include"
export CXXFLAGS="${CFLAGS} -fvisibility-inlines-hidden -stdlib=libc++"

export LDFLAGS="-Wl,-dead_strip -Wl,-dead_strip_dylibs"
export LDFLAGS="${LDFLAGS} -L${PREFIX}/lib"

# ---------------------------------------------------------------------------------------------------------------------
echo ==== Package pkgconfig ====

if [ ! -f ${DOWNLOADS}/pkg-config-${PKG_CONFIG_VERSION}.tar.gz ]; then
  pushd ${DOWNLOADS}
  curl -O https://pkg-config.freedesktop.org/releases/pkg-config-${PKG_CONFIG_VERSION}.tar.gz
  popd
fi

if [ ! -d pkg-config-${PKG_CONFIG_VERSION} ]; then
  tar -xf ${DOWNLOADS}/pkg-config-${PKG_CONFIG_VERSION}.tar.gz
fi

if [ ! -f pkg-config-${PKG_CONFIG_VERSION}/build-done ]; then
  cd pkg-config-${PKG_CONFIG_VERSION}
  ./configure --enable-indirect-deps --with-internal-glib --with-pc-path=$PKG_CONFIG_PATH --prefix=${PREFIX}
  make ${MAKE_ARGS}
  make install
  touch build-done
  cd ..
fi

# ---------------------------------------------------------------------------------------------------------------------
echo ==== Package libogg ====

if [ ! -f ${DOWNLOADS}/libogg-${LIBOGG_VERSION}.tar.gz ]; then
  pushd ${DOWNLOADS}
  curl -O http://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-${LIBOGG_VERSION}.tar.gz
  popd
fi

if [ ! -d libogg-${LIBOGG_VERSION} ]; then
  tar -xf ${DOWNLOADS}/libogg-${LIBOGG_VERSION}.tar.gz
fi

if [ ! -f libogg-${LIBOGG_VERSION}/build-done ]; then
  cd libogg-${LIBOGG_VERSION}
  ./configure --enable-static --disable-shared --prefix=${PREFIX}
  make ${MAKE_ARGS}
  make install
  touch build-done
  cd ..
fi

# ---------------------------------------------------------------------------------------------------------------------
echo ==== Package libvorbis ====

if [ ! -f ${DOWNLOADS}/libvorbis-${LIBVORBIS_VERSION}.tar.gz ]; then
  pushd ${DOWNLOADS}
  curl -O http://ftp.osuosl.org/pub/xiph/releases/vorbis/libvorbis-${LIBVORBIS_VERSION}.tar.gz
  popd
fi

if [ ! -d libvorbis-${LIBVORBIS_VERSION} ]; then
  tar -xf ${DOWNLOADS}/libvorbis-${LIBVORBIS_VERSION}.tar.gz
fi

if [ ! -f libvorbis-${LIBVORBIS_VERSION}/build-done ]; then
  cd libvorbis-${LIBVORBIS_VERSION}
  ./configure --enable-static --disable-shared --prefix=${PREFIX}
  make ${MAKE_ARGS}
  make install
  touch build-done
  cd ..
fi

# ---------------------------------------------------------------------------------------------------------------------
echo ==== Package flac ====

if [ ! -f ${DOWNLOADS}/flac-${FLAC_VERSION}.tar.xz ]; then
  pushd ${DOWNLOADS}
  curl -O http://ftp.osuosl.org/pub/xiph/releases/flac/flac-${FLAC_VERSION}.tar.xz
  popd
fi
if [ ! -d flac-${FLAC_VERSION} ]; then
  tar -xf ${DOWNLOADS}/flac-${FLAC_VERSION}.tar.xz
fi

if [ ! -f flac-${FLAC_VERSION}/build-done ]; then
  cd flac-${FLAC_VERSION}
  sed -i -e "s/HAVE_CPUID_H/HAVE_CPUID_H_NOT/" src/libFLAC/cpu.c
  chmod +x configure install-sh
  ./configure --enable-static --disable-shared --prefix=${PREFIX} \
    --disable-cpplibs
  echo "exit 0" > missing
  make ${MAKE_ARGS}
  make install
  touch build-done
  cd ..
fi

# ---------------------------------------------------------------------------------------------------------------------
echo ==== Package libsndfile ====

if [ ! -f ${DOWNLOADS}/libsndfile-${LIBSNDFILE_VERSION}.tar.gz ]; then
  pushd ${DOWNLOADS}
  curl -O http://www.mega-nerd.com/libsndfile/files/libsndfile-${LIBSNDFILE_VERSION}.tar.gz
  popd
fi

if [ ! -d libsndfile-${LIBSNDFILE_VERSION} ]; then
  tar -xf ${DOWNLOADS}/libsndfile-${LIBSNDFILE_VERSION}.tar.gz
fi

if [ ! -f libsndfile-${LIBSNDFILE_VERSION}/build-done ]; then
  cd libsndfile-${LIBSNDFILE_VERSION}
  ./configure --enable-static --disable-shared --prefix=${PREFIX} \
    --disable-full-suite --disable-sqlite
  make ${MAKE_ARGS}
  make install
  sed -i -e "s|-lsndfile|-lsndfile -lFLAC -lvorbisenc -lvorbis -logg -lm|" ${PREFIX}/lib/pkgconfig/sndfile.pc
  touch build-done
  cd ..
fi

# ---------------------------------------------------------------------------------------------------------------------
echo ==== Package zita-resampler ====

if [ ! -f ${DOWNLOADS}/zita-resampler-${ZITA_RESAMPLER_VERSION}.tar.bz2 ]; then
  pushd ${DOWNLOADS}
  curl -O http://kokkinizita.linuxaudio.org/linuxaudio/downloads/zita-resampler-${ZITA_RESAMPLER_VERSION}.tar.bz2
  popd
fi

if [ ! -d zita-resampler-${ZITA_RESAMPLER_VERSION} ]; then
  tar -xf ${DOWNLOADS}/zita-resampler-${ZITA_RESAMPLER_VERSION}.tar.bz2
fi

if [ ! -f zita-resampler-${ZITA_RESAMPLER_VERSION}/build-done ]; then
  cd zita-resampler-${ZITA_RESAMPLER_VERSION}
  if [ ! -f patched ]; then
    patch -p1 -i ../zita-resampler-static-build.patch
    touch patched
  fi
  make ${MAKE_ARGS} -C source
  mkdir ${PREFIX}/include/zita-resampler
  cp source/*.a ${PREFIX}/lib/
  cp source/zita-resampler/*.h ${PREFIX}/include/zita-resampler/
  touch build-done
  cd ..
fi

# ---------------------------------------------------------------------------------------------------------------------
echo ==== Package drumgizmo ====

if [ ! -f ${DOWNLOADS}/drumgizmo-${DRUMGIZMO_VERSION}.tar.gz ]; then
  pushd ${DOWNLOADS}
  curl -O https://www.drumgizmo.org/releases/drumgizmo-${DRUMGIZMO_VERSION}/drumgizmo-${DRUMGIZMO_VERSION}.tar.gz
  popd
fi

if [ ! -d drumgizmo-${DRUMGIZMO_VERSION} ]; then
  tar -xf ${DOWNLOADS}/drumgizmo-${DRUMGIZMO_VERSION}.tar.gz
fi

if [ ! -f drumgizmo-${DRUMGIZMO_VERSION}/build-done ]; then
  PATH=/usr/local/opt/gettext/bin:$PATH
  cd drumgizmo-${DRUMGIZMO_VERSION}
  ./configure --prefix=${PREFIX} \
    --disable-input-midifile \
    --disable-input-jackmidi \
    --disable-output-jackaudio \
    --disable-input-alsamidi \
    --disable-output-alsa \
    --enable-cli \
    --without-debug \
    --with-test \
    --disable-lv2 \
    --enable-vst \
    --with-vst-sources=$HOME/VST3_SDK
  make ${MAKE_ARGS}
  make install
  touch build-done
  cd ..
fi

# ---------------------------------------------------------------------------------------------------------------------

echo Make macOS package:

otool -L ${PREFIX}/lib/vst/drumgizmo_vst.so

if [ ! -f drumgizmo.vst.tar.gz ]; then
  exit "Missing VST package template: drumgizmo.vst.tar.gz "
fi

if [ ! -d ${DRUMGIZMO_VERSION}/drumgizmo.vst ]; then
  mkdir -p ${DRUMGIZMO_VERSION}
  pushd ${DRUMGIZMO_VERSION}
  tar -xvzf ../drumgizmo.vst.tar.gz
  popd
fi

cp -a ${PREFIX}/lib/vst/drumgizmo_vst.so ${DRUMGIZMO_VERSION}/drumgizmo.vst/Contents/MacOS/drumgizmo
sed -e "s/@VERSION@/${DRUMGIZMO_VERSION}/g" -i .bak ${DRUMGIZMO_VERSION}/drumgizmo.vst/Contents/Info.plist
rm -f ${DRUMGIZMO_VERSION}/drumgizmo.vst/Contents/Info.plist.bak

pushd ${DRUMGIZMO_VERSION}
tar cvzf ../drumgizmo_vst-osx-${DRUMGIZMO_VERSION}.tar.gz drumgizmo.vst/
popd

echo Package is now ready in drumgizmo_vst-osx-${DRUMGIZMO_VERSION}.tar.gz