]> git.proxmox.com Git - cargo.git/blob - debian/rules
Merge tag 'upstream/0.17.0' into debian/sid
[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 += $(foreach flag,$(LDFLAGS),-C link-arg=$(flag))
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 cp -a $(CURDIR)/Cargo.lock $(CURDIR)/.Cargo.lock.orig
28 # Prepare a fake registry by packing all deps
29 ./debian/cargo-vendor-pack.py
30
31 override_dh_auto_build:
32 ifneq ($(filter stage0,$(DEB_BUILD_PROFILES)),)
33 # Bootstrap cargo stage0
34 ./debian/bootstrap.py \
35 --no-clean \
36 --no-clone \
37 --no-git \
38 --no-download \
39 --crate-index $(INDEXDIR)/ \
40 --cargo-root $(CURDIR)/ \
41 --target-dir $(DEPSDIR)/ \
42 --host=$(DEB_HOST_RUST_TYPE) \
43 --target=$(DEB_TARGET_RUST_TYPE)
44 # Workaround for https://github.com/rust-lang/cargo/issues/1423
45 mv $(DEPSDIR) $(CURDIR)/.deps
46 ln -s `find $(CURDIR)/.deps -name 'cargo-*' -type f -executable` $(CURDIR)/cargo-stage0
47 else
48 ln -s `which cargo` $(CURDIR)/cargo-stage0
49 # Workaround for https://github.com/rust-lang/cargo/issues/1423
50 mv $(DEPSDIR) $(CURDIR)/.deps
51 endif
52 # Configure to build cargo using the just-built stage0
53 ./configure \
54 --prefix=/usr \
55 --disable-debug \
56 --enable-optimize \
57 --local-rust-root=/usr \
58 --cargo=$(CURDIR)/cargo-stage0
59 # Build final cargo binary and docs
60 $(MAKE)
61 ifeq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
62 $(MAKE) doc
63 cd target/doc/ && rm -f jquery.js && ln -s /usr/share/javascript/jquery/jquery.js
64 endif
65
66 # Restore from workarounds
67 mv $(CURDIR)/.deps $(DEPSDIR)
68
69 override_dh_auto_clean:
70 -mv $(CURDIR)/.Cargo.lock.orig $(CURDIR)/Cargo.lock
71 -mv $(CURDIR)/.deps $(DEPSDIR)
72 dh_auto_clean
73 -$(RM) -r $(CURDIR)/deps/*.rlib \
74 $(CURDIR)/deps/build_script* \
75 $(CURDIR)/deps/cargo* \
76 $(CURDIR)/deps/*.o \
77 $(CURDIR)/target/ \
78 $(CURDIR)/.cargo/ \
79 $(CURDIR)/config.mk \
80 $(CURDIR)/config.stamp \
81 $(CURDIR)/Makefile \
82 $(CURDIR)/cargo-stage0 \
83 $(CARGO_HOME) \
84 $(VENDORDIR)
85
86 override_dh_auto_install:
87 # We pick stuff directly from target/
88
89 override_dh_auto_test:
90 # we don't run tests at the moment due to too many deps
91