1 # Created by: Jyun-Yan You <jyyou@cs.nctu.edu.tw>
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/:.*//}
16 MAINTAINER?= riggs@FreeBSD.org
17 COMMENT= Language with a focus on memory safety and concurrency
22 # APACHE20 license is standard, see Templates/Licenses/APACHE20
23 LICENSE_FILE_MIT= ${WRKSRC}/LICENSE-MIT
25 BUILD_DEPENDS= cmake:devel/cmake
27 ONLY_FOR_ARCHS?= amd64 i386
28 ONLY_FOR_ARCHS_REASON= requires prebuilt bootstrap compiler
30 DISTINFO_FILE?= ${MASTERDIR}/distinfo.${ARCH}
32 # FIXME: The bootstrapped rustc adds -L/usr/local/lib in front of
33 # the LDFLAGS. When stage0's rustc is linked, it picks the installed
34 # librust*so and fails.
35 CONFLICTS_BUILD?= rust-nightly
36 CONFLICTS_BUILD+= ${PKGBASE}
37 CONFLICTS_INSTALL?= rust-nightly
39 RUST_BOOT_VERSION?= 1.13.0
40 RUST_BOOT= rustc-${RUST_BOOT_VERSION}-${RUST_TARGET}.tar.gz
42 # Rust's libraries are named librustc_${component}-${RUST_VSN_HASH}.so.
43 # The hash depends on Rust version and, if the channel is not "stable",
44 # the channel name. See $(CFG_FILENAME_EXTRA) definition in mk/main.mk.
45 RUST_VSN= ${PORTVERSION:C/\.[0-9]{8}$//}
46 .if defined(.PARSEDIR) # fixes |make describe| on 9.x (which is BROKEN)
47 RUST_CHANNEL= ${PKGNAMESUFFIX:Ustable:S/^-//}
49 RUST_VSN_HASH!= /usr/bin/printf '%s' ${RUST_VSN}${PKGNAMESUFFIX} | /sbin/md5 -q | cut -c 1-8
50 PLIST_SUB+= RUST_VSN_HASH=${RUST_VSN_HASH}
52 # Rust's target arch string is different from *BSD arch strings
53 RUST_ARCH_x86_64= x86_64 # dragonfly
54 RUST_ARCH_amd64= x86_64
56 RUST_TARGET= ${RUST_ARCH_${ARCH}}-unknown-${OPSYS:tl}
57 PLIST_SUB+= RUST_TARGET=${RUST_TARGET}
59 USES= compiler gmake libedit python:2,build
61 CONFIGURE_ARGS= --disable-valgrind \
62 ${CHOSEN_COMPILER_TYPE:Mclang:C/.+/--enable-&/} \
64 --musl-root=${PREFIX} \
65 --local-rust-root=${PREFIX} \
66 --mandir=${MANPREFIX}/man \
67 --release-channel=${RUST_CHANNEL}
73 OPTIONS_DEFINE= DOCS GDB LLNEXTGEN PORT_LLVM
74 GDB_DESC= Install ports gdb (necessary for debugging rust programs)
75 LLNEXTGEN_DESC= Build with grammar verification
77 DOCS_CONFIGURE_ENABLE= docs
78 GDB_RUN_DEPENDS= ${LOCALBASE}/bin/gdb:devel/gdb
79 LLNEXTGEN_BUILD_DEPENDS= LLnextgen:devel/llnextgen
81 # Rust may pass more regression tests with bundled LLVM
82 PORT_LLVM_DESC= Build against devel/llvm${LLVM_VER} instead of bundled version
83 PORT_LLVM_BUILD_DEPENDS= ${LLVM_PREFIX}/bin/FileCheck:devel/llvm${LLVM_VER}
84 PORT_LLVM_CONFIGURE_ON= --llvm-root=${LLVM_PREFIX}
86 LLVM_PREFIX= ${LOCALBASE}/llvm${LLVM_VER}
88 # Note that make test does not work when rust is already installed
90 TEST_ENV+= ALLOW_NONZERO_RLIMIT_CORE=1
93 # FIXME: This is the same check for CONFLICTS as the standard
94 # one, except port origins are not compared. This allows
95 # the port to conflict with itself, because Rust would pick
96 # installed Rust libraries instead of freshly built ones.
98 { ${PKG_QUERY} -g "%n-%v %p %o" ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_BUILD:C/.+/'&'/} 2>/dev/null || : ; } \
99 | while read pkgname prfx orgn; do \
100 if [ "/${PREFIX}" = "/$${prfx}" ]; then \
101 ${ECHO_CMD} -n " $${pkgname}"; \
104 if [ -n "$${conflicts_with}" ]; then \
106 ${ECHO_MSG} "===> ${PKGNAME} conflicts with installed package(s): "; \
107 for entry in $${conflicts_with}; do \
108 ${ECHO_MSG} " $${entry}"; \
111 ${ECHO_MSG} " They will not build together."; \
112 ${ECHO_MSG} " Please remove them first with pkg delete."; \
117 @${MKDIR} ${WRKSRC}/dl
118 ${LN} -sf ${DISTDIR}/${RUST_BOOT} ${WRKSRC}/dl
121 @${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|' \
123 @${REINPLACE_CMD} -e 's|gdb|${LOCALBASE}/bin/gdb|' \
124 ${WRKSRC}/src/etc/rust-gdb
126 # In case the previous "make stage" failed, this ensures rust's
127 # install.sh won't backup previously staged files before reinstalling
128 # new ones. Otherwise, the staging directory is polluted with unneeded
131 @for f in manifest-rustc manifest-rust-std-${RUST_TARGET}; do \
132 if test -f ${STAGEDIR}${PREFIX}/lib/rustlib/$$f; then \
133 ${SED} -E -e 's,^(dir|file:),${STAGEDIR},' \
134 < ${STAGEDIR}${PREFIX}/lib/rustlib/$$f \
139 ${STAGEDIR}${PREFIX}/lib/rustlib/components \
140 ${STAGEDIR}${PREFIX}/lib/rustlib/manifest-rustc \
141 ${STAGEDIR}${PREFIX}/lib/rustlib/manifest-rust-std-${RUST_TARGET} \
142 ${STAGEDIR}${PREFIX}/lib/rustlib/rust-installer-version \
143 ${STAGEDIR}${PREFIX}/lib/rustlib/uninstall.sh
146 @for f in manifest-rust-docs; do \
147 if test -f ${STAGEDIR}${PREFIX}/lib/rustlib/$$f; then \
148 ${SED} -E -e 's,^(dir|file:),${STAGEDIR},' \
149 < ${STAGEDIR}${PREFIX}/lib/rustlib/$$f \
153 @${RM} ${STAGEDIR}${PREFIX}/lib/rustlib/manifest-rust-docs
156 @for f in manifest-rustc manifest-rust-std-${RUST_TARGET}; do \
157 ${REINPLACE_CMD} -e 's|${STAGEDIR}||' \
158 ${STAGEDIR}${PREFIX}/lib/rustlib/$$f; \
159 ${RM} ${STAGEDIR}${PREFIX}/lib/rustlib/$$f.bak; \
161 @${RM} ${STAGEDIR}${PREFIX}/lib/rustlib/install.log
162 # FIXME: Static libraries in lib/rustlib/*/lib/*.rlib are not stripped,
163 # but they contain non-object files which make strip(1) unhappy.
165 ${STAGEDIR}${PREFIX}/bin/rustc \
166 ${STAGEDIR}${PREFIX}/bin/rustdoc \
167 ${STAGEDIR}${PREFIX}/lib/*.so \
168 ${STAGEDIR}${PREFIX}/lib/rustlib/*/lib/*.so
170 post-install-DOCS-on:
171 @for f in manifest-rust-docs; do \
172 ${REINPLACE_CMD} -e 's|${STAGEDIR}||' \
173 ${STAGEDIR}${PREFIX}/lib/rustlib/$$f; \
174 ${RM} ${STAGEDIR}${PREFIX}/lib/rustlib/$$f.bak; \
176 @${RMDIR} ${STAGEDIR}${PREFIX}/share/doc/rust/html/extra
178 .include <bsd.port.mk>