| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# Written by David Stuttard, Intel ([email protected]) 26 June, 2013 |
| 4 |
# This script will use cmake to build and install the linux cm and cmrt libraries |
| 5 |
|
| 6 |
# Process the input options using built-in getopts |
| 7 |
usage(){ |
| 8 |
echo "Usage: `basename $0` -b <relative-path> -h for help"; |
| 9 |
echo " -b <relative-path> : Set the build dir to something other than the default (build.linux)"; |
| 10 |
echo " -h : Help (print out this usage)"; |
| 11 |
echo " -a : build jitter shared library and GenX_IR"; |
| 12 |
echo " -d : Debug build (default build.linux.debug)"; |
| 13 |
echo " -e : Enable EMU build"; |
| 14 |
echo " --32 : Build 32 bit variant (default on 32 bit systems)"; |
| 15 |
echo " --64 : Build 64 bit variant (default on 64 bit systems)"; |
| 16 |
} |
| 17 |
|
| 18 |
function define_colours_on() { |
| 19 |
# Reset |
| 20 |
Colour_Off='\033[0m' # Text Reset |
| 21 |
|
| 22 |
# Regular Colours |
| 23 |
Black='\033[0;30m' # Black |
| 24 |
Red='\033[0;31m' # Red |
| 25 |
Green='\033[0;32m' # Green |
| 26 |
Yellow='\033[0;33m' # Yellow |
| 27 |
Blue='\033[0;34m' # Blue |
| 28 |
Purple='\033[0;35m' # Purple |
| 29 |
Cyan='\033[0;36m' # Cyan |
| 30 |
White='\033[0;37m' # White |
| 31 |
|
| 32 |
# Bold |
| 33 |
BBlack='\033[1;30m' # Black |
| 34 |
BRed='\033[1;31m' # Red |
| 35 |
BGreen='\033[1;32m' # Green |
| 36 |
BYellow='\033[1;33m' # Yellow |
| 37 |
BBlue='\033[1;34m' # Blue |
| 38 |
BPurple='\033[1;35m' # Purple |
| 39 |
BCyan='\033[1;36m' # Cyan |
| 40 |
BWhite='\033[1;37m' # White |
| 41 |
} |
| 42 |
|
| 43 |
function define_colours_off() { |
| 44 |
# Reset |
| 45 |
Colour_Off='' # Text Reset |
| 46 |
|
| 47 |
# Regular Colours |
| 48 |
Black='' # Black |
| 49 |
Red='' # Red |
| 50 |
Green='' # Green |
| 51 |
Yellow='' # Yellow |
| 52 |
Blue='' # Blue |
| 53 |
Purple='' # Purple |
| 54 |
Cyan='' # Cyan |
| 55 |
White='' # White |
| 56 |
|
| 57 |
# Bold |
| 58 |
BBlack='' # Black |
| 59 |
BRed='' # Red |
| 60 |
BGreen='' # Green |
| 61 |
BYellow='' # Yellow |
| 62 |
BBlue='' # Blue |
| 63 |
BPurple='' # Purple |
| 64 |
BCyan='' # Cyan |
| 65 |
BWhite='' # White |
| 66 |
} |
| 67 |
|
| 68 |
BUILD_DIR=build.linux |
| 69 |
DEBUG=0 |
| 70 |
BUILD_SET=0 |
| 71 |
BUILD_32=0 |
| 72 |
BUILD_64=0 |
| 73 |
BUILD_EMU=0 |
| 74 |
CROSS_BUILD=0 |
| 75 |
BUILD_SIZE=0 |
| 76 |
|
| 77 |
# Set up build size |
| 78 |
MACHINE_TYPE=`uname -m` |
| 79 |
if [ ${MACHINE_TYPE} == 'x86_64' ]; then |
| 80 |
BUILD_SIZE=64 |
| 81 |
else |
| 82 |
BUILD_SIZE=32 |
| 83 |
fi |
| 84 |
|
| 85 |
while getopts "b:edah-:" opt; do |
| 86 |
case $opt in |
| 87 |
-) |
| 88 |
case "${OPTARG}" in |
| 89 |
32) |
| 90 |
BUILD_32=1 |
| 91 |
;; |
| 92 |
64) |
| 93 |
BUILD_64=1 |
| 94 |
;; |
| 95 |
esac;; |
| 96 |
b) |
| 97 |
BUILD_DIR=$OPTARG |
| 98 |
BUILD_SET=1 |
| 99 |
;; |
| 100 |
e) |
| 101 |
BUILD_EMU=1 |
| 102 |
;; |
| 103 |
d) |
| 104 |
DEBUG=1 |
| 105 |
;; |
| 106 |
a) |
| 107 |
export BUILD_ALL=1 |
| 108 |
;; |
| 109 |
h) |
| 110 |
usage |
| 111 |
exit 1 |
| 112 |
;; |
| 113 |
\?) |
| 114 |
echo "Unknown option" |
| 115 |
usage |
| 116 |
exit 1 |
| 117 |
;; |
| 118 |
esac |
| 119 |
done |
| 120 |
|
| 121 |
if [[ $BUILD_32 -eq 1 ]]; then |
| 122 |
if [[ $BUILD_64 -eq 1 ]]; then |
| 123 |
echo "Can't specify 32 *and* 64 bit at the same time" |
| 124 |
usage |
| 125 |
exit 1 |
| 126 |
fi |
| 127 |
fi |
| 128 |
|
| 129 |
EXTRA_OPTIONS= |
| 130 |
EXTRA_CMAKE_FLAGS= |
| 131 |
|
| 132 |
if [[ $BUILD_EMU -eq 1 ]]; then |
| 133 |
EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DLATEST_CPP_NEEDED=TRUE -DLIBVA_INSTALL_PATH=$(realpath ../../../../libva-prebuilt-headers)" |
| 134 |
fi |
| 135 |
|
| 136 |
case $BUILD_SIZE in |
| 137 |
32) |
| 138 |
if [[ $BUILD_64 -eq 1 ]]; then |
| 139 |
CROSS_BUILD=1 |
| 140 |
BUILD_SIZE=64 |
| 141 |
EXTRA_OPTIONS="export CFLAGS=-m64 CXXFLAGS=-m64" |
| 142 |
fi |
| 143 |
;; |
| 144 |
64) |
| 145 |
if [[ $BUILD_32 -eq 1 ]]; then |
| 146 |
CROSS_BUILD=1 |
| 147 |
BUILD_SIZE=32 |
| 148 |
EXTRA_OPTIONS="export CFLAGS=-m32 CXXFLAGS=-m32" |
| 149 |
fi |
| 150 |
;; |
| 151 |
esac |
| 152 |
|
| 153 |
if [[ $BUILD_SET -eq 0 ]]; then |
| 154 |
if [[ $DEBUG -eq 1 ]]; then |
| 155 |
BUILD_DIR=build.linux.debug |
| 156 |
fi |
| 157 |
# Add .x. if a cross compile build |
| 158 |
if [[ $CROSS_BUILD -eq 1 ]]; then |
| 159 |
BUILD_DIR="$BUILD_DIR.x" |
| 160 |
fi |
| 161 |
# Append build size to directory name |
| 162 |
BUILD_DIR="$BUILD_DIR.$BUILD_SIZE" |
| 163 |
fi |
| 164 |
|
| 165 |
if [[ $DEBUG -eq 1 ]]; then |
| 166 |
EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DCMAKE_BUILD_TYPE=Debug" |
| 167 |
else |
| 168 |
EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DCMAKE_BUILD_TYPE=Release" |
| 169 |
fi |
| 170 |
|
| 171 |
define_colours_on |
| 172 |
|
| 173 |
echo "We're going to do the build in " $BUILD_DIR |
| 174 |
|
| 175 |
# Do we have cmake installed? |
| 176 |
if hash cmake 2>/dev/null; then |
| 177 |
echo "cmake has been detected ... proceeding" |
| 178 |
else |
| 179 |
echo "cmake is required to perform a linux build. Please install the package (sudo apt-get install cmake)" |
| 180 |
exit 1 |
| 181 |
fi |
| 182 |
|
| 183 |
# By default we will create and do the build in build.linux but this can overridden |
| 184 |
if [ ! -d "$BUILD_DIR" ]; then |
| 185 |
mkdir -p $BUILD_DIR |
| 186 |
fi |
| 187 |
|
| 188 |
CMAKE_ROOT=`pwd` |
| 189 |
|
| 190 |
# The root CMakeLists.txt file is in the same directory as this script - remember this location |
| 191 |
cd $CMAKE_ROOT |
| 192 |
cd $BUILD_DIR |
| 193 |
echo "executing : $EXTRA_OPTIONS cmake" $CMAKE_ROOT |
| 194 |
( |
| 195 |
if [[ $BUILD_EMU -eq 0 ]]; then |
| 196 |
$EXTRA_OPTIONS |
| 197 |
fi |
| 198 |
cmake $EXTRA_CMAKE_FLAGS $CMAKE_ROOT |
| 199 |
) |
| 200 |
if [[ $BUILD_EMU -eq 0 ]]; then |
| 201 |
echo "executing make" |
| 202 |
make |
| 203 |
fi |