buildcommon 5.19 KB
Newer Older
1
set -a
2
export BUILDCOMMONDONE=1
3

4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#############
#  DEFINES  #
#############

GCCVER=4.8
GCCVERFULL=4.8.3

#############
# FUNCTIONS #
#############

checkfail()
{
    if [ ! $? -eq 0 ];then
        echo -e "\e[1m\e[31m$1\e[0m"
        exit 1
    fi
}

#############
# ARGUMENTS #
#############

RELEASE=0
28
STRIP=0
29 30 31 32 33 34 35 36
while [ $# -gt 0 ]; do
    case $1 in
        help|--help)
            echo "Use -a to set the ARCH"
            echo "Use --release to build in release mode"
            exit 1
            ;;
        a|-a)
37
            export TIZEN_ABI=$2
38 39
            shift
            ;;
40 41 42
        s|-s)
            export STRIP=1
            ;;
43
        release|--release)
44
            export RELEASE=1
45 46 47 48 49 50 51 52 53 54 55 56 57 58
            ;;
    esac
    shift
done

if [ -z "$TIZEN_SDK" ]; then
    echo "Please set the TIZEN_SDK environment variable with its path."
    exit 1
fi

if [ -z "$TIZEN_ABI" ]; then
    echo "Please pass the TIZEN_ABI to the correct architecture, using
                ${SCRIPT} -a ARCH
    ARM:     armv7l
59
    X86:     x86"
60 61 62
    exit 1
fi

63
. ${TIZEN_SDK}/sdk.version
64 65

mkdir -p ${PROJECTPATH}/lib
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93

#########
# FLAGS #
#########

# Set up ABI variables
if [ "${TIZEN_ABI}" = "x86" ] ; then
    TARGET_TUPLE="i386-linux-gnueabi"
    PATH_HOST="x86"
    PLATFORM_SHORT_ARCH="x86"
    TIZEN_DEVICE="emulator"
elif [ "${TIZEN_ABI}" = "armv7l" ] ; then
    TARGET_TUPLE="arm-linux-gnueabi"
    PATH_HOST=$TARGET_TUPLE
    HAVE_ARM=1
    PLATFORM_SHORT_ARCH="arm"
    TIZEN_DEVICE="device"
else
    echo -e "\e[1m\e[31mUnknown ABI: '${TIZEN_ABI}'\e[0m"
    exit 2
fi

SYSROOT=${TIZEN_SDK}/tools/${TARGET_TUPLE}-gcc-${GCCVER}
LIBEXEC=${TIZEN_SDK}/tools/${TARGET_TUPLE}-gcc-${GCCVER}/libexec/gcc/${TARGET_TUPLE}/${GCCVERFULL}
TIZEN_TOOLCHAIN_PATH=${SYSROOT}/bin

export PATH=${TIZEN_TOOLCHAIN_PATH}:${LIBEXEC}:${PATH}

94 95 96 97 98 99 100 101 102 103
#################
# GLOBAL EXPORT #
#################

if [ "$RELEASE" = 1 ]; then
    export VLC_BUILD_DIR=build-tizen-${TARGET_TUPLE}-release
else
    export VLC_BUILD_DIR=build-tizen-${TARGET_TUPLE}
fi

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
###############
# DISPLAY ABI #
###############
echo -e "\e[1m\e[36mABI:        $TIZEN_ABI\e[0m"
echo -e "\e[1m\e[36mTIZEN SDK:  $TIZEN_SDK\e[0m"
echo -e "\e[1m\e[36mSYSROOT:    $SYSROOT\e[0m"
echo -e "\e[1m\e[36mPATH:       $PATH\e[0m"

# Make in //
if [ -z "$MAKEFLAGS" ]; then
    UNAMES=$(uname -s)
    MAKEFLAGS=
    if which nproc >/dev/null; then
        MAKEFLAGS=-j`nproc`
    elif [ "$UNAMES" == "Darwin" ] && which sysctl >/dev/null; then
        MAKEFLAGS=-j`sysctl -n machdep.cpu.thread_count`
    fi
fi

###########
# FIX SDK #
###########

LIBSTDCPP=${TIZEN_SDK}/tools/${TARGET_TUPLE}-gcc-${GCCVER}/${TARGET_TUPLE}/lib/libstdc++.la

if [ -f "${LIBSTDCPP}" ] ; then
    mv -f ${LIBSTDCPP} ${LIBSTDCPP}.bak
fi

##########
# CFLAGS #
##########

CFLAGS="${CFLAGS} -fstrict-aliasing -funsafe-math-optimizations"

EXTRA_CFLAGS="-fPIC"
# Setup CFLAGS per ABI
if [ "${TIZEN_ABI}" = "armv7l" ] ; then
    EXTRA_CFLAGS="${EXTRA_CFLAGS} -march=armv7-a -mtune=cortex-a8 -mfpu=vfpv3-d16 -mthumb -mfloat-abi=softfp"
elif [ "${TIZEN_ABI}" = "x86" ] ; then
    EXTRA_CFLAGS="${EXTRA_CFLAGS} -mtune=atom -msse3 -mfpmath=sse -m32"
145
    EXTRA_CFLAGS="${EXTRA_CFLAGS} -DHB_NO_MT" # HACK for harbfuzz atomics
146 147
fi

148 149 150 151
TIZEN_SDK_MAJOR=`echo "${TIZEN_SDK_VERSION}" | cut -d. -f1`
TIZEN_SDK_MINOR=`echo "${TIZEN_SDK_VERSION}" | cut -d. -f2`
TIZEN_SDK_REV=`echo "${TIZEN_SDK_VERSION}" | cut -d. -f3`

152 153 154
if [ ${TIZEN_SDK_VERSION} = "2.3.1" ];then
    TIZEN_CORE="${TIZEN_SDK}/platforms/mobile-${TIZEN_SDK_VERSION}/rootstraps/mobile-${TIZEN_SDK_VERSION}-${TIZEN_DEVICE}.core"
else
155
    TIZEN_SDK_SHORT_VERSION="${TIZEN_SDK_MAJOR}.${TIZEN_SDK_MINOR}"
156 157
    TIZEN_CORE="${TIZEN_SDK}/platforms/tizen-${TIZEN_SDK_SHORT_VERSION}/mobile/rootstraps/mobile-${TIZEN_SDK_SHORT_VERSION}-${TIZEN_DEVICE}.core"
fi
158 159
TIZEN_INCLUDES="${TIZEN_CORE}/usr/include"
TIZEN_LIBS="${TIZEN_CORE}/usr/lib"
160 161
EXTRA_CFLAGS="${EXTRA_CFLAGS} -I${SYSROOT}/include/c++/${GCCVERFULL}"
EXTRA_CFLAGS="${EXTRA_CFLAGS} -I${SYSROOT}/include/c++/${GCCVERFULL}/${TARGET_TUPLE}"
162
EXTRA_CFLAGS="${EXTRA_CFLAGS} -I${TIZEN_INCLUDES} -I${TIZEN_INCLUDES}/media"
163
EXTRA_CFLAGS="${EXTRA_CFLAGS} -DTIZEN_SDK_MAJOR=${TIZEN_SDK_MAJOR} -DTIZEN_SDK_MINOR=${TIZEN_SDK_MINOR}"
164

165
EXTRA_CXXFLAGS="${EXTRA_CFLAGS} -D__STDC_FORMAT_MACROS=1 -D__STDC_CONSTANT_MACROS=1 -D__STDC_LIMIT_MACROS=1"
166

167
CPPFLAGS="-I${SYSROOT}/include/c++/${GCCVERFULL} -I${SYSROOT}/include/c++/${GCCVERFULL}/${TARGET_TUPLE} -I${TIZEN_INCLUDES} -I${TIZEN_INCLUDES}/media"
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 195 196 197 198

#################
# Setup LDFLAGS #
#################

TIZEN_TOOLS=${TIZEN_SDK}/tools/${TARGET_TUPLE}-gcc-${GCCVER}/bin/${TARGET_TUPLE}-
CROSS_COMPILE=${TIZEN_TOOLS}
TIZEN_FLAGS="--sysroot=${TIZEN_CORE}"
export CC="${TIZEN_TOOLS}gcc ${TIZEN_FLAGS}"
export CXX="${TIZEN_TOOLS}g++ ${TIZEN_FLAGS}"
export AR="${TIZEN_TOOLS}ar"
export LD="${TIZEN_TOOLS}ld ${TIZEN_FLAGS}"

EXTRA_LDFLAGS="-L${TIZEN_CORE}/usr/lib"

LDFLAGS="${TIZEN_FLAGS} -Wl,-Bdynamic -Wl,--no-undefined -lrt"

if [ -n "$HAVE_ARM" ]; then
        EXTRA_PARAMS=" --enable-neon"
        LDFLAGS="${LDFLAGS} -Wl,--fix-cortex-a8"
fi

LDFLAGS="${LDFLAGS} -L${SYSROOT}/lib"

# Release or not?
if [ "$RELEASE" = 1 ]; then
    EXTRA_CFLAGS="${EXTRA_CFLAGS} -DNDEBUG "
fi

echo -e "\e[1m\e[36mCFLAGS:            ${CFLAGS}\e[0m"
echo -e "\e[1m\e[36mEXTRA_CFLAGS:      ${EXTRA_CFLAGS}\e[0m"