feat: added cross compiler and moved headers to include dir
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -114,4 +114,5 @@ modules.xml
|
|||||||
*.old
|
*.old
|
||||||
**/__pycache__
|
**/__pycache__
|
||||||
*.img
|
*.img
|
||||||
later/
|
later/
|
||||||
|
compiler/
|
||||||
|
|||||||
@@ -1,12 +1,20 @@
|
|||||||
cmake_minimum_required(VERSION 3.15)
|
cmake_minimum_required(VERSION 3.15)
|
||||||
project(new_kernel C ASM)
|
project(new_kernel C ASM)
|
||||||
|
|
||||||
|
# Define compiler run time
|
||||||
|
SET(COMPILER_RT ${CMAKE_CURRENT_LIST_DIR}/compiler/target/bin)
|
||||||
|
SET(CMAKE_C_COMPILER ${COMPILER_RT}/i686-elf-gcc)
|
||||||
|
SET(CMAKE_ASM_COMPILER ${COMPILER_RT}/i686-elf-gcc)
|
||||||
|
|
||||||
|
# Optionally enable cmake debugging
|
||||||
#SET(CMAKE_VERBOSE_MAKEFILE ON)
|
#SET(CMAKE_VERBOSE_MAKEFILE ON)
|
||||||
SET(GCC_INCLUDE_DIR "/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/include")
|
|
||||||
SET(CMAKE_C_FLAGS "-I${GCC_INCLUDE_DIR} -mno-sse -g -ffreestanding -Wall -Wextra -fno-exceptions -fno-stack-protector -nostdinc -nostdlib -fno-pie -m32")
|
# Set compile flags
|
||||||
|
SET(CMAKE_C_FLAGS "-g -ffreestanding -Wall -Wextra -fno-exceptions -fno-stack-protector -fno-pie -m32")
|
||||||
SET(CMAKE_ASM_FLAGS "${CFLAGS} -m32 -x assembler-with-cpp")
|
SET(CMAKE_ASM_FLAGS "${CFLAGS} -m32 -x assembler-with-cpp")
|
||||||
SET(CMAKE_EXE_LINKER_FLAGS "-T${CMAKE_CURRENT_LIST_DIR}/linker.ld -lgcc -ffreestanding -nostdlib -no-pie")
|
SET(CMAKE_EXE_LINKER_FLAGS "-T${CMAKE_CURRENT_LIST_DIR}/linker.ld -lgcc -ffreestanding -nostdlib -no-pie")
|
||||||
|
|
||||||
include_directories(AFTER kernel boot)
|
include_directories(AFTER include)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by rick on 23-02-21.
|
// Created by rick on 23-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "command.h"
|
#include <command.h>
|
||||||
#include "libk/kprint.h"
|
#include "libk/kprint.h"
|
||||||
#include "libk/libk.h"
|
#include "libk/libk.h"
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by rick on 12-02-21.
|
// Created by rick on 12-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "cpuidx.h"
|
#include <cpu/cpuidx.h>
|
||||||
|
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
#include <cpuid.h>
|
#include <cpuid.h>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by rick on 8/18/19.
|
// Created by rick on 8/18/19.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "idt.h"
|
#include <cpu/idt.h>
|
||||||
|
|
||||||
idt_gate_t idt[IDT_REGISTERS];
|
idt_gate_t idt[IDT_REGISTERS];
|
||||||
idt_register_t idt_reg;
|
idt_register_t idt_reg;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by rick on 8/18/19.
|
// Created by rick on 8/18/19.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "isr.h"
|
#include <cpu/isr.h>
|
||||||
|
|
||||||
#include <debug/debug.h>
|
#include <debug/debug.h>
|
||||||
#include <cpu/idt.h>
|
#include <cpu/idt.h>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by rick on 24-02-21.
|
// Created by rick on 24-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "syscall_handler.h"
|
#include <cpu/syscall_handler.h>
|
||||||
#include <libk/syscall.h>
|
#include <libk/syscall.h>
|
||||||
#include <tasks/task.h>
|
#include <tasks/task.h>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by rick on 9/22/19.
|
// Created by rick on 9/22/19.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "timer.h"
|
#include <cpu/timer.h>
|
||||||
|
|
||||||
#include <drivers/ports.h>
|
#include <drivers/ports.h>
|
||||||
#include <cpu/isr.h>
|
#include <cpu/isr.h>
|
||||||
@@ -63,8 +63,8 @@ int init_timer(uint32_t freq) {
|
|||||||
register_interrupt_handler(IRQ0, timer_callback);
|
register_interrupt_handler(IRQ0, timer_callback);
|
||||||
|
|
||||||
uint32_t divisor = 1193180 / freq;
|
uint32_t divisor = 1193180 / freq;
|
||||||
uint8_t low = (uint8_t) (divisor & 0xFF);
|
uint8_t low = (uint8_t)(divisor & 0xFF);
|
||||||
uint8_t high = (uint8_t) ((divisor >> 8) & 0xFF);
|
uint8_t high = (uint8_t)((divisor >> 8) & 0xFF);
|
||||||
port_byte_out(PORT_PIT_COMMAND,
|
port_byte_out(PORT_PIT_COMMAND,
|
||||||
PIT_MODE_BIN | PIT_MODE_HARDWARE_SQUARE_WAVE_GENERATOR | PIT_ACCESS_MODE_LH | PIT_CHANNEL_0);
|
PIT_MODE_BIN | PIT_MODE_HARDWARE_SQUARE_WAVE_GENERATOR | PIT_ACCESS_MODE_LH | PIT_CHANNEL_0);
|
||||||
port_byte_out(PORT_PIT_DATA_0, low);
|
port_byte_out(PORT_PIT_DATA_0, low);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by rick on 08-03-21.
|
// Created by rick on 08-03-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "debug.h"
|
#include <debug/debug.h>
|
||||||
#include <elf.h>
|
#include <elf.h>
|
||||||
#include <libk/libk.h>
|
#include <libk/libk.h>
|
||||||
#include <libc/libc.h>
|
#include <libc/libc.h>
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
//
|
//
|
||||||
// https://wiki.osdev.org/PCI_IDE_Controller
|
// https://wiki.osdev.org/PCI_IDE_Controller
|
||||||
|
|
||||||
#include "ide.h"
|
#include <drivers/ide.h>
|
||||||
#include <debug/debug.h>
|
#include <debug/debug.h>
|
||||||
#include "ports.h"
|
#include <drivers/ports.h>
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
#include <libk/kprint.h>
|
#include <libk/kprint.h>
|
||||||
#include <drivers/pci.h>
|
#include <drivers/pci.h>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// Created by rick on 23-03-20.
|
// Created by rick on 23-03-20.
|
||||||
//
|
//
|
||||||
#include "keyboard.h"
|
#include <drivers/keyboard.h>
|
||||||
|
|
||||||
#include <drivers/ports.h>
|
#include <drivers/ports.h>
|
||||||
#include <cpu/isr.h>
|
#include <cpu/isr.h>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
// https://wiki.osdev.org/PCI
|
// https://wiki.osdev.org/PCI
|
||||||
|
|
||||||
#include "pci.h"
|
#include <drivers/pci.h>
|
||||||
|
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
#include <drivers/ports.h>
|
#include <drivers/ports.h>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "ports.h"
|
#include <drivers/ports.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read a byte from the specified port
|
* Read a byte from the specified port
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by rick on 28-01-21.
|
// Created by rick on 28-01-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "serial.h"
|
#include <drivers/serial.h>
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
#include <drivers/ports.h>
|
#include <drivers/ports.h>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by rick on 8/18/19.
|
// Created by rick on 8/18/19.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "vgascreen.h"
|
#include <drivers/vgascreen.h>
|
||||||
|
|
||||||
#include <libc/libc.h>
|
#include <libc/libc.h>
|
||||||
#include <drivers/ports.h>
|
#include <drivers/ports.h>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <tasks/task.h>
|
#include <tasks/task.h>
|
||||||
#include <tasks/locking.h>
|
#include <tasks/locking.h>
|
||||||
#include <attributes.h>
|
#include <attributes.h>
|
||||||
#include "blockdev.h"
|
#include <fs/blockdev.h>
|
||||||
|
|
||||||
#define MAX_BLOCK_DEVS 64
|
#define MAX_BLOCK_DEVS 64
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
// Created by rick on 07-02-21.
|
// Created by rick on 07-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "fat.h"
|
#include <fs/fat.h>
|
||||||
#include "blockdev.h"
|
#include <fs/blockdev.h>
|
||||||
|
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
#include <libc/libc.h>
|
#include <libc/libc.h>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by rick on 06-02-21.
|
// Created by rick on 06-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "mbr.h"
|
#include <fs/mbr.h>
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
#include <drivers/ide.h>
|
#include <drivers/ide.h>
|
||||||
#include <libc/kprintf.h>
|
#include <libc/kprintf.h>
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
// Created by rick on 06-02-21.
|
// Created by rick on 06-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "kprintf.h"
|
#include <libc/kprintf.h>
|
||||||
#include "libc.h"
|
#include <libc/libc.h>
|
||||||
#include <libc/string.h>
|
#include <libc/string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <libk/kprint.h>
|
#include <libk/kprint.h>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
#include "libc.h"
|
#include <libc/libc.h>
|
||||||
|
|
||||||
int memcpy(uint8_t *dst, const uint8_t *src, int amount) {
|
int memcpy(uint8_t *dst, const uint8_t *src, int amount) {
|
||||||
for (int i = 0; i < amount; i++) {
|
for (int i = 0; i < amount; i++) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by rick on 01-02-21.
|
// Created by rick on 01-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "readline.h"
|
#include <libc/readline.h>
|
||||||
#include <libc/libc.h>
|
#include <libc/libc.h>
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
#include <libk/kprint.h>
|
#include <libk/kprint.h>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by rick on 30-01-21.
|
// Created by rick on 30-01-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "ringqueue.h"
|
#include <libc/ringqueue.h>
|
||||||
#include <libc/libc.h>
|
#include <libc/libc.h>
|
||||||
#include <mem/malloc.h>
|
#include <mem/malloc.h>
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
// Created by rick on 06-03-21.
|
// Created by rick on 06-03-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "sort.h"
|
#include <libc/sort.h>
|
||||||
#include "libc.h"
|
#include <libc/libc.h>
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
|
|
||||||
// taken from https://github.com/DevSolar/pdclib/blob/master/functions/stdlib/qsort.c
|
// taken from https://github.com/DevSolar/pdclib/blob/master/functions/stdlib/qsort.c
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
// Created by rick on 01-02-21.
|
// Created by rick on 01-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "string.h"
|
#include <libc/string.h>
|
||||||
#include "stdbool.h"
|
#include <stdbool.h>
|
||||||
#include <libc/libc.h>
|
#include <libc/libc.h>
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <attributes.h>
|
#include <attributes.h>
|
||||||
#include <tasks/task.h>
|
#include <tasks/task.h>
|
||||||
#include <libc/libc.h>
|
#include <libc/libc.h>
|
||||||
#include "kprint.h"
|
#include <libk/kprint.h>
|
||||||
|
|
||||||
#define MAX_HANDLERS 8
|
#define MAX_HANDLERS 8
|
||||||
#define STREAM_SIZE (32*1024)
|
#define STREAM_SIZE (32*1024)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <libk/kprint.h>
|
#include <libk/kprint.h>
|
||||||
#include <attributes.h>
|
#include <attributes.h>
|
||||||
#include "libk.h"
|
#include <libk/libk.h>
|
||||||
|
|
||||||
bool k_addr_in_kspace(void* addr) {
|
bool k_addr_in_kspace(void* addr) {
|
||||||
return addr > kernel_start && addr < kernel_end;
|
return addr > kernel_start && addr < kernel_end;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by rick on 22-02-21.
|
// Created by rick on 22-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "syscall.h"
|
#include <libk/syscall.h>
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
#include <attributes.h>
|
#include <attributes.h>
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
#include <libc/kprintf.h>
|
#include <libc/kprintf.h>
|
||||||
#include <tasks/task.h>
|
#include <tasks/task.h>
|
||||||
#include "malloc.h"
|
#include <mem/malloc.h>
|
||||||
#include "pmm.h"
|
#include <mem/pmm.h>
|
||||||
|
|
||||||
// retrieved from https://github.com/blanham/liballoc
|
// retrieved from https://github.com/blanham/liballoc
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by rick on 22-04-20.
|
// Created by rick on 22-04-20.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "pmm.h"
|
#include <mem/pmm.h>
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
#include <mem/mem.h>
|
#include <mem/mem.h>
|
||||||
#include <libc/kprintf.h>
|
#include <libc/kprintf.h>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by rick on 21-02-21.
|
// Created by rick on 21-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "paging.h"
|
#include <mem/paging.h>
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <attributes.h>
|
#include <attributes.h>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <libc/libc.h>
|
#include <libc/libc.h>
|
||||||
#include <libk/libk.h>
|
#include <libk/libk.h>
|
||||||
#include "pmm.h"
|
#include <mem/pmm.h>
|
||||||
|
|
||||||
#define NUM_PAGING_INFOS 16
|
#define NUM_PAGING_INFOS 16
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by rick on 27-02-21.
|
// Created by rick on 27-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "locking.h"
|
#include <tasks/locking.h>
|
||||||
#include <mem/malloc.h>
|
#include <mem/malloc.h>
|
||||||
#include <tasks/task.h>
|
#include <tasks/task.h>
|
||||||
#include <libk/syscall.h>
|
#include <libk/syscall.h>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by rick on 22-02-21.
|
// Created by rick on 22-02-21.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "task.h"
|
#include <tasks/task.h>
|
||||||
#include <cpu/cpu.h>
|
#include <cpu/cpu.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <libc/libc.h>
|
#include <libc/libc.h>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <drivers/ports.h>
|
#include <drivers/ports.h>
|
||||||
#include <attributes.h>
|
#include <attributes.h>
|
||||||
#include <libk/libk.h>
|
#include <libk/libk.h>
|
||||||
#include "power.h"
|
#include <util/power.h>
|
||||||
|
|
||||||
void noreturn power_shutdown() {
|
void noreturn power_shutdown() {
|
||||||
port_word_out(PORT_ACPI, PORT_ACPI_SHUTDOWN);
|
port_word_out(PORT_ACPI, PORT_ACPI_SHUTDOWN);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <mem/malloc.h>
|
#include <mem/malloc.h>
|
||||||
#include <libc/libc.h>
|
#include <libc/libc.h>
|
||||||
#include <tasks/locking.h>
|
#include <tasks/locking.h>
|
||||||
#include "stream.h"
|
#include <util/stream.h>
|
||||||
|
|
||||||
struct stream {
|
struct stream {
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
|
|||||||
126
mkbuildenv.sh
Executable file
126
mkbuildenv.sh
Executable file
@@ -0,0 +1,126 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
COMPILER_DIR="${PWD}/compiler"
|
||||||
|
DOWNLOAD_DIR="${COMPILER_DIR}/download"
|
||||||
|
SOURCES_DIR="${COMPILER_DIR}/sources"
|
||||||
|
BUILD_DIR="${COMPILER_DIR}/build"
|
||||||
|
|
||||||
|
GCC_VER=10.2.0
|
||||||
|
GCC_TAR_FILE="gcc-${GCC_VER}.tar.xz"
|
||||||
|
GCC_TAR_URL="https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VER}/${GCC_TAR_FILE}"
|
||||||
|
GCC_SOURCE="${SOURCES_DIR}/gcc-${GCC_VER}"
|
||||||
|
GCC_BUILD="${BUILD_DIR}/gcc-${GCC_VER}"
|
||||||
|
|
||||||
|
BINUTILS_VER=2.36
|
||||||
|
BINUTILS_TAR_FILE="binutils-${BINUTILS_VER}.tar.xz"
|
||||||
|
BINUTILS_TAR_URL="https://ftp.gnu.org/gnu/binutils/${BINUTILS_TAR_FILE}"
|
||||||
|
BINUTILS_SOURCE="${SOURCES_DIR}/binutils-${BINUTILS_VER}"
|
||||||
|
BINUTILS_BUILD="${BUILD_DIR}/binutils-${BINUTILS_VER}"
|
||||||
|
|
||||||
|
TARGET_COMPILER="${COMPILER_DIR}/target"
|
||||||
|
|
||||||
|
export MAKEFLAGS="-j$(nproc)"
|
||||||
|
|
||||||
|
export PREFIX="${TARGET_COMPILER}"
|
||||||
|
export TARGET=i686-elf
|
||||||
|
export PATH="${PREFIX}/bin:${PATH}"
|
||||||
|
|
||||||
|
function log() {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
function yes_or_no() {
|
||||||
|
while true; do
|
||||||
|
read -p "$* [y/n]: " yn
|
||||||
|
case $yn in
|
||||||
|
[Yy]*) return 0 ;;
|
||||||
|
[Nn]*)
|
||||||
|
echo "Aborted"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function download() {
|
||||||
|
if [ -f "${DOWNLOAD_DIR}/$2" ]; then
|
||||||
|
log "Not downloading $2"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
log "Downloading $2"
|
||||||
|
curl -o "${DOWNLOAD_DIR}/$2" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
function extract_source() {
|
||||||
|
if [ -d "$1" ]; then
|
||||||
|
log "already extracted $2, skipping"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
log "Extracting $2"
|
||||||
|
tar -C "${SOURCES_DIR}" -xf "${DOWNLOAD_DIR}/$2"
|
||||||
|
}
|
||||||
|
|
||||||
|
function ensure_dir() {
|
||||||
|
if [ ! -d "$1" ]; then
|
||||||
|
mkdir -p "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Verify
|
||||||
|
|
||||||
|
if [ -d "${COMPILER_DIR}" ]; then
|
||||||
|
if ! yes_or_no "Do you want to rebuild?"; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Download sources
|
||||||
|
ensure_dir "${COMPILER_DIR}"
|
||||||
|
|
||||||
|
ensure_dir "${DOWNLOAD_DIR}"
|
||||||
|
ensure_dir "${TARGET_COMPILER}"
|
||||||
|
ensure_dir "${BUILD_DIR}"
|
||||||
|
ensure_dir "${GCC_BUILD}"
|
||||||
|
ensure_dir "${BINUTILS_BUILD}"
|
||||||
|
|
||||||
|
download "${GCC_TAR_URL}" "${GCC_TAR_FILE}"
|
||||||
|
download "${BINUTILS_TAR_URL}" "${BINUTILS_TAR_FILE}"
|
||||||
|
|
||||||
|
extract_source "${GCC_SOURCE}" "${GCC_TAR_FILE}"
|
||||||
|
extract_source "${BINUTILS_SOURCE}" "${BINUTILS_TAR_FILE}"
|
||||||
|
|
||||||
|
# Build
|
||||||
|
function build_binutils() {
|
||||||
|
pushd . || return 1
|
||||||
|
cd "${BINUTILS_BUILD}" || return 1
|
||||||
|
"${BINUTILS_SOURCE}/configure" --target=${TARGET} --prefix=${PREFIX} --with-sysroot --disable-nls --disable-werror || return 1
|
||||||
|
make || return 1
|
||||||
|
make install || return 1
|
||||||
|
popd || return 1
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_gcc() {
|
||||||
|
if ! which -- "${TARGET}-as"; then
|
||||||
|
log "Could not find ${TARGET}-as!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
pushd . || return 1
|
||||||
|
cd "${GCC_BUILD}" || return 1
|
||||||
|
"${GCC_SOURCE}/configure" --target=${TARGET} --prefix=${PREFIX} --disable-nls --enable-languages=c --without-headers || return 1
|
||||||
|
make all-gcc || return 1
|
||||||
|
make all-target-libgcc || return 1
|
||||||
|
make install-gcc || return 1
|
||||||
|
make install-target-libgcc || return 1
|
||||||
|
popd || return 1
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if ! build_binutils; then
|
||||||
|
log "Failed to build binutils!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! build_gcc; then
|
||||||
|
log "Failed to build binutils!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user