aboutsummaryrefslogtreecommitdiff
path: root/lang/icc/Makefile
blob: c7567e46b3e8426d7ee7bbc1a4fa28e4b0b21bf2 (plain) (blame)
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# Created by: netchild@FreeBSD.org
# $FreeBSD$

PORTNAME=	icc
PORTVERSION=	8.1.038
PORTREVISION=	2
CATEGORIES=	lang linux devel
MASTER_SITES=	#empty
DISTNAME=	l_cc_pc_${PORTVERSION:C/p.+$//}
DISTFILES=	${DISTNAME}${EXTRACT_SUFX}

# netchild@FreeBSD.org is willing to review patches and to provide background
# infos regarding this port
MAINTAINER=	cpm@fbsd.es
COMMENT=	Intels C/C++ compiler, set up to produce native FreeBSD binaries

LICENSE=	EPL LGPL21
LICENSE_COMB=	multi

EXTRACT_DEPENDS=	rpm2cpio.pl:archivers/rpm2cpio

RESTRICTED=	Intel forbids any redistribution.

USES=		linux
USE_LINUX=	base

PATCHLEVEL=	${PORTVERSION:C/(.+p)(.+)$/pe\2/}
.if ${PORTVERSION} != ${PATCHLEVEL}
DISTFILES+=	${DISTNAME} ${PATCHLEVEL}${EXTRACT_SUFX}
USE_LINUX+=	base:patch
.endif

ONLY_FOR_ARCHS=	i386

USE_LDCONFIG=	yes

COMPILERDIR=	intel_cc_80
PLIST_SUB=	COMPILERDIR=${COMPILERDIR}
PATCH_WRKSRC=	${WRKSRC}/opt/${COMPILERDIR}

OPTIONS_DEFINE=	DOCS

DOCS=	BEA_License_Agreement.txt Disclaimer.txt flex_ug.pdf
ICC_SITE=	https://software.intel.com/en-us/intel-compilers/

SUB_FILES=	pkg-message
SUB_LIST+=	PKGNAME=${PKGNAME} \
		COMPILERDIR=${COMPILERDIR} \
		MAINTAINER=${MAINTAINER}

.include <bsd.port.pre.mk>

EXTRACT_AFTER_ARGS=	--exclude cdt-\*.zip \
			--exclude eclipse-platform\*.zip \
			--exclude intel-icc_ide\*.rpm \
			--exclude intel-iidb\*.rpm \
			--exclude intel-isubh\*.rpm \
			--exclude sdp-core-\*.zip \
			--exclude \*ia64.rpm \
			--exclude flexlm64

ICCCFGVAL_CMD=	${UNAME} -r | ${SED} -e 's/\..*//'

GCCCOMPATVER=	340
GXXINCLUDE=	/usr/include/c++/${GCCCOMPATVER:C/([0-9])([0-9]).+/\1.\2/}

.for f in ${DISTFILES}
.if !exists(${DISTDIR}/${f})
IGNORE=	go to Intel Premier Support \(https://premier.intel.com/\) to obtain ${DISTFILES}. Product updates such as this compiler are posted regularly on Premier Support. You must have a license to obtain access to Premier Support. If you do not already have a license go to ${ICC_SITE} to review licensing options \(evaluation, commercial, and free non-commercial\) and obtain a license. Put ${DISTFILES} into ${DISTDIR} and run make again
.endif
.endfor

.if exists(${LINUXBASE}/boot/kernel.h)
BROKEN=	cannot coexist with linux_devtools
.endif

post-extract:
	cd ${WRKSRC} && rpm2cpio.pl 2>/dev/null *.rpm | ${CPIO} -idu --quiet

intel-patch: extract
# Apply patches from Intel.
.if ${PORTVERSION} != ${PATCHLEVEL}
	${BRANDELF} -t Linux ${WRKSRC}_${PATCHLEVEL}/papply
	${WRKSRC}_${PATCHLEVEL}/papply ${WRKSRC}_${PATCHLEVEL}/icc.rtp \
		${WRKSRC}/opt/${COMPILERDIR}
.endif

pre-patch: intel-patch
# Remove files we do not need on FreeBSD.
	for i in `${CAT} ${FILESDIR}/exclude`; do \
		${RM} -r ${WRKSRC}/opt/${COMPILERDIR}/$$i; done
.if ! ${PORT_OPTIONS:MDOCS}
# Remove docs.
	for i in `${CAT} ${FILESDIR}/exclude_noportdocs`; do \
		${RM} -r ${WRKSRC}/opt/${COMPILERDIR}/$$i; done
.endif
# Remove unneeded/unsafe access rights.
.for i in doc include lib
	${FIND} ${WRKSRC}/opt/${COMPILERDIR}/${i} -type f -print0 | \
		${XARGS} -0 ${CHMOD} a-x,og-w
.endfor
	${FIND} ${WRKSRC}/opt -type d -print0 | ${XARGS} -0 ${CHMOD} go-w
	${CHMOD} a-x ${WRKSRC}/opt/${COMPILERDIR}/bin/Errormatch.txt

post-patch:
# Correct some paths and patch some files
.for i in icc iccvars.csh iccvars.sh icpc
	${REINPLACE_CMD} -i "" -e 's:%%ICC_LOCALBASE%%:${LOCALBASE}:g; \
		s:\<INSTALLDIR\>:${PREFIX}/${COMPILERDIR}:g; \
		s:%%GXX_INCLUDE%%:${GXXINCLUDE}:g; \
		s:man -w:manpath -q:g' ${WRKSRC}/opt/${COMPILERDIR}/bin/${i}
	${CHMOD} 755 ${WRKSRC}/opt/${COMPILERDIR}/bin/${i}
.endfor
.if ${PORTVERSION} != ${PATCHLEVEL}
	${REINPLACE_CMD} -i "" -e \
		's:\<installpackageid\>:${DISTNAME}_${PATCHLEVEL}:g' \
		${WRKSRC}/opt/${COMPILERDIR}/doc/csupport
.else
	${REINPLACE_CMD} -i "" -e 's:\<installpackageid\>:${DISTNAME}:g' \
		${WRKSRC}/opt/${COMPILERDIR}/doc/csupport
.endif
	${RM} ${WRKSRC}/opt/${COMPILERDIR}/include/*.orig
	${RM} ${WRKSRC}/opt/${COMPILERDIR}/include/c++/*.orig
.for i in icc.orig icpc.orig
	${RM} ${WRKSRC}/opt/${COMPILERDIR}/bin/${i}
.endfor
# Provide a more FreeBSD'ish compile environment
.for i in icc.cfg icpc.cfg
	${ECHO_CMD} -e "-Qlocation,ld,${PREFIX}/${COMPILERDIR}/bin/ldwrapper\n\n-wr1125\n-we140\n\n-Ulinux\n-U__linux__\n-U__linux\n-U__gnu_linux__\n\n-D__FreeBSD__=$$(${ICCCFGVAL_CMD})\n\n" >>${WRKSRC}/opt/${COMPILERDIR}/bin/${i}
	${ECHO_CMD} -e "-D__wchar_t=__ct_rune_t\n" >>${WRKSRC}/opt/${COMPILERDIR}/bin/${i}
	${ECHO_CMD} -e "-restrict\n" >>${WRKSRC}/opt/${COMPILERDIR}/bin/${i}
	${CHMOD} a-x,g-w ${WRKSRC}/opt/${COMPILERDIR}/bin/${i}
.endfor
# C++ hack for icpc
	${ECHO_CMD} -e "-gcc-version=${GCCCOMPATVER}\n-cxxlib-gcc\n" \
		>>${WRKSRC}/opt/${COMPILERDIR}/bin/icpc.cfg
	cd ${WRKSRC}/opt/${COMPILERDIR}/bin/ && ${LN} -s icc.cfg iccbin.cfg \
		&& ${LN} -s icpc.cfg icpcbin.cfg

OBJCOPY_OPS=	--redefine-sym stdin=__stdinp \
		--redefine-sym stdout=__stdoutp \
		--redefine-sym stderr=__stderrp

do-build:
# Use the Linux ABI for the binaries
.for i in codecov iccbin iccfilt icpcbin icpi mcpcom prelink profmerge \
	proforder profrun pronto_tool tselect xiar xild
	${BRANDELF} -t Linux ${WRKSRC}/opt/${COMPILERDIR}/bin/${i}
.endfor
# Fix unresolved references
	cd ${WRKSRC} && ${CC} ${CFLAGS} -c ${FILESDIR}/assert_fail.c \
		${FILESDIR}/errno_location.c ${FILESDIR}/mcount.S
.for i in libcxa.a libcxaguard.a libimf.a libirc.a libirc_s.a libsvml.a \
	libunwind.a
	${OBJCOPY} --redefine-sym __sigsetjmp=sigsetjmp \
		${OBJCOPY_OPS} \
		${WRKSRC}/opt/${COMPILERDIR}/lib/${i}
.endfor
	${AR} cr ${WRKSRC}/opt/${COMPILERDIR}/lib/libiccfbsd.a ${WRKSRC}/*.o
# Some magic to be able to link
	${MKDIR} ${WRKSRC}/opt/${COMPILERDIR}/bin/ldwrapper
	${CC} ${CFLAGS} -o \
		${WRKSRC}/opt/${COMPILERDIR}/bin/ldwrapper/ld \
		${FILESDIR}/ld.c
	${STRIP_CMD} ${WRKSRC}/opt/${COMPILERDIR}/bin/ldwrapper/ld
	${CHMOD} 755 ${WRKSRC}/opt/${COMPILERDIR}/bin/ldwrapper/ld
# Make ICC happy with regards to crtbegin.o, crtend.o and libgcc.a which it
# expects to find in GXX_ROOT.
.for f in crtbegin.o crtend.o libgcc.a
	cd ${WRKSRC}/opt/${COMPILERDIR}/lib && ${LN} -s /usr/lib/${f} ${f}
.endfor
# The static linking case expects a crtbeginT.o. Based upon inspection of
# /usr/src/contrib/gnu/crtstuff.c it seems it's the same as crtbegin.o.
	cd ${WRKSRC}/opt/${COMPILERDIR}/lib && ${LN} -s crtbegin.o crtbeginT.o

do-install:
	cd ${WRKSRC}/opt && ${FIND} . -print | \
		${CPIO} -pdu --quiet ${STAGEDIR}${PREFIX}

	${MV} ${STAGEDIR}${PREFIX}/${COMPILERDIR}/man/man1/icc.1 ${STAGEDIR}${MAN1PREFIX}/man/man1
	${RM} -r ${STAGEDIR}${PREFIX}/${COMPILERDIR}/man

.if ${PORT_OPTIONS:MDOCS}
	${MKDIR} ${STAGEDIR}${DOCSDIR}
	cd ${WRKSRC} && ${INSTALL_DATA} ${DOCS} ${STAGEDIR}${DOCSDIR}
	${MV} ${STAGEDIR}${PREFIX}/${COMPILERDIR}/doc/* ${STAGEDIR}${DOCSDIR}
	${RM} -r ${STAGEDIR}${PREFIX}/${COMPILERDIR}/doc
.else
	${MKDIR} ${STAGEDIR}${DOCSDIR}
	${MV} ${STAGEDIR}${PREFIX}/${COMPILERDIR}/doc/* ${STAGEDIR}${DOCSDIR}
	${RM} -r ${STAGEDIR}${PREFIX}/${COMPILERDIR}/doc
.endif

.include <bsd.port.post.mk>