create-universal-binary.sh 2.32 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#!/bin/sh
set -e

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

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

spopd()
{
    popd > /dev/null
}

21
out="/dev/null"
22

23
npapiroot=`pwd`
24
INTEL32ROOT="${npapiroot}/i386-build/VLC-Plugin.plugin"
25 26
INTEL64ROOT="${npapiroot}/x86_64-build/VLC-Plugin.plugin"
UBROOT="${npapiroot}/VLC-Plugin.plugin"
27 28 29

info "checking for libvlc"

30 31 32
if [ ! -e "${npapiroot}/extras/macosx/vlc/x86_64-install" ]; then
    info "libvlc wasn't compiled for 64bit, compiling"
    ./extras/macosx/build-vlc.sh -a x86_64
33 34
fi

35
if [ ! -e "${npapiroot}/extras/macosx/vlc/i386-install" ]; then
36
    info "libvlc wasn't compiled for 32bit, compiling"
37
    ./extras/macosx/build-vlc.sh -a i386
38 39 40 41 42 43 44 45 46 47
fi

spushd ${npapiroot}

if [ ! -e "${INTEL64ROOT}" ]; then
info "compiling x86_64 binary"
./extras/macosx/build-plugin.sh -a x86_64
fi

if [ ! -e "${INTEL32ROOT}" ]; then
48 49
info "compiling i386 binary"
./extras/macosx/build-plugin.sh -a i386
50 51 52 53
fi

info "Creating Universal Binary"
rm -Rf "$UBROOT"
54
rm -Rf "${npapiroot}/VLC Plugin.plugin"
55 56 57 58 59
cp -Rf "$INTEL64ROOT" "$UBROOT"

LIBS=Contents/MacOS/lib
PLUGINS=Contents/MacOS/plugins
rm -Rf $UBROOT/$LIBS/*
60
rm -Rf "$UBROOT/Contents/MacOS/VLC-Plugin"
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
rm -Rf $UBROOT/$PLUGINS/*

function do_lipo {
    file="$1"
    files=""
    echo "..."$file
    if [ "x$INTEL32ROOT" != "x" ]; then
        if [ -e "$INTEL32ROOT/$file" ]; then
            files="$INTEL32ROOT/$file $files"
        fi
    fi
    if [ "x$INTEL64ROOT" != "x" ]; then
        if [ -e "$INTEL64ROOT/$file" ]; then
            files="$INTEL64ROOT/$file $files"
        fi
    fi
    if [ "x$files" != "x" ]; then
78
        lipo $files -create -output "$UBROOT"/$file
79 80 81 82
    fi;
}

info "Installing libs"
83 84 85
echo `dirname $0`
echo `pwd`
for i in `ls "$INTEL32ROOT/$LIBS/" | grep .dylib`
86 87 88 89 90
do
    do_lipo $LIBS/$i
done

info "Installing modules"
91
for i in `ls "$INTEL32ROOT/$PLUGINS/" | grep .dylib`
92 93 94 95 96
do
    do_lipo $PLUGINS/$i
done

info "Installing VLC Plugin"
97
do_lipo "Contents/MacOS/VLC-Plugin"
98 99 100 101

info "Installing Extra modules"

if [ "x$INTEL32ROOT" != "x" ]; then
102
    cp "$INTEL32ROOT/$PLUGINS/"*mmx* "$UBROOT/$PLUGINS/"
103 104 105 106 107
fi
if [ "x$INTEL64ROOT" != "x" ]; then
    cp -f "$INTEL64ROOT/$PLUGINS/"*sse* "$UBROOT/$PLUGINS/"
fi

108 109 110 111
info "moving bundle"

mv "${npapiroot}/VLC-Plugin.plugin" "${npapiroot}/VLC Plugin.plugin"

112
info "Creation succeeded"