1
0
mirror of https://gitlab.os-k.eu/os-k-team/cross-cc-builder.git synced 2023-08-25 14:03:10 +02:00
cross-cc-builder/Makefile

127 lines
5.0 KiB
Makefile

#=----------------------------------------------------------------------------=#
# 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/>. #
#=----------------------------------------------------------------------------=#
.PHONY: retrieve compile showenv deflate configurebinutils binutils gcc clean
.DEFAULT_GOAL := gcc
## VERSIONS ------------------------------------------------------------------ #
GCC_NAME = gcc-10.1.0
BINUTILS_NAME =binutils-2.34
# GCC 10.1.0
GCC_SOURCES = https://ftp.gnu.org/gnu/gcc/$(GCC_NAME)/$(GCC_NAME).tar.xz
# BINUTILS 2.34
BINUTILS_SOURCES = https://ftp.gnu.org/gnu/binutils/$(BINUTILS_NAME).tar.xz
## VARIABLES ----------------------------------------------------------------- #
#ENV
export NTHREADS := $(shell nproc)
export PREFIX := $(shell pwd)/bin
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}
@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}
@mkdir -p bin
cd build-binutils && make install -j $(NTHREADS)
@echo ${CL2}[$@] ${CL}Success.${CL3}
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
@echo ${CL2}[$@] ${CL}Success.${CL3}
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)
@mkdir -p bin
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 *
@rm -rf bin
@echo ${CL2}[$@] ${CL}Success.${CL3}
remove_all:
@rm -rf gcc*
@rm -rf bin*
@echo ${CL2}[$@] ${CL}Success.${CL3}