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

132 lines
5.3 KiB
Makefile
Raw Normal View History

#=----------------------------------------------------------------------------=#
# 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 22:12:55 +02:00
.PHONY: retrieve compile showenv deflate clean cross-cc
.DEFAULT_GOAL := cross-cc
## VERSIONS ------------------------------------------------------------------ #
2020-06-01 20:49:17 +02:00
2020-06-27 00:52:25 +02:00
GCC_NAME =gcc-10.1.0
2020-06-01 20:49:17 +02:00
BINUTILS_NAME =binutils-2.34
# 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
# BINUTILS 2.34
2020-06-01 20:49:17 +02:00
BINUTILS_SOURCES = https://ftp.gnu.org/gnu/binutils/$(BINUTILS_NAME).tar.xz
## 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
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)
2020-06-01 22:12:55 +02:00
$(GCCTARNAME):
@echo ${CL2}[$@] ${NC}Downloading GCC sources...${CL3}
@wget $(GCC_SOURCES) -O $(GCCTARNAME) -q -c --show-progress
2020-06-01 22:12:55 +02:00
@echo ${CL2}[$@] ${CL}Success.${CL3}
$(BINUTILSTARNAME):
@echo ${CL2}[$@] ${NC}Downloading BINUTILS sources...${CL3}
@wget $(BINUTILS_SOURCES) -O $(BINUTILSTARNAME) -q -c --show-progress
2020-06-27 00:52:25 +02:00
@echo ${CL2}[$@] ${CL}Success.${CL3}
2020-06-01 22:12:55 +02:00
2020-06-27 00:52:25 +02:00
./build-binutils: $(BINUTILSTARNAME)
2020-06-01 20:49:17 +02:00
@echo ${CL2}[$@] ${NC}Deflate $(BINUTILS_NAME) sources...${CL3}
@tar -xaf $(BINUTILSTARNAME) --skip-old-files
@echo ${CL2}[$@] ${CL}Success.${CL3}
@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}
2020-06-27 00:52:25 +02:00
$(PREFIX)/bin/x86_64-elf-objcopy: ./build-binutils
2020-06-01 20:49:17 +02:00
@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)
@echo ${CL2}[$@] ${CL}Success.${CL3}
2020-06-27 00:52:25 +02:00
./build-gcc: $(GCCTARNAME)
@echo ${CL2}[$@] ${NC}Deflate $(GCC_NAME) sources...${CL3}
@tar -xaf $(GCCTARNAME) --skip-old-files
@echo ${CL2}[$@] ${CL}Success.${CL3}
2020-06-01 20:49:17 +02:00
@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}
2020-06-27 00:52:25 +02:00
$(PREFIX)/bin/x86_64-elf-gcc: $(PREFIX)/bin/x86_64-elf-objcopy ./build-gcc
2020-06-01 20:49:17 +02:00
@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}The cross compiler has been successfully compiled.${CL3}
@echo It is located in the cross-cc subdirectory.
2020-06-01 20:49:17 +02:00
clean:
2020-06-27 00:58:33 +02:00
cd build-gcc && make clean
cd build-binutils && make clean
2020-06-27 00:52:25 +02:00
@rm -rf cross-cc
-@rm -rf $(GCC_NAME)/gcc/config/i386/t-x86_64-elf
-@echo ${CL2}[$@] ${CL}Success.${CL3}
2020-06-01 20:49:17 +02:00
remove_all:
2020-06-27 00:52:25 +02:00
@rm -rf *gcc*
@rm -rf *bin*
@echo ${CL2}[$@] ${CL}Success.${CL3}
2020-06-01 22:12:55 +02:00
cross-cc: $(PREFIX)/bin/x86_64-elf-gcc