summaryrefslogtreecommitdiff
path: root/doc/HOWTO.OSX
blob: 90c1aedc04cb53a414014a55b1cda4ea3f04c594 (plain)
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
Followed: http://wiki.osdev.org/How_to_develop_on_Mac_OS_X


lynx ftp://ftp.gnu.org/gnu/binutils/
lynx ftp://ftp.gnu.org/gnu/gcc/
tar zxvf binutils-2.28.tar.gz 
tar zxvf gcc-6.3.0.tar.gz 
cd gcc-6.3.0
contrib/download_prerequisites 

# new MacOS (brew)
brew uninstall binutils
brew install gcc
export CC=/usr/local/bin/gcc-6
export CXX=/usr/local/bin/g++-6 
export CPP=/usr/local/bin/cpp-6 
export LD=/usr/local/bin/gcc-6 

# old MacOS (macports)
sudo port install gcc
sudo port select --set gcc mp-gcc7
export CC=/opt/local/bin/gcc
export CXX=/opt/local/bin/g++
export CPP=/opt/local/bin/cpp
export LD=/opt/local/bin/gcc
export PREFIX="$HOME/opt/cross"
export TARGET=i486-elf
export PATH="$PREFIX/bin:$PATH"
mkdir src
mv binutils-2.28* src
mv gcc-6.3.0* src
cd src/
mkdir build-binutils
cd build-binutils
../binutils-2.28/configure --target=$TARGET --prefix="$PREFIX" \
	--with-sysroot --disable-nls --disable-werror
make
make install
which -- $TARGET-as || echo $TARGET-as is not in the PATH
mkdir build-gcc
cd build-gcc
../gcc-6.3.0/configure --target=$TARGET --prefix="$PREFIX" \
	--disable-nls --enable-languages=c,c++ --without-headers
make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc

make TRUNCATE=gtruncate OBJCOPY=~/opt/cross/bin/i486-elf-objcopy \
	CC=~/opt/cross/bin/i486-elf-gcc LD=~/opt/cross/bin/i486-elf-ld \
	clean all run-qemu