Update lang/rust to version 1.14.0
[dports.git] / lang / rust / Makefile
1 # Created by: Jyun-Yan You <jyyou@cs.nctu.edu.tw>
2 # $FreeBSD$
3
4 PORTNAME=       rust
5 PORTVERSION?=   1.14.0
6 CATEGORIES=     lang
7 MASTER_SITES=   http://static.rust-lang.org/dist/:src \
8                 http://static.rust-lang.org/dist/:bootstrap \
9                 https://github.com/dhuseby/rust-manual-snapshots/raw/master/:bootstrap \
10                 LOCAL/marino:bootstrap
11 DISTNAME?=      ${PORTNAME}c-${PORTVERSION}
12 DISTFILES?=     ${DISTNAME}-src${EXTRACT_SUFX}:src
13 DISTFILES+=     ${RUST_BOOT}:bootstrap
14 EXTRACT_ONLY?=  ${DISTFILES:N*\:bootstrap:C/:.*//}
15
16 MAINTAINER?=    riggs@FreeBSD.org
17 COMMENT=        Language with a focus on memory safety and concurrency
18
19 LICENSE=        APACHE20 \
20                 MIT
21 LICENSE_COMB=   dual
22 # APACHE20 license is standard, see Templates/Licenses/APACHE20
23 LICENSE_FILE_MIT=       ${WRKSRC}/LICENSE-MIT
24
25 BUILD_DEPENDS=          cmake:devel/cmake
26
27 ONLY_FOR_ARCHS?=        amd64 i386
28 ONLY_FOR_ARCHS_REASON=  requires prebuilt bootstrap compiler
29
30 BROKEN_FreeBSD_9=       Only compiles on FreeBSD 10 and later
31
32 DISTINFO_FILE?= ${MASTERDIR}/distinfo.${ARCH}
33
34 # FIXME: The bootstrapped rustc adds -L/usr/local/lib in front of
35 # the LDFLAGS. When stage0's rustc is linked, it picks the installed
36 # librust*so and fails.
37 CONFLICTS_BUILD?=       rust-nightly
38 CONFLICTS_BUILD+=       ${PKGBASE}
39 CONFLICTS_INSTALL?=     rust-nightly
40
41 RUST_BOOT_VERSION?=     1.13.0
42 RUST_BOOT=              rustc-${RUST_BOOT_VERSION}-${RUST_TARGET}.tar.gz
43
44 # Rust's libraries are named librustc_${component}-${RUST_VSN_HASH}.so.
45 # The hash depends on Rust version and, if the channel is not "stable",
46 # the channel name. See $(CFG_FILENAME_EXTRA) definition in mk/main.mk.
47 RUST_VSN=       ${PORTVERSION:C/\.[0-9]{8}$//}
48 .if defined(.PARSEDIR) # fixes |make describe| on 9.x (which is BROKEN)
49 RUST_CHANNEL=   ${PKGNAMESUFFIX:Ustable:S/^-//}
50 .endif
51 RUST_VSN_HASH!= /usr/bin/printf '%s' ${RUST_VSN}${PKGNAMESUFFIX} | /sbin/md5 -q | cut -c 1-8
52 PLIST_SUB+=     RUST_VSN_HASH=${RUST_VSN_HASH}
53
54 # Rust's target arch string is different from *BSD arch strings
55 RUST_ARCH_x86_64=       x86_64 # dragonfly
56 RUST_ARCH_amd64=        x86_64
57 RUST_ARCH_i386=         i686
58 RUST_TARGET=            ${RUST_ARCH_${ARCH}}-unknown-${OPSYS:tl}
59 PLIST_SUB+=     RUST_TARGET=${RUST_TARGET}
60
61 USES=           compiler gmake libedit python:2,build
62 HAS_CONFIGURE=  yes
63 CONFIGURE_ARGS= --disable-valgrind \
64                 ${CHOSEN_COMPILER_TYPE:Mclang:C/.+/--enable-&/} \
65                 --prefix=${PREFIX}      \
66                 --musl-root=${PREFIX}   \
67                 --local-rust-root=${PREFIX} \
68                 --mandir=${MANPREFIX}/man \
69                 --release-channel=${RUST_CHANNEL}
70
71 PORTDOCS=       *
72
73 MAKE_ARGS+=     VERBOSE=1
74
75 OPTIONS_DEFINE=         DOCS GDB LLNEXTGEN PORT_LLVM
76 GDB_DESC=               Install ports gdb (necessary for debugging rust programs)
77 LLNEXTGEN_DESC=         Build with grammar verification
78
79 DOCS_CONFIGURE_ENABLE=  docs
80 GDB_RUN_DEPENDS=                ${LOCALBASE}/bin/gdb:devel/gdb
81 LLNEXTGEN_BUILD_DEPENDS=        LLnextgen:devel/llnextgen
82
83 # Rust may pass more regression tests with bundled LLVM
84 PORT_LLVM_DESC= Build against devel/llvm${LLVM_VER} instead of bundled version
85 PORT_LLVM_BUILD_DEPENDS=        ${LLVM_PREFIX}/bin/FileCheck:devel/llvm${LLVM_VER}
86 PORT_LLVM_CONFIGURE_ON=         --llvm-root=${LLVM_PREFIX}
87 LLVM_VER?=                      39
88 LLVM_PREFIX=                    ${LOCALBASE}/llvm${LLVM_VER}
89
90 # Note that make test does not work when rust is already installed
91 TEST_TARGET=    check
92 TEST_ENV+=      ALLOW_NONZERO_RLIMIT_CORE=1
93
94 pre-fetch:
95         # FIXME: This is the same check for CONFLICTS as the standard
96         # one, except port origins are not compared. This allows
97         # the port to conflict with itself, because Rust would pick
98         # installed Rust libraries instead of freshly built ones.
99         @conflicts_with=$$( \
100         { ${PKG_QUERY} -g "%n-%v %p %o" ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_BUILD:C/.+/'&'/} 2>/dev/null || : ; } \
101                 | while read pkgname prfx orgn; do \
102                 if [ "/${PREFIX}" = "/$${prfx}" ]; then \
103                         ${ECHO_CMD} -n " $${pkgname}"; \
104                 fi; \
105         done); \
106         if [ -n "$${conflicts_with}" ]; then \
107                 ${ECHO_MSG}; \
108                 ${ECHO_MSG} "===>  ${PKGNAME} conflicts with installed package(s): "; \
109                 for entry in $${conflicts_with}; do \
110                         ${ECHO_MSG} "      $${entry}"; \
111                 done; \
112                 ${ECHO_MSG}; \
113                 ${ECHO_MSG} "      They will not build together."; \
114                 ${ECHO_MSG} "      Please remove them first with pkg delete."; \
115                 exit 1;\
116         fi
117
118 post-extract:
119         @${MKDIR} ${WRKSRC}/dl
120         ${LN} -sf ${DISTDIR}/${RUST_BOOT} ${WRKSRC}/dl
121
122 post-patch:
123         @${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|' \
124                 ${WRKSRC}/mk/main.mk
125         @${REINPLACE_CMD} -e 's|gdb|${LOCALBASE}/bin/gdb|' \
126                 ${WRKSRC}/src/etc/rust-gdb
127
128 # In case the previous "make stage" failed, this ensures rust's
129 # install.sh won't backup previously staged files before reinstalling
130 # new ones. Otherwise, the staging directory is polluted with unneeded
131 # files.
132 pre-install:
133         @for f in manifest-rustc manifest-rust-std-${RUST_TARGET}; do \
134             if test -f ${STAGEDIR}${PREFIX}/lib/rustlib/$$f; then \
135                 ${SED} -E -e 's,^(dir|file:),${STAGEDIR},' \
136                 < ${STAGEDIR}${PREFIX}/lib/rustlib/$$f \
137                 | ${XARGS} ${RM}; \
138             fi; \
139         done
140         @${RM} \
141                 ${STAGEDIR}${PREFIX}/lib/rustlib/components \
142                 ${STAGEDIR}${PREFIX}/lib/rustlib/manifest-rustc \
143                 ${STAGEDIR}${PREFIX}/lib/rustlib/manifest-rust-std-${RUST_TARGET} \
144                 ${STAGEDIR}${PREFIX}/lib/rustlib/rust-installer-version \
145                 ${STAGEDIR}${PREFIX}/lib/rustlib/uninstall.sh
146
147 pre-install-DOCS-on:
148         @for f in manifest-rust-docs; do \
149             if test -f ${STAGEDIR}${PREFIX}/lib/rustlib/$$f; then \
150                 ${SED} -E -e 's,^(dir|file:),${STAGEDIR},' \
151                 < ${STAGEDIR}${PREFIX}/lib/rustlib/$$f \
152                 | ${XARGS} ${RM}; \
153             fi; \
154         done
155         @${RM} ${STAGEDIR}${PREFIX}/lib/rustlib/manifest-rust-docs
156
157 post-install:
158         @for f in manifest-rustc manifest-rust-std-${RUST_TARGET}; do \
159                 ${REINPLACE_CMD} -e 's|${STAGEDIR}||' \
160                         ${STAGEDIR}${PREFIX}/lib/rustlib/$$f; \
161                 ${RM} ${STAGEDIR}${PREFIX}/lib/rustlib/$$f.bak; \
162         done
163         @${RM} ${STAGEDIR}${PREFIX}/lib/rustlib/install.log
164 # FIXME: Static libraries in lib/rustlib/*/lib/*.rlib are not stripped,
165 # but they contain non-object files which make strip(1) unhappy.
166         @${STRIP_CMD} \
167                 ${STAGEDIR}${PREFIX}/bin/rustc \
168                 ${STAGEDIR}${PREFIX}/bin/rustdoc \
169                 ${STAGEDIR}${PREFIX}/lib/*.so \
170                 ${STAGEDIR}${PREFIX}/lib/rustlib/*/lib/*.so
171
172 post-install-DOCS-on:
173         @for f in manifest-rust-docs; do \
174                 ${REINPLACE_CMD} -e 's|${STAGEDIR}||' \
175                         ${STAGEDIR}${PREFIX}/lib/rustlib/$$f; \
176                 ${RM} ${STAGEDIR}${PREFIX}/lib/rustlib/$$f.bak; \
177         done
178         @${RMDIR} ${STAGEDIR}${PREFIX}/share/doc/rust/html/extra
179
180 .include <bsd.port.mk>