]> git.proxmox.com Git - cargo.git/blame - debian/rules
debian: update vendor-pack helper
[cargo.git] / debian / rules
CommitLineData
d61f8f73
LB
1#!/usr/bin/make -f
2
3include /usr/share/dpkg/pkg-info.mk
4include /usr/share/dpkg/architecture.mk
5include /usr/share/dpkg/buildflags.mk
6RUSTFLAGS = -C link-args="$(LDFLAGS)"
7export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS
8
9rust_cpu = $(subst i586,i686,$(1))
10DEB_HOST_RUST_TYPE := $(call rust_cpu,$(DEB_HOST_GNU_CPU))-unknown-$(DEB_HOST_GNU_SYSTEM)
11DEB_TARGET_RUST_TYPE := $(call rust_cpu,$(DEB_TARGET_GNU_CPU))-unknown-$(DEB_TARGET_GNU_SYSTEM)
12
13# Cargo looks for config in and writes cache to $CARGO_HOME/
ac46c9e2 14export CARGO_HOME = $(CURDIR)/.cargohome
28cb78e3
LB
15# Ask cargo to be verbose when building
16export VERBOSE = 1
d61f8f73
LB
17
18DEB_DESTDIR := $(CURDIR)/debian/tmp
ac46c9e2
LB
19VENDORDIR := $(CURDIR)/vendor
20INDEXDIR := $(CURDIR)/vendor/index
d61f8f73
LB
21DEPSDIR := $(CURDIR)/deps
22
23%:
24 dh $@ --with bash-completion
25
26override_dh_auto_configure:
a02db50d 27 cp -a $(CURDIR)/Cargo.lock $(CURDIR)/.Cargo.lock.orig
ac46c9e2
LB
28 # Prepare a fake registry by packing all deps
29 ./debian/cargo-vendor-pack.py
d61f8f73
LB
30
31override_dh_auto_build:
91fae406
LB
32ifneq ($(filter stage2,$(DEB_BUILD_PROFILES)),)
33 ln -s `which cargo` $(CURDIR)/cargo-stage0
34 # Workaround for https://github.com/rust-lang/cargo/issues/1423
35 mv $(DEPSDIR) $(CURDIR)/.deps
36else
d61f8f73
LB
37 # Bootstrap cargo stage0
38 ./debian/bootstrap.py \
39 --no-clean \
40 --no-clone \
ac46c9e2 41 --no-git \
d61f8f73
LB
42 --crate-index $(INDEXDIR)/ \
43 --cargo-root $(CURDIR)/ \
44 --target-dir $(DEPSDIR)/ \
45 --host=$(DEB_HOST_RUST_TYPE) \
46 --target=$(DEB_TARGET_RUST_TYPE)
ac46c9e2
LB
47 # Workaround for https://github.com/rust-lang/cargo/issues/1423
48 mv $(DEPSDIR) $(CURDIR)/.deps
91fae406
LB
49 ln -s `find $(CURDIR)/.deps -name 'cargo-*' -type f -executable` $(CURDIR)/cargo-stage0
50endif
d61f8f73
LB
51 # Configure to build cargo using the just-built stage0
52 ./configure \
53 --prefix=/usr \
54 --disable-debug \
55 --enable-optimize \
56 --local-rust-root=/usr \
ac46c9e2 57 --local-cargo=$(CURDIR)/cargo-stage0
d61f8f73
LB
58 # Build final cargo binary and docs
59 $(MAKE)
6af7825b 60ifeq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
d61f8f73 61 $(MAKE) doc
1931a4c8 62 cd target/doc/ && rm -f jquery.js && ln -s /usr/share/javascript/jquery/jquery.js
6af7825b 63endif
1931a4c8 64
ac46c9e2
LB
65 # Restore from workarounds
66 mv $(CURDIR)/.deps $(DEPSDIR)
d61f8f73
LB
67
68override_dh_auto_clean:
a02db50d 69 -mv $(CURDIR)/.Cargo.lock.orig $(CURDIR)/Cargo.lock
ac46c9e2 70 -mv $(CURDIR)/.deps $(DEPSDIR)
c2dd508a 71 dh_auto_clean
d61f8f73
LB
72 -$(RM) -r $(CURDIR)/deps/*.rlib \
73 $(CURDIR)/deps/build_script* \
74 $(CURDIR)/deps/cargo* \
75 $(CURDIR)/deps/*.o \
ac46c9e2 76 $(CURDIR)/target/ \
c2dd508a
LB
77 $(CURDIR)/.cargo/ \
78 $(CURDIR)/config.mk \
79 $(CURDIR)/config.stamp \
80 $(CURDIR)/Makefile \
ac46c9e2
LB
81 $(CURDIR)/cargo-stage0 \
82 $(CARGO_HOME) \
83 $(VENDORDIR)
d61f8f73
LB
84
85override_dh_auto_install:
86 # We pick stuff directly from target/
87
88override_dh_auto_test:
ac46c9e2 89 # we don't run tests at the moment due to too many deps
d61f8f73 90