From a294dd3cedf8753a7566a078b8310cd6e0f86e31 Mon Sep 17 00:00:00 2001 From: mintsuki Date: Wed, 22 Dec 2021 01:44:33 +0100 Subject: [PATCH] build: Improve clang detection code --- Makefile | 8 ++++---- decompressor/Makefile | 4 ++++ stage23/Makefile | 12 ++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 46b2ea79..07e0c582 100644 --- a/Makefile +++ b/Makefile @@ -32,12 +32,8 @@ ifeq ($(shell PATH='$(call SHESCAPE,$(PATH))' command -v $(TOOLCHAIN_CC) ; ), ) override TOOLCHAIN_CC := cc endif -ifeq ($(TOOLCHAIN_CC), clang) -TOOLCHAIN_CC += --target=x86_64-elf ifeq ($(TOOLCHAIN_CC), clang) override TOOLCHAIN_CC += --target=x86_64-elf -MAKEOVERRIDES += TOOLCHAIN_CC+=--target=x86_64-elf -endif endif override CC_MACHINE := $(shell PATH='$(call SHESCAPE,$(PATH))' $(TOOLCHAIN_CC) -dumpmachine | dd bs=6 count=1 2>/dev/null) @@ -54,6 +50,10 @@ endif endif endif +ifeq ($(TOOLCHAIN_CC), clang --target=x86_64-elf) +override TOOLCHAIN_CC := clang +endif + override STAGE1_FILES := $(shell find -L ./stage1 -type f -name '*.asm') .PHONY: all diff --git a/decompressor/Makefile b/decompressor/Makefile index 3ff3defd..6a18f4c9 100644 --- a/decompressor/Makefile +++ b/decompressor/Makefile @@ -30,6 +30,10 @@ ifeq ($(shell command -v $(TOOLCHAIN_OBJCOPY) ; ), ) override TOOLCHAIN_OBJCOPY := objcopy endif +ifeq ($(TOOLCHAIN_CC), clang) +override TOOLCHAIN_CC += --target=i686-elf +endif + WERROR = -Werror CFLAGS ?= -Os -pipe -Wall -Wextra $(WERROR) diff --git a/stage23/Makefile b/stage23/Makefile index 531b4108..c46e0ec1 100644 --- a/stage23/Makefile +++ b/stage23/Makefile @@ -55,6 +55,18 @@ ifeq ($(shell command -v $(TOOLCHAIN_READELF) ; ), ) override TOOLCHAIN_READELF := readelf endif +ifeq ($(TOOLCHAIN_CC), clang) +ifeq ($(TARGET), bios) +override TOOLCHAIN_CC += --target=i686-elf +endif +ifeq ($(TARGET), uefi) +override TOOLCHAIN_CC += --target=x86_64-elf +endif +ifeq ($(TARGET), uefi32) +override TOOLCHAIN_CC += --target=i686-elf +endif +endif + COM_OUTPUT = false E9_OUTPUT = false