|
14 | 14 | # - Creates a tar file of the whole install directory |
15 | 15 |
|
16 | 16 | set -e |
17 | | -set -x |
18 | 17 | set -o pipefail |
19 | 18 |
|
20 | | -if ! [ "$#" -ge 3 ]; then |
21 | | - echo "Usage: $0 <config_name> <target> <dest_dir> <march> <mabi> <mcmodel> <cflags...>" |
22 | | - exit 2 |
23 | | -fi; |
24 | | - |
25 | 19 | repo_dir="$(git rev-parse --show-toplevel)" |
26 | 20 | build_dir="${repo_dir}/build" |
27 | 21 | dist_dir="${build_dir}/dist" |
28 | 22 |
|
29 | | -## Take configuration from arguments |
30 | | -# This is the name for the tar file. |
31 | | -toolchain_name="${1}" |
32 | | -# This is the CMake build type (e.g. Release, Debug, RelWithDebInfo) |
33 | | -build_type="${2}" |
34 | | -# This is the expected target triple (so we can set a default) |
35 | | -toolchain_target="${3}" |
36 | | -# -march option default value |
37 | | -march="${4}" |
38 | | -# -mabi option default value |
39 | | -mabi="${5}" |
40 | | -# -mcmodel option default value |
41 | | -mcmodel="${6}" |
42 | | -# Remaining cflags for build configurations |
43 | | -toolchain_cflags=("${@:7}") |
| 23 | +usage="\ |
| 24 | +USAGE: ${0} [options] <args> |
| 25 | +
|
| 26 | +OPTIONS: |
| 27 | + -h,--help Print this message |
| 28 | + --debug Build with assertions and debug info |
| 29 | +
|
| 30 | +ARGS: |
| 31 | + --name <name> Name of the toolchain |
| 32 | + --target <target> Default target triple |
| 33 | + --march <march> Default -march |
| 34 | + --mabi <mabi> Default -mabi |
| 35 | + --mcmodel <mcmodel> Default -mcmodel |
| 36 | +" |
| 37 | +options="$(getopt -a -o '-h' -l 'help,name:,target:,march:,mabi:,mcmodel:,debug' -- "$@")" |
| 38 | + |
| 39 | +err() { |
| 40 | + echo "ERROR ${1}" >&2 |
| 41 | + echo >&2 |
| 42 | + echo "$usage" >&2 |
| 43 | + exit 2 |
| 44 | +} |
| 45 | +[[ "$options" == *"--name"* ]] || err 'Missing argument `--name`' |
| 46 | +[[ "$options" == *"--target"* ]] || err 'Missing argument `--target`' |
| 47 | +[[ "$options" == *"--march"* ]] || err 'Missing argument `--march`' |
| 48 | +[[ "$options" == *"--mabi"* ]] || err 'Missing argument `--mabi`' |
| 49 | +[[ "$options" == *"--mcmodel"* ]] || err 'Missing argument `--mcmodel`' |
| 50 | + |
| 51 | +build_type=Release |
| 52 | + |
| 53 | +eval set -- "$options" |
| 54 | +while true; do |
| 55 | + case "$1" in |
| 56 | + -h,--help) echo "$usage" && exit 0;; |
| 57 | + --name) toolchain_name="$2"; shift 2;; |
| 58 | + --target) toolchain_target="$2"; shift 2;; |
| 59 | + --march) march="$2"; shift 2;; |
| 60 | + --mabi) mabi="$2"; shift 2;; |
| 61 | + --mcmodel) mcmodel="$2"; shift 2;; |
| 62 | + --debug) build_type=Debug; shift 1;; |
| 63 | + --) shift; break;; |
| 64 | + esac |
| 65 | +done |
| 66 | + |
| 67 | +set -x |
44 | 68 |
|
45 | 69 | # For *_VERSION variables |
46 | 70 | # shellcheck source=sw-versions.sh |
@@ -159,7 +183,7 @@ Crosstool-ng version: |
159 | 183 | (git: ${CROSSTOOL_NG_URL} ${CROSSTOOL_NG_VERSION}) |
160 | 184 |
|
161 | 185 | C Flags: |
162 | | - -march=${march} -mabi=${mabi} -mcmodel=${mcmodel} ${toolchain_cflags[@]} |
| 186 | + -march=${march} -mabi=${mabi} -mcmodel=${mcmodel} |
163 | 187 |
|
164 | 188 | Built at ${build_date} on $(hostname) |
165 | 189 | BUILDINFO |
|
0 commit comments