-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.sh
executable file
·81 lines (72 loc) · 2.41 KB
/
build.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
#!/usr/bin/env bash
SRC="src"
BUILD="build"
INSTALL="/opt/avr-gcc" # tar.bz2 needs a prefix of 'avr-gcc'
DOWNLOAD="download"
mkdir ${SRC}
mkdir ${BUILD}
mkdir ${INSTALL}
root=$(pwd)
cores=8
VERSION_BINUTILS="2.41"
VERSION_GCC="13.2.0"
VERSION_LIBC="2.1.0"
# Get sources
wget -q "https://raw.githubusercontent.com/archlinux/svntogit-community/c3efadcb76f4d8b1a3784015e7c472f59dbfa7de/avr-binutils/repos/community-x86_64/avr-size.patch" &
wget -q "https://raw.githubusercontent.com/osx-cross/homebrew-avr/d2e2566b06b90355952ed996707a0a1a24673cd3/Patch/avr-libc-add-mcu-atmega168pb.patch" &
#wget -q "https://raw.githubusercontent.com/osx-cross/homebrew-avr/18d50ba2a168a3b90a25c96e4bc4c053df77d7dc/Patch/avr-binutils-elf-bfd-gdb-fix.patch" &
wget -qO- "https://ftp.gnu.org/gnu/binutils/binutils-${VERSION_BINUTILS}.tar.bz2" | tar xj --directory ${SRC} &
wget -qO- "https://ftp.gnu.org/gnu/gcc/gcc-${VERSION_GCC}/gcc-${VERSION_GCC}.tar.xz" | tar xJ --directory ${SRC} &
wget -qO- "https://download.savannah.gnu.org/releases/avr-libc/avr-libc-${VERSION_LIBC}.tar.bz2" | tar xj --directory ${SRC} &
wait
# Build binutils first
cd ${SRC}/binutils-${VERSION_BINUTILS}
# patch size file
patch -g 0 -f -p1 -i ../../avr-size.patch
mkdir build && cd build
# configure and make
../configure \
--target=avr \
--prefix=${INSTALL}/ \
--disable-nls \
--disable-werror
make -j${cores}
make install
# prepend path of newly compiled avr-binutils
export PATH=${INSTALL}/bin:$PATH
cd ${root}
cd ${SRC}/gcc-${VERSION_GCC}
mkdir build && cd build
../configure \
--target=avr \
--prefix=${INSTALL}/ \
--with-ld=${INSTALL}/bin/avr-ld \
--with-as=${INSTALL}/bin/avr-as \
--libdir=${INSTALL}/avr/lib \
--enable-languages=c,c++ \
--disable-nls \
--disable-libssp \
--disable-shared \
--disable-threads \
--disable-libgomp \
--with-dwarf2 \
--with-avrlibc \
#--with-system-zlib \
--disable-bootstrap
make -j${cores}
make install
# prepend path of newly compiled avr-gcc
#export PATH=${INSTALL}/bin:$PATH
cd ${root}
cd ${SRC}/avr-libc-${VERSION_LIBC}
patch -g 0 -f -p1 -i ../../avr-libc-add-mcu-atmega168pb.patch
build=`./config.guess`
./configure \
--build=${build} \
--prefix=${INSTALL} \
--host=avr
make install -j${cores}
cd ${root}
rm -r build src
rm avr-size.patch
rm avr-libc-add-mcu-atmega168pb.patch