]>
Commit | Line | Data |
---|---|---|
be771b38 LB |
1 | #!/usr/bin/make -f |
2 | # -*- makefile -*- | |
3 | ||
b59979d9 | 4 | include /usr/share/dpkg/pkg-info.mk |
7d40d3e1 AL |
5 | include /usr/share/dpkg/buildflags.mk |
6 | RUSTFLAGS = -C link-args="$(LDFLAGS)" | |
7 | export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS | |
b59979d9 | 8 | |
be771b38 LB |
9 | # Uncomment this to turn on verbose mode. |
10 | #export DH_VERBOSE=1 | |
11 | ||
03b69fec JJ |
12 | # When using sudo pbuilder, this will cause mk/install.mk to run sudo, |
13 | # but we don't need sudo as a build-dep for the package if we unexport | |
14 | # the SUDO_USER variable. | |
15 | unexport SUDO_USER | |
16 | ||
1c8ac2b0 SL |
17 | # Debhelper clears MAKEFLAGS, so we have to do this again for any |
18 | # target where we call $(MAKE) directly. Boo. | |
19 | DEB_PARALLEL_JOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) | |
20 | DEB_MAKE_PARALLEL = $(if $(DEB_PARALLEL_JOBS),-j$(DEB_PARALLEL_JOBS)) | |
21 | ||
2d084d4c | 22 | |
b59979d9 LB |
23 | # $DEB_VERSION_UPSTREAM is the full upstream version (eg. 1.0.0~alpha) |
24 | ||
25 | # This is original/unmangled upstream version (eg. 1.0.0-alpha) | |
26 | UPSTREAM_RUST_VERSION := $(subst ~,-,$(DEB_VERSION_UPSTREAM)) | |
27 | ||
28 | # Main (major.minor) upstream version (eg. 1.0) | |
29 | MAIN_RUST_VERSION := $(shell echo $(DEB_VERSION_UPSTREAM) | egrep -o '^[^\.]+\.[^\.]+') | |
30 | ||
31 | # Upstream version suffix, if any (eg. alpha) | |
32 | UPSTREAM_RUST_SUFFIX := $(shell echo $(DEB_VERSION_UPSTREAM) | egrep -o '[^\~]+$$') | |
33 | ||
34 | # Private dir for rust .so and .rlib | |
3f9812c2 | 35 | RUST_PREFIX := usr/lib/$(DEB_HOST_MULTIARCH)/rust/$(MAIN_RUST_VERSION) |
b59979d9 | 36 | |
d4357a26 LB |
37 | # Release type (one of beta, stable or nightly) |
38 | RELEASE_CHANNEL := beta | |
39 | ||
8354de7a | 40 | DEB_DESTDIR := $(CURDIR)/debian/tmp |
02b74708 JJ |
41 | RUST_TMP_PREFIX := $(DEB_DESTDIR)/$(RUST_PREFIX) |
42 | ||
be771b38 LB |
43 | # These are the normal build flags |
44 | COMMON_FLAGS = \ | |
45 | --disable-manage-submodules \ | |
d4357a26 | 46 | --release-channel=$(RELEASE_CHANNEL) \ |
c92744c0 | 47 | --mandir=/usr/share/man \ |
ac9de7b6 | 48 | --enable-rpath \ |
02b74708 | 49 | --prefix=/$(RUST_PREFIX) |
be771b38 | 50 | |
0577fc84 | 51 | SYSTEM_LLVM = --llvm-root=/usr/lib/llvm-3.6 |
be771b38 | 52 | |
1c8ac2b0 SL |
53 | |
54 | ifeq (,$(findstring dlstage0,$(DEB_BUILD_PROFILES))) | |
55 | # Without these options, a pre-built stage0 will be downloaded from | |
56 | # rust-lang.org at build time. | |
57 | DEB_CONFIGURE_EXTRA_FLAGS += --enable-local-rust --local-rust-root=/usr | |
58 | endif | |
59 | ||
60 | BUILD_DOCS = 1 | |
61 | ifneq (,$(findstring nodocs,$(DEB_BUILD_PROFILES))) | |
62 | DEB_CONFIGURE_EXTRA_FLAGS += --disable-docs | |
63 | BUILD_DOCS = 0 | |
64 | endif | |
65 | ||
66 | ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) | |
67 | DEB_CONFIGURE_EXTRA_FLAGS += --disable-optimize --disable-optimize-cxx --disable-optimize-llvm | |
68 | endif | |
69 | ||
70 | ||
be771b38 | 71 | %: |
2679d355 | 72 | dh $@ --parallel |
be771b38 | 73 | |
7a06551f | 74 | # Note: SHELL is not set by dash, but the configure script wants to use it |
be771b38 | 75 | override_dh_auto_configure: |
7a06551f | 76 | SHELL=/bin/sh \ |
be771b38 LB |
77 | ./configure \ |
78 | $(COMMON_FLAGS) \ | |
0577fc84 AL |
79 | $(DEB_CONFIGURE_EXTRA_FLAGS) \ |
80 | $(SYSTEM_LLVM) | |
ef102071 | 81 | |
1c8ac2b0 | 82 | |
11c430be AL |
83 | override_dh_auto_clean: |
84 | -$(MAKE) $(DEB_MAKE_PARALLEL) clean-all | |
85 | -$(RM) Makefile | |
86 | ||
1c8ac2b0 SL |
87 | override_dh_auto_build-arch: |
88 | dh_auto_build -- all VERBOSE=1 | |
89 | ||
90 | override_dh_auto_build-indep: | |
91 | $(if $(BUILD_DOCS),dh_auto_build -- docs) | |
becfe001 | 92 | |
0f729e31 | 93 | LD_TMP1 := $(RUST_TMP_PREFIX)/lib |
7bdffa5b SL |
94 | # TODO improve this stuff to make it dynamic |
95 | LD_TMP_i386 := $(LD_TMP1)/rustlib/i686-unknown-linux-gnu/lib | |
96 | LD_TMP_AMD64 := $(LD_TMP1)/rustlib/x86_64-unknown-linux-gnu/lib | |
97 | RUST_TMP_LD_PATH := $(LD_TMP1):$(LD_TMP_i386):$(LD_TMP_AMD64) | |
0f729e31 | 98 | |
c92744c0 | 99 | override_dh_shlibdeps: |
0f729e31 JJ |
100 | LD_LIBRARY_PATH=$(RUST_TMP_LD_PATH):$(LD_LIBRARY_PATH) \ |
101 | dh_shlibdeps -l$(RUST_TMP_LD_PATH) | |
c92744c0 | 102 | |
23d2674b | 103 | override_dh_auto_install: |
39a0abff | 104 | dh_auto_install --destdir=$(DEB_DESTDIR) |
3f9812c2 LB |
105 | dh_link $(RUST_PREFIX)/bin/rustc usr/bin/rustc-$(MAIN_RUST_VERSION) |
106 | dh_link usr/bin/rustc-$(MAIN_RUST_VERSION) usr/bin/rustc | |
107 | dh_link $(RUST_PREFIX)/bin/rustdoc usr/bin/rustdoc-$(MAIN_RUST_VERSION) | |
108 | dh_link usr/bin/rustdoc-$(MAIN_RUST_VERSION) usr/bin/rustdoc | |
109 | dh_link $(RUST_PREFIX)/bin/rust-gdb usr/bin/rust-gdb-$(MAIN_RUST_VERSION) | |
110 | dh_link usr/bin/rust-gdb-$(MAIN_RUST_VERSION) usr/bin/rust-gdb | |
6fce0a99 SL |
111 | |
112 | override_dh_install: | |
113 | # Brute force to remove privacy-breach-logo lintian warning. | |
114 | # We could have updated the upstream sources but it would complexify | |
115 | # the rebase | |
bc0aa84e | 116 | if test "$(BUILD_DOCS)" = "1"; then \ |
1c8ac2b0 | 117 | sed -i '/rel="shortcut icon" href="http:\/\/www.rust-lang.org\/favicon.ico"/d' `find $(DEB_DESTDIR) -iname '*.html'`; \ |
bc0aa84e | 118 | rm -f `find $(DEB_DESTDIR) -iname '*.html' -empty` $(DEB_DESTDIR)/usr/share/doc/rust-doc/html/.lock; \ |
1c8ac2b0 | 119 | fi |
6fce0a99 | 120 | dh_install |
1c8ac2b0 | 121 | |
bc0aa84e AL |
122 | override_dh_installchangelogs: |
123 | dh_installchangelogs RELEASES.md | |
124 | ||
125 | override_dh_installdocs: | |
126 | dh_installdocs -X.tex -X.aux -X.log -X.out -X.toc | |
127 | ||
1c8ac2b0 SL |
128 | override_dh_auto_test: |
129 | # NB: not parallel - there is some race that leads to failures like: | |
130 | # note: cc: error: x86_64-unknown-linux-gnu/test/run-pass/generic-default-type-params-cross-crate.stage2-x86_64-unknown-linux-gnulibaux/default_type_params_xc.o: No such file or directory | |
0be7358c | 131 | ifeq (, $(filter nocheck,$(DEB_BUILD_OPTIONS))) |
1c8ac2b0 | 132 | $(MAKE) check-notidy |
0be7358c | 133 | endif |