summaryrefslogtreecommitdiff
path: root/setup.sh
blob: bb20c18f63725993e5fa521ae7dfab8f8a90cfb6 (plain) (blame)
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
#!/bin/sh

LIMINE_TAG=v7.5.1
MINTSUKI_HEADERS_COMMIT=dd3abd2d7147efc4170dff478d3b7730bed14147
BINUTILS_TAG=binutils-2_42
GCC_TAG=releases/gcc-14.1.0

PROJECT_ROOT="$(pwd)"

if [ -e .setup-complete ]; then
  echo setup has already completed. refusing to run again.
  echo to run again anyway, delete .setup-complete
  echo to clean the dependencies, run clean-dependencies.sh
  exit 1
fi

if [ -e .setup-started ]; then
  echo setup has already been started, but failed. refusing to run again.
  echo to run again anyway, delete .setup-started
  echo to clean the dependencies, run clean-dependencies.sh
  exit 1
fi

if [ -z "$MAKEOPTS" ]; then
  MAKEOPTS=-j$(nproc)
fi

touch .setup-started

set -e

mkdir -p dependencies toolchain/usr
cd dependencies

git clone --depth 1 -b "$LIMINE_TAG" https://github.com/limine-bootloader/limine limine
cd limine
./bootstrap
./configure --enable-bios --enable-bios-cd
make $MAKEOPTS
cd ..

git clone --depth 1 https://github.com/osdev0/freestanding-headers mintsuki-headers
cd mintsuki-headers
git fetch --depth=1 origin "$MINTSUKI_HEADERS_COMMIT"
git checkout "$MINTSUKI_HEADERS_COMMIT"
patch stddef.h "$PROJECT_ROOT"/patches/mintsuki-stddef.patch
cd ..

git clone --depth 1 -b "$BINUTILS_TAG" https://sourceware.org/git/binutils-gdb binutils
mkdir binutils/build
cd binutils/build
../configure --disable-gdb --target=x86_64-elf --prefix="$PROJECT_ROOT"/toolchain/usr
make $MAKEOPTS
make $MAKEOPTS install
cd ../..

git clone --depth 1 -b "$GCC_TAG" https://gcc.gnu.org/git/gcc gcc
mkdir gcc/build
cd gcc/build
../configure --disable-fixed-point --disable-gcov --disable-multilib \
  --disable-shared --disable-hosted-libstdcxx --enable-languages=c++ \
  --target=x86_64-elf --enable-cstdio=stdio_pure \
  --prefix="$PROJECT_ROOT"/toolchain/usr --without-headers \
  --enable-cxx-flags=-mno-sse
make $MAKEOPTS all-gcc
make $MAKEOPTS install-gcc
make $MAKEOPTS all-target-libgcc
make $MAKEOPTS install-target-libgcc
make $MAKEOPTS all-target-libstdc++-v3
make $MAKEOPTS install-target-libstdc++-v3
patch "$PROJECT_ROOT"/toolchain/usr/x86_64-elf/include/c++/14.1.0/memory \
      "$PROJECT_ROOT"/patches/gcc-memory.patch
cd ../..

cd ..
touch .setup-complete