buildVLCKit.sh 5.42 KB
Newer Older
1 2 3 4 5 6 7
#!/bin/sh
# Copyright (C) Pierre d'Herbemont, 2010
# Copyright (C) Felix Paul Kühne, 2012-2016

set -e

SDK=`xcrun --sdk macosx --show-sdk-version`
8
SDK_MIN=10.9
9 10 11 12 13
VERBOSE=no
CONFIGURATION="Release"
NONETWORK=no
SKIPLIBVLCCOMPILATION=no
SCARY=yes
14
DEBUG="no"
15

16 17 18 19
if [ -z "$MAKE_JOBS" ]; then
    CORE_COUNT=`sysctl -n machdep.cpu.core_count`
    let MAKE_JOBS=$CORE_COUNT+1
fi
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

usage()
{
cat << EOF
usage: $0 [-s] [-v] [-k sdk]

OPTIONS
   -k       Specify which sdk to use (see 'xcodebuild -showsdks', current: ${SDK})
   -v       Be more verbose
   -d       Enable Debug
   -n       Skip script steps requiring network interaction
   -l       Skip libvlc compilation
   -w       Build a limited stack of non-scary libraries only
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"
}

buildxcodeproj()
{
    local target="$2"
    local PLATFORM="$3"

    info "Building $1 ($target, ${CONFIGURATION}, $PLATFORM)"

    local architectures="x86_64"

    local defs="$GCC_PREPROCESSOR_DEFINITIONS"
    if [ "$SCARY" = "no" ]; then
        defs="$defs NOSCARYCODECS"
    fi
    xcodebuild -project "$1.xcodeproj" \
               -target "$target" \
               -sdk $PLATFORM$SDK \
               -configuration ${CONFIGURATION} \
               ARCHS="${architectures}" \
               MACOSX_DEPLOYMENT_TARGET=${SDK_MIN} \
               GCC_PREPROCESSOR_DEFINITIONS="$defs" \
               > ${out}
}

while getopts "hvwsfbdntlk:" OPTION
do
     case $OPTION in
         h)
             usage
             exit 1
             ;;
         v)
             VERBOSE=yes
             ;;
         d)  CONFIGURATION="Debug"
87
             DEBUG="yes"
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
             ;;
         w)  SCARY="no"
             ;;
         n)
             NONETWORK=yes
             ;;
         l)
             SKIPLIBVLCCOMPILATION=yes
             ;;
         k)
             SDK=$OPTARG
             ;;
         ?)
             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

# Get root dir
spushd .
aspen_root_dir=`pwd`
spopd

info "Preparing build dirs"

mkdir -p libvlc

spushd libvlc

if [ "$NONETWORK" != "yes" ]; then
if ! [ -e vlc ]; then
git clone git://git.videolan.org/vlc.git vlc
else
cd vlc
git pull --rebase
cd ..
fi
fi

spopd

#
# Build time
#

buildLibVLC() {
146 147 148
    export CC=`xcrun -f clang`
    export CXX=`xcrun -f clang++`
    export OBJC=`xcrun -f clang`
149

150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
    args=""
    if [ "$VERBOSE" = "yes" ]; then
        args="${args} V=1"
    fi

    spushd libvlc
    spushd vlc

    VLCROOT=`pwd` # Let's make sure VLCROOT is an absolute path
    PREFIX="${VLCROOT}/install-macos"

    if [ "$SKIPLIBVLCCOMPILATION" != "yes" ]; then
    
    export PATH="${VLCROOT}/extras/tools/build/bin:${VLCROOT}/contrib/x86_64-apple-darwin15/bin:$PATH"
    
165 166
    export ac_cv_func_open_memstream=no

167 168 169
    info "Building tools"
    spushd extras/tools
    ./bootstrap
170
    make -j$MAKE_JOBS ${args}
171 172
    spopd # extras/tools

173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
#    export CFLAGS="-Werror=partial-availability"

    SDK_VERSION=`xcrun --sdk macosx --show-sdk-version`
    SDKROOT=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SDK_VERSION}.sdk
    ARCH=x86_64
    TARGET=${ARCH}-apple-darwin15

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

    if [ "$DEBUG" = "yes" ]; then
        OPTIM="-O0 -g"
    else
        OPTIM="-O3 -g"
    fi

    # clean the environment
    export PATH="${VLCROOT}/extras/tools/build/bin:${VLCROOT}/contrib/${TARGET}/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"

195 196 197 198
    info "Building contrib"
    spushd contrib
    mkdir -p vlckitbuild
    spushd vlckitbuild
199
    export USE_FFMPEG=1
200
    ../bootstrap --build=${TARGET} --disable-bluray --disable-growl --disable-sparkle --disable-SDL --disable-SDL_image --disable-microdns --disable-fontconfig --disable-bghudappkit --disable-protobuf
201

202
    make -j$MAKE_JOBS fetch ${args}
203
    make -j$MAKE_JOBS .gettext ${args}
204
    make -j$MAKE_JOBS ${args}
205 206
    spopd # vlckitbuild
    spopd # contrib
207 208 209 210 211 212 213

    info "Bootstraping vlc"
    info "VLCROOT = ${VLCROOT}"
    if ! [ -e ${VLCROOT}/configure ]; then
        ${VLCROOT}/bootstrap
    fi

214 215 216
    mkdir -p vlckitbuild

    spushd vlckitbuild
217 218

    ../configure --build=${TARGET} --prefix="${PREFIX}" \
219
        --with-macosx-version-min=${SDK_MIN} \
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
        --disable-macosx \
        --enable-merge-ffmpeg \
        --disable-sparkle \
        --enable-osx-notifications \
        --enable-faad \
        --enable-flac \
        --enable-theora \
        --enable-shout \
        --enable-ncurses \
        --enable-twolame \
        --enable-realrtsp \
        --enable-libass \
        --enable-macosx-qtkit \
        --enable-macosx-avfoundation \
        --disable-skins2 \
235
        --disable-chromecast \
236 237 238 239 240 241
        --disable-qt \
        --disable-xcb \
        --disable-caca \
        --disable-pulse \
        --disable-gnutls \
        --disable-vnc
242
    make -j$MAKE_JOBS ${args}
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
    make install $(args)    
    spopd #vlckitbuild

fi

    spopd #vlc
    spopd #libvlc
    
}

buildLibVLC

info "libvlc compilation done"

info "Building VLCKit.framework"

buildxcodeproj VLCKit "VLCKit" macosx

info "Build of VLCKit.framework completed"