1 # Created by: Jyun-Yan You <jyyou@cs.nctu.edu.tw>
8 MASTER_SITES= http://static.rust-lang.org/dist/:src \
9 http://static.rust-lang.org/stage0-snapshots/:bootstrap \
10 https://github.com/dhuseby/rust-manual-snapshots/raw/master/: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 ONLY_FOR_ARCHS?= amd64 i386
26 ONLY_FOR_ARCHS_REASON= requires prebuilt bootstrap compiler
28 BROKEN_FreeBSD_9= Only compiles on FreeBSD 10 and 11
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= rust-stage0-${RUST_BOOT_SIG_${ARCH}}.tar.bz2
41 RUST_BOOT_SIG_x86_64?= 2016-03-18-235d774-dragonfly-x86_64-e790279a7b286ddf2e716ccd3bb1b7f0a386a5c7
42 RUST_BOOT_SIG_amd64?= 2016-03-18-235d774-freebsd-x86_64-390b9a9f60f3d0d6a52c04d939a0355f572d03b3
43 RUST_BOOT_SIG_i386?= 2016-03-18-235d774-freebsd-i386-b5a87e66e3e3eed5f0b68367ad22f25f0be2d4ea
45 # Rust's libraries are named librustc_${component}-${RUST_VSN_HASH}.so.
46 # The hash depends on Rust version and, if the channel is not "stable",
47 # the channel name. See $(CFG_FILENAME_EXTRA) definition in mk/main.mk.
48 RUST_VSN= ${PORTVERSION:C/\.[0-9]{8}$//}
49 .if defined(.PARSEDIR) # fixes |make describe| on 9.x (which is BROKEN)
50 RUST_CHANNEL= ${PKGNAMESUFFIX:Ustable:S/^-//}
52 RUST_VSN_HASH!= /usr/bin/printf '%s' ${RUST_VSN}${PKGNAMESUFFIX} | /sbin/md5 -q | cut -c 1-8
53 PLIST_SUB+= RUST_VSN_HASH=${RUST_VSN_HASH}
55 # Rust's target arch string is different from *BSD arch strings
56 RUST_ARCH_x86_64= x86_64 # dragonfly
57 RUST_ARCH_amd64= x86_64
59 RUST_TARGET= ${RUST_ARCH_${ARCH}}-unknown-${OPSYS:tl}
60 PLIST_SUB+= RUST_TARGET=${RUST_TARGET}
62 USES= compiler gmake libedit python:2,build
64 CONFIGURE_ARGS= --disable-valgrind \
65 ${CHOSEN_COMPILER_TYPE:Mclang:C/.+/--enable-&/} \
66 --mandir=${MANPREFIX}/man \
67 --release-channel=${RUST_CHANNEL}
71 .if defined(BATCH) || defined(PACKAGE_BUILDING)
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
79 DOCS_CONFIGURE_ENABLE= docs
80 GDB_RUN_DEPENDS= ${LOCALBASE}/bin/gdb:devel/gdb
81 LLNEXTGEN_BUILD_DEPENDS= LLnextgen:devel/llnextgen
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?= 36 # XXX Move to DEFAULT_VERSIONS
88 LLVM_PREFIX= ${LOCALBASE}/llvm${LLVM_VER}
90 # Note that make test does not work when rust is already installed
92 TEST_ENV+= ALLOW_NONZERO_RLIMIT_CORE=1
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.
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}"; \
106 if [ -n "$${conflicts_with}" ]; then \
108 ${ECHO_MSG} "===> ${PKGNAME} conflicts with installed package(s): "; \
109 for entry in $${conflicts_with}; do \
110 ${ECHO_MSG} " $${entry}"; \
113 ${ECHO_MSG} " They will not build together."; \
114 ${ECHO_MSG} " Please remove them first with pkg delete."; \
119 @${MKDIR} ${WRKSRC}/dl
120 ${LN} -sf ${DISTDIR}/${RUST_BOOT} ${WRKSRC}/dl
121 ${FIND} ${WRKSRC} -type d -exec ${CHMOD} 0755 {} +
124 @${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|' \
126 @${REINPLACE_CMD} -e 's|gdb|${LOCALBASE}/bin/gdb|' \
127 ${WRKSRC}/src/etc/rust-gdb
129 # In case the previous "make stage" failed, this ensures rust's
130 # install.sh won't backup previously staged files before reinstalling
131 # new ones. Otherwise, the staging directory is polluted with unneeded
134 @for f in manifest-rustc manifest-rust-std-${RUST_TARGET}; do \
135 if test -f ${STAGEDIR}${PREFIX}/lib/rustlib/$$f; then \
136 ${SED} -E -e 's,^(dir|file:),${STAGEDIR},' \
137 < ${STAGEDIR}${PREFIX}/lib/rustlib/$$f \
142 ${STAGEDIR}${PREFIX}/lib/rustlib/components \
143 ${STAGEDIR}${PREFIX}/lib/rustlib/manifest-rustc \
144 ${STAGEDIR}${PREFIX}/lib/rustlib/manifest-rust-std-${RUST_TARGET} \
145 ${STAGEDIR}${PREFIX}/lib/rustlib/rust-installer-version \
146 ${STAGEDIR}${PREFIX}/lib/rustlib/uninstall.sh
149 @for f in manifest-rust-docs; do \
150 if test -f ${STAGEDIR}${PREFIX}/lib/rustlib/$$f; then \
151 ${SED} -E -e 's,^(dir|file:),${STAGEDIR},' \
152 < ${STAGEDIR}${PREFIX}/lib/rustlib/$$f \
156 @${RM} ${STAGEDIR}${PREFIX}/lib/rustlib/manifest-rust-docs
159 @for f in manifest-rustc manifest-rust-std-${RUST_TARGET}; do \
160 ${REINPLACE_CMD} -e 's|${STAGEDIR}||' \
161 ${STAGEDIR}${PREFIX}/lib/rustlib/$$f; \
162 ${RM} ${STAGEDIR}${PREFIX}/lib/rustlib/$$f.bak; \
164 @${RM} ${STAGEDIR}${PREFIX}/lib/rustlib/install.log
165 # FIXME: Static libraries in lib/rustlib/*/lib/*.rlib are not stripped,
166 # but they contain non-object files which make strip(1) unhappy.
168 ${STAGEDIR}${PREFIX}/bin/rustc \
169 ${STAGEDIR}${PREFIX}/bin/rustdoc \
170 ${STAGEDIR}${PREFIX}/lib/*.so \
171 ${STAGEDIR}${PREFIX}/lib/rustlib/*/lib/*.so
173 post-install-DOCS-on:
174 @for f in manifest-rust-docs; do \
175 ${REINPLACE_CMD} -e 's|${STAGEDIR}||' \
176 ${STAGEDIR}${PREFIX}/lib/rustlib/$$f; \
177 ${RM} ${STAGEDIR}${PREFIX}/lib/rustlib/$$f.bak; \
179 @${RMDIR} ${STAGEDIR}${PREFIX}/share/doc/rust/html/extra
181 .include <bsd.port.mk>