|
1 | 1 | #!/bin/bash |
2 | 2 | # binutils-2.14.sh by Francisco Javier Trujillo Mata ([email protected]) |
3 | 3 |
|
| 4 | +## Exit with code 1 when any command executed returns a non-zero exit code. |
| 5 | +onerr() |
| 6 | +{ |
| 7 | + exit 1; |
| 8 | +} |
| 9 | +trap onerr ERR |
| 10 | + |
4 | 11 | ## Download the source code. |
5 | 12 | REPO_URL="https://github.com/ps2dev/binutils-gdb.git" |
6 | 13 | REPO_FOLDER="binutils-gdb" |
7 | 14 | BRANCH_NAME="dvp-v2.14" |
8 | 15 | if test ! -d "$REPO_FOLDER"; then |
9 | | - git clone --depth 1 -b $BRANCH_NAME $REPO_URL && cd "$REPO_FOLDER" || exit 1 |
| 16 | + git clone --depth 1 -b "$BRANCH_NAME" "$REPO_URL" |
10 | 17 | else |
11 | | - cd "$REPO_FOLDER" && git fetch origin && git reset --hard "origin/${BRANCH_NAME}" && git checkout "$BRANCH_NAME" || exit 1 |
| 18 | + git -C "$REPO_FOLDER" fetch origin |
| 19 | + git -C "$REPO_FOLDER" reset --hard "origin/${BRANCH_NAME}" |
| 20 | + git -C "$REPO_FOLDER" checkout "$BRANCH_NAME" |
12 | 21 | fi |
| 22 | +cd "$REPO_FOLDER" |
13 | 23 |
|
14 | 24 | TARGET_ALIAS="dvp" |
15 | | -TARGET="dvp" |
16 | 25 | TARG_XTRA_OPTS="" |
17 | 26 | OSVER=$(uname) |
18 | 27 |
|
|
31 | 40 | ## Determine the maximum number of processes that Make can work with. |
32 | 41 | PROC_NR=$(getconf _NPROCESSORS_ONLN) |
33 | 42 |
|
34 | | -## Create and enter the toolchain/build directory |
35 | | -rm -rf build-$TARGET && mkdir build-$TARGET && cd build-$TARGET || { exit 1; } |
36 | | - |
37 | | -## Configure the build. |
38 | | -../configure \ |
39 | | - --quiet \ |
40 | | - --prefix="$PS2DEV/$TARGET_ALIAS" \ |
41 | | - --target="$TARGET" \ |
42 | | - --disable-nls \ |
43 | | - --disable-build-warnings \ |
44 | | - $TARG_XTRA_OPTS || { exit 1; } |
45 | | - |
46 | | -## Compile and install. |
47 | | -make --quiet -j $PROC_NR clean || { exit 1; } |
48 | | -make --quiet -j $PROC_NR CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0 -O2 -Wno-implicit-function-declaration" LDFLAGS="$LDFLAGS -s" || { exit 1; } |
49 | | -make --quiet -j $PROC_NR install || { exit 1; } |
50 | | -make --quiet -j $PROC_NR clean || { exit 1; } |
51 | | - |
52 | | -## Exit the build directory. |
53 | | -cd .. || { exit 1; } |
| 43 | +## For each target... |
| 44 | +for TARGET in "dvp"; do |
| 45 | + ## Create and enter the toolchain/build directory |
| 46 | + rm -rf "build-$TARGET" |
| 47 | + mkdir "build-$TARGET" |
| 48 | + cd "build-$TARGET" |
| 49 | + |
| 50 | + ## Configure the build. |
| 51 | + ../configure \ |
| 52 | + --quiet \ |
| 53 | + --prefix="$PS2DEV/$TARGET_ALIAS" \ |
| 54 | + --target="$TARGET" \ |
| 55 | + --disable-nls \ |
| 56 | + --disable-build-warnings \ |
| 57 | + $TARG_XTRA_OPTS |
| 58 | + |
| 59 | + ## Compile and install. |
| 60 | + make --quiet -j "$PROC_NR" CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0 -O2 -Wno-implicit-function-declaration" LDFLAGS="$LDFLAGS -s" |
| 61 | + make --quiet -j "$PROC_NR" install |
| 62 | + make --quiet -j "$PROC_NR" clean |
| 63 | + |
| 64 | + ## Exit the build directory. |
| 65 | + cd .. |
| 66 | + |
| 67 | + ## End target. |
| 68 | +done |
0 commit comments