forked from allwincnc/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_drv.sh
executable file
·116 lines (86 loc) · 2.37 KB
/
install_drv.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
source tools.sh
# var list
NAME="ARISC driver for the LinuxCNC"
CHIP=""
CUR_DIR=$(pwd)
SRC_DIR="linuxcnc/drv"
TARGET_ID="0"
ALL_FILES=("api.h" "arisc.c")
C_FILES=("arisc.c")
# greetings
log ""
log "--- Installing **${NAME}** -------"
# select a SoC from the arguments list
if [[ $# != 0 ]]; then
for arg in $*; do
case $arg in
"h3") CHIP="h3"; ;;
"H3") CHIP="h3"; ;;
"h5") CHIP="h5"; ;;
"H5") CHIP="h5"; ;;
"h6") CHIP="h6"; ;;
"H6") CHIP="h6"; ;;
esac
done
fi
# if no SoC selected yet
while [[ "${CHIP}" != "1" && "${CHIP}" != "2" && "${CHIP}" != "3" && \
"${CHIP}" != "h3" && "${CHIP}" != "H3" && \
"${CHIP}" != "h5" && "${CHIP}" != "H5" && \
"${CHIP}" != "h6" && "${CHIP}" != "H6" ]]; do
log "Please select your SoC:"
log " 1: Allwinner H3"
log " 2: Allwinner H5"
log " 3: Allwinner H6"
read -p "SoC: " CHIP
done
# set SoC
case "${CHIP}" in
"1") CHIP="h3"; ;;
"2") CHIP="h5"; ;;
"3") CHIP="h6"; ;;
"h3") CHIP="h3"; ;;
"H3") CHIP="h3"; ;;
"h5") CHIP="h5"; ;;
"H5") CHIP="h5"; ;;
"h6") CHIP="h6"; ;;
"H6") CHIP="h6"; ;;
*) CHIP="h3"; ;;
esac
# setup sources folder based on the SoC name
SRC_DIR="${SRC_DIR}/${CHIP}"
# check a folder with sources
if [[ ! -d "${SRC_DIR}" ]]; then
log "!!ERROR!!: Can't find the **./${SRC_DIR}** folder [**${0}:${LINENO}**]."
cd "${CUR_DIR}"
exit 1
fi
cd "${SRC_DIR}"
for file in ${ALL_FILES[*]}; do
if [[ ! -f "${file}" ]]; then
log "!!ERROR!!: Can't find the **./${SRC_DIR}/${file}** file [**${0}:${LINENO}**]."
cd "${CUR_DIR}"
exit 1
fi
done
# find a compiler
if [[ $(halcompile --help | grep Usage) ]]; then
COMPILER="halcompile"
elif [[ $(comp --help | grep Usage) ]]; then
COMPILER="comp"
else
log "!!ERROR!!: Can't find a components compiler for the **${TARGET}** [**${0}:${LINENO}**]."
exit 1
fi
# compiling the driver
log "Compiling the drivers ..."
for file in ${C_FILES[*]}; do
if [[ ! $(sudo "${COMPILER}" --install "${file}" | grep Linking) ]]; then
log "!!ERROR!!: Failed to compile the **${file}** file [**${0}:${LINENO}**]."
exit 1
fi
done
cd "${CUR_DIR}"
log "--- **${NAME}** ++successfully installed++ -------"
log ""