-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbuild-toolchain.sh
executable file
·100 lines (87 loc) · 2.75 KB
/
build-toolchain.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
#!/bin/bash
###################################################################
#Script Name : build-toolchain
#Description : build toolchain for the Motorola 68000
#Date : samedi, 4 avril 2020
#Args : Welcome to the next level!
#Author : Jacques Belosoukinski (kentosama)
#Email : [email protected]
###################################################################
BUILD_BINUTILS="yes"
BUILD_GCC_STAGE_1="yes"
BUILD_GCC_STAGE_2="no"
BUILD_NEWLIB="no"
CPU="m68000"
PREFIX="m68k-elf-"
# Check if user is root
if [ ${EUID} == 0 ]; then
echo "Please don't run this script as root!"
exit
fi
# Check all args
i=1
for arg do
if [[ "$arg" == "--with-newlib" ]]; then
${BUILD_NEWLIB}="yes"
${BUILD_GCC_STAGE_2}="yes"
export WITH_NEWLIB="--with-newlib"
elif [[ "$arg" == "--with-cpu=" ]]; then
${CPU} = ${i}
elif [[ "$arg" == "--program-prefix=" ]]; then
${PREFIX} = ${i}
fi
i=$((i + 1))
done
# Export
export ARCH=$(uname -m)
export TARGET="m68k-elf"
export BUILD_MACH="${ARCH}-pc-linux-gnu"
export HOST_MACH="${ARCH}-pc-linux-gnu"
export NUM_PROC=$(nproc)
export PROGRAM_PREFIX=${PREFIX}
export INSTALL_DIR="${PWD}/m68k-toolchain"
export DOWNLOAD_DIR="${PWD}/download"
export ROOT_DIR="${PWD}"
export BUILD_DIR="${ROOT_DIR}/build"
export SRC_DIR="${ROOT_DIR}/source"
export WITH_CPU=${CPU}
# Create main folders in the root dir
mkdir -p ${INSTALL_DIR}
mkdir -p ${BUILD_DIR}
mkdir -p ${SRC_DIR}
mkdir -p ${DOWNLOAD_DIR}
export PATH=$INSTALL_DIR/bin:$PATH
# Build binutils
if [ ${BUILD_BINUTILS} == "yes" ]; then
./build-binutils.sh
if [ $? -ne 0 ]; then
"Failed to build binutils, please check build.log"
exit 1
fi
fi
# Build GCC stage 1
if [ ${BUILD_GCC_STAGE_1} == "yes" ]; then
./build-gcc.sh
if [ $? -ne 0 ]; then
"Failed to build gcc stage 1, please check build.log"
exit
fi
fi
# Build newlib
if [ ${BUILD_NEWLIB} == "yes" ]; then
./build-newlib.sh
if [ $? -ne 0 ]; then
"Failed to build newlib, please check build.log"
exit
else
# Build GCC stage 2 (with newlib)
if [ ${BUILD_GCC_STAGE_2} == "yes" ]; then
./build-gcc.sh
if [ $? -ne 0 ]; then
"Failed to build gcc stage 2, please check build.log"
exit
fi
fi
fi
fi
echo "m68k toolchain build was terminated"