2020-06-01 19:46:52 +02:00
|
|
|
#=----------------------------------------------------------------------------=#
|
|
|
|
# OS/K CROSS COMPILER BUILDER #
|
|
|
|
# #
|
|
|
|
# Desc: Project Makefile #
|
|
|
|
# #
|
|
|
|
# #
|
|
|
|
# Copyright © 2018-2020 The OS/K Team #
|
|
|
|
# #
|
|
|
|
# This file is part of OS/K. #
|
|
|
|
# #
|
|
|
|
# OS/K is free software: you can redistribute it and/or modify #
|
|
|
|
# it under the terms of the GNU General Public License as published by #
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or #
|
|
|
|
# any later version. #
|
|
|
|
# #
|
|
|
|
# OS/K is distributed in the hope that it will be useful, #
|
|
|
|
# but WITHOUT ANY WARRANTY# without even the implied warranty of #
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
|
|
# GNU General Public License for more details. #
|
|
|
|
# #
|
|
|
|
# You should have received a copy of the GNU General Public License #
|
|
|
|
# along with OS/K. If not, see <https://www.gnu.org/licenses/>. #
|
|
|
|
#=----------------------------------------------------------------------------=#
|
|
|
|
|
2020-06-01 20:49:17 +02:00
|
|
|
.PHONY: retrieve compile showenv deflate configurebinutils binutils gcc clean
|
|
|
|
.DEFAULT_GOAL := gcc
|
2020-06-01 19:46:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
## VERSIONS ------------------------------------------------------------------ #
|
|
|
|
|
2020-06-01 20:49:17 +02:00
|
|
|
|
|
|
|
GCC_NAME = gcc-10.1.0
|
|
|
|
BINUTILS_NAME =binutils-2.34
|
2020-06-01 19:46:52 +02:00
|
|
|
# GCC 10.1.0
|
2020-06-01 20:49:17 +02:00
|
|
|
GCC_SOURCES = https://ftp.gnu.org/gnu/gcc/$(GCC_NAME)/$(GCC_NAME).tar.xz
|
2020-06-01 19:46:52 +02:00
|
|
|
# BINUTILS 2.34
|
2020-06-01 20:49:17 +02:00
|
|
|
BINUTILS_SOURCES = https://ftp.gnu.org/gnu/binutils/$(BINUTILS_NAME).tar.xz
|
2020-06-01 19:46:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
## VARIABLES ----------------------------------------------------------------- #
|
|
|
|
|
|
|
|
#ENV
|
2020-06-01 20:49:17 +02:00
|
|
|
export NTHREADS := $(shell nproc)
|
2020-06-01 21:13:01 +02:00
|
|
|
export PREFIX := $(shell pwd)/cross-cc
|
2020-06-01 19:46:52 +02:00
|
|
|
export TARGET := x86_64-elf
|
|
|
|
export PATH := $(PREFIX)/bin:$(PATH)
|
|
|
|
export XZ_DEFAULTS := -T $(NTHREADS)
|
|
|
|
|
|
|
|
|
|
|
|
GCCTARNAME = gcc.tar.xz
|
|
|
|
BINUTILSTARNAME = binutils.tar.xz
|
|
|
|
GCCDIRNAME = gcc-src
|
|
|
|
BINUTILSDIRNAME = binutils-src
|
|
|
|
|
|
|
|
# Color codes
|
|
|
|
CL='\033[0;32m'
|
|
|
|
CL2='\033[1;36m'
|
|
|
|
CL3='\033[0m'
|
|
|
|
NC='\033[1;37m'
|
|
|
|
|
|
|
|
|
|
|
|
## RECIPES ------------------------------------------------------------------- #
|
|
|
|
|
|
|
|
showenv:
|
|
|
|
@echo Installation path prefix : $(PREFIX)
|
|
|
|
@echo Installation path : $(PATH)
|
|
|
|
@echo Target : $(TARGET)
|
|
|
|
@echo Thread number : $(NTHREADS)
|
|
|
|
|
|
|
|
retrieve: showenv
|
|
|
|
@echo ${CL2}[$@] ${NC}Downloading GCC sources...${CL3}
|
|
|
|
@wget $(GCC_SOURCES) -O $(GCCTARNAME) -q -c --show-progress
|
|
|
|
@echo ${CL2}[$@] ${NC}Downloading BINUTILS sources...${CL3}
|
|
|
|
@wget $(BINUTILS_SOURCES) -O $(BINUTILSTARNAME) -q -c --show-progress
|
|
|
|
@echo ${CL2}[$@] ${CL}Success.${CL3}
|
|
|
|
|
|
|
|
deflate:
|
|
|
|
@echo ${CL2}[$@] ${NC}Deflate GCC sources...${CL3}
|
2020-06-01 20:49:17 +02:00
|
|
|
@tar -xaf $(GCCTARNAME) --skip-old-files
|
|
|
|
@echo ${CL2}[$@] ${NC}Deflate $(BINUTILS_NAME) sources...${CL3}
|
|
|
|
@tar -xaf $(BINUTILSTARNAME) --skip-old-files
|
|
|
|
@echo ${CL2}[$@] ${CL}Success.${CL3}
|
|
|
|
|
|
|
|
configurebinutils: retrieve deflate
|
|
|
|
@echo ${CL2}[$@] ${NC}Configuring $(BINUTILS_NAME)...${CL3}
|
|
|
|
@mkdir -p build-binutils
|
|
|
|
cd build-binutils && ../$(BINUTILS_NAME)/configure --target=$(TARGET) --prefix="$(PREFIX)" --with-sysroot --disable-nls --disable-werror
|
|
|
|
@echo ${CL2}[$@] ${CL}Success.${CL3}
|
|
|
|
|
|
|
|
binutils: configurebinutils
|
|
|
|
@echo ${CL2}[$@] ${NC}Compiling $(BINUTILS_NAME)...${CL3}
|
|
|
|
cd build-binutils && make -j $(NTHREADS)
|
|
|
|
@echo ${CL2}[$@] ${NC}Compiling $(BINUTILS_NAME)...${CL3}
|
2020-06-01 21:13:01 +02:00
|
|
|
@mkdir -p cross-cc
|
2020-06-01 20:49:17 +02:00
|
|
|
cd build-binutils && make install -j $(NTHREADS)
|
2020-06-01 19:46:52 +02:00
|
|
|
@echo ${CL2}[$@] ${CL}Success.${CL3}
|
|
|
|
|
2020-06-01 20:49:17 +02:00
|
|
|
configuregcc:
|
|
|
|
@echo ${CL2}[$@] ${NC}Configuring $(GCC_NAME)...${CL3}
|
|
|
|
@cp multilib.opt $(GCC_NAME)/gcc/config/i386/t-x86_64-elf
|
|
|
|
@patch $(GCC_NAME)/gcc/config.gcc < patch-red-zone.diff
|
|
|
|
@mkdir -p build-gcc
|
|
|
|
cd build-gcc && ../$(GCC_NAME)/configure --target=$(TARGET) --prefix="$(PREFIX)" --disable-nls --enable-languages=c,c++ --without-headers
|
2020-06-01 19:46:52 +02:00
|
|
|
@echo ${CL2}[$@] ${CL}Success.${CL3}
|
|
|
|
|
2020-06-01 20:49:17 +02:00
|
|
|
gcc: binutils configuregcc
|
|
|
|
@echo ${CL2}[$@] ${NC}Compiling $(GCC_NAME)...${CL3}
|
|
|
|
cd build-gcc && make all-gcc -j $(NTHREADS)
|
|
|
|
cd build-gcc && make all-target-libgcc -j $(NTHREADS)
|
2020-06-01 21:13:01 +02:00
|
|
|
@mkdir -p cross-cc
|
2020-06-01 20:49:17 +02:00
|
|
|
cd build-gcc && make install-gcc -j $(NTHREADS)
|
|
|
|
cd build-gcc && make install-target-libgcc -j $(NTHREADS)
|
|
|
|
@echo ${CL2}[$@] ${CL}Success.${CL3}
|
|
|
|
|
|
|
|
clean:
|
|
|
|
@mkdir -p build-gcc build-binutils
|
|
|
|
@cd build-gcc && rm -rf *
|
|
|
|
@cd build-binutils && rm -rf *
|
2020-06-01 21:13:01 +02:00
|
|
|
@rm -rf cross-cc
|
2020-06-01 20:49:17 +02:00
|
|
|
@echo ${CL2}[$@] ${CL}Success.${CL3}
|
|
|
|
|
|
|
|
|
2020-06-01 19:46:52 +02:00
|
|
|
remove_all:
|
|
|
|
@rm -rf gcc*
|
2020-06-01 20:49:17 +02:00
|
|
|
@rm -rf bin*
|
2020-06-01 19:46:52 +02:00
|
|
|
@echo ${CL2}[$@] ${CL}Success.${CL3}
|