File: rules

package info (click to toggle)
ocaml 4.11.1-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 34,304 kB
  • sloc: ml: 290,481; ansic: 45,162; sh: 19,565; asm: 3,783; makefile: 3,618; awk: 254; perl: 45; fortran: 21; cs: 9
file content (302 lines) | stat: -rwxr-xr-x 9,904 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk
include /usr/share/dpkg/buildflags.mk

PACKAGE := ocaml
ALL_PACKAGES := $(shell dh_listpackages)

# Can't use /usr/share/ocaml/ocamlvars.mk because it tries to run ocamlc
include $(CURDIR)/debian/ocamlvars.mk

# Use ccache if pkg.ocaml.ccache build-profile is active.
ifneq (,$(filter pkg.ocaml.ccache,$(DEB_BUILD_PROFILES)))
export PATH := /usr/lib/ccache:$(PATH)
export CCACHE_DIR := $(CURDIR)/debian/ccache
#export CCACHE_BASEDIR := $(CURDIR)/debian/build
$(shell mkdir -p "$(CCACHE_DIR)")
endif

# Build cache (for Debian debugging)
BUILDCACHE := $(wildcard ../ocaml.cache)

MD5SUMSDIR = /var/lib/ocaml/md5sums
INSTDIR = $(CURDIR)/debian/tmp/usr
DISTDIR = $(PACKAGE)-$(OCAML_ABI)
UPSTREAM_VERSION = $(shell dpkg-parsechangelog | awk '/^Version:/{print $$2}' | { read u; echo $${u%-*}; })
UPSTREAM_TARBALL = $(wildcard ../$(PACKAGE)_$(UPSTREAM_VERSION).orig.tar.*)
SRCTARBALL = $(PACKAGE)-source-$(OCAML_ABI).tar

TESTDIR := debian/test-build
TESTRULES := debian/rules DEB_TEST_BUILD_PREFIX=$(CURDIR)/$(TESTDIR)

BUILD_DATE := $(shell dpkg-parsechangelog --show-field=Date)

ifeq (,$(DEB_TEST_BUILD_PREFIX))
ifneq (,$(findstring ocaml-source,$(ALL_PACKAGES)))
  TARBALL_TARGET = debian/$(SRCTARBALL)
endif
endif

# Environment variable for dh_ocaml
export OCAMLOBJINFO = OCAMLLIB=tools boot/ocamlrun tools/ocamlobjinfo

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export DH_OPTIONS

# This has to be exported to make dispatch work
export OCAML_OPT_ARCH
export OCAML_STDLIB_DIR

export DEB_BUILD_MAINT_OPTIONS=hardening=+bindnow
export CCLINKFLAGS=$(shell dpkg-buildflags --get LDFLAGS)

CONFIGURE_OPTS := \
  --host $(DEB_BUILD_GNU_TYPE)\
  -prefix $(DEB_TEST_BUILD_PREFIX)/usr \
  -libdir $(DEB_TEST_BUILD_PREFIX)$(OCAML_STDLIB_DIR) \
  --with-x \
  -mandir $(DEB_TEST_BUILD_PREFIX)/usr/share/man \

# Upstream recommends dropping support on armel, see https://github.com/ocaml/ocaml/issues/7642
# Binaries generated by ocamlopt segfault on x32
# ld reports spurious messages on powerpc, see https://github.com/ocaml/ocaml/issues/8846
ifeq (,$(OCAML_OPT_ARCH))
CONFIGURE_OPTS += --disable-native-compiler
endif

# To avoid Lintian's file-references-package-build-path
export BUILD_PATH_PREFIX_MAP=.=$(CURDIR)

%:
	dh $@

# Needed because there is a "build" in the upstream tarball
.PHONY: build
build:
	dh $@

# Generate ocaml-native-compilers' Architecture field.
# Should never be called automatically.
.PHONY: debian/control
debian/control:
	sed -e 's/@OCamlNativeArchs@/$(OCAML_NATIVE_ARCHS)/g' debian/control.in > $@

pre-config-stamp: $(TARBALL_TARGET)
# Backup upstream config.{sub,guess}, and use most up-to-date ones
	set -e; for ext in sub guess; do \
	  if [ -f /usr/share/misc/config.$$ext ] && \
	    ! [ -f debian/config.orig.$$ext ]; then \
	    mv build-aux/config.$$ext debian/config.orig.$$ext; \
	    cp -f /usr/share/misc/config.$$ext build-aux/config.$$ext; \
	  fi; \
	done
# Debian kfreebsd has non-working shims for dup3/pipe2, see #827935. Upstream
# ./configure isn't sophisticated enough to detect this so patch it out here.
ifeq (kfreebsd,$(DEB_HOST_ARCH_OS))
	sed -i -e '/HAS_DUP3/d' -e '/HAS_PIPE2/d' ./configure
endif
	touch $@

ifneq (,$(TARBALL_TARGET))
$(TARBALL_TARGET): $(UPSTREAM_TARBALL)
	mkdir -p debian/$(DISTDIR)
# Copy upstream tarball
	cp $< debian/$(DISTDIR)
# Copy debian/patches
	cp -a debian/patches debian/$(DISTDIR)/debian-patches
# Set permissions (workaround for #796257)
	chmod 755 debian/$(DISTDIR)/debian-patches
	chmod 644 debian/$(DISTDIR)/debian-patches/*
# Create the tarball and cleanup
	cd debian && find $(DISTDIR) -not -type d -print0 | \
		LC_ALL=C sort --zero-terminated | \
		tar --create --null --files-from=- \
			--file=$(abspath $@) --mtime="$(BUILD_DATE)" \
			--owner=root --group=root --numeric-owner
	rm -Rf debian/$(DISTDIR)
endif

.PHONY: override_dh_auto_configure
override_dh_auto_configure: config-stamp ocamlinit-stamp

config-stamp: pre-config-stamp
	./configure $(CONFIGURE_OPTS)
	touch $@

ocamlinit-stamp: $(TARBALL_TARGET) config-stamp
	$(MAKE) -f $(CURDIR)/debian/ocamlinit.mk ocamlinit-stamp

.PHONY: override_dh_auto_build
override_dh_auto_build: build-stamp

build-stamp: config-stamp
	if test ! -d boot.debian; then \
	  cp -xa boot boot.debian; \
	fi
ifeq ($(BUILDCACHE),)
	$(MAKE) world
	$(MAKE) bootstrap
	$(MAKE) -C tools dumpobj
ifeq (,$(OCAML_OPT_ARCH))
# As of 3.11.0, manpages are made only in `make opt.opt'
	make -C ocamldoc manpages \
	  OCAMLDOC_RUN="../boot/ocamlrun -I ../otherlibs/unix -I ../otherlibs/str ./ocamldoc"
else
	@echo "Building native compilers"
	$(MAKE) opt opt.opt
	touch opt-built-stamp
endif
else
	@echo "===> WARNING: $(BUILDCACHE) detected, compilation skipped! <==="
	rsync -a --exclude=debian --exclude=.git $(BUILDCACHE)/ .
	rm -f build-stamp install-stamp*
endif
	touch $@

.PHONY: override_dh_auto_clean
override_dh_auto_clean:
ifneq ($(wildcard $(CURDIR)/Makefile.config),)
	$(MAKE) clean
endif
	$(MAKE) -f $(CURDIR)/debian/ocamlinit.mk ocamlinit-clean
# Restore files altered by the build process
	if test -d boot.debian; then \
	  rm -Rf boot; \
	  mv boot.debian boot; \
	fi
	set -e; for ext in sub guess; do \
	  if [ -f debian/config.orig.$$ext ] ; then \
	    mv -f debian/config.orig.$$ext build-aux/config.$$ext; \
	  fi; \
	done
# Remaining stuff
	-rm -Rf debian/$(SRCTARBALL) $(TESTDIR)

.PHONY: override_dh_auto_install-arch override_dh_auto_install-indep
override_dh_auto_install-arch: install-stamp-arch
override_dh_auto_install-indep: install-stamp-indep

install-stamp-indep: install-stamp
	touch $@

install-stamp-arch: install-stamp
# Install additional files not handled by dh_install
# Beware: dh_install does not handle renamings, please pay attention
	set -e; for u in dumpobj; do \
	  if [ -f tools/$$u ]; then \
	    cp tools/$$u debian/ocaml-nox/usr/bin/ocaml$$u; \
	  fi \
	done
# Install the seq compatibility package (OCaml >= 4.07)
	mkdir -p debian/ocaml-base-nox$(OCAML_STDLIB_DIR)/seq
	cp debian/META.seq debian/ocaml-base-nox$(OCAML_STDLIB_DIR)/seq/META
# Install the uchar compatibility package (OCaml >= 4.03)
	mkdir -p debian/ocaml-base-nox$(OCAML_STDLIB_DIR)/uchar
	cp debian/META.uchar debian/ocaml-base-nox$(OCAML_STDLIB_DIR)/uchar/META
# Install the stdlib-shims compatibility package (OCaml >= 4.07)
	mkdir -p debian/ocaml-base-nox$(OCAML_STDLIB_DIR)/stdlib-shims
	cp debian/META.stdlib-shims debian/ocaml-base-nox$(OCAML_STDLIB_DIR)/stdlib-shims/META
# Remaining stuff
	touch $@

install-stamp:
# Install OCaml
	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
ifeq (,$(DEB_TEST_BUILD_PREFIX))
# Remove Debian-specific file
	rm -f $(INSTDIR)/lib/ocaml/ld.conf
# Remove uninstalled files
	rm -f \
	  $(INSTDIR)/share/man/man1/ocamlopt.opt.1 \
	  $(INSTDIR)/share/man/man1/ocamlc.opt.1
ifeq ($(OCAML_HAVE_OCAMLOPT),no)
# Remove files that make no sense without ocamlopt
	rm -f \
	  $(INSTDIR)/share/man/man1/ocamloptp.1 \
	  $(INSTDIR)/share/man/man1/ocamlopt.1 \
	  $(INSTDIR)/bin/ocamloptp.* \
	  $(INSTDIR)/bin/ocamloptp
endif
# Dispatch files with dh_install
	find debian/tmp \( -type f -or -type l \) -printf '%P\n' > debian/installed-files
	boot/ocamlrun ./ocaml -nostdlib -I debian/tmp/usr/lib/ocaml debian/dispatch.ml
	dh_install
endif
	touch $@

.PHONY: override_dh_gencontrol
override_dh_gencontrol:
	set -e; for u in ocaml-source ocaml-interp ocaml-compiler-libs; do \
	  echo 'F:OCamlABI=$(OCAML_ABI)' >> debian/$$u.substvars; \
	done
ifeq (,$(OCAML_OPT_ARCH))
	echo 'F:NativeProvides=' >> debian/ocaml-nox.substvars
else
	echo 'F:NativeProvides=ocaml-native-compilers (= $${binary:Version})' >> debian/ocaml-nox.substvars
endif
# Create .md5sums files and compute dependencies. Use $(OCAML_ABI)
# because we know that OCaml ABI represents best dependencies for
# OCaml package.
	dh_ocaml -Xcompiler-libs \
	 --runtime-map ocaml-nox:ocaml-base-nox,ocaml:ocaml-base \
	 --checksum $(OCAML_ABI)
	dh_gencontrol
# Check that OCAML_ABI is correct
	if [ "$(OCAML_ABI)" != "$(shell boot/ocamlrun ./ocamlc -version | { read a && echo $${a%%_*}; })" ]; then \
	  echo "Please adjust OCAML_ABI in debian/rules"; \
	  exit 2; \
	fi

.PHONY: regenerate
regenerate: debian/control
	git ls-tree --name-only -r HEAD debian \
	  | grep -v '^debian/\(patches/\|source/local-\)' \
	> debian/MANIFEST

# Architectures where running the test suite completely makes the
# whole build last more than 30 minutes on buildds. Originally,
# because some tests do not even finish on mips.
SLOW_ARCHITECTURES := armel armhf ia64 mips mipsel powerpc powerpcspe sparc

.PHONY: override_dh_auto_test
override_dh_auto_test:
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	: # tries to connect the net
	rm -f testsuite/tests/lib-threads/sockets.*
	: # FIXME: the following test fails, we temporarily disable it
	rm -rf testsuite/tests/tool-debugger/find-artifacts/
ifneq (,$(filter $(DEB_BUILD_ARCH),$(SLOW_ARCHITECTURES)))
	rm -f testsuite/tests/misc-unsafe/almabench.ml
endif
ifneq (,$(findstring hurd,$(DEB_BUILD_ARCH)))
	rm -f testsuite/tests/lib-threads/beat.ml
	rm -f testsuite/tests/lib-systhreads/threadsigmask.ml
	# Takes forever
	rm -f testsuite/tests/lib-systhreads/testyield.ml
	# Fail
	rm -f testsuite/tests/lib-unix/unix-socket/recvfrom_unix.ml
	rm -f testsuite/tests/tool-debugger/no_debug_event/noev.ml
	rm -f testsuite/tests/tool-debugger/printer/debuggee.ml
	rm -f testsuite/tests/misc/weaklifetime.ml
	rm -f testsuite/tests/tool-debugger/basic/debuggee.ml
	rm -f testsuite/tests/tool-debugger/dynlink/host.ml
endif
ifeq (,$(DEB_TEST_BUILD_PREFIX))
	make -C ocamltest
	make -C testsuite all
endif
endif

.PHONY: override_dh_installdocs
override_dh_installdocs:
	dh_installdocs --package=ocaml-base-nox --doc-main-package=ocaml
	dh_installdocs --remaining-packages

override_dh_autoreconf:
	./tools/autogen

# FIXME: figure out why dh_dwz fails
override_dh_dwz: