-
Notifications
You must be signed in to change notification settings - Fork 2
/
buildcommon
executable file
·206 lines (170 loc) · 5.49 KB
/
buildcommon
1
2
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
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
87
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
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
195
196
197
198
199
200
201
202
203
204
205
206
set -a
export BUILDCOMMONDONE=1
#############
# DEFINES #
#############
if [ "${TIZEN_SDK_VERSION}" = "2.3.1" ];then
GCCVER=4.8
GCCVERFULL=4.8.3
else
GCCVER=4.9
GCCVERFULL=4.9.2
fi
#############
# FUNCTIONS #
#############
checkfail()
{
if [ ! $? -eq 0 ];then
echo -e "\e[1m\e[31m$1\e[0m"
exit 1
fi
}
#############
# ARGUMENTS #
#############
RELEASE=0
STRIP=0
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)
export TIZEN_ABI=$2
shift
;;
s|-s)
export STRIP=1
;;
release|--release)
export RELEASE=1
;;
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
X86: x86"
exit 1
fi
cat "${TIZEN_SDK}/sdk.version" | sed -e 's|\([^=]*\)=\(.*\)|\1="\2"|g' > sdk.version.tmp
. sdk.version.tmp
mkdir -p ${PROJECTPATH}/lib
#########
# 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}
#################
# 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
###############
# 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"
EXTRA_CFLAGS="${EXTRA_CFLAGS} -DHB_NO_MT" # HACK for harbfuzz atomics
fi
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`
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
TIZEN_SDK_SHORT_VERSION="${TIZEN_SDK_MAJOR}.${TIZEN_SDK_MINOR}"
TIZEN_CORE="${TIZEN_SDK}/platforms/tizen-${TIZEN_SDK_SHORT_VERSION}/mobile/rootstraps/mobile-${TIZEN_SDK_SHORT_VERSION}-${TIZEN_DEVICE}.core"
fi
TIZEN_INCLUDES="${TIZEN_CORE}/usr/include"
TIZEN_LIBS="${TIZEN_CORE}/usr/lib"
EXTRA_CFLAGS="${EXTRA_CFLAGS} -I${SYSROOT}/include/c++/${GCCVERFULL}"
EXTRA_CFLAGS="${EXTRA_CFLAGS} -I${SYSROOT}/include/c++/${GCCVERFULL}/${TARGET_TUPLE}"
EXTRA_CFLAGS="${EXTRA_CFLAGS} -I${TIZEN_INCLUDES} -I${TIZEN_INCLUDES}/media -I${TIZEN_INCLUDES}/efl-1 -I${TIZEN_INCLUDES}/eo-1"
EXTRA_CFLAGS="${EXTRA_CFLAGS} -DTIZEN_SDK_MAJOR=${TIZEN_SDK_MAJOR} -DTIZEN_SDK_MINOR=${TIZEN_SDK_MINOR}"
EXTRA_CXXFLAGS="${EXTRA_CFLAGS} -D__STDC_FORMAT_MACROS=1 -D__STDC_CONSTANT_MACROS=1 -D__STDC_LIMIT_MACROS=1"
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"
#################
# 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 -O3 "
else
EXTRA_CFLAGS="${EXTRA_CFLAGS} -O0 "
fi
echo -e "\e[1m\e[36mCFLAGS: ${CFLAGS}\e[0m"
echo -e "\e[1m\e[36mEXTRA_CFLAGS: ${EXTRA_CFLAGS}\e[0m"