compile.sh 6.41 KB
Newer Older
1
2
#! /bin/sh

Rafaël Carré's avatar
Rafaël Carré committed
3
4
set -e

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
5
usage()
6
{
7
    echo "Usage: compile <arch> <TargetOS>"
8
    echo "archs: i686,x86_64,armv7,aarch64"
9
    echo "os: win10"
10
11
}

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
12
using()
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{
    echo "preparing for MSVC target: $MSVC_TUPLE"
}

if [ "$1" != "" ]; then

case "$1" in

i686)
    MSVC_TUPLE="Win32"
    using
    ;;
x86_64)
    MSVC_TUPLE="x64"
    using
    ;;
armv7)
    MSVC_TUPLE="ARM"
    using
    ;;
33
34
35
36
aarch64)
    MSVC_TUPLE="ARM64"
    using
    ;;
37
38
39
40
41
42
*) echo "Unknown arch: $1"
   usage
   exit 1
   ;;
esac

43
44
45
case "$2" in
    win10)
        WINVER=0xA00
46
47
        RUNTIME=ucrt
        RUNTIME_EXTRA='-lvcruntime140_app'
48
49
        LIBKERNEL32='-lwindowsapp'
        LIBLOLE32=
50
51
        ;;
    win81)
52
53
54
55
56
57
58
        echo "win81 not supported anymore"
        usage
        exit 1
        #~ WINVER=0x602
        #~ RUNTIME=msvcr120_app
        #~ LIBKERNEL32=-lkernel32
        #~ LIBLOLE32=-lole32
59
60
        ;;
    *)
61
62
63
64
        echo "Unknown OS: $2"
        usage
        exit 1
        ;;
65
66
esac

67
# 1/ libvlc, libvlccore and its plugins
Rafaël Carré's avatar
Rafaël Carré committed
68
TESTED_HASH=45df8a6415
69
70
if [ ! -d "vlc" ]; then
    echo "VLC source not found, cloning"
71
    git clone http://git.videolan.org/git/vlc/vlc-3.0.git vlc
72
    cd vlc
73
74
    git config --global user.email "cone@example.com"
    git config --local user.name "Cony Cone"
75
76
77
78
79
80
    git am -3 ../patches/*.patch
    if [ $? -ne 0 ]; then
        git am --abort
        echo "Applying the patches failed, aborting git-am"
        exit 1
    fi
81
82
83
84
85
86
87
88
89
90
91
92
93
94
else
    echo "VLC source found"
    cd vlc
    if ! git cat-file -e ${TESTED_HASH}; then
        cat << EOF
***
*** Error: Your vlc checkout does not contain the latest tested commit ***
***

EOF
        exit 1
    fi
fi

95
96
97
98
99
100
MAKEFLAGS=
if which nproc >/dev/null
then
MAKEFLAGS=-j`nproc`
fi

101
TARGET_TUPLE=${1}-w64-mingw32
102
103
104
105
case "${1}" in
    *)
        COMPILER=${TARGET_TUPLE}-gcc
        COMPILERXX=${TARGET_TUPLE}-g++
106
107
108
109
110
111
        if ${COMPILER} --version | grep -q gcc ; then
            HAS_GCC=1
        else
            HAS_CLANG=1
        fi
        if [ "${HAS_GCC}" = "1" ]; then
112
113
114
115
116
            ${COMPILER} -dumpspecs | sed -e "s/-lmingwex/-lwinstorecompat -lmingwex -lwinstorecompat $LIBLOLE32 -lruntimeobject -lsynchronization/" -e "s/-lmsvcrt/$RUNTIME_EXTRA -l$RUNTIME/" -e "s/-lkernel32/$LIBKERNEL32/" > ../newspecfile
            NEWSPECFILE="`pwd`/../newspecfile"
            COMPILER="${COMPILER} -specs=$NEWSPECFILE"
            COMPILERXX="${COMPILERXX} -specs=$NEWSPECFILE"
        fi
117
118
119
        BUILD_ARCH=`gcc -dumpmachine`
        ;;
esac
120

121
122
123
# Build tools with the native compiler
echo "Compiling missing tools..."
cd extras/tools
Steve Lhomme's avatar
Steve Lhomme committed
124
125
126

export PATH="$PWD/build/bin":"$PATH"
# Force patched meson as newer versions don't add -lpthread properly in libplacebo.pc
127
FORCED_TOOLS="meson"
Steve Lhomme's avatar
Steve Lhomme committed
128
if [ "${HAS_CLANG}" = "1" ] ; then
129
130
131
    # We need a patched version of libtool & cmake, regardless of which
    # version is installed on the system.
    # cmake can go away when we switch to 3.13.0
132
    FORCED_TOOLS="$FORCED_TOOLS libtool"
133
fi
Steve Lhomme's avatar
Steve Lhomme committed
134
NEEDED="$FORCED_TOOLS" ./bootstrap && make $MAKEFLAGS
135
cd ../../
136

137
EXTRA_CPPFLAGS="-D_WIN32_WINNT=$WINVER -DWINVER=$WINVER -DWINSTORECOMPAT -D_UNICODE -DUNICODE -DWINAPI_FAMILY=WINAPI_FAMILY_APP"
138
if [ "${HAS_GCC}" = 1 ]; then
139
140
141
142
143
144
    EXTRA_LDFLAGS="-lnormaliz -lwinstorecompat -lruntimeobject"
else
    # Clang doesn't support spec files, but will skip the builtin -lmsvcrt and -lkernel32 etc if it detects -lmsvcr* or -lucrt*, and
    # -lwindowsapp on the command line.
    EXTRA_LDFLAGS="-lnormaliz -lwinstorecompat $LIBOLE32 -lruntimeobject -lsynchronization $RUNTIME_EXTRA -l$RUNTIME $LIBKERNEL32"
fi
Rafaël Carré's avatar
Rafaël Carré committed
145

146
echo "Building the contribs"
147
CONTRIB_FOLDER=contrib/winrt-$1-$RUNTIME
148
149
mkdir -p $CONTRIB_FOLDER
cd $CONTRIB_FOLDER
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
150
../bootstrap --host=${TARGET_TUPLE} --build=$BUILD_ARCH --disable-disc \
151
    --disable-sdl \
152
    --disable-schroedinger \
Rafaël Carré's avatar
Rafaël Carré committed
153
    --disable-vncserver \
Rafaël Carré's avatar
Rafaël Carré committed
154
    --disable-chromaprint \
Rafaël Carré's avatar
Rafaël Carré committed
155
    --disable-modplug \
156
157
    --disable-SDL_image \
    --disable-fontconfig \
158
    --enable-zvbi \
159
160
    --disable-caca \
    --disable-gettext \
161
    --enable-gme \
162
    --enable-vorbis \
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
163
    --enable-mad \
164
    --enable-sidplay2 \
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
165
    --enable-samplerate \
166
167
    --enable-iconv \
    --disable-goom \
168
    --enable-dca \
169
170
171
    --disable-fontconfig \
    --disable-gpg-error \
    --disable-projectM \
172
    --enable-ass \
173
    --disable-qt \
Steve Lhomme's avatar
Steve Lhomme committed
174
    --disable-qtsvg \
175
    --disable-aribb25 \
176
    --disable-gnuv3 \
177
    --enable-ssh2 \
178
179
180
    --disable-vncclient \
    --enable-jpeg \
    --enable-postproc \
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
181
    --enable-vpx \
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
182
    --enable-libdsm \
183
    --disable-x264 \
184
    --disable-x265 \
185
186
    --disable-srt \
    --disable-aom
187

188
echo "EXTRA_CFLAGS=${EXTRA_CPPFLAGS}" >> config.mak
Rafaël Carré's avatar
Rafaël Carré committed
189
echo "EXTRA_LDFLAGS=${EXTRA_LDFLAGS}" >> config.mak
190
echo "HAVE_WINSTORE := 1" >> config.mak
191
192
echo "CC=${COMPILER}" >> config.mak
echo "CXX=${COMPILERXX}" >> config.mak
193
echo "MAKEFLAGS=${MAKEFLAGS}" >> config.mak
194
export PKG_CONFIG_LIBDIR="`pwd`/../${TARGET_TUPLE}/lib/pkgconfig"
Rafaël Carré's avatar
Rafaël Carré committed
195

196
USE_FFMPEG=1 make || USE_FFMPEG=1 make -j1
197

198
BUILD_FOLDER=winrt-$1-$RUNTIME
199
cd ../.. && mkdir -p ${BUILD_FOLDER} && cd ${BUILD_FOLDER}
200
201
202
203
204

echo "Bootstraping"
../bootstrap

echo "Configuring"
Rafaël Carré's avatar
Rafaël Carré committed
205
206
CPPFLAGS="${EXTRA_CPPFLAGS}" \
LDFLAGS="${EXTRA_LDFLAGS}" \
207
208
CC="${COMPILER}" \
CXX="${COMPILERXX}" \
209
ac_cv_search_connect="-lws2_32" \
Rafaël Carré's avatar
Rafaël Carré committed
210
../../configure.sh --host=${TARGET_TUPLE}
211
212

echo "Building"
213
make $MAKEFLAGS
214
215
216
217

echo "Package"
make install

218
rm -rf tmp && mkdir tmp
219

220
221
222
# Compiler shared DLLs, when using compilers built with --enable-shared
# The shared DLLs may not necessarily be in the first LIBRARY_PATH, we
# should check them all.
Rafaël Carré's avatar
Rafaël Carré committed
223
library_path_list=`${TARGET_TUPLE}-g++ -v /dev/null 2>&1 | grep ^LIBRARY_PATH|cut -d= -f2` ;
224

225
find _win32/bin -name "*.dll" -exec cp -v {} tmp \;
226
cp -r _win32/include tmp/
227
cp -r _win32/lib/vlc/plugins tmp/
228

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
229
230
find tmp -name "*.la" -exec rm -v {} \;
find tmp -name "*.a" -exec rm -v {} \;
231
blocklist="
Rafaël Carré's avatar
Rafaël Carré committed
232
233
234
wingdi
waveout
dshow
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
235
236
237
238
239
240
241
242
243
244
245
directdraw
windrive
globalhotkeys
direct2d
ntservice
dxva2
dtv
vcd
cdda
quicktime
atmo
Rafaël Carré's avatar
Rafaël Carré committed
246
247
248
oldrc
dmo
panoramix
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
249
250
251
screen
win_msg
win_hotkeys
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
252
253
crystalhd
smb
Rafaël Carré's avatar
Rafaël Carré committed
254
255
"
regexp=
256
for i in ${blocklist}
Rafaël Carré's avatar
Rafaël Carré committed
257
258
259
260
261
262
263
264
265
266
do
    if [ -z "${regexp}" ]
    then
        regexp="${i}"
    else
        regexp="${regexp}|${i}"
    fi
done
rm `find tmp/plugins -name 'lib*plugin.dll' | grep -E "lib(${regexp})_plugin.dll"`

267
find tmp \( -name "*.dll" -o -name "*.exe" \) -exec ${TARGET_TUPLE}-strip {} \;
268
find tmp \( -name "*.dll" -o -name "*.exe" \) -exec ../../appcontainer.pl {} \;
269

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
270
271
cp lib/.libs/libvlc.dll.a tmp/libvlc.lib
cp src/.libs/libvlccore.dll.a tmp/libvlccore.lib
Rafaël Carré's avatar
Rafaël Carré committed
272

273
CURRENTDATE="$(date +%Y%m%d-%H%M)"
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
274

275
cd tmp
276
7z a ../vlc-${1}-${2}-${CURRENTDATE}.7z *
Rafaël Carré's avatar
Rafaël Carré committed
277
cd ..
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
278
rm -rf tmp
279
280
281
282

else
    usage
fi