]> git.proxmox.com Git - rustc.git/blob - debian/rules
Declare dh_install overrides as -arch
[rustc.git] / debian / rules
1 #!/usr/bin/make -f
2 # -*- makefile -*-
3
4 include /usr/share/dpkg/pkg-info.mk
5 include /usr/share/dpkg/architecture.mk
6 include /usr/share/dpkg/buildflags.mk
7 RUSTFLAGS = -C link-args="$(LDFLAGS)"
8 export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS
9
10 # Defines DEB_*_RUST_TYPE triples
11 include debian/architecture.mk
12
13 # Uncomment this to turn on verbose mode.
14 #export DH_VERBOSE=1
15
16 # When using sudo pbuilder, this will cause mk/install.mk to run sudo,
17 # but we don't need sudo as a build-dep for the package if we unexport
18 # the SUDO_USER variable.
19 unexport SUDO_USER
20
21 # src/rt/miniz.c (incorrectly) triggers -Wmisleading-indentation with
22 # gcc-6. See bug #811573.
23 CFLAGS += -Wno-misleading-indentation
24
25 # Debhelper clears MAKEFLAGS, so we have to do this again for any
26 # target where we call $(MAKE) directly. Boo.
27 DEB_PARALLEL_JOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
28 PMAKE = $(MAKE) $(if $(DEB_PARALLEL_JOBS),-j$(DEB_PARALLEL_JOBS))
29
30 # Release type (one of beta, stable or nightly)
31 RELEASE_CHANNEL := stable
32
33 DEB_DESTDIR := $(CURDIR)/debian/tmp
34
35 RUST_VERSION := $(shell dpkg-parsechangelog --show-field Version | sed -re 's/([^.]+)\.([^.]+)\..*/\1.\2/')
36 LIBSTD_PKG := libstd-rust-$(RUST_VERSION)
37
38 # These are the normal build flags
39 DEB_CONFIGURE_FLAGS = \
40 --host=$(DEB_HOST_RUST_TYPE) \
41 --target=$(DEB_TARGET_RUST_TYPE) \
42 --disable-manage-submodules \
43 --release-channel=$(RELEASE_CHANNEL) \
44 --prefix=/usr
45
46 # Use system LLVM (comment out to use vendored LLVM)
47 DEB_CONFIGURE_FLAGS += --llvm-root=/usr/lib/llvm-3.7
48
49 ifeq (,$(findstring dlstage0,$(DEB_BUILD_PROFILES)))
50 # Without these options, a pre-built stage0 will be downloaded from
51 # rust-lang.org at build time (or looked for in dl/).
52 #DEB_CONFIGURE_FLAGS += --enable-local-rust --local-rust-root=/usr
53 endif
54
55 BUILD_DOCS = 1
56 ifneq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
57 DEB_CONFIGURE_FLAGS += --disable-docs
58 BUILD_DOCS =
59 endif
60
61 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
62 DEB_CONFIGURE_FLAGS += --disable-optimize --disable-optimize-cxx --disable-optimize-llvm
63 endif
64
65
66 %:
67 dh $@ --parallel
68
69 # Note: SHELL is not set by dash, but the configure script wants to use it
70 override_dh_auto_configure:
71 SHELL=/bin/sh \
72 ./configure $(DEB_CONFIGURE_FLAGS)
73 # test "$$($(MAKE) --no-print-directory print-CFG_FILENAME_EXTRA | tail -n1 | cut -d= -f2)" = "$$(echo $(RUST_VERSION))"
74
75
76 override_dh_auto_clean:
77 set -e; \
78 if [ -f Makefile ]; then \
79 $(PMAKE) clean-all; \
80 $(RM) Makefile config.stamp; \
81 fi
82 $(RM) src/etc/snapshot.pyc
83
84 override_dh_auto_build-arch:
85 dh_auto_build -- all VERBOSE=1
86
87 override_dh_auto_build-indep:
88 $(if $(BUILD_DOCS),dh_auto_build -- docs)
89
90 override_dh_auto_install:
91 dh_auto_install --destdir=$(DEB_DESTDIR)
92
93 mkdir -p $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/
94 mv $(DEB_DESTDIR)/usr/lib/lib*.so $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/
95
96 # Replace duplicated compile-time/run-time dylibs with symlinks
97 @set -e; \
98 for f in $(DEB_DESTDIR)/usr/lib/rustlib/$(DEB_HOST_RUST_TYPE)/lib/lib*.so; do \
99 name=$${f##*/}; \
100 if [ -f "$(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/$$name" ]; then \
101 echo "ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f"; \
102 ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f; \
103 fi; \
104 done
105
106 ifneq (,$(BUILD_DOCS))
107 # Brute force to remove privacy-breach-logo lintian warning.
108 # We could have updated the upstream sources but it would complexify
109 # the rebase
110 @set -e; \
111 find $(DEB_DESTDIR)/usr/share/doc/rust/html -iname '*.html' | \
112 while read file; do \
113 topdir=$$(echo "$$file" | sed 's,^$(DEB_DESTDIR)/usr/share/doc/rust/html/,,; s,/[^/]*$$,/,; s,^[^/]*$$,,; s,[^/]\+/,../,g'); \
114 sed -i -e "s,https://doc.rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," \
115 -e "s,https://www.rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," "$$file"; \
116 done
117
118 find $(DEB_DESTDIR) \( -iname '*.html' -empty -o -name .lock -o -name '*.inc' \) -delete
119 endif
120
121 override_dh_install-arch:
122 dh_install
123 dh_install -p$(LIBSTD_PKG) usr/lib/$(DEB_HOST_MULTIARCH)/
124
125 chmod -x \
126 debian/rust-gdb/usr/share/rust-gdb/*.py \
127 debian/rust-lldb/usr/share/rust-lldb/*.py
128
129 override_dh_installchangelogs:
130 dh_installchangelogs RELEASES.md
131
132 override_dh_installdocs:
133 dh_installdocs -X.tex -X.aux -X.log -X.out -X.toc
134
135 override_dh_compress:
136 dh_compress -X.woff
137
138 override_dh_auto_test:
139 ifeq (, $(filter nocheck,$(DEB_BUILD_OPTIONS)))
140 $(PMAKE) check-notidy
141 endif
142
143 override_dh_makeshlibs:
144 dh_makeshlibs -V
145
146 # dh_makeshlibs doesn't support our "libfoo-version.so" naming
147 # structure, so we have to do this ourselves.
148 install -o 0 -g 0 -d debian/$(LIBSTD_PKG)/DEBIAN
149 ls debian/$(LIBSTD_PKG)/usr/lib/$(DEB_HOST_MULTIARCH)/lib*.so | \
150 sed -n 's,^.*/\(lib.*\)-\(.\+\)\.so$$,\1 \2,p' | \
151 while read name version; do \
152 echo "$$name $$version $(LIBSTD_PKG) (>= $(DEB_VERSION_UPSTREAM))"; \
153 done > debian/$(LIBSTD_PKG)/DEBIAN/shlibs
154 chmod 644 debian/$(LIBSTD_PKG)/DEBIAN/shlibs
155 chown 0:0 debian/$(LIBSTD_PKG)/DEBIAN/shlibs
156
157 override_dh_shlibdeps:
158 dh_shlibdeps -- -x$(LIBSTD_PKG)