compile.sh 5.45 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>"
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
8
    echo "archs: i686,x86_64,armv7"
9
    echo "os: win81,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
33
34
35
36
37
38
{
    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
    ;;
*) echo "Unknown arch: $1"
   usage
   exit 1
   ;;
esac

39
40
41
case "$2" in
    win10)
        WINVER=0xA00
42
        RUNTIME=msvcr120_app
43
44
        LIBKERNEL32='-lwindowsapp'
        LIBLOLE32=
45
46
47
        ;;
    win81)
        WINVER=0x602
48
        RUNTIME=msvcr120_app
49
50
        LIBKERNEL32=-lkernel32
        LIBLOLE32=-lole32
51
52
        ;;
    *)
53
54
55
56
        echo "Unknown OS: $2"
        usage
        exit 1
        ;;
57
58
esac

59
# 1/ libvlc, libvlccore and its plugins
Rafaël Carré's avatar
Rafaël Carré committed
60
TESTED_HASH=45df8a6415
61
62
if [ ! -d "vlc" ]; then
    echo "VLC source not found, cloning"
63
    git clone http://git.videolan.org/git/vlc/vlc-3.0.git vlc
64
    cd vlc
65
66
67
68
69
70
    git am -3 ../patches/*.patch
    if [ $? -ne 0 ]; then
        git am --abort
        echo "Applying the patches failed, aborting git-am"
        exit 1
    fi
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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

85
86
87
88
89
90
MAKEFLAGS=
if which nproc >/dev/null
then
MAKEFLAGS=-j`nproc`
fi

91
92
93
94
95
96
97
# Build tools with the native compiler
echo "Compiling missing tools..."
cd extras/tools
./bootstrap && make $MAKEFLAGS
export PATH=`pwd`/build/bin:$PATH
cd ../../

98
TARGET_TUPLE=${1}-w64-mingw32
99
100
case "${1}" in
    armv7)
101
102
        COMPILER="armv7-w64-mingw32-clang"
        COMPILERXX="armv7-w64-mingw32-clang++"
103
104
105
106
107
108
109
        # Clang will yield armv7-windows-gnu as build arch, which seems
        # to confuse some configure scripts
        BUILD_ARCH=x86_64-linux-gnu
        ;;
    *)
        COMPILER=${TARGET_TUPLE}-gcc
        COMPILERXX=${TARGET_TUPLE}-g++
110
        ${COMPILER} -dumpspecs | sed -e "s/-lmingwex/-lwinstorecompat -lmingwex -lwinstorecompat $LIBLOLE32 -lruntimeobject -lsynchronization/" -e "s/-lmsvcrt/-l$RUNTIME/" -e "s/-lkernel32/$LIBKERNEL32/" > ../newspecfile
111
112
113
114
115
116
        NEWSPECFILE="`pwd`/../newspecfile"
        COMPILER="${COMPILER} -specs=$NEWSPECFILE"
        COMPILERXX="${COMPILERXX} -specs=$NEWSPECFILE"
        BUILD_ARCH=`gcc -dumpmachine`
        ;;
esac
117

118

119
EXTRA_CPPFLAGS="-D_WIN32_WINNT=$WINVER -DWINVER=$WINVER -DWINSTORECOMPAT -D_UNICODE -DUNICODE -DWINAPI_FAMILY=WINAPI_FAMILY_APP"
120
EXTRA_LDFLAGS="-lnormaliz -lwinstorecompat -lruntimeobject"
Rafaël Carré's avatar
Rafaël Carré committed
121

122
echo "Building the contribs"
123
CONTRIB_FOLDER=contrib/winrt-$1-$RUNTIME
124
125
mkdir -p $CONTRIB_FOLDER
cd $CONTRIB_FOLDER
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
126
../bootstrap --host=${TARGET_TUPLE} --build=$BUILD_ARCH --disable-disc \
127
    --disable-sdl \
128
    --disable-schroedinger \
Rafaël Carré's avatar
Rafaël Carré committed
129
    --disable-vncserver \
Rafaël Carré's avatar
Rafaël Carré committed
130
    --disable-chromaprint \
Rafaël Carré's avatar
Rafaël Carré committed
131
    --disable-modplug \
132
133
    --disable-SDL_image \
    --disable-fontconfig \
134
    --enable-zvbi \
135
136
    --disable-caca \
    --disable-gettext \
137
    --enable-gme \
138
    --enable-vorbis \
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
139
    --enable-mad \
140
    --enable-sidplay2 \
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
141
    --enable-samplerate \
142
143
    --enable-iconv \
    --disable-goom \
144
    --enable-dca \
145
146
147
    --disable-fontconfig \
    --disable-gpg-error \
    --disable-projectM \
148
    --enable-ass \
149
    --disable-qt \
Steve Lhomme's avatar
Steve Lhomme committed
150
    --disable-qtsvg \
151
    --disable-aribb25 \
152
    --disable-gnuv3 \
153
    --enable-ssh2 \
154
155
156
    --disable-vncclient \
    --enable-jpeg \
    --enable-postproc \
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
157
    --enable-vpx \
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
158
    --enable-libdsm \
159
    --disable-mfx \
160
    --disable-x264 \
161
162
    --disable-x265 \ 
    --disable-srt
163

164
echo "EXTRA_CFLAGS=${EXTRA_CPPFLAGS}" >> config.mak
Rafaël Carré's avatar
Rafaël Carré committed
165
echo "EXTRA_LDFLAGS=${EXTRA_LDFLAGS}" >> config.mak
166
echo "HAVE_WINSTORE := 1" >> config.mak
167
168
echo "CC=${COMPILER}" >> config.mak
echo "CXX=${COMPILERXX}" >> config.mak
169
export PKG_CONFIG_LIBDIR="`pwd`/contrib/${TARGET_TUPLE}/lib/pkgconfig"
Rafaël Carré's avatar
Rafaël Carré committed
170

171
USE_FFMPEG=1 \
172
make $MAKEFLAGS
173

174
BUILD_FOLDER=winrt-$1-$RUNTIME
175
cd ../.. && mkdir -p ${BUILD_FOLDER} && cd ${BUILD_FOLDER}
176
177
178
179
180

echo "Bootstraping"
../bootstrap

echo "Configuring"
Rafaël Carré's avatar
Rafaël Carré committed
181
182
CPPFLAGS="${EXTRA_CPPFLAGS}" \
LDFLAGS="${EXTRA_LDFLAGS}" \
183
184
CC="${COMPILER}" \
CXX="${COMPILERXX}" \
185
ac_cv_search_connect="-lws2_32" \
Rafaël Carré's avatar
Rafaël Carré committed
186
../../configure.sh --host=${TARGET_TUPLE}
187
188

echo "Building"
189
make $MAKEFLAGS
190
191
192
193

echo "Package"
make install

194
rm -rf tmp && mkdir tmp
195

196
197
198
# 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
199
library_path_list=`${TARGET_TUPLE}-g++ -v /dev/null 2>&1 | grep ^LIBRARY_PATH|cut -d= -f2` ;
200

201
find _win32/bin -name "*.dll" -exec cp -v {} tmp \;
202
cp -r _win32/include tmp/
203
cp -r _win32/lib/vlc/plugins tmp/
204

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
205
206
find tmp -name "*.la" -exec rm -v {} \;
find tmp -name "*.a" -exec rm -v {} \;
Rafaël Carré's avatar
Rafaël Carré committed
207
208
209
210
blacklist="
wingdi
waveout
dshow
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
211
212
213
214
215
216
217
218
219
220
221
directdraw
windrive
globalhotkeys
direct2d
ntservice
dxva2
dtv
vcd
cdda
quicktime
atmo
Rafaël Carré's avatar
Rafaël Carré committed
222
223
224
oldrc
dmo
panoramix
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
225
226
227
screen
win_msg
win_hotkeys
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
228
229
crystalhd
smb
Rafaël Carré's avatar
Rafaël Carré committed
230
231
232
233
234
235
236
237
238
239
240
241
242
"
regexp=
for i in ${blacklist}
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"`

243
find tmp \( -name "*.dll" -o -name "*.exe" \) -exec ${TARGET_TUPLE}-strip {} \;
244
find tmp \( -name "*.dll" -o -name "*.exe" \) -exec ../../appcontainer.pl {} \;
245

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
246
247
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
248

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

251
cd tmp
252
7z a ../vlc-${1}-${2}-${CURRENTDATE}.7z *
Rafaël Carré's avatar
Rafaël Carré committed
253
cd ..
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
254
rm -rf tmp
255
256
257
258

else
    usage
fi