]> git.proxmox.com Git - cargo.git/blob - debian/rules
Don't clean Cargo.toml.orig files
[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 include /usr/share/rustc/architecture.mk
7
8 # For cross-compiling; perhaps we should add this to dh-cargo or debcargo
9 export PKG_CONFIG = $(DEB_HOST_GNU_TYPE)-pkg-config
10 export PKG_CONFIG_ALLOW_CROSS = 1
11 RUSTFLAGS += -C linker=$(DEB_HOST_GNU_TYPE)-gcc
12
13 # Pass on dpkg-buildflags stuff
14 RUSTFLAGS += $(foreach flag,$(LDFLAGS),-C link-arg=$(flag))
15 export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS
16
17 CARGO = RUST_BACKTRACE=1 cargo
18 CARGOFLAGS = --release --target=$(DEB_HOST_RUST_TYPE)
19 # Cargo looks for config in and writes cache to $CARGO_HOME/
20 export CARGO_HOME = $(CURDIR)/debian/cargohome
21 # Ask cargo to be verbose when building
22 export VERBOSE = 1
23
24 %:
25 dh $@ --with bash-completion
26
27 override_dh_auto_configure:
28 cp -a $(CURDIR)/Cargo.lock $(CURDIR)/.Cargo.lock.orig
29 ifneq ($(filter pkg.cargo.mkstage0,$(DEB_BUILD_PROFILES)),)
30 # NOTE: this very likely doesn't work any more, see bootstrap.py for details
31 # Instead, you can try to bootstrap by setting PATH to a binary cargo
32 # downloaded from upstream; or by cross-compiling, see "build-cross" below
33 # Preserved in case someone wants to resurrect it later:
34 # Bootstrap cargo stage0
35 ./debian/bootstrap.py \
36 --no-clean \
37 --no-clone \
38 --no-git \
39 --no-download \
40 --crate-index $(CURDIR)/vendor/index / \
41 --cargo-root $(CURDIR)/ \
42 --target-dir $(CURDIR)/deps \
43 --host=$(DEB_HOST_RUST_TYPE) \
44 --target=$(DEB_TARGET_RUST_TYPE)
45 # Workaround for https://github.com/rust-lang/cargo/issues/1423
46 ln -s `find $(CURDIR)/deps -name 'cargo-*' -type f -executable` $(CURDIR)/cargo-stage0
47 else
48 ln -sf `which cargo` $(CURDIR)/cargo-stage0
49 endif
50 debian/scripts/prune-checksums vendor/backtrace-sys-*/
51 debian/scripts/prune-checksums vendor/libgit2-sys-*/
52
53 override_dh_auto_build-arch:
54 $(CARGO) build $(CARGOFLAGS)
55
56 override_dh_auto_build-indep:
57 ifeq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
58 $(CARGO) doc $(CARGOFLAGS)
59 cd target/doc/ && rm -f jquery.js && ln -s /usr/share/javascript/jquery/jquery.js
60 endif
61
62 override_dh_auto_test:
63 ifeq (,$(findstring nocheck,$(DEB_BUILD_PROFILES)))
64 ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
65 CFG_DISABLE_CROSS_TESTS=1 $(CARGO) test $(CARGOFLAGS)
66 endif
67 endif
68
69 override_dh_auto_install:
70 # We pick stuff directly from target/
71
72 override_dh_auto_clean:
73 -mv $(CURDIR)/.Cargo.lock.orig $(CURDIR)/Cargo.lock
74 $(CARGO) clean $(CARGOFLAGS)
75 -$(RM) -r $(CURDIR)/target/ \
76 $(CURDIR)/.cargo \
77 $(CURDIR)/config.mk \
78 $(CURDIR)/config.stamp \
79 $(CURDIR)/Makefile \
80 $(CURDIR)/cargo-stage0
81
82 override_dh_clean:
83 # Upstream contains a lot of these
84 dh_clean -XCargo.toml.orig
85
86 CROSS_SBUILD = sbuild --profiles=nocheck \
87 --build-failed-commands '%SBUILD_SHELL' \
88 --host=$(DEB_HOST_ARCH) \
89 --no-arch-all $(EXTRA_SBUILD_FLAGS)
90
91 SBUILD_REPO_EXPERIMENTAL = --extra-repository="deb http://httpredir.debian.org/debian experimental main"
92
93 # Sometimes this is necessary, if the mirrors have different versions for different architectures
94 ifeq (1,$(SBUILD_USE_INCOMING))
95 CROSS_SBUILD += --extra-repository="deb http://incoming.debian.org/debian-buildd buildd-unstable main"
96 SBUILD_REPO_EXPERIMENTAL += --extra-repository="deb http://incoming.debian.org/debian-buildd buildd-experimental main"
97 endif
98
99 crossbuild:
100 $(CROSS_SBUILD) .
101
102 crossbuild-experimental:
103 $(CROSS_SBUILD) $(SBUILD_REPO_EXPERIMENTAL) --build-dep-resolver=aspcud .