File: build_linux.sh

package info (click to toggle)
intel-media-driver 25.2.3%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 151,588 kB
  • sloc: cpp: 1,609,549; ansic: 215,001; asm: 39,161; python: 555; sh: 177; makefile: 16
file content (203 lines) | stat: -rw-r--r-- 5,132 bytes parent folder | download | duplicates (8)
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
#!/bin/bash

# Written by David Stuttard, Intel (david.stuttard@intel.com) 26 June, 2013
# This script will use cmake to build and install the linux cm and cmrt libraries

# Process the input options using built-in getopts
usage(){
    echo "Usage: `basename $0` -b <relative-path> -h for help";
    echo "    -b <relative-path> : Set the build dir to something other than the default (build.linux)";
    echo "    -h                 : Help (print out this usage)";
    echo "    -a                 : build jitter shared library and GenX_IR";
    echo "    -d                 : Debug build (default build.linux.debug)";
    echo "    -e                 : Enable EMU build";
    echo "    --32               : Build 32 bit variant (default on 32 bit systems)";
    echo "    --64               : Build 64 bit variant (default on 64 bit systems)";
}

function define_colours_on() {
    # Reset
    Colour_Off='\033[0m'      # Text Reset

    # Regular Colours
    Black='\033[0;30m'        # Black
    Red='\033[0;31m'          # Red
    Green='\033[0;32m'        # Green
    Yellow='\033[0;33m'       # Yellow
    Blue='\033[0;34m'         # Blue
    Purple='\033[0;35m'       # Purple
    Cyan='\033[0;36m'         # Cyan
    White='\033[0;37m'        # White
    
    # Bold
    BBlack='\033[1;30m'       # Black
    BRed='\033[1;31m'         # Red
    BGreen='\033[1;32m'       # Green
    BYellow='\033[1;33m'      # Yellow
    BBlue='\033[1;34m'        # Blue
    BPurple='\033[1;35m'      # Purple
    BCyan='\033[1;36m'        # Cyan
    BWhite='\033[1;37m'       # White
}

function define_colours_off() {
    # Reset
    Colour_Off=''      # Text Reset

    # Regular Colours
    Black=''        # Black
    Red=''          # Red
    Green=''        # Green
    Yellow=''       # Yellow
    Blue=''         # Blue
    Purple=''       # Purple
    Cyan=''         # Cyan
    White=''        # White
    
    # Bold
    BBlack=''       # Black
    BRed=''         # Red
    BGreen=''       # Green
    BYellow=''      # Yellow
    BBlue=''        # Blue
    BPurple=''      # Purple
    BCyan=''        # Cyan
    BWhite=''       # White
}

BUILD_DIR=build.linux
DEBUG=0
BUILD_SET=0
BUILD_32=0
BUILD_64=0
BUILD_EMU=0
CROSS_BUILD=0
BUILD_SIZE=0

# Set up build size
MACHINE_TYPE=`uname -m`
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
    BUILD_SIZE=64
else
    BUILD_SIZE=32
fi

while getopts "b:edah-:" opt; do
    case $opt in
        -)
            case "${OPTARG}" in
                32)
                    BUILD_32=1
                    ;;
                64)
                    BUILD_64=1
                    ;;
            esac;;
        b) 
            BUILD_DIR=$OPTARG
            BUILD_SET=1
            ;;
        e)
            BUILD_EMU=1
            ;;
        d)
            DEBUG=1
            ;;
        a)
            export BUILD_ALL=1
            ;;            
        h) 
            usage
            exit 1
            ;;
        \?)
            echo "Unknown option"
            usage
            exit 1
            ;;
    esac
done

if [[ $BUILD_32 -eq 1 ]]; then
    if [[ $BUILD_64 -eq 1 ]]; then
        echo "Can't specify 32 *and* 64 bit at the same time"
        usage
        exit 1
    fi
fi

EXTRA_OPTIONS=
EXTRA_CMAKE_FLAGS=

if [[ $BUILD_EMU -eq 1 ]]; then
    EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DLATEST_CPP_NEEDED=TRUE -DLIBVA_INSTALL_PATH=$(realpath ../../../../libva-prebuilt-headers)"
fi

case $BUILD_SIZE in
    32)
        if [[ $BUILD_64 -eq 1 ]]; then
            CROSS_BUILD=1
            BUILD_SIZE=64
            EXTRA_OPTIONS="export CFLAGS=-m64 CXXFLAGS=-m64"
        fi
        ;;
    64)
        if [[ $BUILD_32 -eq 1 ]]; then
            CROSS_BUILD=1
            BUILD_SIZE=32
            EXTRA_OPTIONS="export CFLAGS=-m32 CXXFLAGS=-m32"
        fi
        ;;
esac

if [[ $BUILD_SET -eq 0 ]]; then
    if [[ $DEBUG -eq 1 ]]; then
        BUILD_DIR=build.linux.debug
    fi
    # Add .x. if a cross compile build
    if [[ $CROSS_BUILD -eq 1 ]]; then
        BUILD_DIR="$BUILD_DIR.x"
    fi
    # Append build size to directory name
    BUILD_DIR="$BUILD_DIR.$BUILD_SIZE"
fi

if [[ $DEBUG -eq 1 ]]; then
    EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DCMAKE_BUILD_TYPE=Debug"
else
    EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DCMAKE_BUILD_TYPE=Release"
fi

define_colours_on

echo "We're going to do the build in " $BUILD_DIR        

# Do we have cmake installed?
if hash cmake 2>/dev/null; then
    echo "cmake has been detected ... proceeding"
else
    echo "cmake is required to perform a linux build. Please install the package (sudo apt-get install cmake)"
    exit 1
fi

# By default we will create and do the build in build.linux but this can overridden 
if [ ! -d "$BUILD_DIR" ]; then
    mkdir -p $BUILD_DIR
fi

CMAKE_ROOT=`pwd`

# The root CMakeLists.txt file is in the same directory as this script - remember this location
cd $CMAKE_ROOT
cd $BUILD_DIR
echo "executing : $EXTRA_OPTIONS cmake" $CMAKE_ROOT
(
if [[ $BUILD_EMU -eq 0 ]]; then
  $EXTRA_OPTIONS
fi
cmake $EXTRA_CMAKE_FLAGS $CMAKE_ROOT
)
if [[ $BUILD_EMU -eq 0 ]]; then
  echo "executing make"
  make
fi