| 1 |
#!/usr/bin/make -f |
| 2 |
|
| 3 |
include /usr/share/dpkg/pkg-info.mk |
| 4 |
include /usr/share/dpkg/buildflags.mk |
| 5 |
|
| 6 |
PACKAGE := ocaml |
| 7 |
ALL_PACKAGES := $(shell dh_listpackages) |
| 8 |
|
| 9 |
# Can't use /usr/share/ocaml/ocamlvars.mk because it tries to run ocamlc |
| 10 |
include $(CURDIR)/debian/ocamlvars.mk |
| 11 |
|
| 12 |
# Use ccache if pkg.ocaml.ccache build-profile is active. |
| 13 |
ifneq (,$(filter pkg.ocaml.ccache,$(DEB_BUILD_PROFILES))) |
| 14 |
export PATH := /usr/lib/ccache:$(PATH) |
| 15 |
export CCACHE_DIR := $(CURDIR)/debian/ccache |
| 16 |
#export CCACHE_BASEDIR := $(CURDIR)/debian/build |
| 17 |
$(shell mkdir -p "$(CCACHE_DIR)") |
| 18 |
endif |
| 19 |
|
| 20 |
# Build cache (for Debian debugging) |
| 21 |
BUILDCACHE := $(wildcard ../ocaml.cache) |
| 22 |
|
| 23 |
MD5SUMSDIR = /var/lib/ocaml/md5sums |
| 24 |
INSTDIR = $(CURDIR)/debian/tmp/usr |
| 25 |
DISTDIR = $(PACKAGE)-$(OCAML_ABI) |
| 26 |
UPSTREAM_VERSION = $(shell dpkg-parsechangelog | awk '/^Version:/{print $$2}' | { read u; echo $${u%-*}; }) |
| 27 |
UPSTREAM_TARBALL = $(wildcard ../$(PACKAGE)_$(UPSTREAM_VERSION).orig.tar.*) |
| 28 |
SRCTARBALL = $(PACKAGE)-source-$(OCAML_ABI).tar |
| 29 |
|
| 30 |
TESTDIR := debian/test-build |
| 31 |
TESTRULES := debian/rules DEB_TEST_BUILD_PREFIX=$(CURDIR)/$(TESTDIR) |
| 32 |
|
| 33 |
BUILD_DATE := $(shell dpkg-parsechangelog --show-field=Date) |
| 34 |
|
| 35 |
ifeq (,$(DEB_TEST_BUILD_PREFIX)) |
| 36 |
ifneq (,$(findstring ocaml-source,$(ALL_PACKAGES))) |
| 37 |
TARBALL_TARGET = debian/$(SRCTARBALL) |
| 38 |
endif |
| 39 |
endif |
| 40 |
|
| 41 |
# Environment variable for dh_ocaml |
| 42 |
export OCAMLOBJINFO = OCAMLLIB=tools boot/ocamlrun tools/ocamlobjinfo |
| 43 |
|
| 44 |
# Uncomment this to turn on verbose mode. |
| 45 |
#export DH_VERBOSE=1 |
| 46 |
|
| 47 |
export DH_OPTIONS |
| 48 |
|
| 49 |
# This has to be exported to make dispatch work |
| 50 |
export OCAML_OPT_ARCH |
| 51 |
export OCAML_STDLIB_DIR |
| 52 |
|
| 53 |
export DEB_BUILD_MAINT_OPTIONS=hardening=+bindnow |
| 54 |
export CCLINKFLAGS=$(shell dpkg-buildflags --get LDFLAGS) |
| 55 |
|
| 56 |
CONFIGURE_OPTS := \ |
| 57 |
--without-zstd \ |
| 58 |
--enable-ocamltest \ |
| 59 |
--host $(DEB_BUILD_GNU_TYPE)\ |
| 60 |
-prefix $(DEB_TEST_BUILD_PREFIX)/usr \ |
| 61 |
-libdir $(DEB_TEST_BUILD_PREFIX)$(OCAML_STDLIB_DIR) \ |
| 62 |
-mandir $(DEB_TEST_BUILD_PREFIX)/usr/share/man \ |
| 63 |
|
| 64 |
# Upstream recommends dropping support on armel, see https://github.com/ocaml/ocaml/issues/7642 |
| 65 |
# Binaries generated by ocamlopt segfault on x32 |
| 66 |
# ld reports spurious messages on powerpc, see https://github.com/ocaml/ocaml/issues/8846 |
| 67 |
ifeq (,$(OCAML_OPT_ARCH)) |
| 68 |
CONFIGURE_OPTS += --disable-native-compiler |
| 69 |
endif |
| 70 |
|
| 71 |
# fma does not work on m68k, enable emulation as instructed by configure script |
| 72 |
ifeq (m68k,$(DEB_BUILD_ARCH)) |
| 73 |
CONFIGURE_OPTS += --enable-imprecise-c99-float-ops |
| 74 |
IGNORE_TESTS_FAILURE := || true |
| 75 |
# fma test from test suite fails on hppa, enable emulation like on m68k |
| 76 |
else ifeq (hppa,$(DEB_BUILD_ARCH)) |
| 77 |
CONFIGURE_OPTS += --enable-imprecise-c99-float-ops |
| 78 |
IGNORE_TESTS_FAILURE := || true |
| 79 |
else ifneq (,$(findstring hurd,$(DEB_BUILD_ARCH))) |
| 80 |
IGNORE_TESTS_FAILURE := || true |
| 81 |
else |
| 82 |
IGNORE_TESTS_FAILURE := |
| 83 |
endif |
| 84 |
|
| 85 |
# To avoid Lintian's file-references-package-build-path |
| 86 |
export BUILD_PATH_PREFIX_MAP=.=$(CURDIR) |
| 87 |
|
| 88 |
%: |
| 89 |
dh $@ |
| 90 |
|
| 91 |
# Needed because there is a "build" in the upstream tarball |
| 92 |
.PHONY: build |
| 93 |
build: |
| 94 |
dh $@ |
| 95 |
|
| 96 |
pre-config-stamp: $(TARBALL_TARGET) |
| 97 |
# Backup upstream config.{sub,guess}, and use most up-to-date ones |
| 98 |
set -e; for ext in sub guess; do \ |
| 99 |
if [ -f /usr/share/misc/config.$$ext ] && \ |
| 100 |
! [ -f debian/config.orig.$$ext ]; then \ |
| 101 |
mv build-aux/config.$$ext debian/config.orig.$$ext; \ |
| 102 |
cp -f /usr/share/misc/config.$$ext build-aux/config.$$ext; \ |
| 103 |
fi; \ |
| 104 |
done |
| 105 |
# Debian kfreebsd has non-working shims for dup3/pipe2, see #827935. Upstream |
| 106 |
# ./configure isn't sophisticated enough to detect this so patch it out here. |
| 107 |
ifeq (kfreebsd,$(DEB_HOST_ARCH_OS)) |
| 108 |
sed -i -e '/HAS_DUP3/d' -e '/HAS_PIPE2/d' ./configure |
| 109 |
endif |
| 110 |
touch $@ |
| 111 |
|
| 112 |
ifneq (,$(TARBALL_TARGET)) |
| 113 |
$(TARBALL_TARGET): $(UPSTREAM_TARBALL) |
| 114 |
mkdir -p debian/$(DISTDIR) |
| 115 |
# Copy upstream tarball |
| 116 |
cp $< debian/$(DISTDIR) |
| 117 |
# Copy debian/patches |
| 118 |
cp -a debian/patches debian/$(DISTDIR)/debian-patches |
| 119 |
# Set permissions (workaround for #796257) |
| 120 |
chmod 755 debian/$(DISTDIR)/debian-patches |
| 121 |
chmod 644 debian/$(DISTDIR)/debian-patches/* |
| 122 |
# Create the tarball and cleanup |
| 123 |
cd debian && find $(DISTDIR) -not -type d -print0 | \ |
| 124 |
LC_ALL=C sort --zero-terminated | \ |
| 125 |
tar --create --null --files-from=- \ |
| 126 |
--file=$(abspath $@) --mtime="$(BUILD_DATE)" \ |
| 127 |
--owner=root --group=root --numeric-owner |
| 128 |
rm -Rf debian/$(DISTDIR) |
| 129 |
endif |
| 130 |
|
| 131 |
.PHONY: override_dh_auto_configure |
| 132 |
override_dh_auto_configure: config-stamp ocamlinit-stamp |
| 133 |
|
| 134 |
config-stamp: pre-config-stamp |
| 135 |
./configure $(CONFIGURE_OPTS) |
| 136 |
sed -r -i '/^CFLAGS/s/-f(file|debug)-prefix-map=[^ ]* //g' Makefile.config |
| 137 |
touch $@ |
| 138 |
|
| 139 |
ocamlinit-stamp: $(TARBALL_TARGET) config-stamp |
| 140 |
$(MAKE) -f $(CURDIR)/debian/ocamlinit.mk ocamlinit-stamp |
| 141 |
|
| 142 |
.PHONY: override_dh_auto_build |
| 143 |
override_dh_auto_build: build-stamp |
| 144 |
|
| 145 |
build-stamp: config-stamp |
| 146 |
if test ! -d boot.debian; then \ |
| 147 |
cp -xa boot boot.debian; \ |
| 148 |
fi |
| 149 |
ifeq ($(BUILDCACHE),) |
| 150 |
$(MAKE) world |
| 151 |
$(MAKE) -C tools dumpobj |
| 152 |
ifneq (,$(OCAML_OPT_ARCH)) |
| 153 |
@echo "Building native compilers" |
| 154 |
$(MAKE) opt opt.opt |
| 155 |
touch opt-built-stamp |
| 156 |
endif |
| 157 |
@echo "Building manpages" |
| 158 |
$(MAKE) manpages |
| 159 |
else |
| 160 |
@echo "===> WARNING: $(BUILDCACHE) detected, compilation skipped! <===" |
| 161 |
rsync -a --exclude=debian --exclude=.git $(BUILDCACHE)/ . |
| 162 |
rm -f build-stamp install-stamp* |
| 163 |
endif |
| 164 |
touch $@ |
| 165 |
|
| 166 |
.PHONY: override_dh_auto_clean |
| 167 |
override_dh_auto_clean: |
| 168 |
ifneq ($(wildcard $(CURDIR)/Makefile.config),) |
| 169 |
$(MAKE) clean |
| 170 |
endif |
| 171 |
$(MAKE) -f $(CURDIR)/debian/ocamlinit.mk ocamlinit-clean |
| 172 |
# Restore files altered by the build process |
| 173 |
if test -d boot.debian; then \ |
| 174 |
rm -Rf boot; \ |
| 175 |
mv boot.debian boot; \ |
| 176 |
fi |
| 177 |
set -e; for ext in sub guess; do \ |
| 178 |
if [ -f debian/config.orig.$$ext ] ; then \ |
| 179 |
mv -f debian/config.orig.$$ext build-aux/config.$$ext; \ |
| 180 |
fi; \ |
| 181 |
done |
| 182 |
# Remaining stuff |
| 183 |
-rm -Rf debian/$(SRCTARBALL) $(TESTDIR) |
| 184 |
|
| 185 |
execute_after_dh_clean: |
| 186 |
rm -f install-stamp-* |
| 187 |
rm -f debian/installed-files debian/*.install |
| 188 |
|
| 189 |
.PHONY: override_dh_auto_install-arch override_dh_auto_install-indep |
| 190 |
override_dh_auto_install-arch: install-stamp-arch |
| 191 |
override_dh_auto_install-indep: install-stamp-indep |
| 192 |
|
| 193 |
install-stamp-indep: install-stamp |
| 194 |
touch $@ |
| 195 |
|
| 196 |
install-stamp-arch: install-stamp |
| 197 |
# Install additional files not handled by dh_install |
| 198 |
# Beware: dh_install does not handle renamings, please pay attention |
| 199 |
set -e; for u in dumpobj; do \ |
| 200 |
if [ -f tools/$$u ]; then \ |
| 201 |
cp tools/$$u debian/ocaml/usr/bin/ocaml$$u; \ |
| 202 |
fi \ |
| 203 |
done |
| 204 |
# Install the seq compatibility package (OCaml >= 4.07) |
| 205 |
mkdir -p debian/libstdlib-ocaml-dev$(OCAML_STDLIB_DIR)/seq |
| 206 |
cp debian/META.seq debian/libstdlib-ocaml-dev$(OCAML_STDLIB_DIR)/seq/META |
| 207 |
# Install the uchar compatibility package (OCaml >= 4.03) |
| 208 |
mkdir -p debian/libstdlib-ocaml-dev$(OCAML_STDLIB_DIR)/uchar |
| 209 |
cp debian/META.uchar debian/libstdlib-ocaml-dev$(OCAML_STDLIB_DIR)/uchar/META |
| 210 |
# Install the stdlib-shims compatibility package (OCaml >= 4.07) |
| 211 |
mkdir -p debian/libstdlib-ocaml-dev$(OCAML_STDLIB_DIR)/stdlib-shims |
| 212 |
cp debian/META.stdlib-shims debian/libstdlib-ocaml-dev$(OCAML_STDLIB_DIR)/stdlib-shims/META |
| 213 |
# Install the bigarray compatibility package (OCaml >= 5.2) |
| 214 |
mkdir -p debian/libstdlib-ocaml-dev$(OCAML_STDLIB_DIR)/bigarray |
| 215 |
cp debian/META.bigarray debian/libstdlib-ocaml-dev$(OCAML_STDLIB_DIR)/bigarray/META |
| 216 |
# Install the bytes compatibility package (OCaml >= 5.2) |
| 217 |
mkdir -p debian/libstdlib-ocaml-dev$(OCAML_STDLIB_DIR)/bytes |
| 218 |
cp debian/META.bytes debian/libstdlib-ocaml-dev$(OCAML_STDLIB_DIR)/bytes/META |
| 219 |
# Remaining stuff |
| 220 |
touch $@ |
| 221 |
|
| 222 |
install-stamp: |
| 223 |
# Install OCaml |
| 224 |
$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp |
| 225 |
# Remove config.cmx so that it is not part of compiler-libs ABI |
| 226 |
rm -f debian/tmp$(OCAML_STDLIB_DIR)/compiler-libs/config.cmx |
| 227 |
ifeq (,$(DEB_TEST_BUILD_PREFIX)) |
| 228 |
# Remove Debian-specific file |
| 229 |
rm -f debian/tmp$(OCAML_STDLIB_DIR)/ld.conf |
| 230 |
# Remove uninstalled files |
| 231 |
rm -f \ |
| 232 |
$(INSTDIR)/share/man/man1/ocamlopt.opt.1 \ |
| 233 |
$(INSTDIR)/share/man/man1/ocamlc.opt.1 |
| 234 |
ifeq ($(OCAML_HAVE_OCAMLOPT),no) |
| 235 |
# Remove files that make no sense without ocamlopt |
| 236 |
rm -f \ |
| 237 |
$(INSTDIR)/share/man/man1/ocamloptp.1 \ |
| 238 |
$(INSTDIR)/share/man/man1/ocamlopt.1 \ |
| 239 |
$(INSTDIR)/bin/ocamloptp.* \ |
| 240 |
$(INSTDIR)/bin/ocamloptp |
| 241 |
endif |
| 242 |
# Remove irrelevant files |
| 243 |
rm -f \ |
| 244 |
$(INSTDIR)/share/doc/ocaml/README.win32.adoc \ |
| 245 |
$(INSTDIR)/share/doc/ocaml/LICENSE |
| 246 |
# Dispatch files with dh_install |
| 247 |
find debian/tmp \( -type f -or -type l \) -printf '%P\n' > debian/installed-files |
| 248 |
boot/ocamlrun ./ocaml -nostdlib -I debian/tmp$(OCAML_STDLIB_DIR) debian/dispatch.ml |
| 249 |
dh_install |
| 250 |
endif |
| 251 |
touch $@ |
| 252 |
|
| 253 |
.PHONY: override_dh_gencontrol |
| 254 |
override_dh_gencontrol: |
| 255 |
set -e; for u in ocaml-source ocaml-interp ocaml-base ocaml; do \ |
| 256 |
echo 'F:OCamlABI=$(OCAML_ABI)' >> debian/$$u.substvars; \ |
| 257 |
done |
| 258 |
ifeq (,$(OCAML_OPT_ARCH)) |
| 259 |
echo 'F:NativeProvides=' >> debian/ocaml.substvars |
| 260 |
else |
| 261 |
echo 'F:NativeProvides=ocaml-native-compilers (= $${binary:Version})' >> debian/ocaml.substvars |
| 262 |
endif |
| 263 |
# Create .md5sums files and compute dependencies. |
| 264 |
dh_ocaml |
| 265 |
dh_gencontrol |
| 266 |
# Check that OCAML_ABI is correct |
| 267 |
if [ "$(OCAML_ABI)" != "$(shell boot/ocamlrun ./ocamlc -version | { read a && echo $${a%%_*}; })" ]; then \ |
| 268 |
echo "Please adjust OCAML_ABI in debian/rules"; \ |
| 269 |
exit 2; \ |
| 270 |
fi |
| 271 |
|
| 272 |
# Architectures where running the test suite completely makes the |
| 273 |
# whole build last more than 30 minutes on buildds. Originally, |
| 274 |
# because some tests do not even finish on mips. |
| 275 |
SLOW_ARCHITECTURES := armel armhf ia64 mips mipsel powerpc powerpcspe sparc |
| 276 |
|
| 277 |
.PHONY: override_dh_auto_test |
| 278 |
override_dh_auto_test: |
| 279 |
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS))) |
| 280 |
: # tries to connect the net |
| 281 |
rm -f testsuite/tests/lib-threads/sockets.* |
| 282 |
: # FIXME: the following test fails, we temporarily disable it |
| 283 |
rm -rf testsuite/tests/tool-debugger/find-artifacts/ |
| 284 |
ifeq ($(DEB_BUILD_ARCH),arm64) |
| 285 |
: # the following test is flaky, see #1103008 |
| 286 |
rm -f testsuite/tests/lib-runtime-events/test_dropped_events.ml |
| 287 |
endif |
| 288 |
ifneq (,$(filter $(DEB_BUILD_ARCH),$(SLOW_ARCHITECTURES))) |
| 289 |
rm -f testsuite/tests/misc-unsafe/almabench.ml |
| 290 |
endif |
| 291 |
ifeq (,$(DEB_TEST_BUILD_PREFIX)) |
| 292 |
OCAML_TEST_SIZE=1 make tests $(IGNORE_TESTS_FAILURE) |
| 293 |
endif |
| 294 |
endif |
| 295 |
|
| 296 |
.PHONY: override_dh_installdocs |
| 297 |
override_dh_installdocs: |
| 298 |
dh_installdocs --package=ocaml-base --doc-main-package=ocaml |
| 299 |
dh_installdocs --remaining-packages |
| 300 |
|
| 301 |
override_dh_autoreconf: |
| 302 |
./tools/autogen |