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