build: Improve clang detection code

This commit is contained in:
mintsuki 2021-12-22 01:44:33 +01:00
parent 364809bc5f
commit b332e85876
3 changed files with 20 additions and 4 deletions

View File

@ -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

View File

@ -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)

View File

@ -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