build-vlc.sh 7.96 KB
Newer Older
1
#!/bin/sh
2 3 4
# Copyright (C) Pierre d'Herbemont, 2010
# Copyright (C) Felix Paul Kühne, 2012-2018

5
set -e
6

7 8 9 10 11 12
info()
{
    local green="\033[1;32m"
    local normal="\033[0m"
    echo "[${green}build${normal}] $1"
}
13

14
OSX_VERSION=`xcrun --sdk macosx --show-sdk-version`
15
ARCH="x86_64"
16
MINIMAL_OSX_VERSION="10.7"
17
SDKROOT=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk
18
UNSTABLE=no
19

20 21 22 23 24
if [ -z "$MAKE_JOBS" ]; then
    CORE_COUNT=`sysctl -n machdep.cpu.core_count`
    let MAKE_JOBS=$CORE_COUNT+1
fi

25 26 27 28 29 30
usage()
{
cat << EOF
usage: $0 [-v] [-d]

OPTIONS
31
   -v            Be more verbose
32
   -u            Use unstable libvlc
33 34
   -k <sdk>      Use the specified sdk (default: $SDKROOT for $ARCH)
   -a <arch>     Use the specified arch (default: $ARCH)
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
EOF
}

spushd()
{
     pushd "$1" 2>&1> /dev/null
}

spopd()
{
     popd 2>&1> /dev/null
}

info()
{
     local green="\033[1;32m"
     local normal="\033[0m"
     echo "[${green}info${normal}] $1"
}

55
while getopts "hvua:k:" OPTION
56 57 58 59 60 61 62 63 64
do
     case $OPTION in
         h)
             usage
             exit 1
             ;;
         v)
             VERBOSE=yes
             ;;
65 66 67
         u)
             UNSTABLE=yes
             ;;
68 69 70 71 72
         a)
             ARCH=$OPTARG
             ;;
         k)
             SDKROOT=$OPTARG
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
             ;;
         ?)
             usage
             exit 1
             ;;
     esac
done
shift $(($OPTIND - 1))

out="/dev/null"
if [ "$VERBOSE" = "yes" ]; then
   out="/dev/stdout"
fi

if [ "x$1" != "x" ]; then
    usage
    exit 1
fi

92 93
export OSX_VERSION

94 95 96 97 98 99 100 101 102 103 104 105
# Get root dir
spushd .
npapi_root_dir=`pwd`
spopd

info $npapi_root_dir

info "Preparing build dirs"

spushd extras/macosx

if ! [ -e vlc ]; then
106
if [ "$UNSTABLE" = "yes" ]; then
107
git clone git://git.videolan.org/vlc.git vlc
108
else
109
git clone git://git.videolan.org/vlc/vlc-3.0.git vlc
110
fi
111 112 113 114 115 116 117 118
fi

spopd #extras/macosx

#
# Build time
#

119
export PATH="${npapi_root_dir}/extras/macosx/vlc/extras/tools/build/bin:${npapi_root_dir}/extras/macosx/contrib/${ARCH}-apple-darwin14/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
120

121 122 123 124 125 126 127
info "Building tools"
spushd extras/macosx/vlc/extras/tools
if ! [ -e build ]; then
./bootstrap && make
fi
spopd

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
info "Exporting environment"

if [ ! -d "${SDKROOT}" ]
then
    echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
    exit 1
fi

# partially clean the environment
export CFLAGS=""
export CPPFLAGS=""
export CXXFLAGS=""
export OBJCFLAGS=""
export LDFLAGS=""

export PLATFORM=$PLATFORM
export SDK_VERSION=$SDK_VERSION
export VLCSDKROOT=$SDKROOT

CFLAGS="-isysroot ${SDKROOT} -arch ${ARCH} ${OPTIM}"
OBJCFLAGS="${OPTIM}"

CFLAGS+=" -mmacosx-version-min=${MINIMAL_OSX_VERSION}"

export CFLAGS="${CFLAGS}"
export CXXFLAGS="${CFLAGS}"
export CPPFLAGS="${CFLAGS}"
export OBJCFLAGS="${OBJCFLAGS}"

export LDFLAGS="-arch ${ARCH}"

EXTRA_CFLAGS="-arch ${ARCH}"
EXTRA_CFLAGS+=" -mmacosx-version-min=${MINIMAL_OSX_VERSION}"
EXTRA_LDFLAGS=" -Wl,-macosx_version_min,${MINIMAL_OSX_VERSION}"
export LDFLAGS="${LDFLAGS} -v -Wl,-macosx_version_min,${MINIMAL_OSX_VERSION}"

# The following symbols do not exist on the minimal macOS version (10.7), so they are disabled
# here. This allows compilation also with newer macOS SDKs.
# Added symbols in 10.13
export ac_cv_func_open_wmemstream=no
export ac_cv_func_fmemopen=no
export ac_cv_func_open_memstream=no
export ac_cv_func_futimens=no
export ac_cv_func_utimensat=no

# Added symbols between 10.11 and 10.12
export ac_cv_func_basename_r=no
export ac_cv_func_clock_getres=no
export ac_cv_func_clock_gettime=no
export ac_cv_func_clock_settime=no
export ac_cv_func_dirname_r=no
export ac_cv_func_getentropy=no
export ac_cv_func_mkostemp=no
export ac_cv_func_mkostemps=no

# Added symbols between 10.7 and 10.11
export ac_cv_func_ffsll=no
export ac_cv_func_flsll=no
export ac_cv_func_fdopendir=no
export ac_cv_func_openat=no
export ac_cv_func_fstatat=no
export ac_cv_func_readlinkat=no

export CC="xcrun clang"
export CXX="xcrun clang++"
export OBJC="xcrun clang"

195 196 197 198
info "Fetching contrib"

spushd extras/macosx/vlc/contrib

199 200
if ! [ -e ${ARCH}-npapi ]; then
mkdir ${ARCH}-npapi
201
fi
202
cd ${ARCH}-npapi
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 259 260 261 262 263 264 265 266 267

export USE_FFMPEG=1
../bootstrap --build=${ARCH}-apple-darwin14 \
    --enable-ad-clauses \
    --disable-disc \
    --disable-sdl \
    --disable-SDL_image \
    --disable-iconv \
    --enable-zvbi \
    --disable-kate \
    --disable-caca \
    --disable-gettext \
    --disable-mpcdec \
    --disable-upnp \
    --disable-gme \
    --disable-srt \
    --disable-tremor \
    --enable-vorbis \
    --disable-sidplay2 \
    --disable-samplerate \
    --disable-goom \
    --disable-vncserver \
    --disable-orc \
    --disable-schroedinger \
    --disable-libmpeg2 \
    --disable-chromaprint \
    --disable-mad \
    --enable-fribidi \
    --enable-libxml2 \
    --enable-freetype2 \
    --enable-ass \
    --disable-fontconfig \
    --disable-gpg-error \
    --disable-vncclient \
    --disable-gnutls \
    --disable-lua \
    --disable-luac \
    --disable-aribb24 \
    --disable-aribb25 \
    --enable-libdsm \
    --enable-libplacebo \
    --disable-sparkle \
    --disable-growl \
    --disable-breakpad \
    --disable-ncurses \
    --disable-asdcplib \
    --enable-soxr \
    --disable-protobuf \
    --disable-sout \
    --disable-fontconfig \
    --disable-bghudappkit \
    --disable-twolame \
    --disable-microdns \
    --disable-SDL \
    --disable-SDL_image \
    --disable-cddb \
    --disable-bluray \
    --disable-vncserver \
    --disable-vpx

echo "EXTRA_CFLAGS += ${EXTRA_CFLAGS}" >> config.mak
echo "EXTRA_LDFLAGS += ${EXTRA_LDFLAGS}" >> config.mak

make fetch -j$MAKE_JOBS
make -j$MAKE_JOBS > ${out}
268 269 270

spopd

271
PREFIX="${npapi_root_dir}/extras/macosx/vlc/${ARCH}-install"
272

273
info "Configuring VLC"
274 275 276 277 278 279 280 281 282

if ! [ -e ${PREFIX} ]; then
    mkdir ${PREFIX}
fi

spushd extras/macosx/vlc
if ! [ -e configure ]; then
    ./bootstrap > ${out}
fi
283 284
if ! [ -e ${ARCH}-build ]; then
    mkdir ${ARCH}-build
285
fi
286

287 288 289 290 291 292
# Available but not authorized
export ac_cv_func_daemon=no
export ac_cv_func_fork=no

export CXXFLAGS="${CXXFLAGS} -stdlib=libc++"
export LDFLAGS="${LDFLAGS} -read_only_relocs suppress"
293

294
cd ${ARCH}-build
295
../configure \
296
        --build=${ARCH}-apple-darwin14 \
297 298 299
        --prefix=${PREFIX} \
        --with-macosx-version-min=${MINIMAL_OSX_VERSION} \
        --with-macosx-sdk=$SDKROOT \
300
        --disable-lua --disable-vlm --disable-sout \
301
        --disable-vcd --disable-screen \
302
        --disable-debug \
303
        --disable-macosx \
304 305
        --disable-notify \
        --disable-projectm \
306
        --disable-faad \
307
        --disable-bluray \
308 309 310
        --enable-flac \
        --enable-theora \
        --enable-shout \
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
311 312
        --disable-ncurses \
        --disable-twolame \
313 314
        --enable-realrtsp \
        --enable-libass \
315
        --disable-macosx-avfoundation \
316
        --disable-macosx-qtkit \
317 318 319 320 321 322 323 324
        --disable-skins2 \
        --disable-xcb \
        --disable-caca \
        --disable-samplerate \
        --disable-upnp \
        --disable-goom \
        --disable-nls \
        --disable-sdl-image \
325 326 327 328 329
        --disable-sparkle \
        --disable-addonmanagermodules \
        --disable-mad \
        --enable-merge-ffmpeg \
        > ${out}
330

331
info "Compiling VLC"
332 333 334 335 336 337 338 339 340 341 342

if [ "$VERBOSE" = "yes" ]; then
    make V=1 -j$MAKE_JOBS > ${out}
else
    make -j$MAKE_JOBS > ${out}
fi

info "Installing VLC"
make install > ${out}
cd ..

343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
info "Removing unneeded modules"
blacklist="
stats
access_bd
shm
access_imem
oldrc
real
hotkeys
gestures
sap
dynamicoverlay
rss
ball
magnify
audiobargraph_
clone
mosaic
osdmenu
puzzle
mediadirs
t140
ripple
motion
sharpen
grain
posterize
mirror
wall
scene
blendbench
psychedelic
alphamask
netsync
audioscrobbler
motiondetect
motionblur
export
smf
podcast
bluescreen
erase
stream_filter_record
speex_resampler
remoteosd
magnify
gradient
logger
visual
fb
aout_file
dummy
invert
sepia
wave
hqdn3d
headphone_channel_mixer
gaussianblur
gradfun
extract
colorthres
antiflicker
anaglyph
remap
"

for i in ${blacklist}
do
    find ${PREFIX}/lib/vlc/plugins -name *$i* -type f -exec rm '{}' \;
done
413 414 415 416

spopd

info "Build completed"