| 1 |
#!/usr/bin/make -f |
| 2 |
# -*- makefile -*- |
| 3 |
|
| 4 |
export DH_VERBOSE=1 |
| 5 |
|
| 6 |
export DEBIAN_DISABLE_RUBYGEMS_INTEGRATION = 1 |
| 7 |
|
| 8 |
# This has to be exported to make some magic below work. |
| 9 |
export DH_OPTIONS |
| 10 |
TESTOPTS += -v |
| 11 |
export TESTOPTS |
| 12 |
|
| 13 |
DEB_BUILD_OPTIONS += abi=time64 |
| 14 |
|
| 15 |
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) |
| 16 |
DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) |
| 17 |
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) |
| 18 |
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) |
| 19 |
|
| 20 |
include /usr/share/dpkg/pkg-info.mk |
| 21 |
|
| 22 |
export RUBY_VERSION := $(patsubst ruby%,%,$(DEB_SOURCE)) |
| 23 |
export RUBY_API_VERSION := $(RUBY_VERSION).0 |
| 24 |
|
| 25 |
configure_options += --prefix=/usr |
| 26 |
configure_options += --enable-multiarch |
| 27 |
configure_options += --target=$(DEB_HOST_MULTIARCH) |
| 28 |
configure_options += --program-suffix=$(RUBY_VERSION) |
| 29 |
configure_options += --with-soname=ruby-$(RUBY_VERSION) |
| 30 |
configure_options += --enable-shared |
| 31 |
configure_options += --disable-rpath |
| 32 |
configure_options += --with-sitedir='/usr/local/lib/site_ruby' |
| 33 |
configure_options += --with-sitearchdir="/usr/local/lib/$(DEB_HOST_MULTIARCH)/site_ruby" |
| 34 |
configure_options += --runstatedir=/var/run |
| 35 |
configure_options += --localstatedir=/var |
| 36 |
configure_options += --sysconfdir=/etc |
| 37 |
|
| 38 |
# These are embedded in rbconfig.rb and should be triplet-prefixed for |
| 39 |
# cross compilation. |
| 40 |
configure_options += AS=$(DEB_HOST_GNU_TYPE)-as |
| 41 |
configure_options += CC=$(DEB_HOST_GNU_TYPE)-gcc |
| 42 |
configure_options += CXX=$(DEB_HOST_GNU_TYPE)-g++ |
| 43 |
configure_options += LD=$(DEB_HOST_GNU_TYPE)-ld |
| 44 |
|
| 45 |
ifneq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE)) |
| 46 |
# Cross-building. This is the same logic that debhelper's |
| 47 |
# lib/Debian/Debhelper/Buildsystem/autoconf.pm uses. |
| 48 |
# note that you also need --with-baseruby, so use the "cross" build-profile. |
| 49 |
configure_options += --build=$(DEB_BUILD_GNU_TYPE) |
| 50 |
configure_options += --host=$(DEB_HOST_GNU_TYPE) |
| 51 |
endif |
| 52 |
ifneq ($(filter cross,$(DEB_BUILD_PROFILES)),) |
| 53 |
configure_options += --with-baseruby=/usr/bin/$(DEB_SOURCE) |
| 54 |
endif |
| 55 |
|
| 56 |
# the following are ignored by ./configure, but used by some extconf.rb scripts |
| 57 |
configure_options += --enable-ipv6 |
| 58 |
configure_options += --with-dbm-type=gdbm_compat |
| 59 |
|
| 60 |
# do not compress debug sections for arch-dep Ruby packages with dh_compat 12 |
| 61 |
configure_options += --with-compress-debug-sections=no |
| 62 |
|
| 63 |
# hardening and other standard Debian build flags |
| 64 |
# TODO: remove optimize=-lto once we import ruby 3.1.0 where |
| 65 |
# https://bugs.ruby-lang.org/issues/18062 is apparently fixed |
| 66 |
export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow optimize=-lto |
| 67 |
configure_options += $(shell dpkg-buildflags --export=configure) |
| 68 |
|
| 69 |
# Pass variables to ensure consistent values when built on a usrmerge |
| 70 |
# or non-usrmerge system. |
| 71 |
configure_options += EGREP='/bin/grep -E' |
| 72 |
configure_options += GREP='/bin/grep' |
| 73 |
configure_options += MAKEDIRS='/bin/mkdir -p' |
| 74 |
configure_options += MKDIR_P='/bin/mkdir -p' |
| 75 |
configure_options += SHELL='/bin/sh' |
| 76 |
configure_options += PKG_CONFIG=$(DEB_HOST_GNU_TYPE)-pkg-config |
| 77 |
|
| 78 |
# Requires Rust |
| 79 |
configure_options += --disable-yjit |
| 80 |
|
| 81 |
# For more info see #999351 |
| 82 |
ifneq (,$(filter $(DEB_HOST_ARCH),alpha)) |
| 83 |
export DEB_CFLAGS_MAINT_APPEND += -O1 |
| 84 |
endif |
| 85 |
|
| 86 |
# See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93808 |
| 87 |
ifneq (,$(filter $(DEB_HOST_ARCH),sh3 sh4)) |
| 88 |
export DEB_CFLAGS_MAINT_APPEND += -fno-crossjumping |
| 89 |
endif |
| 90 |
|
| 91 |
# See: Fix FTBFS on arm64 https://bugzilla.redhat.com/show_bug.cgi?id=2343981 |
| 92 |
ifneq (,$(filter $(DEB_HOST_ARCH),arm64)) |
| 93 |
export DEB_CFLAGS_MAINT_APPEND += -Wl,-z,gcs-report-dynamic=none |
| 94 |
endif |
| 95 |
|
| 96 |
export LANG := C.UTF-8 |
| 97 |
export LC_ALL := $(LANG) |
| 98 |
|
| 99 |
%: |
| 100 |
dh $@ |
| 101 |
|
| 102 |
override_dh_auto_configure: |
| 103 |
cp /usr/share/misc/config.guess tool |
| 104 |
cp /usr/share/misc/config.sub tool |
| 105 |
./configure $(configure_options) |
| 106 |
|
| 107 |
override_dh_auto_clean: |
| 108 |
$(MAKE) clean || true |
| 109 |
$(MAKE) distclean-ext || true |
| 110 |
rm -f tool/config.guess tool/config.sub |
| 111 |
$(RM) test/excludes/$(DEB_HOST_ARCH) |
| 112 |
$(RM) -r .ext |
| 113 |
$(RM) -r doc/capi |
| 114 |
$(RM) .installed.list GNUmakefile Makefile builtin_binary.inc \ |
| 115 |
config.status enc.mk uncommon.mk verconf.h config.log |
| 116 |
|
| 117 |
override_dh_auto_build-arch: |
| 118 |
dh_auto_build -- main V=1 |
| 119 |
sed -i -e "s,$(CURDIR),BUILDDIR,g" ./rbconfig.rb |
| 120 |
|
| 121 |
# see full list in common.mk (search for /^check:/) |
| 122 |
TEST_TARGETS := test test-tool test-all # missing test-spec |
| 123 |
|
| 124 |
excludes = |
| 125 |
excludes += --excludes-dir=debian/tests/excludes/any/ |
| 126 |
excludes += --excludes-dir=debian/tests/excludes/$(DEB_HOST_ARCH)/ |
| 127 |
ifneq (,$(DEBIAN_RUBY_EXTRA_TEST_EXCLUDES)) |
| 128 |
excludes += --excludes-dir=debian/tests/excludes/$(DEBIAN_RUBY_EXTRA_TEST_EXCLUDES)/ |
| 129 |
endif |
| 130 |
override_dh_auto_test-arch: |
| 131 |
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) |
| 132 |
# dpkg-source does not allow empty file creation via patch file. |
| 133 |
# This is needed by openssl 3.0.0 |
| 134 |
touch $(CURDIR)/test/openssl/fixtures/pkey/empty.pem |
| 135 |
$(MAKE) $(TEST_TARGETS) V=1 RUBY_TESTOPTS=-v TESTS="$(excludes)" OPENSSL_CONF=$(CURDIR)/debian/openssl.cnf |
| 136 |
endif |
| 137 |
|
| 138 |
override_dh_auto_install-arch: |
| 139 |
$(MAKE) install-nodoc V=1 DESTDIR=$(CURDIR)/debian/tmp |
| 140 |
# handle embedded copy of jquery |
| 141 |
$(RM) $(CURDIR)/debian/tmp/usr/lib/ruby/$(RUBY_API_VERSION)/rdoc/generator/template/darkfish/js/jquery.js |
| 142 |
dh_link -plibruby$(RUBY_VERSION) /usr/share/javascript/jquery/jquery.min.js /usr/lib/ruby/$(RUBY_API_VERSION)/rdoc/generator/template/darkfish/js/jquery.js |
| 143 |
# handle embedded copy of Lato (font) |
| 144 |
$(RM) $(CURDIR)/debian/tmp/usr/lib/ruby/$(RUBY_API_VERSION)/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf |
| 145 |
dh_link -plibruby$(RUBY_VERSION) /usr/share/fonts/truetype/lato/Lato-Regular.ttf /usr/lib/ruby/$(RUBY_API_VERSION)/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf |
| 146 |
$(RM) $(CURDIR)/debian/tmp/usr/lib/ruby/$(RUBY_API_VERSION)/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf |
| 147 |
dh_link -plibruby$(RUBY_VERSION) /usr/share/fonts/truetype/lato/Lato-Italic.ttf /usr/lib/ruby/$(RUBY_API_VERSION)/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf |
| 148 |
$(RM) $(CURDIR)/debian/tmp/usr/lib/ruby/$(RUBY_API_VERSION)/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf |
| 149 |
dh_link -plibruby$(RUBY_VERSION) /usr/share/fonts/truetype/lato/Lato-Light.ttf /usr/lib/ruby/$(RUBY_API_VERSION)/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf |
| 150 |
$(RM) $(CURDIR)/debian/tmp/usr/lib/ruby/$(RUBY_API_VERSION)/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf |
| 151 |
dh_link -plibruby$(RUBY_VERSION) /usr/share/fonts/truetype/lato/Lato-LightItalic.ttf /usr/lib/ruby/$(RUBY_API_VERSION)/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf |
| 152 |
# remove embedded SSL certificates (replaced using ca-certificates via rubygems-integration) |
| 153 |
$(RM) -r $(CURDIR)/debian/tmp/usr/lib/ruby/$(RUBY_API_VERSION)/rubygems/ssl_certs/* |
| 154 |
$(RM) -r $(CURDIR)/debian/tmp/usr/lib/ruby/$(RUBY_API_VERSION)/bundler/ssl_certs/* |
| 155 |
# remove extension build directories |
| 156 |
$(RM) -r $(CURDIR)/debian/tmp/usr/lib/ruby/gems/$(RUBY_API_VERSION)/gems/*/ext/ |
| 157 |
# ship rubygems system install directory |
| 158 |
mkdir -p $(CURDIR)/debian/tmp/var/lib/gems/$(RUBY_API_VERSION) |
| 159 |
# fix pkg-config |
| 160 |
# FIXME there is probably less brutal way of doing this |
| 161 |
sed -i -e 's/^DLDFLAGS=.*/DLDFLAGS=/; s/LIBPATH=.*/LIBPATH=/' \ |
| 162 |
$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/ruby-$(RUBY_VERSION).pc |
| 163 |
# sanity check |
| 164 |
debian/sanity_check |
| 165 |
|
| 166 |
override_dh_auto_build-indep: |
| 167 |
$(MAKE) docs V=1 |
| 168 |
|
| 169 |
override_dh_auto_install-indep: |
| 170 |
$(MAKE) install-doc V=1 DESTDIR=$(CURDIR)/debian/ruby$(RUBY_VERSION)-doc |
| 171 |
find $(CURDIR)/debian/ruby$(RUBY_VERSION)-doc -name created.rid -delete |
| 172 |
|
| 173 |
override_dh_install-arch: |
| 174 |
# install SystemTap tapfile |
| 175 |
mkdir -p $(CURDIR)/debian/tmp/usr/share/systemtap/tapset |
| 176 |
sed 's|@LIBRARY_PATH@|/usr/lib/$(DEB_HOST_MULTIARCH)/libruby-$(RUBY_VERSION).so|g' $(CURDIR)/debian/libruby.stp > $(CURDIR)/debian/tmp/usr/share/systemtap/tapset/libruby$(RUBY_VERSION)-$(DEB_HOST_MULTIARCH).stp |
| 177 |
dh_install |
| 178 |
find $(CURDIR)/debian/libruby$(RUBY_VERSION)/usr/lib/ruby/gems/$(RUBY_API_VERSION)/gems/ \ |
| 179 |
'(' -name \*.so -or -name \*.o ')' \ |
| 180 |
-delete |
| 181 |
find $(CURDIR)/debian/ruby$(RUBY_VERSION)/usr/bin -name \*.lock -delete |
| 182 |
|
| 183 |
override_dh_gencontrol: |
| 184 |
./debian/genprovides $(CURDIR)/debian/libruby$(RUBY_VERSION)/usr/lib/ruby/gems/$(RUBY_API_VERSION)/specifications/ \ |
| 185 |
>> debian/libruby$(RUBY_VERSION).substvars |
| 186 |
dh_gencontrol |