compile.sh 5.27 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.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
TARGET_TUPLE=${1}-w64-mingw32
92
93
case "${1}" in
    armv7)
94
95
        COMPILER="armv7-w64-mingw32-clang"
        COMPILERXX="armv7-w64-mingw32-clang++"
96
97
98
99
100
101
102
        # 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++
103
        ${COMPILER} -dumpspecs | sed -e "s/-lmingwex/-lwinstorecompat -lmingwex -lwinstorecompat $LIBLOLE32 -lruntimeobject -lsynchronization/" -e "s/-lmsvcrt/-l$RUNTIME/" -e "s/-lkernel32/$LIBKERNEL32/" > ../newspecfile
104
105
106
107
108
109
        NEWSPECFILE="`pwd`/../newspecfile"
        COMPILER="${COMPILER} -specs=$NEWSPECFILE"
        COMPILERXX="${COMPILERXX} -specs=$NEWSPECFILE"
        BUILD_ARCH=`gcc -dumpmachine`
        ;;
esac
110

111

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

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

156
echo "EXTRA_CFLAGS=${EXTRA_CPPFLAGS}" >> config.mak
Rafaël Carré's avatar
Rafaël Carré committed
157
echo "EXTRA_LDFLAGS=${EXTRA_LDFLAGS}" >> config.mak
158
echo "HAVE_WINSTORE := 1" >> config.mak
159
160
echo "CC=${COMPILER}" >> config.mak
echo "CXX=${COMPILERXX}" >> config.mak
161
export PKG_CONFIG_LIBDIR="`pwd`/contrib/${TARGET_TUPLE}/lib/pkgconfig"
Rafaël Carré's avatar
Rafaël Carré committed
162

163
USE_FFMPEG=1 \
164
make $MAKEFLAGS
165

166
BUILD_FOLDER=winrt-$1-$RUNTIME
167
cd ../.. && mkdir -p ${BUILD_FOLDER} && cd ${BUILD_FOLDER}
168
169
170
171
172

echo "Bootstraping"
../bootstrap

echo "Configuring"
Rafaël Carré's avatar
Rafaël Carré committed
173
174
CPPFLAGS="${EXTRA_CPPFLAGS}" \
LDFLAGS="${EXTRA_LDFLAGS}" \
175
176
CC="${COMPILER}" \
CXX="${COMPILERXX}" \
177
ac_cv_search_connect="-lws2_32" \
Rafaël Carré's avatar
Rafaël Carré committed
178
../../configure.sh --host=${TARGET_TUPLE}
179
180

echo "Building"
181
make $MAKEFLAGS
182
183
184
185

echo "Package"
make install

186
rm -rf tmp && mkdir tmp
187

188
189
190
# 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
191
library_path_list=`${TARGET_TUPLE}-g++ -v /dev/null 2>&1 | grep ^LIBRARY_PATH|cut -d= -f2` ;
192

193
find _win32/bin -name "*.dll" -exec cp -v {} tmp \;
194
cp -r _win32/include tmp/
195
cp -r _win32/lib/vlc/plugins tmp/
196

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

235
find tmp \( -name "*.dll" -o -name "*.exe" \) -exec ${TARGET_TUPLE}-strip {} \;
236
find tmp \( -name "*.dll" -o -name "*.exe" \) -exec ../../appcontainer.pl {} \;
237

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
238
239
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
240

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

243
cd tmp
244
7z a ../vlc-${1}-${2}-${CURRENTDATE}.7z *
Rafaël Carré's avatar
Rafaël Carré committed
245
cd ..
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
246
rm -rf tmp
247
248
249
250

else
    usage
fi