Make sure that jjb-cleanup.sh allows unbound vars
[releng/global-jjb.git] / shell / cmake-build.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2018 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 echo "---> cmake-build.sh"
12
13 build_dir="${BUILD_DIR:-$WORKSPACE/target}"
14 cmake_opts="${CMAKE_OPTS:-}"
15 make_opts="${MAKE_OPTS:-}"
16 # Not a misspelling as shellcheck reports.
17 # shellcheck disable=SC2153
18 project="${PROJECT//\//\-}"
19
20 ################
21 # Script start #
22 ################
23
24 set -eux -o pipefail
25
26 mkdir -p "$build_dir"
27 cd "$build_dir" || exit
28 # $cmake_opts needs to wordsplit to pass options.
29 # shellcheck disable=SC2086
30 eval cmake -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" $cmake_opts ..
31 # $make_opts needs to wordsplit to pass options.
32 # shellcheck disable=SC2086
33 make $make_opts
34 make install
35
36 mkdir -p "$WORKSPACE/dist"
37 tar -cJvf "$WORKSPACE/dist/$project.tar.xz" -C "$INSTALL_PREFIX" .
38
39 sudo tar -xvf "$WORKSPACE/dist/$project.tar.xz" -C "/usr/local"
40 sudo ldconfig