2021-08-03 09:28:15 +02:00
|
|
|
# $NetBSD: clang.mk,v 1.27 2021/08/03 07:28:15 nia Exp $
|
2010-09-24 00:26:06 +02:00
|
|
|
#
|
|
|
|
# This is the compiler definition for the clang compiler.
|
|
|
|
#
|
|
|
|
# User-settable variables:
|
|
|
|
#
|
|
|
|
# CLANGBASE
|
|
|
|
# The base directory where the compiler is installed.
|
|
|
|
#
|
|
|
|
|
|
|
|
.if !defined(COMPILER_CLANG_MK)
|
|
|
|
COMPILER_CLANG_MK= defined
|
|
|
|
|
|
|
|
# Add the dependency on clang
|
|
|
|
# TODO: may be installed already, check for this
|
2013-05-10 01:37:25 +02:00
|
|
|
#TOOL_DEPENDS+= clang-[0-9]*:../../lang/clang
|
2010-09-24 00:26:06 +02:00
|
|
|
|
|
|
|
.include "../../mk/bsd.prefs.mk"
|
|
|
|
|
2010-11-03 19:05:05 +01:00
|
|
|
CLANGBASE?= ${LOCALBASE}
|
2010-09-24 00:26:06 +02:00
|
|
|
LANGUAGES.clang= # empty
|
|
|
|
|
|
|
|
.if exists(${CLANGBASE}/bin/clang)
|
2010-11-03 19:05:05 +01:00
|
|
|
LANGUAGES.clang+= c objc
|
|
|
|
_COMPILER_STRIP_VARS+= CC
|
|
|
|
CCPATH= ${CLANGBASE}/bin/clang
|
|
|
|
PKG_CC:= ${CCPATH}
|
2010-09-24 00:26:06 +02:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if exists(${CLANGBASE}/bin/clang++)
|
2010-10-21 15:55:13 +02:00
|
|
|
LANGUAGES.clang+= c++
|
2010-11-03 19:05:05 +01:00
|
|
|
_COMPILER_STRIP_VARS+= CXX
|
|
|
|
CXXPATH= ${CLANGBASE}/bin/clang++
|
|
|
|
PKG_CXX:= ${CXXPATH}
|
2010-09-24 00:26:06 +02:00
|
|
|
.endif
|
|
|
|
|
2011-07-19 16:02:47 +02:00
|
|
|
.if exists(${CLANGBASE}/bin/clang-cpp)
|
|
|
|
CPPPATH= ${CLANGBASE}/bin/clang-cpp
|
|
|
|
PKG_CPP:= ${CPPPATH}
|
|
|
|
.endif
|
|
|
|
|
2010-09-24 00:26:06 +02:00
|
|
|
.if exists(${CCPATH})
|
|
|
|
CC_VERSION_STRING!= ${CCPATH} -v 2>&1
|
2013-07-31 08:37:27 +02:00
|
|
|
CC_VERSION!= ${CCPATH} --version 2>&1 | ${SED} -n "s/^.* version /clang-/p"
|
2010-09-24 00:26:06 +02:00
|
|
|
.else
|
|
|
|
CC_VERSION_STRING?= ${CC_VERSION}
|
|
|
|
CC_VERSION?= clang
|
|
|
|
.endif
|
|
|
|
|
2010-12-26 09:12:30 +01:00
|
|
|
_COMPILER_ABI_FLAG.32= -m32
|
|
|
|
_COMPILER_ABI_FLAG.64= -m64
|
2010-11-03 19:05:05 +01:00
|
|
|
_COMPILER_LD_FLAG= -Wl,
|
2013-05-22 14:13:35 +02:00
|
|
|
_LINKER_RPATH_FLAG= -R
|
2013-05-29 15:19:02 +02:00
|
|
|
_COMPILER_RPATH_FLAG= ${_COMPILER_LD_FLAG}${_LINKER_RPATH_FLAG}
|
2010-11-03 19:05:05 +01:00
|
|
|
|
2018-11-12 15:22:58 +01:00
|
|
|
_CTF_CFLAGS= -gdwarf-2
|
|
|
|
|
2019-01-09 14:19:03 +01:00
|
|
|
# The user can choose the level of RELRO.
|
|
|
|
.if ${PKGSRC_USE_RELRO} == "partial"
|
|
|
|
_RELRO_LDFLAGS= -Wl,-z,relro
|
|
|
|
.else
|
|
|
|
_RELRO_LDFLAGS= -Wl,-z,relro -Wl,-z,now
|
|
|
|
.endif
|
|
|
|
|
2017-05-18 03:29:55 +02:00
|
|
|
# The user can choose the level of stack smashing protection.
|
|
|
|
.if ${PKGSRC_USE_SSP} == "all"
|
|
|
|
_SSP_CFLAGS= -fstack-protector-all
|
2021-08-03 09:28:15 +02:00
|
|
|
.elif ${PKGSRC_USE_SSP} == "strong"
|
|
|
|
_SSP_CFLAGS= -fstack-protector-strong
|
2017-05-18 03:29:55 +02:00
|
|
|
.else
|
|
|
|
_SSP_CFLAGS= -fstack-protector
|
|
|
|
.endif
|
|
|
|
|
2019-01-09 14:19:03 +01:00
|
|
|
.if ${_PKGSRC_USE_RELRO} == "yes"
|
|
|
|
_CLANG_LDFLAGS+= ${_RELRO_LDFLAGS}
|
|
|
|
CWRAPPERS_APPEND.ld+= ${_RELRO_LDFLAGS}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
LDFLAGS+= ${_CLANG_LDFLAGS}
|
|
|
|
|
2010-09-24 00:26:06 +02:00
|
|
|
# _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the
|
|
|
|
# ones requested by the package in USE_LANGUAGES.
|
|
|
|
#
|
|
|
|
_LANGUAGES.clang= # empty
|
|
|
|
.for _lang_ in ${USE_LANGUAGES}
|
|
|
|
_LANGUAGES.clang+= ${LANGUAGES.clang:M${_lang_}}
|
|
|
|
.endfor
|
|
|
|
|
2020-03-14 11:00:37 +01:00
|
|
|
PKGSRC_FORTRAN?=gfortran
|
2011-07-19 16:02:47 +02:00
|
|
|
|
2013-05-09 16:01:08 +02:00
|
|
|
.if !empty(PKGSRC_FORTRAN) && (!empty(USE_LANGUAGES:Mfortran) || !empty(USE_LANGUAGES:Mfortran77))
|
2010-12-26 15:09:01 +01:00
|
|
|
. include "../../mk/compiler/${PKGSRC_FORTRAN}.mk"
|
2010-12-26 10:46:24 +01:00
|
|
|
.endif
|
|
|
|
|
2020-04-17 15:35:36 +02:00
|
|
|
_WRAP_EXTRA_ARGS.CC+= -Qunused-arguments -fcommon
|
2020-04-17 15:36:26 +02:00
|
|
|
CWRAPPERS_APPEND.cc+= -Qunused-arguments
|
|
|
|
CWRAPPERS_PREPEND.cc+= -Qunused-arguments -fcommon
|
2011-07-19 16:02:47 +02:00
|
|
|
_WRAP_EXTRA_ARGS.CXX+= -Qunused-arguments
|
2014-12-03 15:05:25 +01:00
|
|
|
CWRAPPERS_APPEND.cxx+= -Qunused-arguments
|
2011-07-19 16:02:47 +02:00
|
|
|
|
2020-09-21 15:09:21 +02:00
|
|
|
# Xcode 12 has a zealous new default. Turn it off until we're ready,
|
|
|
|
# while allowing callers (or users, via CFLAGS/CPPFLAGS) to override.
|
|
|
|
.if ${OPSYS} == "Darwin"
|
|
|
|
_NOERROR_IMPLICIT_cmd= ${CCPATH} -\#\#\# -E -x c /dev/null 2>&1 \
|
|
|
|
| ${GREP} -q Werror=implicit-function-declaration \
|
|
|
|
&& ${ECHO} -Wno-error=implicit-function-declaration \
|
|
|
|
|| ${TRUE}
|
|
|
|
CWRAPPERS_PREPEND.cc+= ${_NOERROR_IMPLICIT_cmd:sh}
|
|
|
|
.endif
|
|
|
|
|
2019-07-15 18:06:19 +02:00
|
|
|
.for _version_ in ${_CXX_STD_VERSIONS}
|
|
|
|
_CXX_STD_FLAG.${_version_}?= -std=${_version_}
|
|
|
|
.endfor
|
|
|
|
|
2010-09-24 00:26:06 +02:00
|
|
|
.endif # COMPILER_CLANG_MK
|