Prune devel/py-EnthoughtBase
[dports.git] / devel / cargo / Makefile
1 # Created by: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
2 # $FreeBSD$
3
4 PORTNAME=       cargo
5 PORTVERSION=    0.4.0.20150720
6 CATEGORIES=     devel
7
8 MAINTAINER=     dumbbell@FreeBSD.org
9 COMMENT=        Rust's Package Manager
10 # ' <-- Help Vim syntax hilighting...
11
12 LICENSE=        APACHE20 \
13                 MIT
14 LICENSE_COMB=   dual
15 LICENSE_FILE=   ${WRKSRC}/LICENSE-APACHE \
16                 ${WRKSRC}/LICENSE-MIT
17
18 # The following files are required:
19 #
20 # Main source archive from GitHub
21 #   This is the source of Cargo, taken from GitHub.
22 #
23 # :bootstrap
24 #   Like Rust, this is a prebuilt "cargo" used to bootstrap it, because
25 #   Cargo is a standard Rust package itself.
26 #
27 # :registry
28 #   Cargo clones several Git repositories for its dependencies and
29 #   caches them in its "registry". This is an archive of this registry
30 #   so nothing is downloaded during the build.
31 #
32 # :rust_installer
33 #   This is a collection of mainly shell scripts which are used to
34 #   install Cargo.
35
36 MASTER_SITES=   https://static.rust-lang.org/cargo-dist/2015-04-02/:bootstrap \
37                 LOCAL/dumbbell:registry
38
39 DISTFILES=      ${CARGO_BOOT}:bootstrap
40 EXTRACT_ONLY=   ${DISTNAME}${_GITHUB_EXTRACT_SUFX} \
41                 ${DISTFILE_rust_installer}
42
43 .if (${.TARGET} != gen-registry) && !defined(SKIP_CARGO_REGISTRY)
44 DISTFILES+=     ${CARGO_REGISTRY}:registry
45 EXTRACT_ONLY+=  ${CARGO_REGISTRY}
46 .endif
47
48 USE_GITHUB=     yes
49 GH_ACCOUNT=     rust-lang
50 GH_PROJECT=     ${PORTNAME} \
51                 rust-installer:rust_installer
52 GH_TAGNAME=     9c5ffcb871 \
53                 c37d374:rust_installer
54
55 CARGO_BOOT_SIG= x86_64-unknown-freebsd
56 CARGO_BOOT=     ${PORTNAME}-nightly-${CARGO_BOOT_SIG}${EXTRACT_SUFX}
57 CARGO_REGISTRY= ${DISTNAME:S/${GH_ACCOUNT}-${PORTNAME}/${PORTNAME}-registry/}${EXTRACT_SUFX}
58
59 USES=           gmake python:2,build pkgconfig
60
61 # The bootstrapped cargo is built with OpenSSL from ports (libssl.so.8).
62 USE_OPENSSL=    yes
63 WITH_OPENSSL_PORT=yes
64
65 # We don't USES=cmake here, because cmake is not Cargo's build system.
66 # It's used by a bundled dependency (libgit2).
67 BUILD_DEPENDS=  ${LOCALBASE}/bin/cmake:${PORTSDIR}/devel/cmake \
68                 rustc:${PORTSDIR}/lang/rust-nightly
69 LIB_DEPENDS=    libssh2.so:${PORTSDIR}/security/libssh2 \
70                 libcurl.so:${PORTSDIR}/ftp/curl
71
72 # FIXME: Don't add rust as a runtime dependency. As we need rust-nightly
73 # to build Cargo, the same version would be pulled by installing Cargo,
74 # preventing its use with the stable version of Rust.
75 # RUN_DEPENDS=  rustc:${PORTSDIR}/lang/rust
76
77 HAS_CONFIGURE=  yes
78 CONFIGURE_ARGS= --mandir=${MANPREFIX}/man
79 MAKE_ENV+=      LD_LIBRARY_PATH="${WRKSRC}/target/snapshot/cargo/lib"
80
81 # git log -1 --date=short --pretty=format:'%cd'
82 CFG_VER_DATE=   ${PORTVERSION:C/.*\.([0-9]{4})([0-9]{2})([0-9]{2})/\1-\2-\3/}
83 # git rev-parse --short HEAD
84 CFG_VER_HASH=   ${GH_TAGNAME}
85
86 .if defined(BATCH) || defined(PACKAGE_BUILDING)
87 MAKE_ARGS+=     VERBOSE=1
88 .endif
89
90 MAKE_JOBS_UNSAFE=       yes
91
92 .include <bsd.port.pre.mk>
93
94 post-extract:
95         @(${RMDIR} ${WRKSRC}/src/rust-installer && \
96           ${MV} ${WRKSRC_rust_installer} ${WRKSRC}/src/rust-installer)
97         @${MKDIR} ${WRKSRC}/target/dl
98         ${LN} -sf ${DISTDIR}/${CARGO_BOOT} ${WRKSRC}/target/dl/
99
100 post-patch:
101         ${REINPLACE_CMD} \
102                 -e 's|^CFG_VER_DATE =.*|CFG_VER_DATE = ${CFG_VER_DATE}|' \
103                 -e 's|^CFG_VER_HASH =.*|CFG_VER_HASH = ${CFG_VER_HASH}|' \
104                 ${WRKSRC}/Makefile.in
105
106 # In case the previous "make stage" failed, this ensures rust's
107 # install.sh won't backup previously staged files before reinstalling
108 # new ones. Otheriwe, the staging directory is polluted with unneeded
109 # files.
110 pre-install:
111         @if test -f ${STAGEDIR}${PREFIX}/lib/rustlib/manifest-cargo; then \
112                 ${SED} -E -e 's,^(dir|file:),${STAGEDIR},' \
113                 < ${STAGEDIR}${PREFIX}/lib/rustlib/manifest-cargo \
114                 | ${XARGS} ${RM}; \
115         fi
116         @${RM} \
117                 ${STAGEDIR}${PREFIX}/lib/rustlib/components \
118                 ${STAGEDIR}${PREFIX}/lib/rustlib/manifest-cargo \
119                 ${STAGEDIR}${PREFIX}/lib/rustlib/rust-installer-version \
120                 ${STAGEDIR}${PREFIX}/lib/rustlib/uninstall.sh
121
122 post-install:
123         @${RM} ${STAGEDIR}${PREFIX}/lib/rustlib/install.log
124         @${MV} ${STAGEDIR}${PREFIX}/share/man/man1/cargo.1 \
125                 ${STAGEDIR}${PREFIX}/man/man1/cargo.1
126         @${RMDIR} ${STAGEDIR}${PREFIX}/share/man/man1 \
127                 ${STAGEDIR}${PREFIX}/share/man
128         @${REINPLACE_CMD} -e 's|${STAGEDIR}||' \
129                 -e 's|share/man/man1/cargo\.1|man/man1/cargo.1.gz|' \
130                 ${STAGEDIR}${PREFIX}/lib/rustlib/manifest-cargo
131         @${RM} ${STAGEDIR}${PREFIX}/lib/rustlib/manifest-cargo.bak
132         @${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/cargo
133         @${RM} \
134                 ${STAGEDIR}${PREFIX}/lib/rustlib/components \
135                 ${STAGEDIR}${PREFIX}/lib/rustlib/rust-installer-version \
136                 ${STAGEDIR}${PREFIX}/lib/rustlib/uninstall.sh
137
138 # "make gen-registry" is a special target to ease this port update.
139 #
140 # After changing the version number and the Git revision, you can run
141 # "make registry" to update the distinfo and create a new snapshot of
142 # the registry. The new registry is written to ${DISTDIR} and can be
143 # uploaded.
144
145 gen-registry:
146         ${MAKE} -DSKIP_CARGO_REGISTRY makesum
147         ${MAKE} -DSKIP_CARGO_REGISTRY
148         cd ${WRKDIR} && \
149                 ${TAR} cvf - \
150                 --exclude libgit2/tests/ \
151                 --exclude curl/tests/ \
152                 --exclude 'index/github.com-*/.git/' \
153                 .cargo | ${GZIP_CMD} > ${DISTDIR}/${CARGO_REGISTRY}
154         ${MAKE} makesum
155
156 .include <bsd.port.post.mk>