-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup.sh
executable file
·108 lines (95 loc) · 3.76 KB
/
setup.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
#!/usr/bin/env bash
# fancy colors cause we're fancy
CLEAR='\033[0m'
BOLD='\033[1m'
RED='\033[1;31m'
YELLOW='\033[1;33m'
GREEN='\033[1;32m'
function fail() {
echo -e "${RED}${1}${CLEAR}"
exit -1
}
function cmdcheck() {
echo -n "$1 ... "
command -v $1 >/dev/null || fail "not found!" && echo -e "${GREEN}found!${CLEAR}"
}
[[ -z "${SGDK}" ]] && SGDK='/opt/sgdk'
[[ -z "${M68K_PREFIX}" ]] && M68K_PREFIX='m68k-elf-'
echo -e "${BOLD}SGDK for *nix - Initial Setup${CLEAR}"
read -ep "Please specify SGDK directory: " -i ${SGDK} SGDK
[[ -d "${SGDK}" ]] || fail "SGDK directory not found!"
SGDK_BIN=${SGDK}/bin
read -ep "Please specify M68k toolchain prefix: " -i ${M68K_PREFIX} M68K_PREFIX
echo
echo -e "${YELLOW}Checking for necessary tools...${CLEAR}"
cmdcheck gcc
cmdcheck unzip
cmdcheck java
cmdcheck sjasmplus
cmdcheck ${M68K_PREFIX}gcc
cmdcheck ${M68K_PREFIX}objcopy
cmdcheck ${M68K_PREFIX}nm
cmdcheck ${M68K_PREFIX}ld
echo
echo -ne "${YELLOW}Updating project and library makefiles...${CLEAR} "
sed -i -E "s@SGDK\?=[A-Za-z0-9_./-]{1,}@SGDK?=${SGDK}@; s@M68K_PREFIX\?=[A-Za-z0-9_./-]{1,}@M68K_PREFIX?=${M68K_PREFIX}@" makefile_lib
[[ $? != 0 ]] && fail "Failed to update SGDK library makefile"
sed -i -E "s@SGDK\?=[A-Za-z0-9_./-]{1,}@SGDK?=${SGDK}@; s@M68K_PREFIX\?=[A-Za-z0-9_./-]{1,}@M68K_PREFIX?=${M68K_PREFIX}@" makefile
[[ $? != 0 ]] && fail "Failed to update project makefile"
echo -e "${GREEN}done!${CLEAR}"
if [[ ! -x ${SGDK_BIN}/appack ]]
then
echo
echo -e "${YELLOW}Building appack...${CLEAR}"
[[ ! -f "sgdk_tools/appack/example/appack.c" || ! -f "sgdk_tools/appack/lib/elf64/aplib.a" ]] && unzip -q -x sgdk_tools/appack/aPLib-1.1.1.zip -d sgdk_tools/appack
(export SGDK=${SGDK}; cd sgdk_tools/appack && make && make install && make clean)
[[ $? != 0 ]] && fail "Failed to build appack"
[[ -x ${SGDK_BIN}/appack ]] || fail "Failed to install appack"
echo -e "${GREEN}Success!${CLEAR}"
fi
if [[ ! -x ${SGDK_BIN}/xgmtool ]]
then
echo
echo -e "${YELLOW}Building xgmtool...${CLEAR}"
(export SGDK=${SGDK}; cd sgdk_tools/xgmtool && make && make install && make clean)
[[ $? != 0 ]] && fail "Failed to build xgmtool"
[[ -x ${SGDK_BIN}/xgmtool ]] || fail "Failed to install xgmtool"
echo -e "${GREEN}Success!${CLEAR}"
fi
if [[ ! -x ${SGDK_BIN}/bintos ]]
then
echo
echo -e "${YELLOW}Building bintos...${CLEAR}"
(export SGDK=${SGDK}; cd sgdk_tools/bintos && make && make install && make clean)
[[ $? != 0 ]] && fail "Failed to build bintos"
[[ -x ${SGDK_BIN}/bintos ]] || fail "Failed to install bintos"
echo -e "${GREEN}Success!${CLEAR}"
fi
if [[ ! -x ${SGDK_BIN}/maccer ]]
then
echo
echo -e "${YELLOW}Building maccer...${CLEAR}"
(export SGDK=${SGDK}; cd sgdk_tools/maccerx && make && make install && make clean)
[[ $? != 0 ]] && fail "Failed to build maccer"
[[ -x ${SGDK_BIN}/maccer ]] || fail "Failed to install maccer"
echo -e "${GREEN}Success!${CLEAR}"
fi
echo
echo -e "${YELLOW}Building SGDK library...${CLEAR}"
(export SGDK=${SGDK}; make -f makefile_lib && make -f makefile_lib cleanobj)
(export SGDK=${SGDK}; make -f makefile_lib debug && make -f makefile_lib cleanobj)
[[ $? != 0 ]] && fail "Failed to build SGDK library"
[[ -f ${SGDK}/lib/libmd.a ]] || fail "Failed to build SGDK library"
echo -e "${GREEN}Success!${CLEAR}"
echo
while true; do
read -p "Do you wish to remove the Windows specific binaries from the SGDK directory? " winrm
case $winrm in
[Yy]* ) rm -f ${SGDK_BIN}/*.exe ${SGDK_BIN}/*.dll; break;;
[Nn]* ) break;;
* ) echo "Please type Y or N";;
esac; done
echo
echo -e "${GREEN}Setup complete!${CLEAR}"
echo "You should be good to go. Copy 'makefile' into the root of your project directory and modify the settings inside at the top."
echo "You do NOT need to run this setup again for a new project. Just copy makefile into as many projects as you like."