summaryrefslogtreecommitdiff
path: root/mk/compiler/icc.mk
blob: 99a6dc1adfcbca9aac7c65e2c777b2dfd23a3b25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# $NetBSD: icc.mk,v 1.8 2011/05/19 22:37:55 alnsn Exp $
#
# This is the compiler definition for the Intel compilers.
#
# User-settable variables:
#
# ICCBASE
#	The base directory where the compiler is installed.
#

.if !defined(COMPILER_ICC_MK)
COMPILER_ICC_MK=	defined

.include "../../mk/bsd.prefs.mk"

ICCBASE?=		/opt/intel_cc_80

# LANGUAGES.<compiler> is the list of supported languages by the
# compiler.
#
LANGUAGES.icc=		# empty

_ICC_DIR=		${WRKDIR}/.icc
_ICC_VARS=		# empty

.if exists(${ICCBASE}/bin/icc)
LANGUAGES.icc+=		c
_ICC_VARS+=		CC
_ICC_CC=		${_ICC_DIR}/bin/icc
_ALIASES.CC=		cc
CCPATH=			${ICCBASE}/bin/icc
PKG_CC:=		${_ICC_CC}
_ICC_VARS+=		CPP
_ICC_CPP=		${_ICC_DIR}/bin/cpp
PKG_CPP:=		${_ICC_CPP}
.endif

.if exists(${ICCBASE}/bin/icpc)
LANGUAGES.icc+=		c++
_ICC_VARS+=		CXX
_ICC_CXX=		${_ICC_DIR}/bin/icpc
_ALIASES.CXX=		CC c++
CXXPATH=		${ICCBASE}/bin/icpc
PKG_CXX:=		${_ICC_CXX}
.endif

_COMPILER_STRIP_VARS+=	${_ICC_VARS}

# icc passes rpath directives to the linker using "-Wl,-R".
_LINKER_RPATH_FLAG=	-Wl,-R

# icc passes rpath directives to the linker using "-Wl,-R".
_COMPILER_RPATH_FLAG=	-Wl,-R

.if exists(${CCPATH})
CC_VERSION_STRING!=	${CCPATH} -V 2>&1 | ${GREP} '^Intel'
_CC_VERSION!=		${CCPATH} -v 2>&1 || ${TRUE}
CC_VERSION=		Intel C++ Compiler ${_CC_VERSION}
.else
CC_VERSION_STRING?=	${CC_VERSION}
CC_VERSION?=		Intel C++ Compiler
.endif

# _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the
# ones requested by the package in USE_LANGUAGES.
#
_LANGUAGES.icc=	# empty
.for _lang_ in ${USE_LANGUAGES}
_LANGUAGES.icc+=	${LANGUAGES.icc:M${_lang_}}
.endfor

# Prepend the path to the compiler to the PATH.
.if !empty(_LANGUAGES.icc)
PREPEND_PATH+=	${_ICC_DIR}/bin
.endif

# icc supports __attribute__, but the GNU configure test uses a nested
# function, which icc does not support. #undef'ing __attribute__ has the
# unfortunate side-effect of breaking many of the Linux header files, which
# cannot be compiled properly without __attribute__. The test must be
# overridden so that __attribute__ is assumed supported by the compiler.
.if defined(GNU_CONFIGURE)
CONFIGURE_ENV+=		ac_cv___attribute__=yes
.endif

override-tools: ${_ICC_CPP}
${_ICC_CPP}:
	${RUN}${MKDIR} ${.TARGET:H}
	${RUN}						\
	(${ECHO} '#!${TOOLS_SHELL}';			\
	 ${ECHO} 'for o in "$$@"'; ${ECHO} 'do';	\
	 ${ECHO} ' case "$$o"'; ${ECHO} ' in';		\
	 ${ECHO} ' -undef) undef=1;;'; ${ECHO} ' esac';	\
	 ${ECHO} 'done';				\
	 ${ECHO} 'if [ -n "$$undef" ]'; ${ECHO} 'then';	\
	 ${ECHO} 'exec ${ICCBASE}/bin/icc -E -Uunix "$$@"';	\
	 ${ECHO} 'else';				\
	 ${ECHO} 'exec ${ICCBASE}/bin/icc -E "$$@"';	\
	 ${ECHO} 'fi'					\
	) > ${.TARGET}
	${RUN}${CHMOD} +x ${.TARGET}

# Create compiler driver scripts in ${WRKDIR}.
.for _var_ in ${_ICC_VARS}
.  if !target(${_ICC_${_var_}})
override-tools: ${_ICC_${_var_}}
${_ICC_${_var_}}:
	${RUN}${MKDIR} ${.TARGET:H}
.    if !empty(COMPILER_USE_SYMLINKS:M[Yy][Ee][Ss])
	${RUN}${RM} -f ${.TARGET}
	${RUN}${LN} -s ${ICCBASE}/bin/${.TARGET:T} ${.TARGET}
.    else
	${RUN}					\
	(${ECHO} '#!${TOOLS_SHELL}';					\
	 ${ECHO} 'exec ${ICCBASE}/bin/${.TARGET:T} "$$@"';		\
	) > ${.TARGET}
	${RUN}${CHMOD} +x ${.TARGET}
.    endif
.    for _alias_ in ${_ALIASES.${_var_}:S/^/${.TARGET:H}\//}
	${RUN}					\
	if [ ! -x "${_alias_}" ]; then					\
		${LN} -f -s ${.TARGET} ${_alias_};			\
	fi
.    endfor
.  endif
.endfor

.endif	# COMPILER_ICC_MK