| 1 |
#!/usr/bin/make -f |
| 2 |
# -*- makefile -*- |
| 3 |
|
| 4 |
include /usr/share/dpkg/default.mk |
| 5 |
include /usr/share/rustc/architecture.mk |
| 6 |
|
| 7 |
# Disable CET, until JIT is ported too, preventing accidentally |
| 8 |
# building incompatible binaries. |
| 9 |
# https://salsa.debian.org/gnome-team/mozjs68/-/merge_requests/3 |
| 10 |
ifeq ($(DEB_HOST_ARCH),amd64) |
| 11 |
export DEB_CFLAGS_MAINT_APPEND=-fcf-protection=none |
| 12 |
export DEB_CXXFLAGS_MAINT_APPEND=-fcf-protection=none |
| 13 |
endif |
| 14 |
|
| 15 |
# This can be disabled if the bundled icu overtakes the system version, |
| 16 |
# or for backporting |
| 17 |
WITH_SYSTEM_ICU = no |
| 18 |
|
| 19 |
export DEB_HOST_ARCH |
| 20 |
# mozjs' build process does not seem to be compatible with other shells |
| 21 |
# like zsh |
| 22 |
export SHELL = /bin/sh |
| 23 |
export PYTHON3 = python3 |
| 24 |
export PYTHONPATH=$(CURDIR)/debian/site-packages |
| 25 |
export MOZBUILD_STATE_PATH = $(CURDIR)/debian/.mozbuild |
| 26 |
# Please tell us what you're thinking... |
| 27 |
export MOZ_CONFIGURE_TRACE = yes |
| 28 |
|
| 29 |
SRCDIR = $(CURDIR)/js/src |
| 30 |
BUILDDIR = $(CURDIR)/debian/build |
| 31 |
CARGO_HOME = $(BUILDDIR)/cargo-home |
| 32 |
CONFIGURE_FLAGS = |
| 33 |
RUSTFLAGS = |
| 34 |
|
| 35 |
UPSTREAM_VERSION = $(shell echo $(DEB_VERSION_UPSTREAM) | sed -e 's/[-+~].*//') |
| 36 |
UPSTREAM_MAJOR = $(shell echo $(UPSTREAM_VERSION) | cut -d. -f1) |
| 37 |
UPSTREAM_MINOR = $(shell echo $(UPSTREAM_VERSION) | cut -d. -f2) |
| 38 |
UPSTREAM_PATCH = $(shell echo $(UPSTREAM_VERSION) | cut -d. -f3) |
| 39 |
|
| 40 |
export MOZJS_VERSION = $(UPSTREAM_MAJOR) |
| 41 |
LIBNAME = libmozjs-$(MOZJS_VERSION) |
| 42 |
SONAME = $(LIBNAME).so.0 |
| 43 |
|
| 44 |
VERSIONED_LIBNAME = \ |
| 45 |
$(LIBNAME).so.$(UPSTREAM_MAJOR).$(UPSTREAM_MINOR).$(UPSTREAM_PATCH) |
| 46 |
|
| 47 |
# ia64 currently has toolchain issues, so relax the link optimization |
| 48 |
ifneq (,$(findstring $(DEB_BUILD_ARCH),ia64)) |
| 49 |
DEB_CFLAGS_MAINT_APPEND += -G0 |
| 50 |
DEB_CXXFLAGS_MAINT_APPEND += -G0 |
| 51 |
endif |
| 52 |
|
| 53 |
ifneq (,$(findstring $(DEB_BUILD_ARCH),sh4)) |
| 54 |
DEB_CFLAGS_MAINT_APPEND += -mlra |
| 55 |
DEB_CXXFLAGS_MAINT_APPEND += -mlra |
| 56 |
endif |
| 57 |
|
| 58 |
ifneq (,$(findstring $(DEB_BUILD_ARCH),armel)) |
| 59 |
DEB_LDFLAGS_MAINT_APPEND += -Wl,--allow-multiple-definition |
| 60 |
CONFIGURE_FLAGS += --disable-shared-memory |
| 61 |
endif |
| 62 |
|
| 63 |
export DEB_CFLAGS_MAINT_APPEND DEB_CXXFLAGS_MAINT_APPEND DEB_LDFLAGS_MAINT_APPEND |
| 64 |
|
| 65 |
EXCLUDED_TESTS := |
| 66 |
|
| 67 |
# Upstream assumes everything uses SSE mathematics, but SSE isn't in |
| 68 |
# Debian's baseline for i386, so we are stuck with i387 and its weird |
| 69 |
# 80-bit floating point registers. We can't even work around this with |
| 70 |
# -fexcess-precision=standard, because mozjs is C++. |
| 71 |
# https://bugzilla.mozilla.org/show_bug.cgi?id=1621900 |
| 72 |
ifneq (,$(findstring $(DEB_BUILD_ARCH),i386)) |
| 73 |
EXCLUDED_TESTS += basic/bug653153.js |
| 74 |
EXCLUDED_TESTS += basic/fdlibm-for-sin-cos-tan-argument.js |
| 75 |
endif |
| 76 |
|
| 77 |
# See: https://bugzilla.mozilla.org/show_bug.cgi?id=1755540 |
| 78 |
ifneq (,$(findstring $(DEB_BUILD_ARCH),powerpc ppc64 sparc64 s390x)) |
| 79 |
EXCLUDED_TESTS += large-arraybuffers/basic.js |
| 80 |
endif |
| 81 |
|
| 82 |
ifneq (,$(findstring $(DEB_BUILD_ARCH),armel)) |
| 83 |
EXCLUDED_TESTS += basic/bug-1649234-1.js |
| 84 |
endif |
| 85 |
|
| 86 |
ifneq (,$(findstring $(DEB_HOST_ARCH),mips mipsel mips64el)) |
| 87 |
CONFIGURE_FLAGS += --disable-jit |
| 88 |
endif |
| 89 |
|
| 90 |
ifeq ($(DEB_HOST_ARCH),sh4) |
| 91 |
DEB_LDFLAGS_MAINT_APPEND += -no-pie |
| 92 |
endif |
| 93 |
|
| 94 |
ifeq ($(WITH_SYSTEM_ICU),yes) |
| 95 |
CONFIGURE_FLAGS += --with-system-icu |
| 96 |
else |
| 97 |
CONFIGURE_FLAGS += --without-system-icu |
| 98 |
endif |
| 99 |
|
| 100 |
export CARGO_HOME |
| 101 |
export RUST_FLAGS |
| 102 |
|
| 103 |
%: |
| 104 |
dh $@ --sourcedirectory=$(SRCDIR) --builddirectory=$(BUILDDIR) --with pkgkde-symbolshelper |
| 105 |
|
| 106 |
execute_after_dh_clean: |
| 107 |
find $(CURDIR) -name \*.pyc -exec rm {} \; |
| 108 |
find $(CURDIR)/js/src/ -type l -exec rm {} \; |
| 109 |
rm -f $(CURDIR)/js/src/config/nsinstall |
| 110 |
rm -f $(CURDIR)/js/src/dist/bin/.purgecaches |
| 111 |
rm -f $(CURDIR)/js/src/js$(MOZJS_VERSION)-config \ |
| 112 |
$(CURDIR)/js/src/mozjs-$(MOZJS_VERSION).pc \ |
| 113 |
$(CURDIR)/js/src/symverscript |
| 114 |
rm -f $(CURDIR)/js/src/config.log |
| 115 |
rm -fr $(CURDIR)/intl/icu/source/autom4te.cache |
| 116 |
rm -fr $(CURDIR)/debian/build |
| 117 |
rm -rf third_party/python/psutil/build/ third_party/python/psutil/psutil/_*.so third_party/python/psutil/tmp/ |
| 118 |
|
| 119 |
override_dh_autoreconf: |
| 120 |
WITH_SYSTEM_ICU=$(WITH_SYSTEM_ICU) dh_autoreconf $(CURDIR)/debian/autogen.sh |
| 121 |
|
| 122 |
# dh_auto_configure does not properly handle autoconf2.13 generated configure |
| 123 |
# scripts, so we call configure ourselves. |
| 124 |
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=570375 |
| 125 |
# The bundled copy of icu prefers clang, which we need to override to |
| 126 |
# use gcc because clang doesn't support our DEB_CFLAGS_MAINT_APPEND |
| 127 |
ifeq ($(origin CC),default) |
| 128 |
CC := $(DEB_HOST_GNU_TYPE)-gcc |
| 129 |
endif |
| 130 |
ifeq ($(origin CXX),default) |
| 131 |
CXX := $(DEB_HOST_GNU_TYPE)-g++ |
| 132 |
endif |
| 133 |
|
| 134 |
override_dh_auto_configure: |
| 135 |
# We have modified the vendored cc library, so we must remove its checksum |
| 136 |
sed -i 's/{"files":.*"package":/{"files":{},"package":/' third_party/rust/cc/.cargo-checksum.json |
| 137 |
mkdir -p $(CURDIR)/debian/site-packages |
| 138 |
ln -fns /usr/lib/python3/dist-packages/cgi* $(CURDIR)/debian/site-packages/ |
| 139 |
mkdir -p $(BUILDDIR)/dist/cppunittests |
| 140 |
cd $(BUILDDIR); \ |
| 141 |
if env \ |
| 142 |
CC=$(CC) \ |
| 143 |
CXX=$(CXX) \ |
| 144 |
RUST_HOST=$(DEB_BUILD_RUST_TYPE) \ |
| 145 |
RUST_TARGET=$(DEB_HOST_RUST_TYPE) \ |
| 146 |
$(SHELL) $(SRCDIR)/configure \ |
| 147 |
--host=$(DEB_BUILD_GNU_TYPE) \ |
| 148 |
--target=$(DEB_HOST_GNU_TYPE) \ |
| 149 |
--prefix=/usr \ |
| 150 |
--includedir=/usr/include/${DEB_HOST_MULTIARCH} \ |
| 151 |
--libdir=/usr/lib/${DEB_HOST_MULTIARCH}/ \ |
| 152 |
--with-system-zlib \ |
| 153 |
--disable-strip \ |
| 154 |
--with-intl-api \ |
| 155 |
--enable-readline \ |
| 156 |
--disable-jemalloc \ |
| 157 |
$(CONFIGURE_FLAGS) \ |
| 158 |
; then \ |
| 159 |
echo Configure successful; \ |
| 160 |
else \ |
| 161 |
echo Configure failed with status $$?; \ |
| 162 |
tail -v -n +0 config.log; \ |
| 163 |
exit 1; \ |
| 164 |
fi |
| 165 |
|
| 166 |
execute_before_dh_install: |
| 167 |
# move library and create additional symlinks to standardize the file layout |
| 168 |
cd $(CURDIR)/debian/tmp/usr/lib/${DEB_HOST_MULTIARCH}/ && \ |
| 169 |
mv libjs_static.ajs $(LIBNAME).a && \ |
| 170 |
mv $(LIBNAME).so $(VERSIONED_LIBNAME) && \ |
| 171 |
ln -s $(VERSIONED_LIBNAME) $(SONAME) && \ |
| 172 |
ln -s $(SONAME) $(LIBNAME).so |
| 173 |
rm debian/tmp/usr/lib/${DEB_HOST_MULTIARCH}/$(LIBNAME).a |
| 174 |
|
| 175 |
execute_after_dh_fixperms: |
| 176 |
chmod a-x $(CURDIR)/debian/$(LIBNAME)-dev/usr/lib/${DEB_HOST_MULTIARCH}/pkgconfig/mozjs-$(MOZJS_VERSION).pc |
| 177 |
|
| 178 |
override_dh_auto_test: |
| 179 |
@: |
| 180 |
ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) |
| 181 |
SRCDIR=${SRCDIR} BUILDDIR=${BUILDDIR} DEB_HOST_ARCH=${DEB_HOST_ARCH} $(CURDIR)/debian/test.sh $(EXCLUDED_TESTS) |
| 182 |
endif |