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

4 5 6 7
#############
#  DEFINES  #
#############

Ludovic Fauvet's avatar
Ludovic Fauvet committed
8
if [ "${TIZEN_SDK_VERSION}" = "2.3.1" ];then
9 10 11 12 13 14
    GCCVER=4.8
    GCCVERFULL=4.8.3
else
    GCCVER=4.9
    GCCVERFULL=4.9.2
fi
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

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

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

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

RELEASE=0
33
STRIP=0
34 35 36 37 38 39 40 41
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)
42
            export TIZEN_ABI=$2
43 44
            shift
            ;;
45 46 47
        s|-s)
            export STRIP=1
            ;;
48
        release|--release)
49
            export RELEASE=1
50 51 52 53 54 55 56 57 58 59 60 61 62 63
            ;;
    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
64
    X86:     x86"
65 66 67
    exit 1
fi

68 69
cat "${TIZEN_SDK}/sdk.version" | sed -e 's|\([^=]*\)=\(.*\)|\1="\2"|g'  > sdk.version.tmp
. sdk.version.tmp
70 71

mkdir -p ${PROJECTPATH}/lib
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

#########
# 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}

100 101 102 103 104 105 106 107 108 109
#################
# 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

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 146 147 148 149 150
###############
# 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"
151
    EXTRA_CFLAGS="${EXTRA_CFLAGS} -DHB_NO_MT" # HACK for harbfuzz atomics
152 153
fi

154 155 156 157
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`

158
if [ "${TIZEN_SDK_VERSION}" = "2.3.1" ];then
159 160
    TIZEN_CORE="${TIZEN_SDK}/platforms/mobile-${TIZEN_SDK_VERSION}/rootstraps/mobile-${TIZEN_SDK_VERSION}-${TIZEN_DEVICE}.core"
else
161
    TIZEN_SDK_SHORT_VERSION="${TIZEN_SDK_MAJOR}.${TIZEN_SDK_MINOR}"
162 163
    TIZEN_CORE="${TIZEN_SDK}/platforms/tizen-${TIZEN_SDK_SHORT_VERSION}/mobile/rootstraps/mobile-${TIZEN_SDK_SHORT_VERSION}-${TIZEN_DEVICE}.core"
fi
164 165
TIZEN_INCLUDES="${TIZEN_CORE}/usr/include"
TIZEN_LIBS="${TIZEN_CORE}/usr/lib"
166 167
EXTRA_CFLAGS="${EXTRA_CFLAGS} -I${SYSROOT}/include/c++/${GCCVERFULL}"
EXTRA_CFLAGS="${EXTRA_CFLAGS} -I${SYSROOT}/include/c++/${GCCVERFULL}/${TARGET_TUPLE}"
168
EXTRA_CFLAGS="${EXTRA_CFLAGS} -I${TIZEN_INCLUDES} -I${TIZEN_INCLUDES}/media -I${TIZEN_INCLUDES}/efl-1 -I${TIZEN_INCLUDES}/eo-1"
169
EXTRA_CFLAGS="${EXTRA_CFLAGS} -DTIZEN_SDK_MAJOR=${TIZEN_SDK_MAJOR} -DTIZEN_SDK_MINOR=${TIZEN_SDK_MINOR}"
170

171
EXTRA_CXXFLAGS="${EXTRA_CFLAGS} -D__STDC_FORMAT_MACROS=1 -D__STDC_CONSTANT_MACROS=1 -D__STDC_LIMIT_MACROS=1"
172

173
CPPFLAGS="-I${SYSROOT}/include/c++/${GCCVERFULL} -I${SYSROOT}/include/c++/${GCCVERFULL}/${TARGET_TUPLE} -I${TIZEN_INCLUDES} -I${TIZEN_INCLUDES}/media -I${TIZEN_INCLUDES}/efl-1"
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 199

#################
# 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
200 201 202
    EXTRA_CFLAGS="${EXTRA_CFLAGS} -DNDEBUG -O3 "
else
    EXTRA_CFLAGS="${EXTRA_CFLAGS} -O0 "
203 204 205 206
fi

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