forked from Wafelack/orion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·79 lines (69 loc) · 1.84 KB
/
configure
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
set -euo pipefail
DONE='\033[0;32mdone\033[0m'
SHELL_PATH=""
SHELL_VAR=""
FILE=""
DONE_2=""
SHELL=$(basename $SHELL)
case $SHELL in
"bash")
SHELL_PATH="PATH=\$(PREFIX)/bin:\$PATH"
SHELL_VAR="export ORION_LIB=\$(PREFIX)/\$(LIB)/orion"
FILE="${HOME}/.bash_profile"
DONE_2="$DONE"
;;
"zsh")
SHELL_PATH="PATH=\$(PREFIX)/bin:\$PATH"
SHELl_VAR="export ORION_LIB=\$(PREFIX)/\$(LIB)/orion"
FILE="${HOME}/.zshrc"
DONE_2="$DONE"
;;
"fish")
SHELL_PATH="set PATH \$(PREFIX)/bin \\\$\$PATH"
SHELL_VAR="export ORION_LIB=\$(PREFIX)/\$(LIB)/orion"
FILE="${HOME}/.config/fish/config.fish"
DONE_2="$DONE"
;;
*)
SHELL_PATH="\033[0;31mfailed\033[0m\nCannot automatically detect your shell.\nPlease add \$(PREFIX) to your PATH and set the ORION_LIB variable to \$(PREFIX)/\$(LIB)."
FILE="/dev/stdout"
;;
esac
echo -n "* Generating Makefile ... "
cat > Makefile << EOF
FILES := \$(shell find src/ -name *.rs)
PREFIX ?= /usr/
TARGET := target/release/orion
LIB := lib/
\$(TARGET) : \$(FILES)
cargo test
cargo build --release
update : \$(TARGET) \$(LIB) uninstall
@echo -n "* Creating Orion directory ... "
@mkdir -p \$(PREFIX)
@echo -e "$DONE"
@echo -n "* Copying Orion binary ... "
@mkdir -p \$(PREFIX)/bin/
@cp \$(TARGET) \$(PREFIX)/bin/
@echo -e "$DONE"
@echo -n "* Copying Orion core and standard libraries ... "
@mkdir -p \$(PREFIX)/lib/
@cp -r \$(LIB) \$(PREFIX)/lib/orion/
@echo -e "$DONE"
install : update
@echo -n "* Adding Orion to PATH ... "
@echo -e ${SHELL_PATH} >> ${FILE}
@echo -e "${DONE_2}"
@echo -n "* Setting ORION_LIB ... "
@echo -e ${SHELL_VAR} >> ${FILE}
@echo -e "${DONE_2}"
uninstall : \$(PREFIX)
@echo -n "* Removing Orion binary ... "
@rm -fr \$(PREFIX)/bin/orion
@echo -e "$DONE"
@echo -n "* Removing Orion library ... "
@rm -fr \$(PREFIX)/lib/orion/
@echo -e "$DONE"
EOF
echo -e $DONE