clang detection in unix hints

Closes #1500 but it does apply the pull request.
Hopefully, this makes things a little clearer.
This commit is contained in:
nhmall
2026-04-20 20:47:59 -04:00
parent b5e6840bea
commit 7d377a0f02
3 changed files with 16 additions and 7 deletions

View File

@@ -14,7 +14,7 @@ CCFLAGS = -g
#If you want to force use of one particular set of compilers, do it
#here, ahead of the detection, so that the detection will match your
#choice and set variables CCISCLANG, GCCGTEQ, CLANGPPGTEQ9 etc.
#choice and set variables CCISCLANG, CCISGCC, GCCGTEQ, CLANGPPGTEQ9 etc.
#accordingly.
#
#CC= gcc
@@ -41,7 +41,7 @@ endif
# If you want to override the compiler detection just carried out
# uncomment one of the following pairs. Note, however, that
# doing this after the detection above will likely result in
# mismatched variable values for CCISCLANG, GCCGTEQ, CLANGPPGTEQ9 etc.
# mismatched variable values for CCISCLANG, CCISGCC, GCCGTEQ, CLANGPPGTEQ9 etc.
#
#CC= gcc
#CXX= g++ -std-gnu++11
@@ -72,8 +72,17 @@ CFLAGS+=-Wstrict-prototypes
CFLAGS+=-Wnonnull
#detection of clang vs gcc
CCISCLANG := $(shell echo `$(CC) --version` | grep clang)
ifeq "$(CCISCLANG)" ""
CCTEST := $(shell echo `$(CC) --version` | grep clang)
ifneq "$(CCTEST)" ""
CCISCLANG=1
CCISGCC=
else
CCISCLANG=
CCISGCC=1
endif
#$(info CCISCLANG=$(CCISCLANG), CCISGCC=$(CCISGCC))
ifeq "$(CCISGCC)" "1"
# gcc-specific follows
CXX=g++ -std=gnu++11
# get the version of gcc
@@ -95,8 +104,8 @@ CFLAGS+=-Wimplicit-fallthrough
#endif
# end of gcc-specific
else # gcc or clang?
CXX=clang++ -std=gnu++11
# clang-specific follows
CXX=clang++ -std=gnu++11
CLANGGTEQ12 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 12)
CLANGGTEQ14 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 14)
CLANGGTEQ21 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 21)

View File

@@ -415,7 +415,7 @@ endif
SYSCFLAGS=-DLUA_USE_LINUX
ifdef GITSUBMODULES
LUAFLAGS=CC='$(CC)' SYSCFLAGS='$(SYSCFLAGS)'
ifneq "$(CCISCLANG)" ""
ifeq "$(CCISCLANG)" "1"
# clang
LUAFLAGS +=CWARNGCC=''
endif # clang

View File

@@ -338,7 +338,7 @@ endif # WANT_LIBNH
# this needs to be passed via make rather than defined in unixconf.h
ifdef GITSUBMODULES
LUAFLAGS=CC='$(CC)' MYCFLAGS=' -DLUA_USE_MACOSX'
ifneq "$(CCISCLANG)" ""
ifeq "$(CCISCLANG)" "1"
# clang
LUAFLAGS +=CWARNGCC=''
endif # clang