]> git.proxmox.com Git - cargo.git/blob - debian/rules
cargo: add a new stage2 profile
[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 ifneq ($(filter stage2,$(DEB_BUILD_PROFILES)),)
32 ln -s `which cargo` $(CURDIR)/cargo-stage0
33 # Workaround for https://github.com/rust-lang/cargo/issues/1423
34 mv $(DEPSDIR) $(CURDIR)/.deps
35 else
36 # Bootstrap cargo stage0
37 ./debian/bootstrap.py \
38 --no-clean \
39 --no-clone \
40 --no-git \
41 --crate-index $(INDEXDIR)/ \
42 --cargo-root $(CURDIR)/ \
43 --target-dir $(DEPSDIR)/ \
44 --host=$(DEB_HOST_RUST_TYPE) \
45 --target=$(DEB_TARGET_RUST_TYPE)
46 # Workaround for https://github.com/rust-lang/cargo/issues/1423
47 mv $(DEPSDIR) $(CURDIR)/.deps
48 ln -s `find $(CURDIR)/.deps -name 'cargo-*' -type f -executable` $(CURDIR)/cargo-stage0
49 endif
50 # Configure to build cargo using the just-built stage0
51 ./configure \
52 --prefix=/usr \
53 --disable-debug \
54 --enable-optimize \
55 --local-rust-root=/usr \
56 --local-cargo=$(CURDIR)/cargo-stage0
57 # Build final cargo binary and docs
58 $(MAKE)
59 $(MAKE) doc
60 cd target/doc/ && rm -f jquery.js && ln -s /usr/share/javascript/jquery/jquery.js
61
62 # Restore from workarounds
63 mv $(CURDIR)/.deps $(DEPSDIR)
64
65 override_dh_auto_clean:
66 -mv $(CURDIR)/.deps $(DEPSDIR)
67 -$(RM) -r $(CURDIR)/deps/*.rlib \
68 $(CURDIR)/deps/build_script* \
69 $(CURDIR)/deps/cargo* \
70 $(CURDIR)/deps/*.o \
71 $(CURDIR)/target/ \
72 $(CURDIR)/cargo-stage0 \
73 $(CARGO_HOME) \
74 $(VENDORDIR)
75 dh_auto_clean
76
77 override_dh_auto_install:
78 # We pick stuff directly from target/
79
80 override_dh_auto_test:
81 # we don't run tests at the moment due to too many deps
82