]>
Commit | Line | Data |
---|---|---|
d61f8f73 LB |
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 | |
eadc1aeb XL |
6 | include /usr/share/rustc/architecture.mk |
7 | ||
eedc4049 XL |
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 | |
7f9c5c2a | 14 | RUSTFLAGS += $(foreach flag,$(LDFLAGS),-C link-arg=$(flag)) |
d61f8f73 LB |
15 | export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS |
16 | ||
d61f8f73 | 17 | # Cargo looks for config in and writes cache to $CARGO_HOME/ |
695031df | 18 | export CARGO_HOME = $(CURDIR)/debian/cargohome |
28cb78e3 LB |
19 | # Ask cargo to be verbose when building |
20 | export VERBOSE = 1 | |
d61f8f73 | 21 | |
d61f8f73 LB |
22 | %: |
23 | dh $@ --with bash-completion | |
24 | ||
25 | override_dh_auto_configure: | |
a02db50d | 26 | cp -a $(CURDIR)/Cargo.lock $(CURDIR)/.Cargo.lock.orig |
a96ed33a | 27 | ifneq ($(filter pkg.cargo.mkstage0,$(DEB_BUILD_PROFILES)),) |
eadc1aeb XL |
28 | # NOTE: this very likely doesn't work any more, see bootstrap.py for details |
29 | # Instead, you can try to bootstrap by setting PATH to a binary cargo | |
eedc4049 | 30 | # downloaded from upstream; or by cross-compiling, see "build-cross" below |
eadc1aeb | 31 | # Preserved in case someone wants to resurrect it later: |
d61f8f73 LB |
32 | # Bootstrap cargo stage0 |
33 | ./debian/bootstrap.py \ | |
34 | --no-clean \ | |
35 | --no-clone \ | |
ac46c9e2 | 36 | --no-git \ |
971277f5 | 37 | --no-download \ |
eadc1aeb | 38 | --crate-index $(CURDIR)/vendor/index / \ |
d61f8f73 | 39 | --cargo-root $(CURDIR)/ \ |
eadc1aeb | 40 | --target-dir $(CURDIR)/deps \ |
d61f8f73 LB |
41 | --host=$(DEB_HOST_RUST_TYPE) \ |
42 | --target=$(DEB_TARGET_RUST_TYPE) | |
ac46c9e2 | 43 | # Workaround for https://github.com/rust-lang/cargo/issues/1423 |
eadc1aeb | 44 | ln -s `find $(CURDIR)/deps -name 'cargo-*' -type f -executable` $(CURDIR)/cargo-stage0 |
13dd69ee LB |
45 | else |
46 | ln -s `which cargo` $(CURDIR)/cargo-stage0 | |
91fae406 | 47 | endif |
d61f8f73 LB |
48 | # Configure to build cargo using the just-built stage0 |
49 | ./configure \ | |
50 | --prefix=/usr \ | |
51 | --disable-debug \ | |
52 | --enable-optimize \ | |
53 | --local-rust-root=/usr \ | |
eedc4049 XL |
54 | --release-channel=stable \ |
55 | --cargo=$(CURDIR)/cargo-stage0 \ | |
56 | --build=$(DEB_BUILD_RUST_TYPE) \ | |
57 | --host=$(DEB_HOST_RUST_TYPE) \ | |
58 | --target=$(DEB_TARGET_RUST_TYPE) | |
a5996efa | 59 | |
eedc4049 XL |
60 | override_dh_auto_build-arch: |
61 | RUST_BACKTRACE=1 $(MAKE) | |
62 | ||
63 | override_dh_auto_build-indep: | |
6af7825b | 64 | ifeq (,$(findstring nodoc,$(DEB_BUILD_PROFILES))) |
d61f8f73 | 65 | $(MAKE) doc |
1931a4c8 | 66 | cd target/doc/ && rm -f jquery.js && ln -s /usr/share/javascript/jquery/jquery.js |
6af7825b | 67 | endif |
1931a4c8 | 68 | |
06619bc5 XL |
69 | override_dh_auto_test: |
70 | RUST_BACKTRACE=1 CFG_DISABLE_CROSS_TESTS=1 dh_auto_test | |
71 | ||
a5996efa XL |
72 | override_dh_auto_install: |
73 | # We pick stuff directly from target/ | |
74 | ||
d61f8f73 | 75 | override_dh_auto_clean: |
a02db50d | 76 | -mv $(CURDIR)/.Cargo.lock.orig $(CURDIR)/Cargo.lock |
c2dd508a | 77 | dh_auto_clean |
eadc1aeb | 78 | -$(RM) -r $(CURDIR)/target/ \ |
695031df | 79 | $(CURDIR)/.cargo \ |
c2dd508a LB |
80 | $(CURDIR)/config.mk \ |
81 | $(CURDIR)/config.stamp \ | |
82 | $(CURDIR)/Makefile \ | |
eadc1aeb | 83 | $(CURDIR)/cargo-stage0 |
eedc4049 | 84 | |
953ed6cf | 85 | CROSS_SBUILD = DEB_BUILD_OPTIONS=nocheck sbuild --profiles=nocheck \ |
eedc4049 XL |
86 | --build-failed-commands '%SBUILD_SHELL' \ |
87 | --add-depends=libc-dev:$(DEB_HOST_ARCH) \ | |
88 | $(EXTRA_SBUILD_FLAGS) \ | |
89 | --host=$(DEB_HOST_ARCH) \ | |
953ed6cf XL |
90 | --no-arch-all |
91 | ||
92 | crossbuild: | |
93 | $(CROSS_SBUILD) . | |
94 | ||
95 | crossbuild-experimental: | |
96 | $(CROSS_SBUILD) \ | |
97 | --extra-repository='deb http://httpredir.debian.org/debian experimental main' \ | |
98 | --build-dep-resolver=aspcud \ | |
99 | . |