-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcross-cc
executable file
·56 lines (49 loc) · 1.68 KB
/
cross-cc
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/sh
readonly DEFAULT_PREFIX="/usr/local"
tree="$1"
if [ "$#" -lt "1" -o -z "$tree" -o ! -e "$tree/configure" ]
then
echo "USAGE: `basename "$0"` <path to gcc source tree> [installation prefix] [configuration flag]..."
exit 1
elif [ ! -e "$tree/bfd" -o ! -e "$tree/binutils" -o ! -e "$tree/gas" -o ! -e "$tree/gnulib" -o ! -e "$tree/ld" -o ! -e "$tree/libctf" -o ! -e "$tree/libsframe" -o ! -e "$tree/opcodes" ]
then
cat 2>&1 <<-tac
ERROR: You must first symlink the following from the binutils source tree into the gcc one:
bfd/
binutils/
gas/
gnulib/
ld/
libctf/
libsframe/
opcodes/
sim/ (optional, available from the repository but not the release tarballs)
tac
exit 2
fi
shift
prefix="$DEFAULT_PREFIX"
if [ "$#" -ge "1" ]
then
prefix="$1"
shift
fi
stdlibs="$prefix/lib/gcc/riscv32-elf/`cat "$tree/gcc/BASE-VER"`"
if [ -e "$prefix/lib" ]
then
echo "NOTE: If you are planning to distribute a prebuilt toolchain, you should have cleaned out $prefix before running this script!"
sleep 5
fi
do=""
if ! mkdir -p "$stdlibs" 2>/dev/null
then
do="sudo"
sudo mkdir -p "$stdlibs"
fi
touch "$stdlibs/nosys.specs" 2>/dev/null || sudo touch "$stdlibs/nosys.specs"
cat <<-tac | $do tee "$stdlibs/nosys.specs" >/dev/null
%rename lib old_lib
*lib:
-Ttext=0 %(old_lib)
tac
exec "$tree/configure" --prefix="$prefix" --target=riscv32-elf --with-arch=rv32i --with-specs='%:if-exists-then-else(nosys.specs%s -specs=nosys.specs %:if-exists-then-else(%:getenv(PWD /nosys.specs) -specs=nosys.specs)) %:if-exists-then-else(%:getenv(PWD /libc.a) -L.) %:if-exists-then-else(%:getenv(PWD /crtbegin%O) -B.)' --program-prefix=riscv32- --disable-libssp --enable-languages=c --without-headers "$@"