| 1 |
#!/usr/bin/make -f |
| 2 |
|
| 3 |
# https://wiki.debian.org/PackagingLessCommonBinutilsTargets |
| 4 |
|
| 5 |
# -format: errors in libcpp/expr.cc, seen with gcc-15. |
| 6 |
DEB_BUILD_MAINT_OPTIONS := hardening=+all,-format |
| 7 |
DPKG_EXPORT_BUILDFLAGS := 1 |
| 8 |
include /usr/share/dpkg/buildflags.mk |
| 9 |
include /usr/share/dpkg/buildopts.mk |
| 10 |
include /usr/share/dpkg/pkg-info.mk |
| 11 |
|
| 12 |
gnu_type := or1k-elf |
| 13 |
# Not deducible from package name because of possible underscore characters. |
| 14 |
gnu_type_in_deb_name = $(subst _,-,$(gnu_type)) |
| 15 |
package = gcc-$(gnu_type_in_deb_name) |
| 16 |
tmpdir = debian/$(package) |
| 17 |
|
| 18 |
gcc-version-major := $(shell sed '/^ gcc-\(.*\)-source,$$/!d;s//\1/;q' debian/control) |
| 19 |
# The Debian packaging calls this BV. |
| 20 |
|
| 21 |
gcc-version != dpkg-query -Wf'$${Version}' gcc-$(gcc-version-major)-source |
| 22 |
|
| 23 |
# https://gcc.gnu.org/install/configure.html recommends out-of-tree builds. |
| 24 |
%: |
| 25 |
dh $@ |
| 26 |
|
| 27 |
execute_before_dh_update_autotools_config: src |
| 28 |
tar_dir = /usr/src/gcc-$(gcc-version-major) |
| 29 |
src: |
| 30 |
tar -xf $(tar_dir)/gcc-*.tar.xz --transform='s|[^/]*|src|' |
| 31 |
# git-updates.diff always exists, but may contain no diff chunk. |
| 32 |
if grep -q '^---' $(tar_dir)/patches/git-updates.diff; then \ |
| 33 |
patch -p1 < $(tar_dir)/patches/git-updates.diff; \ |
| 34 |
fi |
| 35 |
# Apply patches, either local or from $(tar_dir)/patches/, with |
| 36 |
# 'patch -p1 < PATCH': |
| 37 |
patch -p1 < $(tar_dir)/patches/gcc-gfdl-build.diff |
| 38 |
|
| 39 |
# _GCC_AUTOCONF_VERSION_CHECK in config/override.m4 requires 2.69. |
| 40 |
# Seen with gcc-15. |
| 41 |
override_dh_autoreconf: |
| 42 |
dh_autoreconf autoreconf2.69 -- -f -i -v `grep -v \# debian/autoreconf` |
| 43 |
|
| 44 |
# libssp: libssp requires glibc |
| 45 |
# Install to the same path hierarchy than other GCCs: neither |
| 46 |
# multiarch components nor GCC minor versions. |
| 47 |
|
| 48 |
# Translations would duplicate the suggested gcc-locales. |
| 49 |
configure_options += --disable-nls |
| 50 |
|
| 51 |
# Hardering options for host code. |
| 52 |
configure_options += --enable-host-pie --enable-host-bind-now |
| 53 |
|
| 54 |
override_dh_auto_configure: |
| 55 |
# Imitate dh_auto_configure -- $(confargs), but without |
| 56 |
# --runstatedir because of autoconf2.69 (see above). |
| 57 |
install -d bld |
| 58 |
$(filter-out --runstatedir=/run, \ |
| 59 |
$(shell dh_auto_configure -Dsrc -Bbld --no-act)) \ |
| 60 |
--target=$(gnu_type) \ |
| 61 |
--disable-shared \ |
| 62 |
--disable-multilib \ |
| 63 |
--disable-bootstrap \ |
| 64 |
--enable-languages=c \ |
| 65 |
--disable-libssp \ |
| 66 |
--libdir=\$${prefix}/lib \ |
| 67 |
--with-gcc-major-version-only \ |
| 68 |
--without-included-gettext \ |
| 69 |
--with-pkgversion='GCC $(gcc-version) Debian $(DEB_VERSION)' \ |
| 70 |
$(configure_options) \ |
| 71 |
--with-system-zlib |
| 72 |
|
| 73 |
# Prevent dh_auto_{build,test,install} from parsing Makefile, see |
| 74 |
# https://gcc.gnu.org/legacy-ml/gcc/2013-04/msg00171.html |
| 75 |
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100933 |
| 76 |
|
| 77 |
override_dh_auto_build: |
| 78 |
cd bld && $(MAKE) $(addprefix -j,$(DEB_BUILD_OPTION_PARALLEL)) |
| 79 |
|
| 80 |
override_dh_auto_test: |
| 81 |
# Skip tests because they consume a lot of time and space, their |
| 82 |
# results are ignored, and most are redundant with native builds. |
| 83 |
# cd bld && $(MAKE) check |
| 84 |
|
| 85 |
# Even if building one package, install in two steps and display |
| 86 |
# explicit install/missing lists. |
| 87 |
override_dh_auto_install: |
| 88 |
cd bld && $(MAKE) install DESTDIR='$(CURDIR)/debian/tmp' AM_UPDATE_INFO_DIR=no |
| 89 |
|
| 90 |
override_dh_strip: |
| 91 |
dh_strip --exclude=.a |
| 92 |
# dh_fixperms would be more consistent, but comes before dh_strip. |
| 93 |
chmod 644 $(tmpdir)/usr/libexec/gcc/$(gnu_type)/$(gcc-version-major)/liblto_plugin.so |
| 94 |
# See 90f50a12 d4e32cd0 0aebd7b3 before changing this. |
| 95 |
$(gnu_type)-strip --strip-debug \ |
| 96 |
--remove-section=.comment --remove-section=.note \ |
| 97 |
$(tmpdir)/usr/lib/gcc/$(gnu_type)/$(gcc-version-major)/lib*.a |
| 98 |
|
| 99 |
# The private shared library needs no ldconfig trigger. |
| 100 |
override_dh_makeshlibs: |
| 101 |
dh_makeshlibs --no-scripts |
| 102 |
|
| 103 |
override_dh_gencontrol: |
| 104 |
dh_gencontrol -- -v${gcc-version}+$(DEB_VERSION) \ |
| 105 |
-Vgcc-version-major=$(gcc-version-major) |