| 1 |
#!/usr/bin/make -f |
| 2 |
|
| 3 |
include /usr/share/dpkg/architecture.mk |
| 4 |
include /usr/share/dpkg/pkg-info.mk |
| 5 |
include /usr/share/dpkg/vendor.mk |
| 6 |
|
| 7 |
SPACE := $(EMPTY) $(EMPTY) |
| 8 |
COMMA = , |
| 9 |
|
| 10 |
# The top-level configure script fails to pass these down properly ... |
| 11 |
export DEB_BUILD_MAINT_OPTIONS = hardening=+all |
| 12 |
DPKG_EXPORT_BUILDFLAGS = 1 |
| 13 |
include /usr/share/dpkg/buildflags.mk |
| 14 |
|
| 15 |
CXXFLAGS += -fPIC |
| 16 |
CFLAGS += -fPIC |
| 17 |
export $(DPKG_BUILDFLAGS_LIST) |
| 18 |
|
| 19 |
# Ensure texlive respects DEB_TIMESTAMP |
| 20 |
export FORCE_SOURCE_DATE = 1 |
| 21 |
# Also force "TeX output" string in dvi file, thus %DVIPSSource in the ps file |
| 22 |
FAKETIME = TZ=UTC faketime "$(shell TZ=UTC date +"%Y-%m-%d %T" --date=@$(DEB_TIMESTAMP))" |
| 23 |
|
| 24 |
# Rather paranoid than sorry. Make the shell exit with an error if an |
| 25 |
# untested command fails. |
| 26 |
SHELL += -e |
| 27 |
|
| 28 |
export INSTALL = /usr/bin/install -p |
| 29 |
|
| 30 |
derivative = $(shell if dpkg-vendor --derives-from Ubuntu; then echo Ubuntu; \ |
| 31 |
elif dpkg-vendor --derives-from Debian; then echo Debian; \ |
| 32 |
else echo Unknown; fi) |
| 33 |
|
| 34 |
# Support parallel=<n> in DEB_BUILD_OPTIONS (see #209008) |
| 35 |
ifneq (,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS)))) |
| 36 |
NJOBS := -j $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS)))) |
| 37 |
endif |
| 38 |
|
| 39 |
nodoc_profile = $(if $(filter nodoc,$(DEB_BUILD_PROFILES)),no,yes) |
| 40 |
|
| 41 |
# Don't include docs with GFDL invariant sections |
| 42 |
GFDL_INVARIANT_FREE = yes |
| 43 |
ifeq ($(derivative),Ubuntu) |
| 44 |
GFDL_INVARIANT_FREE = no |
| 45 |
endif |
| 46 |
|
| 47 |
with_doc = no |
| 48 |
ifneq ($(GFDL_INVARIANT_FREE),yes) |
| 49 |
ifneq ($(nodoc_profile),yes) |
| 50 |
with_doc = yes |
| 51 |
endif |
| 52 |
endif |
| 53 |
|
| 54 |
with_multiarch = $(if $(filter pkg.gdb.no-multiarch,$(DEB_BUILD_PROFILES)),no,yes) |
| 55 |
|
| 56 |
# ---------- settings for cross builds ---------- |
| 57 |
|
| 58 |
# Cross configuration support. Check for an environment variable |
| 59 |
# $GDB_TARGET, or a file debian/target. |
| 60 |
ifndef GDB_TARGET |
| 61 |
DEBIAN_TARGET_FILE := $(strip $(shell cat debian/target 2>/dev/null)) |
| 62 |
ifneq ($(DEBIAN_TARGET_FILE),) |
| 63 |
GDB_TARGET := $(DEBIAN_TARGET_FILE) |
| 64 |
endif |
| 65 |
endif |
| 66 |
|
| 67 |
DEB_TARGET_ALIAS ?= $(DEB_TARGET_GNU_TYPE) |
| 68 |
|
| 69 |
ifneq ($(GDB_TARGET),) |
| 70 |
configure_target_args = --with-gdb-datadir="\$${prefix}/share/gdb-$(DEB_TARGET_GNU_TYPE)" |
| 71 |
endif |
| 72 |
|
| 73 |
ifeq ($(DEB_TARGET_ARCH),) |
| 74 |
$(error GDB_TARGET value "$(GDB_TARGET)" is not a valid Debian architecture) |
| 75 |
endif |
| 76 |
|
| 77 |
ifdef GDB_TARGET |
| 78 |
DEB_CROSS = yes |
| 79 |
# TP: Target Prefix. Used primarily as a prefix for cross tool |
| 80 |
# names (e.g. powerpc-linux-gcc). |
| 81 |
# TS: Target Suffix. Used primarily at the end of cross compiler |
| 82 |
# package names (e.g. gcc-powerpc). |
| 83 |
TP = $(DEB_TARGET_ALIAS)- |
| 84 |
TS = -$(DEB_TARGET_ALIAS) |
| 85 |
endif |
| 86 |
|
| 87 |
# ---------- configure options, architecture specific ---------- |
| 88 |
|
| 89 |
ifeq ($(DEB_HOST_GNU_CPU),ia64) |
| 90 |
arch_config_args = --with-libunwind-ia64 |
| 91 |
endif |
| 92 |
|
| 93 |
# Enable Intel Processor Trace (PT) on Linux x86 platform |
| 94 |
ifneq (,$(filter $(DEB_HOST_ARCH),amd64 i386)) |
| 95 |
arch_config_args += --with-intel-pt |
| 96 |
endif |
| 97 |
|
| 98 |
ifdef GDB_TARGET |
| 99 |
arch_config_args += \ |
| 100 |
--program-prefix=$(TP) \ |
| 101 |
--target=$(DEB_TARGET_ALIAS) \ |
| 102 |
--with-sysroot=/usr/$(DEB_TARGET_ALIAS) |
| 103 |
else |
| 104 |
# To avoid file conflicts, only enable the global gdbinit file for native |
| 105 |
# debuggers. |
| 106 |
arch_config_args += \ |
| 107 |
--with-system-gdbinit=/etc/gdb/gdbinit \ |
| 108 |
--with-system-gdbinit-dir=/etc/gdb/gdbinit.d |
| 109 |
endif |
| 110 |
|
| 111 |
run_tests = yes |
| 112 |
ifneq (,$(filter nocheck, $(DEB_BUILD_OPTIONS))) |
| 113 |
run_tests = disabled by DEB_BUILD_OPTIONS |
| 114 |
endif |
| 115 |
|
| 116 |
ifeq (,$(findstring linux, $(DEB_HOST_GNU_SYSTEM))) |
| 117 |
run_tests = only enabled for Linux targets |
| 118 |
endif |
| 119 |
|
| 120 |
ifdef GDB_TARGET |
| 121 |
run_tests = disabled for cross builds |
| 122 |
endif |
| 123 |
|
| 124 |
# List of architectures where tests are flaky (and therefore |
| 125 |
# disabled). |
| 126 |
FLAKY_TEST_ARCHITECTURES = \ |
| 127 |
alpha \ |
| 128 |
hppa \ |
| 129 |
sparc64 \ |
| 130 |
x32 |
| 131 |
|
| 132 |
ifneq (,$(filter $(DEB_HOST_ARCH),$(FLAKY_TEST_ARCHITECTURES))) |
| 133 |
run_tests = disable on $(DEB_HOST_ARCH) due to flakiness |
| 134 |
endif |
| 135 |
|
| 136 |
# Architectures where gdbserver's libinproctrace is available. |
| 137 |
LIBINPROCTRACE_AVAILABLE_ARCHITECTURES = \ |
| 138 |
amd64 \ |
| 139 |
arm64 \ |
| 140 |
i386 \ |
| 141 |
ppc64el \ |
| 142 |
s390x \ |
| 143 |
powerpc \ |
| 144 |
ppc64 \ |
| 145 |
x32 |
| 146 |
|
| 147 |
# ---------- configure options, for all variants ---------- |
| 148 |
|
| 149 |
variants = default multiarch |
| 150 |
|
| 151 |
# We pass srcdir explicitly to avoid an extra '/.' at the end of it. That |
| 152 |
# causes a harmless, but ugly, testsuite failure in maint.exp. |
| 153 |
common_configure_args = \ |
| 154 |
--build=$(DEB_BUILD_GNU_TYPE) \ |
| 155 |
--host=$(DEB_HOST_GNU_TYPE) \ |
| 156 |
--prefix=/usr \ |
| 157 |
--libexecdir="\$${prefix}/lib/gdb" \ |
| 158 |
--disable-maintainer-mode \ |
| 159 |
--disable-dependency-tracking \ |
| 160 |
--disable-silent-rules \ |
| 161 |
--disable-gdbtk \ |
| 162 |
--disable-shared \ |
| 163 |
--with-pkgversion='$(DEB_VENDOR)___$(DEB_VERSION)' \ |
| 164 |
--srcdir=$(CURDIR) \ |
| 165 |
--disable-readline \ |
| 166 |
--with-system-readline \ |
| 167 |
--with-expat \ |
| 168 |
--with-system-zlib \ |
| 169 |
--without-guile \ |
| 170 |
--without-babeltrace \ |
| 171 |
$(if $(filter linux, $(DEB_HOST_ARCH_OS)),--with-debuginfod) \ |
| 172 |
$(arch_config_args) \ |
| 173 |
|
| 174 |
default_configure_args = \ |
| 175 |
$(common_configure_args) \ |
| 176 |
$(configure_target_args) \ |
| 177 |
--enable-tui \ |
| 178 |
--with-lzma \ |
| 179 |
--with-python=python3 \ |
| 180 |
--with-xxhash \ |
| 181 |
--enable-64-bit-bfd |
| 182 |
|
| 183 |
multiarch_configure_args = \ |
| 184 |
$(default_configure_args) \ |
| 185 |
--enable-targets=all \ |
| 186 |
--enable-obsolete \ |
| 187 |
--disable-sim |
| 188 |
|
| 189 |
builddir_default = build/default |
| 190 |
builddir_multiarch = build/multiarch |
| 191 |
builddir_source = build/gdb |
| 192 |
|
| 193 |
%: |
| 194 |
dh $@ |
| 195 |
|
| 196 |
# There's no need to run autoreconf as upstream already ships a |
| 197 |
# working configure script. |
| 198 |
override_dh_autoreconf: |
| 199 |
|
| 200 |
# Configure GDB. |
| 201 |
# First and only argument is the build flavour. |
| 202 |
define configure-gdb |
| 203 |
mkdir -p $(builddir_$(1)) $(builddir_$(1))/sim/common |
| 204 |
@echo "gdb-$(1): configure with: $(subst ___, ,$(foreach i,$($(1)_configure_args),$(i)\n\t))" |
| 205 |
cd $(builddir_$(1)) && ../../configure $(subst ___,$(SPACE),$($(1)_configure_args)) |
| 206 |
endef |
| 207 |
|
| 208 |
override_dh_auto_configure-arch: |
| 209 |
$(call configure-gdb,default) |
| 210 |
ifeq ($(with_multiarch),yes) |
| 211 |
$(call configure-gdb,multiarch) |
| 212 |
endif |
| 213 |
|
| 214 |
override_dh_auto_configure-indep: |
| 215 |
|
| 216 |
# Build GDB. |
| 217 |
# First and only argument is the build flavour. |
| 218 |
define build-gdb |
| 219 |
$(MAKE) V=1 -C $(builddir_$(1)) $(NJOBS) |
| 220 |
endef |
| 221 |
|
| 222 |
override_dh_auto_build-arch: |
| 223 |
$(call build-gdb,default) |
| 224 |
ifeq ($(with_multiarch),yes) |
| 225 |
$(call build-gdb,multiarch) |
| 226 |
endif |
| 227 |
$(FAKETIME) $(MAKE) -C $(builddir_default)/gdb/doc refcard.dvi refcard.ps |
| 228 |
ifeq ($(with_doc),yes) |
| 229 |
$(MAKE) -C $(builddir_default) info |
| 230 |
$(MAKE) -C $(builddir_default)/gdb/doc pdf html |
| 231 |
endif |
| 232 |
|
| 233 |
override_dh_auto_build-indep: |
| 234 |
|
| 235 |
# GDB's testsuite has historically been flaky and its results haven't |
| 236 |
# been very trustworthy. Instead of running the entire testsuite (and |
| 237 |
# wasting a lot of time and CPU), pick only a subset of tests that are |
| 238 |
# known to be non-flaky. If any of these fail, something is really |
| 239 |
# wrong. |
| 240 |
# |
| 241 |
# This list was inspired by |
| 242 |
# https://sourceware.org/git/?p=builder.git;a=blob;f=builder/master.cfg |
| 243 |
TESTS_NON_FLAKY = \ |
| 244 |
gdb.base/break-always.exp \ |
| 245 |
gdb.base/break-caller-line.exp \ |
| 246 |
gdb.base/break-entry.exp \ |
| 247 |
gdb.base/break.exp \ |
| 248 |
gdb.base/break-fun-addr.exp \ |
| 249 |
gdb.base/break-idempotent.exp \ |
| 250 |
gdb.base/break-include.exp \ |
| 251 |
gdb.base/break-inline.exp \ |
| 252 |
gdb.base/break-main-file-remove-fail.exp \ |
| 253 |
gdb.base/break-on-linker-gcd-function.exp \ |
| 254 |
gdb.base/breakpoint-in-ro-region.exp \ |
| 255 |
gdb.base/breakpoint-shadow.exp \ |
| 256 |
gdb.base/break-probes.exp \ |
| 257 |
gdb.gdb/unittest.exp \ |
| 258 |
gdb.server/unittest.exp |
| 259 |
|
| 260 |
# Test GDB. |
| 261 |
# First and only argument is the build flavour. |
| 262 |
define test-gdb |
| 263 |
$(MAKE) -C $(builddir_$(1))/gdb \ |
| 264 |
check//unix check//native-gdbserver check//native-extended-gdbserver \ |
| 265 |
TESTS="$(TESTS_NON_FLAKY)" |
| 266 |
endef |
| 267 |
|
| 268 |
override_dh_auto_test-arch: |
| 269 |
ifeq ($(run_tests),yes) |
| 270 |
# Run the non-flaky tests. |
| 271 |
# |
| 272 |
# Don't parallelize because things can get racy, and we're not |
| 273 |
# dealing with that many tests anyway. |
| 274 |
$(call test-gdb,default) |
| 275 |
ifeq ($(with_multiarch),yes) |
| 276 |
$(call test-gdb,multiarch) |
| 277 |
endif |
| 278 |
else |
| 279 |
@echo "***Tests disabled: $(run_tests) ***" |
| 280 |
endif |
| 281 |
|
| 282 |
override_dh_auto_test-indep: |
| 283 |
|
| 284 |
execute_after_dh_clean: debian/control |
| 285 |
rm -rf build |
| 286 |
|
| 287 |
if test -f gdb/version.in.backup; then \ |
| 288 |
mv -f gdb/version.in.backup gdb/version.in; \ |
| 289 |
fi |
| 290 |
|
| 291 |
# Prevent gratuitous rebuilds of the BFD documentation, since it |
| 292 |
# updates the copy in the source directory. |
| 293 |
find bfd -name bfd.info\* | xargs --no-run-if-empty touch |
| 294 |
|
| 295 |
override_dh_install-arch: |
| 296 |
# gdb install |
| 297 |
$(MAKE) -C $(builddir_default) install DESTDIR=$(CURDIR)/debian/tmp |
| 298 |
|
| 299 |
# Remove files that we don't ship. |
| 300 |
find $(CURDIR)/debian/tmp/usr/share/locale -type f \ |
| 301 |
\( -name "bfd.mo" -or -name "opcodes.mo" \) -delete |
| 302 |
find $(CURDIR)/debian/tmp/usr/share/locale -type d -empty -delete |
| 303 |
rm -rfv $(CURDIR)/debian/tmp/usr/include/*.h \ |
| 304 |
$(CURDIR)/debian/tmp/usr/include/sim/ \ |
| 305 |
$(CURDIR)/debian/tmp/usr/share/doc/ppc/ \ |
| 306 |
$(CURDIR)/debian/tmp/usr/lib/*.a \ |
| 307 |
$(CURDIR)/debian/tmp/usr/lib/*.la |
| 308 |
ifeq ($(with_doc),no) |
| 309 |
rm -fv $(CURDIR)/debian/tmp/usr/share/info/*.info |
| 310 |
endif |
| 311 |
|
| 312 |
dh_install |
| 313 |
|
| 314 |
install -m 755 debian/gdbtui debian/gdb$(TS)/usr/bin/$(TP)gdbtui |
| 315 |
|
| 316 |
mkdir -p debian/gdb$(TS)/usr/share/man/man1 |
| 317 |
install -m 644 debian/gcore.1 debian/gdb$(TS)/usr/share/man/man1/. |
| 318 |
|
| 319 |
if [ -x debian/tmp/usr/bin/run ]; then \ |
| 320 |
mv debian/tmp/usr/bin/run \ |
| 321 |
debian/gdb$(TS)/usr/bin/$(DEB_TARGET_ALIAS)-run; \ |
| 322 |
fi |
| 323 |
ifeq ($(with_doc),yes) |
| 324 |
if [ -r debian/tmp/usr/share/man/man1/run.1 ]; then \ |
| 325 |
mv debian/tmp/usr/share/man/man1/run.1 \ |
| 326 |
debian/gdb$(TS)/usr/share/man/man1/$(DEB_TARGET_ALIAS)-run.1; \ |
| 327 |
fi |
| 328 |
endif |
| 329 |
|
| 330 |
ifneq ($(GFDL_INVARIANT_FREE),yes) |
| 331 |
mkdir -p debian/gdb$(TS)/usr/share/man/man5 |
| 332 |
install -m 644 $(builddir_default)/gdb/doc/gdbinit.5 \ |
| 333 |
debian/gdb$(TS)/usr/share/man/man5/. |
| 334 |
install -m 644 $(builddir_default)/gdb/doc/gdb.1 \ |
| 335 |
debian/gdb$(TS)/usr/share/man/man1/. |
| 336 |
install -m 644 $(builddir_default)/gdb/doc/gdb-add-index.1 \ |
| 337 |
debian/gdb$(TS)/usr/share/man/man1/. |
| 338 |
endif |
| 339 |
|
| 340 |
ifneq ($(DEB_CROSS),yes) |
| 341 |
# Only ship a global gdbinit for the native GDB. |
| 342 |
mkdir -p debian/gdb$(TS)/etc/gdb/gdbinit.d |
| 343 |
install -m 644 debian/gdbinit debian/gdb$(TS)/etc/gdb/ |
| 344 |
# Likewise gdb-add-index |
| 345 |
mv -v $(CURDIR)/debian/tmp/usr/bin/gdb-add-index debian/gdb$(TS)/usr/bin/gdb-add-index |
| 346 |
endif |
| 347 |
|
| 348 |
ifeq ($(with_multiarch),yes) |
| 349 |
# gdb-multiarch install |
| 350 |
mkdir -p debian/gdb-multiarch/usr/bin |
| 351 |
install -m 755 $(builddir_multiarch)/gdb/gdb debian/gdb-multiarch/usr/bin/gdb-multiarch |
| 352 |
endif |
| 353 |
|
| 354 |
ifneq (,$(filter $(DEB_HOST_ARCH),$(LIBINPROCTRACE_AVAILABLE_ARCHITECTURES))) |
| 355 |
# libinproctrace (gdbserver) install |
| 356 |
mkdir -p debian/gdbserver/usr/lib |
| 357 |
mv -v $(CURDIR)/debian/tmp/usr/lib/libinproctrace.so debian/gdbserver/usr/lib/ |
| 358 |
endif |
| 359 |
|
| 360 |
ifneq ($(GFDL_INVARIANT_FREE),yes) |
| 361 |
mkdir -p debian/gdbserver/usr/share/man/man1 |
| 362 |
install -m 644 $(builddir_default)/gdb/doc/gdbserver.1 \ |
| 363 |
debian/gdbserver/usr/share/man/man1/. |
| 364 |
endif |
| 365 |
|
| 366 |
ifeq ($(with_doc),yes) |
| 367 |
mkdir -p debian/gdb-doc/usr/share/info |
| 368 |
install -m 644 debian/tmp/usr/share/info/gdb.info debian/gdb-doc/usr/share/info/. |
| 369 |
install -m 644 debian/tmp/usr/share/info/stabs.info debian/gdb-doc/usr/share/info/. |
| 370 |
|
| 371 |
$(MAKE) -C $(builddir_default)/gdb/doc DESTDIR=$(CURDIR)/debian/gdb-doc \ |
| 372 |
pdfdir=/usr/share/doc/gdb-doc/pdf \ |
| 373 |
htmldir=/usr/share/doc/gdb-doc/html \ |
| 374 |
install-html install-pdf |
| 375 |
|
| 376 |
# This manual documents a long-obsolete facility |
| 377 |
rm -fv debian/gdb-doc/usr/share/info/annota* |
| 378 |
rm -rfv debian/gdb-doc/usr/share/doc/gdb-doc/*/annota* |
| 379 |
|
| 380 |
rm -fv debian/gdb-doc/usr/share/info/dir* |
| 381 |
|
| 382 |
# Symlink stuff into gdb's doc directory |
| 383 |
mkdir -p debian/gdb-doc/usr/share/doc/gdb |
| 384 |
ln -s ../gdb-doc/html debian/gdb-doc/usr/share/doc/gdb/html |
| 385 |
ln -s ../gdb-doc/pdf debian/gdb-doc/usr/share/doc/gdb/pdf |
| 386 |
endif |
| 387 |
|
| 388 |
override_dh_install-indep: |
| 389 |
# gdb-source install |
| 390 |
mkdir -p debian/gdb-source/usr/src |
| 391 |
mkdir -p $(builddir_source) |
| 392 |
tar --exclude build --exclude stamps --exclude .git -cf - . \ |
| 393 |
| (cd $(builddir_source) && tar -xf -) |
| 394 |
cd $(builddir_source) && debian/rules clean |
| 395 |
cd $(dir $(builddir_source)) \ |
| 396 |
&& tar cfJ $(CURDIR)/debian/gdb-source/usr/src/gdb.tar.xz \ |
| 397 |
--format=gnu \ |
| 398 |
--mode=755 \ |
| 399 |
--mtime="@$(DEB_TIMESTAMP)" --clamp-mtime \ |
| 400 |
--numeric-owner --owner=0 --group=0 \ |
| 401 |
--sort=name \ |
| 402 |
$(notdir $(builddir_source)) |
| 403 |
|
| 404 |
debian/control: debian/control.in debian/control.doc |
| 405 |
cat debian/control.in \ |
| 406 |
| sed "s/@TS@/$(TS)/g" \ |
| 407 |
> debian/control |
| 408 |
ifeq ($(with_doc),yes) |
| 409 |
cat debian/control.doc >> debian/control |
| 410 |
endif |
| 411 |
ifeq ($(DEB_CROSS),yes) |
| 412 |
sed -i "/Package: gdb-multiarch/,\$$ d" debian/control |
| 413 |
sed "s+/gdb+/$(TP)gdb+g; s+usr/share/$(TP)gdb+usr/share/gdb$(TS)+g" \ |
| 414 |
debian/gdb.install > debian/gdb$(TS).install |
| 415 |
endif |
| 416 |
|
| 417 |
execute_after_dh_installdocs: |
| 418 |
dh_installdocs -pgdb$(TS) \ |
| 419 |
gdb/NEWS gdb/README gdb/doc/refcard.tex \ |
| 420 |
$(builddir_default)/gdb/doc/refcard.dvi \ |
| 421 |
$(builddir_default)/gdb/doc/refcard.ps |