]>
Commit | Line | Data |
---|---|---|
d61f8f73 LB |
1 | #!/usr/bin/make -f |
2 | ||
3 | include /usr/share/dpkg/pkg-info.mk | |
4 | include /usr/share/dpkg/architecture.mk | |
5 | include /usr/share/dpkg/buildflags.mk | |
6 | RUSTFLAGS = -C link-args="$(LDFLAGS)" | |
7 | export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS | |
8 | ||
9 | rust_cpu = $(subst i586,i686,$(1)) | |
10 | DEB_HOST_RUST_TYPE := $(call rust_cpu,$(DEB_HOST_GNU_CPU))-unknown-$(DEB_HOST_GNU_SYSTEM) | |
11 | DEB_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 | 14 | export CARGO_HOME = $(CURDIR)/.cargohome |
28cb78e3 LB |
15 | # Ask cargo to be verbose when building |
16 | export VERBOSE = 1 | |
d61f8f73 LB |
17 | |
18 | DEB_DESTDIR := $(CURDIR)/debian/tmp | |
ac46c9e2 LB |
19 | VENDORDIR := $(CURDIR)/vendor |
20 | INDEXDIR := $(CURDIR)/vendor/index | |
d61f8f73 LB |
21 | DEPSDIR := $(CURDIR)/deps |
22 | ||
23 | %: | |
24 | dh $@ --with bash-completion | |
25 | ||
26 | override_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 | |
31 | override_dh_auto_build: | |
91fae406 LB |
32 | ifneq ($(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 | |
36 | else | |
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 |
50 | endif | |
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 | 60 | ifeq (,$(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 | 63 | endif |
1931a4c8 | 64 | |
ac46c9e2 LB |
65 | # Restore from workarounds |
66 | mv $(CURDIR)/.deps $(DEPSDIR) | |
d61f8f73 LB |
67 | |
68 | override_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 | |
85 | override_dh_auto_install: | |
86 | # We pick stuff directly from target/ | |
87 | ||
88 | override_dh_auto_test: | |
ac46c9e2 | 89 | # we don't run tests at the moment due to too many deps |
d61f8f73 | 90 |