compile.sh 5.1 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
45
        ;;
    win81)
        WINVER=0x602
46
        RUNTIME=msvcr120_app
47
48
        ;;
    *)
49
50
51
52
        echo "Unknown OS: $2"
        usage
        exit 1
        ;;
53
54
esac

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

81
82
83
84
85
86
MAKEFLAGS=
if which nproc >/dev/null
then
MAKEFLAGS=-j`nproc`
fi

87
TARGET_TUPLE=${1}-w64-mingw32
88
89
90
91
92
93
94
95
96
97
98
case "${1}" in
    armv7)
        COMPILER="clang -target armv7-windows-gnu"
        COMPILERXX="clang++ -target armv7-windows-gnu"
        # 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++
99
        ${COMPILER} -dumpspecs | sed -e 's/-lmingwex/-lwinstorecompat -lmingwex -lwinstorecompat -lole32 -lruntimeobject -lsynchronization/' -e "s/-lmsvcrt/-l$RUNTIME/" > ../newspecfile
100
101
102
103
104
105
        NEWSPECFILE="`pwd`/../newspecfile"
        COMPILER="${COMPILER} -specs=$NEWSPECFILE"
        COMPILERXX="${COMPILERXX} -specs=$NEWSPECFILE"
        BUILD_ARCH=`gcc -dumpmachine`
        ;;
esac
106

107

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

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

150
echo "EXTRA_CFLAGS=${EXTRA_CPPFLAGS}" >> config.mak
Rafaël Carré's avatar
Rafaël Carré committed
151
echo "EXTRA_LDFLAGS=${EXTRA_LDFLAGS}" >> config.mak
152
echo "HAVE_WINSTORE := 1" >> config.mak
153
154
echo "CC=${COMPILER}" >> config.mak
echo "CXX=${COMPILERXX}" >> config.mak
155
export PKG_CONFIG_LIBDIR="`pwd`/contrib/${TARGET_TUPLE}/lib/pkgconfig"
Rafaël Carré's avatar
Rafaël Carré committed
156

157
USE_FFMPEG=1 \
158
make $MAKEFLAGS
159

160
BUILD_FOLDER=winrt-$1-$RUNTIME
161
cd ../.. && mkdir -p ${BUILD_FOLDER} && cd ${BUILD_FOLDER}
162
163
164
165
166

echo "Bootstraping"
../bootstrap

echo "Configuring"
Rafaël Carré's avatar
Rafaël Carré committed
167
168
CPPFLAGS="${EXTRA_CPPFLAGS}" \
LDFLAGS="${EXTRA_LDFLAGS}" \
169
170
CC="${COMPILER}" \
CXX="${COMPILERXX}" \
171
ac_cv_search_connect="-lws2_32" \
Rafaël Carré's avatar
Rafaël Carré committed
172
../../configure.sh --host=${TARGET_TUPLE}
173
174

echo "Building"
175
make $MAKEFLAGS
176
177
178
179

echo "Package"
make install

180
rm -rf tmp && mkdir tmp
181

182
183
184
# 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
185
library_path_list=`${TARGET_TUPLE}-g++ -v /dev/null 2>&1 | grep ^LIBRARY_PATH|cut -d= -f2` ;
186

187
find _win32/bin -name "*.dll" -exec cp -v {} tmp \;
188
cp -r _win32/include tmp/
189
cp -r _win32/lib/vlc/plugins tmp/
190

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

229
find tmp \( -name "*.dll" -o -name "*.exe" \) -exec ${TARGET_TUPLE}-strip {} \;
230
find tmp \( -name "*.dll" -o -name "*.exe" \) -exec ../../appcontainer.pl {} \;
231

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
232
233
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
234

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

237
cd tmp
238
7z a ../vlc-${1}-${2}-${CURRENTDATE}.7z *
Rafaël Carré's avatar
Rafaël Carré committed
239
cd ..
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
240
rm -rf tmp
241
242
243
244

else
    usage
fi