2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2020 The Linux Foundation and others.
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 ##############################################################################
12 # Invokes configure and make with the specified options.
13 # Optionally runs make install and tars up all files from the install prefix,
14 # then uses sudo to extract those files to /usr/local and runs ldconfig,
15 # leaving shared lib(s) ready for use.
17 # The build minion has make, gcc etc.
18 # The project repo has an executable shell script "configure"
19 # Environment variables:
20 # WORKSPACE is a non-empty path (required)
21 # INSTALL_PREFIX is a non-empty path (required)
22 # PROJECT is a non-empty name (required)
23 # CONFIGURE_OPTS has options for configure (optional, empty default)
24 # MAKE_OPTS has options for make (optional, empty default)
25 # INSTALL is "true" or "false" (optional, default false)
27 echo "---> autotools-build.sh"
29 # be careful and verbose
32 c="$WORKSPACE/configure"
33 if [[ ! -f $c || ! -x $c ]]; then
34 echo "ERROR: failed to find executable file $c"
38 configure_opts="${CONFIGURE_OPTS:-}"
39 make_opts="${MAKE_OPTS:-}"
40 install="${INSTALL:-false}"
41 # Not a misspelling as shellcheck reports.
42 # shellcheck disable=SC2153
43 project="${PROJECT//\//\-}"
45 # use eval to disable bash quoting behavior;
46 # e.g., if configure-opts=CXXFLAGS="-O0 --coverage"
47 # configure needs to wordsplit to pass options
48 # shellcheck disable=SC2086
49 eval $c --prefix="$INSTALL_PREFIX" $configure_opts
51 # show make version to assist debugging
53 # use eval to disable bash quoting behavior
54 # $make_opts may be empty
55 # make needs to wordsplit to pass options
56 # shellcheck disable=SC2086
59 if [[ $install == true ]]; then
61 mkdir -p "$WORKSPACE/dist"
62 tar -cJvf "$WORKSPACE/dist/$project.tar.xz" -C "$INSTALL_PREFIX" .
63 sudo tar -xvf "$WORKSPACE/dist/$project.tar.xz" -C "/usr/local"
67 echo "---> autotools-build.sh ends"