-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.sh
executable file
·57 lines (34 loc) · 1.53 KB
/
make.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/env bash
# needs root to write to /usr/local/include/... and /usr/local/lib/...
[[ "$EUID" -ne 0 ]] && echo "must be run as root" && exit 1
#### CONFIG ####
# target directory for the header files to be copied to
BIN_DIR="/usr/local/bin/"
# target directory for the final lib file to be copied to
MAN_DIR="/usr/local/man/man1/"
# project root, $(pwd) works as long as you run this script in the root directory of the project
PROJ_ROOT=$(pwd)
# filename for the final lib file
TARGET="argos"
#### LOGIC ####
# make sure config settings are good
[[ -z "$PROJ_ROOT" ]] && echo "PROJ_ROOT is not set" && exit 1
[[ -z "$BIN_DIR" ]] && echo "BIN_DIR is not set" && exit 1
[[ -z "$MAN_DIR" ]] && echo "MAN_DIR is not set" && exit 1
[[ -z "$TARGET" ]] && echo "TARGET is not set" && exit 1
# if the build directory does not exist, create it
[[ ! -d "$PROJ_ROOT/build" ]] && mkdir "$PROJ_ROOT/build/"
# clear the build directory
rm -rf "$PROJ_ROOT/build/"*
# enter the build directory and compile all the sources into the target
cd "$PROJ_ROOT/build/" && gcc "$PROJ_ROOT/"*.c -lsoph -o "$TARGET"
# copy the bin file into $BIN_DIR
cp "$PROJ_ROOT/build/$TARGET" "$BIN_DIR"
# create a man file by running help2man on the executable
help2man "$PROJ_ROOT/build/$TARGET" > "$PROJ_ROOT/build/$TARGET.1"
# create a man file by running help2man on the executable
gzip "$PROJ_ROOT/build/$TARGET.1" -k
# copy the man file into $MAN_DIR
cp "$PROJ_ROOT/build/$TARGET.1.gz" "$MAN_DIR"
# remove the temporary build directory
#rm -rf "$PROJ_ROOT/build"