]> git.proxmox.com Git - cargo.git/blob - debian/rules
Update upstream source from tag 'upstream/0.26.0'
[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 # TODO: we cannot enable this until dh_shlibdeps works correctly; atm we get:
13 # dpkg-shlibdeps: warning: can't extract name and version from library name 'libstd-XXXXXXXX.so'
14 # and the resulting cargo.deb does not depend on the correct version of libstd-rust-1.XX
15 # We probably need to add override_dh_makeshlibs to d/rules of rustc
16 #RUSTFLAGS += -C prefer-dynamic
17
18 # Pass on dpkg-buildflags stuff
19 RUSTFLAGS += $(foreach flag,$(LDFLAGS),-C link-arg=$(flag))
20 export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS
21
22 CARGO = RUST_BACKTRACE=1 cargo
23 CARGOFLAGS = --release --target=$(DEB_HOST_RUST_TYPE) --verbose
24 # Cargo looks for config in and writes cache to $CARGO_HOME/
25 export CARGO_HOME = $(CURDIR)/debian/cargohome
26
27 # Work around #865549, needed when using older cargo that is affected by it.
28 # TODO: remove after cargo/unstable is a version that was compiled with rustc
29 # >= 1.18 where this bug was fixed in Debian (i.e. probably after 0.20).
30 ifeq (0,$(shell test $$(uname -s) = "Linux" -a $$(getconf PAGESIZE) -gt 4096; echo $$?))
31 SYSTEM_WORKAROUNDS += ulimit -s $$(expr $$(getconf PAGESIZE) / 1024 '*' 256 + 8192);
32 endif
33
34 # Disable tests on powerpc and powerpcspe for now.
35 # cbmuser requested this and will fix the errors later
36 # TODO: once powerpc powerpcspe test failures are fixed drop this
37 ifeq ($(DEB_HOST_ARCH), powerpc)
38 DEB_BUILD_PROFILES = nocheck
39 endif
40
41 ifeq ($(DEB_HOST_ARCH), powerpcspe)
42 DEB_BUILD_PROFILES = nocheck
43 endif
44
45 %:
46 $(SYSTEM_WORKAROUNDS) dh $@ --with bash-completion
47
48 override_dh_auto_configure:
49 # cp -a $(CURDIR)/Cargo.lock $(CURDIR)/.Cargo.lock.orig
50 ifneq ($(filter pkg.cargo.mkstage0,$(DEB_BUILD_PROFILES)),)
51 # NOTE: this very likely doesn't work any more, see bootstrap.py for details
52 # Instead, you can try to bootstrap by setting PATH to a binary cargo
53 # downloaded from upstream; or by cross-compiling, see "build-cross" below
54 # Preserved in case someone wants to resurrect it later:
55 # Bootstrap cargo stage0
56 ./debian/bootstrap.py \
57 --no-clean \
58 --no-clone \
59 --no-git \
60 --no-download \
61 --crate-index $(CURDIR)/vendor/index / \
62 --cargo-root $(CURDIR)/ \
63 --target-dir $(CURDIR)/deps \
64 --host=$(DEB_HOST_RUST_TYPE) \
65 --target=$(DEB_TARGET_RUST_TYPE)
66 # Workaround for https://github.com/rust-lang/cargo/issues/1423
67 ln -s `find $(CURDIR)/deps -name 'cargo-*' -type f -executable` $(CURDIR)/cargo-stage0
68 else
69 ln -sf `which cargo` $(CURDIR)/cargo-stage0
70 endif
71 debian/scripts/prune-checksums vendor/backtrace-sys-*/
72 debian/scripts/prune-checksums vendor/libgit2-sys-*/
73
74 override_dh_auto_build-arch:
75 $(CARGO) build $(CARGOFLAGS)
76
77 override_dh_auto_build-indep:
78 ifeq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
79 $(CARGO) doc $(CARGOFLAGS)
80 # Extra instructions from README.md, unfortunately not done by "cargo doc"
81 sh src/ci/dox.sh
82 # Post-processing for Debian
83 cd target/doc/ && rm -f jquery.js && ln -s /usr/share/javascript/jquery/jquery.js
84 endif
85
86 override_dh_auto_test:
87 ifeq (,$(findstring nocheck,$(DEB_BUILD_PROFILES)))
88 ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
89 CFG_DISABLE_CROSS_TESTS=1 $(CARGO) test $(CARGOFLAGS)
90 endif
91 endif
92
93 override_dh_auto_install:
94 # We pick stuff directly from target/
95
96 override_dh_auto_clean:
97 -mv $(CURDIR)/.Cargo.lock.orig $(CURDIR)/Cargo.lock
98 $(CARGO) clean $(CARGOFLAGS)
99 -$(RM) -r $(CURDIR)/target/ \
100 $(CURDIR)/.cargo \
101 $(CURDIR)/config.mk \
102 $(CURDIR)/config.stamp \
103 $(CURDIR)/Makefile \
104 $(CURDIR)/Cargo.lock \
105 $(CURDIR)/cargo-stage0
106
107 override_dh_clean:
108 # Upstream contains a lot of these
109 dh_clean -XCargo.toml.orig
110
111 CROSS_SBUILD = sbuild --profiles=nocheck \
112 --build-failed-commands '%SBUILD_SHELL' \
113 --host=$(DEB_HOST_ARCH) \
114 --no-arch-all $(EXTRA_SBUILD_FLAGS)
115
116 SBUILD_REPO_EXPERIMENTAL = --extra-repository="deb http://httpredir.debian.org/debian experimental main"
117
118 # Sometimes this is necessary, if the mirrors have different versions for different architectures
119 ifeq (1,$(SBUILD_USE_INCOMING))
120 CROSS_SBUILD += --extra-repository="deb http://incoming.debian.org/debian-buildd buildd-unstable main"
121 SBUILD_REPO_EXPERIMENTAL += --extra-repository="deb http://incoming.debian.org/debian-buildd buildd-experimental main"
122 endif
123
124 crossbuild:
125 $(CROSS_SBUILD) .
126
127 crossbuild-experimental:
128 $(CROSS_SBUILD) $(SBUILD_REPO_EXPERIMENTAL) --build-dep-resolver=aspcud .