equal
deleted
inserted
replaced
1 #!/usr/bin/env bash |
|
2 # |
|
3 # Multi-platform build script |
|
4 |
|
5 unset CDPATH |
|
6 THIS="$(cd "$(dirname "$0")"; pwd)" |
|
7 PRG="$(basename "$0")" |
|
8 |
|
9 |
|
10 # diagnostics |
|
11 |
|
12 function usage() |
|
13 { |
|
14 echo |
|
15 echo "Usage: $PRG PLATFORM" |
|
16 echo |
|
17 exit 1 |
|
18 } |
|
19 |
|
20 function fail() |
|
21 { |
|
22 echo "$1" >&2 |
|
23 exit 2 |
|
24 } |
|
25 |
|
26 |
|
27 # command line args |
|
28 |
|
29 [ "$#" -eq 0 ] && usage |
|
30 PLATFORM="$1"; shift |
|
31 |
|
32 [ "$#" -eq 0 ] || usage |
|
33 |
|
34 |
|
35 # main |
|
36 |
|
37 PLATFORM_DIR="platform_${PLATFORM}" |
|
38 |
|
39 case "$PLATFORM" in |
|
40 arm64-linux | arm64-darwin) |
|
41 mkdir -p "$PLATFORM_DIR" |
|
42 cc -Wall bash_process.c -o "$PLATFORM_DIR/bash_process" |
|
43 ;; |
|
44 x86_64-linux | x86_64-darwin) |
|
45 mkdir -p "$PLATFORM_DIR" |
|
46 cc -Wall -m64 bash_process.c -o "$PLATFORM_DIR/bash_process" |
|
47 ;; |
|
48 x86_64-cygwin) |
|
49 mkdir -p "$PLATFORM_DIR" |
|
50 cc -Wall bash_process.c -o "$PLATFORM_DIR/bash_process.exe" |
|
51 ;; |
|
52 *) |
|
53 fail "Bad target platform: \"$PLATFORM\"" |
|
54 ;; |
|
55 esac |
|