forked from unknownv2/LinuxDetours
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·86 lines (75 loc) · 1.71 KB
/
build.sh
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
#!/bin/bash
BUILD_TYPE=release
BUILD_DIR=build
THIRDPARTY_PREFIX=external
UNAME=$(uname)
KERNEL_NAME=$(uname)
MACHINE_NAME=$(uname -m)
DEV_MODE="0"
OEM=
if [ ${UNAME} = "Darwin" ] ; then
export MACOSX_DEPLOYMENT_TARGET=10.9
fi
function die()
{
echo "Error: $*" >&2
exit 1
}
function get_cpu_count()
{
if [ ${UNAME} = "Darwin" ] ; then
CPU_COUNT=$(sysctl -n hw.ncpu)
else
CPU_COUNT=$(grep processor /proc/cpuinfo | wc -l)
fi
}
function usage()
{
echo "Usage: $0 [ debug | release ] [dev]" >&2
exit 1
}
for arg in "$@"
do
if [ $arg = "debug" -o $arg = "release" ]; then
BUILD_TYPE=$arg
elif [[ $arg =~ ^oem=.*$ ]] ; then
OEM=${arg#oem=}
elif [ $arg = "dev" ]; then
DEV_MODE="1"
else
usage
fi
done
echo "OEM=$OEM"
echo "BUILD_TYPE: $BUILD_TYPE"
echo "kernel: $KERNEL_NAME"
echo "machine: $MACHINE_NAME"
if [ x$CPU_COUNT = x ] ; then
get_cpu_count
fi
if [ x$CPU_COUNT = x ] ; then
CPU_COUNT=4
fi
echo "CPU count: ${CPU_COUNT}."
echo "install the dependency thirdpart libraries ..."
if [ ${UNAME} = "Linux" ] ; then
LINUX_OS="Debian7_8"
echo "Linux OS: $LINUX_OS"
fi
echo "remove build directory"
rm -rf ${BUILD_DIR}
mkdir ${BUILD_DIR}
ret=1
pushd ${BUILD_DIR}
if [ "${DEV_MODE}" == "1" ]; then
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPLATFORM_TYPE="x86_64" -DCPU_COUNT=$CPU_COUNT -DKERNEL_NAME=$KERNEL_NAME -DMACHINE_NAME=$MACHINE_NAME -G Xcode ..
ret=$?
else
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPLATFORM_TYPE="x86_64" -DCPU_COUNT=$CPU_COUNT -DKERNEL_NAME=$KERNEL_NAME -DMACHINE_NAME=$MACHINE_NAME ..
make VERBOSE=1 -j ${CPU_COUNT}
make install -j ${CPU_COUNT}
make package
ret=$?
fi
popd
exit ${ret}