diff --git a/BaseTools/Source/C/DevicePath/GNUmakefile b/BaseTools/Source/C/DevicePath/GNUmakefile index 3afc7fc050..f61b1b2f17 100644 --- a/BaseTools/Source/C/DevicePath/GNUmakefile +++ b/BaseTools/Source/C/DevicePath/GNUmakefile @@ -14,8 +14,9 @@ OBJECTS = DevicePath.o UefiDevicePathLib.o DevicePathFromText.o DevicePathUtili include $(MAKEROOT)/Makefiles/app.makefile GCCVERSION = $(shell $(CC) -dumpversion | awk -F'.' '{print $$1}') +CLANG := $(shell $(CC) --version | grep clang) ifneq ("$(GCCVERSION)", "5") -ifneq ($(CXX), llvm) +ifeq ($(CLANG),) ifneq ($(DARWIN),Darwin) # gcc 12 trips over device path handling CFLAGS += -Wno-error=stringop-overflow diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile index 0fb315a25a..bcc2791998 100644 --- a/BaseTools/Source/C/Makefiles/header.makefile +++ b/BaseTools/Source/C/Makefiles/header.makefile @@ -44,18 +44,19 @@ endif CYGWIN:=$(findstring CYGWIN, $(shell uname -s)) LINUX:=$(findstring Linux, $(shell uname -s)) DARWIN:=$(findstring Darwin, $(shell uname -s)) -ifeq ($(CXX), llvm) +CLANG:=$(shell $(CC) --version | grep clang) +ifneq ($(CLANG),) CC ?= $(CLANG_BIN)clang CXX ?= $(CLANG_BIN)clang++ AS ?= $(CLANG_BIN)clang AR ?= $(CLANG_BIN)llvm-ar LD ?= $(CLANG_BIN)llvm-ld -else -CC ?= gcc -CXX ?= g++ -AS ?= gcc -AR ?= ar -LD ?= ld +else ifeq ($(origin CC),default) +CC = gcc +CXX = g++ +AS = gcc +AR = ar +LD = ld endif LINKER ?= $(CC) ifeq ($(HOST_ARCH), IA32) @@ -91,7 +92,7 @@ ifeq ($(DARWIN),Darwin) CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror \ -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -g else -ifeq ($(CXX), llvm) +ifneq ($(CLANG),) CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fwrapv \ -fno-delete-null-pointer-checks -Wall -Werror \ -Wno-deprecated-declarations -Wno-self-assign \ @@ -103,7 +104,7 @@ CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fwrapv \ -Wno-unused-result -nostdlib -g endif endif -ifeq ($(CXX), llvm) +ifneq ($(CLANG),) LDFLAGS = CXXFLAGS = -Wno-deprecated-register -Wno-unused-result else diff --git a/BaseTools/Source/C/VfrCompile/GNUmakefile b/BaseTools/Source/C/VfrCompile/GNUmakefile index e227b10791..7d5976649d 100644 --- a/BaseTools/Source/C/VfrCompile/GNUmakefile +++ b/BaseTools/Source/C/VfrCompile/GNUmakefile @@ -16,7 +16,8 @@ TOOL_INCLUDE = -I Pccts/h #OBJECTS = VfrSyntax.o VfrServices.o DLGLexer.o EfiVfrParser.o ATokenBuffer.o DLexerBase.o AParser.o OBJECTS = AParser.o DLexerBase.o ATokenBuffer.o EfiVfrParser.o VfrLexer.o VfrSyntax.o \ VfrFormPkg.o VfrError.o VfrUtilityLib.o VfrCompiler.o -ifeq ($(CXX), llvm) +CLANG:=$(shell $(CC) --version | grep clang) +ifneq ($(CLANG),) VFR_CPPFLAGS = -Wno-deprecated-register -std=c++14 -DPCCTS_USE_NAMESPACE_STD $(CPPFLAGS) else VFR_CPPFLAGS = -DPCCTS_USE_NAMESPACE_STD $(CPPFLAGS) diff --git a/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile index 3bd9b6b1df..42b603571f 100644 --- a/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile +++ b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile @@ -164,10 +164,10 @@ PCCTS_H=../h # # UNIX (default) # -ifeq ($(CXX), llvm) +ifneq ($(CLANG),) CC?=$(CLANG_BIN)clang -else -CC?=gcc +else ifeq ($(origin CC),default) +CC=gcc endif COPT=-O ANTLR=${BIN_DIR}/antlr diff --git a/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile b/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile index 61366185c1..e45ac98e04 100644 --- a/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile +++ b/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile @@ -114,10 +114,11 @@ PCCTS_H=../h # # UNIX # -ifeq ($(CXX), llvm) -BUILD_CC?=$(CLANG_BIN)clang -else -BUILD_CC?=cc +CLANG:=$(shell $(CC) --version | grep clang) +ifneq ($(CLANG),) +CC?=$(CLANG_BIN)clang +else ifeq ($(origin CC),default) +CC=gcc endif COPT=-O ANTLR=${BIN_DIR}/antlr