summaryrefslogtreecommitdiff
path: root/lang/clang/Makefile.common
blob: d87e6b3202d3704ffac891f2dfd5ae10194cb2f1 (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
# $NetBSD: Makefile.common,v 1.7 2015/07/20 05:49:53 adam Exp $
#
# used by lang/clang/Makefile
# used by lang/libLLVM/Makefile

DISTNAME=	clang-3.6.2
CATEGORIES=	lang
MASTER_SITES=	http://llvm.org/releases/${PKGVERSION_NOREV}/
DISTFILES=	llvm-${PKGVERSION_NOREV}.src.tar.xz \
		libcxx-${PKGVERSION_NOREV}.src.tar.xz \
		cfe-${PKGVERSION_NOREV}.src.tar.xz \
		compiler-rt-${PKGVERSION_NOREV}.src.tar.xz

MAINTAINER=	adam.hoka@gmail.com
HOMEPAGE=	http://llvm.org/
COMMENT=	Low Level Virtual Machine compiler infrastructure
LICENSE=	modified-bsd

WRKSRC=			${WRKDIR}/llvm-${PKGVERSION_NOREV}.src

USE_LANGUAGES=		c c++
USE_TOOLS+=		chown gmake groff gzip pod2html pod2man
GCC_REQD+=		4.7 4.8
GNU_CONFIGURE=		yes
CONFIGURE_ARGS+=	--disable-assertions
CONFIGURE_ARGS+=	--disable-bindings	# disable OCaml
CONFIGURE_ARGS+=	--disable-timestamps
CONFIGURE_ARGS+=	--enable-optimized

CHECK_PORTABILITY_SKIP=	utils/buildit/build_llvm

TEST_TARGET=		check unittests

DISTINFO_FILE=		${.CURDIR}/../../lang/clang/distinfo
PATCHDIR=		${.CURDIR}/../../lang/clang/patches

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

.if ${_OPSYS_SHLIB_TYPE} == "dylib"
PLIST_SUBST+=		SOEXT="dylib"
.else
PLIST_SUBST+=		SOEXT="so"
.endif

.include "../../mk/compiler.mk"

.if ${OPSYS} == "SunOS" && !empty(PKGSRC_COMPILER:Mgcc)
# This should probably be in hacks, but since clang hardcodes gcc paths
# put this here so it can be removed when clang matures.
# cxa_finalize.o is no longer necessary with libc.so >= ILLUMOS_0.5
TEST_ILLUMOS_3849!=\
	if /usr/bin/elfdump -v /lib/libc.so | \
		${GREP} -q 'ILLUMOS_0.5' ; then ${ECHO} 1; \
	else ${ECHO} 0; \
	fi

#doesn't seem to be needed anymore, but may be dependent on
#a recent version of solaris (illumos) ld.
#
#CFLAGS.SunOS+=		-mimpure-text

SUBST_CLASSES+=			fix-paths
SUBST_STAGE.fix-paths=		pre-configure
SUBST_MESSAGE.fix-paths=	Fixing absolute gcc paths for SunOS.
SUBST_FILES.fix-paths=		tools/clang/lib/Driver/Tools.cpp
.  if defined(_GCC_ARCHDIR)
SUBST_SED.fix-paths=		-e 's,/usr/gcc/4.5/lib/gcc/,${_GCC_ARCHDIR}/,g'
.  else
LIBGCCDIR!=	${CC} -print-libgcc-file-name
ARCHDIR:=	${LIBGCCDIR:H}
SUBST_SED.fix-paths=		-e 's,/usr/gcc/4.5/lib/gcc/,${ARCHDIR}/,g'
.  endif
SUBST_SED.fix-paths+=		-e '/^.*i386.*getVendorName.*$$/{d;}'
SUBST_SED.fix-paths+=		-e '/^.*GCCLibPath +=$$/d'
SUBST_SED.fix-paths+=		-e 's,/4.5.2/amd64/,amd64/,g'
SUBST_SED.fix-paths+=		-e 's,"as","gas",g'
.  if exists(/usr/bin/ld)
SUBST_SED.fix-paths+=		-e 's,getToolChain().GetProgramPath("ld"),"/usr/bin/ld",g'
.  else
SUBST_SED.fix-paths+=		-e 's,getToolChain().GetProgramPath("ld"),"/usr/ccs/bin/ld",g'
.  endif
.  if ${TEST_ILLUMOS_3849}
SUBST_SED.fix-paths+=		-e 's,^.*cxa_finalize.*$$,		; //cxa_finalize.o,g'
.  endif
.endif

# patch NetBSD::GetCXXStdlibType
.if ${OPSYS} == "NetBSD" && !empty(PKGSRC_COMPILER:Mgcc)
SUBST_CLASSES+=			libcxx
SUBST_STAGE.libcxx=		pre-configure
SUBST_MESSAGE.libcxx=		Patching toolchain to use libstdc++ as we're using GCC
SUBST_FILES.libcxx=		tools/clang/lib/Driver/ToolChains.cpp
SUBST_SED.libcxx=		-e 's,Major >= 7 || (Major == 6 && Minor == 99 && Micro >= 49) || Major == 0,false,'
.endif

post-extract:
	mv ${WRKDIR}/libcxx-${PKGVERSION_NOREV}.src ${WRKSRC}/projects/libcxx
	mv ${WRKDIR}/compiler-rt-${PKGVERSION_NOREV}.src ${WRKSRC}/projects/compiler-rt
	mv ${WRKDIR}/cfe-${PKGVERSION_NOREV}.src ${WRKSRC}/tools/clang
.if ${OPSYS} == "SunOS"
	${ECHO} "int sun_ld_needs_a_symbol=0;" >> ${WRKSRC}/lib/Target/NVPTX/InstPrinter/NVPTXInstPrinter.cpp
.endif

.include "../../devel/zlib/buildlink3.mk"
.include "../../lang/python/tool.mk"
.include "../../mk/bsd.pkg.mk"