]> git.proxmox.com Git - cargo.git/blob - debian/rules
dcc5fc5b36e2e8cdc79dd4d8494810b341404173
[cargo.git] / debian / rules
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/
14 export CARGO_HOME = $(CURDIR)/.cargohome
15 # Ask cargo to be verbose when building
16 export VERBOSE = 1
17
18 DEB_DESTDIR := $(CURDIR)/debian/tmp
19 VENDORDIR := $(CURDIR)/vendor
20 INDEXDIR := $(CURDIR)/vendor/index
21 DEPSDIR := $(CURDIR)/deps
22
23 %:
24 dh $@ --with bash-completion
25
26 override_dh_auto_configure:
27 # Prepare a fake registry by packing all deps
28 ./debian/cargo-vendor-pack.py
29
30 override_dh_auto_build:
31 # Bootstrap cargo stage0
32 ./debian/bootstrap.py \
33 --no-clean \
34 --no-clone \
35 --no-git \
36 --crate-index $(INDEXDIR)/ \
37 --cargo-root $(CURDIR)/ \
38 --target-dir $(DEPSDIR)/ \
39 --host=$(DEB_HOST_RUST_TYPE) \
40 --target=$(DEB_TARGET_RUST_TYPE)
41 # Workaround for https://github.com/rust-lang/cargo/issues/1423
42 mv $(DEPSDIR) $(CURDIR)/.deps
43 ln -s `find $(CURDIR)/.deps -name 'cargo-*' -type f -executable` $(CURDIR)/cargo-stage0
44 # Configure to build cargo using the just-built stage0
45 ./configure \
46 --prefix=/usr \
47 --disable-debug \
48 --enable-optimize \
49 --local-rust-root=/usr \
50 --local-cargo=$(CURDIR)/cargo-stage0
51 # Build final cargo binary and docs
52 $(MAKE)
53 $(MAKE) doc
54 cd target/doc/ && rm -f jquery.js && ln -s /usr/share/javascript/jquery/jquery.js
55
56 # Restore from workarounds
57 mv $(CURDIR)/.deps $(DEPSDIR)
58
59 override_dh_auto_clean:
60 -mv $(CURDIR)/.deps $(DEPSDIR)
61 -$(RM) -r $(CURDIR)/deps/*.rlib \
62 $(CURDIR)/deps/build_script* \
63 $(CURDIR)/deps/cargo* \
64 $(CURDIR)/deps/*.o \
65 $(CURDIR)/target/ \
66 $(CURDIR)/cargo-stage0 \
67 $(CARGO_HOME) \
68 $(VENDORDIR)
69 dh_auto_clean
70
71 override_dh_auto_install:
72 # We pick stuff directly from target/
73
74 override_dh_auto_test:
75 # we don't run tests at the moment due to too many deps
76