1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
|
#!/usr/bin/make -f
SPACE := $(EMPTY) $(EMPTY)
COMMA := ,
include /usr/share/dpkg/architecture.mk
SOURCE_DATE_EPOCH ?= $(shell dpkg-parsechangelog -SDate | date -f- +%s)
deb_version := $(shell dpkg-parsechangelog | awk '/^Version:/ {print $$2}')
# The top-level configure script fails to pass these down properly ...
export CPPFLAGS
export LDFLAGS
CPPFLAGS += -fPIC
install = /usr/bin/install -p
# Rather paranoid than sorry. Make the shell exit with an error if an
# untested command fails.
SHELL += -e
INSTALL = $(install)
export INSTALL
distribution := $(shell lsb_release -is)
derivative := $(shell if dpkg-vendor --derives-from Ubuntu; then echo Ubuntu; \
elif dpkg-vendor --derives-from Debian; then echo Debian; \
else echo Unknown; fi)
# Support parallel=<n> in DEB_BUILD_OPTIONS (see #209008)
ifneq (,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
NJOBS := -j $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
endif
ifneq (,$(filter nodoc, $(DEB_BUILD_PROFILES)))
nodoc_profile = yes
endif
# Don't include docs with GFDL invariant sections
GFDL_INVARIANT_FREE := yes
ifeq ($(derivative),Ubuntu)
GFDL_INVARIANT_FREE := no
FORCE_CONTROL = FORCE
endif
ifneq ($(GFDL_INVARIANT_FREE),yes)
ifneq ($(nodoc_profile),yes)
with_doc := yes
endif
endif
# ---------- settings for cross builds ----------
# Cross configuration support. Check for an environment variable
# $GDB_TARGET, or a file debian/target.
ifndef GDB_TARGET
DEBIAN_TARGET_FILE := $(strip $(shell cat debian/target 2>/dev/null))
ifneq ($(DEBIAN_TARGET_FILE),)
GDB_TARGET := $(DEBIAN_TARGET_FILE)
endif
endif
DEB_TARGET_ALIAS ?= $(DEB_TARGET_GNU_TYPE)
ifneq ($(GDB_TARGET),)
configure_target_args = --with-gdb-datadir="\$${prefix}/share/gdb-$(DEB_TARGET_GNU_TYPE)"
endif
ifeq ($(DEB_TARGET_ARCH),)
$(error GDB_TARGET value "$(GDB_TARGET)" is not a valid Debian architecture)
endif
ifdef GDB_TARGET
DEB_CROSS = yes
# TP: Target Prefix. Used primarily as a prefix for cross tool
# names (e.g. powerpc-linux-gcc).
# TS: Target Suffix. Used primarily at the end of cross compiler
# package names (e.g. gcc-powerpc).
TP = $(DEB_TARGET_ALIAS)-
TS = -$(DEB_TARGET_ALIAS)
FORCE_CONTROL = FORCE
endif
# ---------- configure options, architecture specific ----------
ifeq ($(DEB_HOST_GNU_CPU),ia64)
arch_config_args := --with-libunwind-ia64
endif
arch_config_args += --with-babeltrace
# Enable Intel Processor Trace (PT) on Linux x86 platform
ifneq (,$(filter $(DEB_HOST_ARCH),amd64 i386))
arch_config_args += --with-intel-pt
endif
ifdef GDB_TARGET
arch_config_args += --program-prefix=$(TP) \
--target=$(DEB_TARGET_ALIAS) --with-sysroot=/usr/$(DEB_TARGET_ALIAS)
else
# To avoid file conflicts, only enable the global gdbinit file for native
# debuggers.
arch_config_args += --with-system-gdbinit=/etc/gdb/gdbinit --with-system-gdbinit-dir=/etc/gdb/gdbinit.d
endif
# ---------- running tests? ----------
run_tests := yes
ifneq (,$(filter nocheck, $(DEB_BUILD_OPTIONS)))
run_tests := disabled by DEB_BUILD_OPTIONS
endif
ifeq (,$(findstring linux, $(DEB_HOST_GNU_SYSTEM)))
run_tests := only enabled for linux targets
endif
ifdef GDB_TARGET
run_tests := disabled for cross builds
endif
# ---------- configure options, for all variants ----------
variants = default multiarch minimal
ifeq ($(derivative),Ubuntu)
variants = default multiarch
endif
# We pass srcdir explicitly to avoid an extra '/.' at the end of it. That
# causes a harmless, but ugly, testsuite failure in maint.exp.
common_configure_args = \
--build=$(DEB_BUILD_GNU_TYPE) \
--host=$(DEB_HOST_GNU_TYPE) \
--prefix=/usr \
--libexecdir="\$${prefix}/lib/gdb" \
--disable-maintainer-mode \
--disable-dependency-tracking \
--disable-silent-rules \
--disable-gdbtk \
--disable-shared \
--with-pkgversion='$(distribution)___$(deb_version)' \
--srcdir=$(CURDIR) \
--disable-readline \
--with-system-readline \
--with-expat \
--with-system-zlib \
--without-guile \
--without-babeltrace \
$(if $(filter linux, $(DEB_HOST_ARCH_OS)),--with-debuginfod) \
$(arch_config_args) \
default_configure_args = \
$(common_configure_args) \
$(configure_target_args) \
--enable-tui \
--with-lzma \
--with-python=python3 \
--with-xxhash \
--with-mpfr \
# multiarch targets; this is taken from the binutils-multiarch package but
# doesn't seem like a terribly nice list; see
# <20110117211551.GA7216@bee.dooz.org> for discussion -- locally updated
MULTIARCH_TARGETS := \
aarch64-linux-gnu \
alpha-linux-gnu \
arm-linux-gnu \
arm-linux-gnueabi \
arm-linux-gnueabihf \
arm-none-eabi \
hppa-linux-gnu \
i686-linux-gnu \
ia64-linux-gnu \
m68k-linux-gnu \
m68k-rtems \
mips-linux-gnu \
mipsel-linux-gnu \
mips64-linux-gnu \
mips64el-linux-gnu \
powerpc-linux-gnu \
powerpc-linux-gnuspe \
powerpc64le-linux-gnu \
powerpc64-linux-gnu \
ppc64-linux-gnu \
riscv32-linux-gnu \
riscv64-linux-gnu \
s390-linux-gnu \
s390x-linux-gnu \
sh-linux-gnu \
sparc-linux-gnu \
sparc64-linux-gnu \
x86_64-linux-gnu \
x86_64-linux-gnux32 \
m32r-linux-gnu
# broken, see https://launchpad.net/bugs/1233185
#MULTIARCH_TARGETS := all
# --enable-targets=$(MULTIARCH_TARGETS) \
# multiarch flags
multiarch_configure_args = \
$(default_configure_args) \
--enable-64-bit-bfd \
--enable-targets=$(subst $(SPACE),$(COMMA),$(MULTIARCH_TARGETS)) \
--disable-sim \
--enable-obsolete
# Minimal flags
minimal_configure_args = \
$(common_configure_args) \
--disable-tui \
--without-python \
--without-babeltrace \
--disable-source-highlight \
--without-mpfr \
# ---------- configure and build targets ----------
builddir_default = build/default
builddir_minimal = build/minimal
builddir_multiarch = build/multiarch
builddir_source = build/gdb
stamps/configure-%:
@mkdir -p stamps
rm -rf $(builddir_$*)
mkdir -p $(builddir_$*)
@echo "gdb-$*: configured with: $(subst ___, ,$(foreach i,$($*_configure_args),$(i)\n\t))"
cd $(builddir_$*) && CFLAGS="$(CFLAGS)" \
../../configure $(subst ___,$(SPACE),$($*_configure_args))
touch $@
stamps/build-%: stamps/configure-%
V=1 $(MAKE) -C $(builddir_$*) $(NJOBS)
$(if $(filter yes, $(nodoc_profile)),, \
$(if $(filter default, $*), \
$(MAKE) -C $(builddir_default) info))
$(if $(filter yes, $(nodoc_profile)),, \
$(if $(filter default, $*), \
$(MAKE) -C $(builddir_$*)/gdb/doc refcard.dvi refcard.ps))
touch $@
stamps/check: stamps/build-default
ifeq ($(run_tests),yes)
$(MAKE) $(NJOBS) -C $(builddir_default)/gdb check \
|| echo "*** Tests failed, of course. ***"
else
@echo "***Tests disabled: $(run_tests) ***"
endif
touch $@
stamps/build-doc: stamps/build-default
$(MAKE) -C $(builddir_default)/gdb/doc pdf html
# ---------- installation and packaging targets ----------
clean: debian/control
dh_clean
rm -rf stamps build
rm -f debian/files
if test -f gdb/version.in.backup; then \
mv -f gdb/version.in.backup gdb/version.in; \
fi
# # For snapshots this is appropriate; careful of release tarballs
# # which include .gmo files.
# find -type f -name '*.gmo' | xargs rm -f
# Prevent gratuitous rebuilds of the BFD documentation, since it
# updates the copy in the source directory.
find bfd -name bfd.info\* | xargs --no-run-if-empty touch
install-pre:
dh_prep
install: install-pre
: # gdb install
$(MAKE) -C $(builddir_default) install DESTDIR=$(CURDIR)/debian/tmp
rm -rf debian/gdb-doc/usr/share/man
dh_install
install -d debian/gdb$(TS)/usr/share/man/man1; \
install -m 644 debian/gcore.1 debian/gdb$(TS)/usr/share/man/man1/.
if [ -x debian/tmp/usr/bin/run ]; then \
mv debian/tmp/usr/bin/run \
debian/gdb$(TS)/usr/bin/$(DEB_TARGET_ALIAS)-run; \
fi
if [ -r debian/tmp/usr/share/man/man1/run.1 ]; then \
mv debian/tmp/usr/share/man/man1/run.1 \
debian/gdb$(TS)/usr/share/man/man1/$(DEB_TARGET_ALIAS)-run.1; \
fi
ifneq ($(GFDL_INVARIANT_FREE),yes)
install -d debian/gdb$(TS)/usr/share/man/man5
install -m 644 $(builddir_default)/gdb/doc/gdbinit.5 \
debian/gdb$(TS)/usr/share/man/man5/.
install -m 644 $(builddir_default)/gdb/doc/gdb.1 \
debian/gdb$(TS)/usr/share/man/man1/.
install -m 644 $(builddir_default)/gdb/doc/gdb-add-index.1 \
debian/gdb$(TS)/usr/share/man/man1/.
endif
ifeq ($(run_tests),yes)
ifneq (,$(wildcard $(builddir_default)/gdb/testsuite/gdb.sum))
install -d debian/gdb$(TS)/usr/share/doc/gdb
install -m 644 $(builddir_default)/gdb/testsuite/gdb.sum \
debian/gdb$(TS)/usr/share/doc/gdb/check.log
endif
endif
ifneq ($(DEB_CROSS),yes)
: # Only ship a global gdbinit for the native GDB.
install -d debian/gdb$(TS)/etc/gdb
install -d debian/gdb$(TS)/etc/gdb/gdbinit.d
install -m 644 debian/gdbinit debian/gdb$(TS)/etc/gdb/
: # Likewise gdb-add-index
install -m 755 gdb/contrib/gdb-add-index.sh debian/gdb$(TS)/usr/bin/gdb-add-index
endif
rm -f debian/gdb$(TS)/usr/bin/$(TP)gdbtui
install -m 755 debian/gdbtui debian/gdb$(TS)/usr/bin/$(TP)gdbtui
: # gdb-multiarch install
install -d debian/gdb-multiarch/usr/bin
install -m 755 $(builddir_multiarch)/gdb/gdb debian/gdb-multiarch/usr/bin/gdb-multiarch
: # gdbserver install
install -d debian/gdbserver/usr/lib
: # This file is only built on some arches (x86 ones, so far)
-install debian/tmp/usr/lib/libinproctrace.so debian/gdbserver/usr/lib/
ifneq ($(GFDL_INVARIANT_FREE),yes)
install -d debian/gdbserver/usr/share/man/man1
install -m 644 $(builddir_default)/gdb/doc/gdbserver.1 \
debian/gdbserver/usr/share/man/man1/.
endif
ifneq (,$(filter minimal, $(variants)))
: # gdb-minimal install
install -d debian/gdb-minimal/usr/bin
$(INSTALL) -m 755 -o root -g root \
$(builddir_minimal)/gdb/gdb debian/gdb-minimal/usr/bin/gdb
$(INSTALL) -m 755 -o root -g root \
$(builddir_minimal)/gdb/gcore debian/gdb-minimal/usr/bin/gcore
endif
: # Only ship a global gdbinit for the native GDB.
install -d debian/gdb-minimal/etc/gdb
install -d debian/gdb-minimal/etc/gdb/gdbinit.d
install -m 644 debian/gdbinit debian/gdb-minimal/etc/gdb/
ifeq ($(with_doc),yes)
install -d debian/gdb-doc/usr/share/info
install -m 644 debian/tmp/usr/share/info/gdb.info debian/gdb-doc/usr/share/info/.
install -m 644 debian/tmp/usr/share/info/stabs.info debian/gdb-doc/usr/share/info/.
$(MAKE) -C $(builddir_default)/gdb/doc DESTDIR=$(CURDIR)/debian/gdb-doc \
pdfdir=/usr/share/doc/gdb-doc/pdf \
htmldir=/usr/share/doc/gdb-doc/html \
install-html install-pdf
: # This manual documents a long-obsolete facility
rm -f debian/gdb-doc/usr/share/info/annota*
rm -rf debian/gdb-doc/usr/share/doc/gdb-doc/*/annota*
rm -f debian/gdb-doc/usr/share/info/dir*
: # Symlink stuff into gdb's doc directory
install -d debian/gdb-doc/usr/share/doc/gdb
ln -s ../gdb-doc/html debian/gdb-doc/usr/share/doc/gdb/html
ln -s ../gdb-doc/pdf debian/gdb-doc/usr/share/doc/gdb/pdf
endif
install-indep: install-pre
: # gdb-source install
install -d debian/gdb-source/usr/src
mkdir -p $(builddir_source)
tar --exclude build --exclude stamps --exclude .git -cf - . \
| (cd $(builddir_source) && tar -xf -)
cd $(builddir_source) && debian/rules clean
cd $(dir $(builddir_source)) \
&& tar cfJ $(CURDIR)/debian/gdb-source/usr/src/gdb.tar.xz \
--format=gnu \
--mode=755 \
--mtime="@$(SOURCE_DATE_EPOCH)" --clamp-mtime \
--numeric-owner --owner=0 --group=0 \
--sort=name \
$(notdir $(builddir_source))
debian/control: debian/control.in debian/control.minimal debian/control.doc $(FORCE_CONTROL)
cat debian/control.in \
| sed "s/@TS@/$(TS)/g" \
> debian/control
ifneq (,$(filter minimal, $(variants)))
cat debian/control.minimal >> debian/control
endif
ifeq ($(with_doc),yes)
cat debian/control.doc >> debian/control
endif
ifeq ($(DEB_CROSS),yes)
sed -i "/Package: gdb-multiarch/,\$$ d" debian/control
sed "s+/gdb+/$(TP)gdb+g; s+usr/share/$(TP)gdb+usr/share/gdb$(TS)+g" \
debian/gdb.install > debian/gdb$(TS).install
endif
gdb_substvars =
ifeq (,$(filter minimal, $(variants)))
gdb_substvars = -Vgdb:minimal='gdb-minimal (= $${binary:Version})'
endif
build-indep: $(foreach v,$(variants),stamps/build-$(v)) $(if $(filter yes,$(with_doc)),stamps/build-doc)
build-arch: $(foreach v,$(variants),stamps/build-$(v)) stamps/check
build: build-arch build-indep
binary-indep: build-indep install install-indep
dh_installdocs -i
dh_installchangelogs -i
dh_strip -i
dh_compress -i -X.pdf
dh_fixperms -i
dh_installdeb -i
dh_shlibdeps -i
dh_gencontrol -i
dh_md5sums -i
dh_builddeb -i
binary-arch: build-arch install
dh_installdocs -pgdb$(TS) \
gdb/NEWS gdb/README gdb/doc/refcard.tex \
$(if $(filter yes, $(nodoc_profile)),, \
$(builddir_default)/gdb/doc/refcard.dvi \
$(builddir_default)/gdb/doc/refcard.ps) \
gdb/contrib/
dh_installchangelogs -pgdb$(TS) gdb/ChangeLog
ifneq (,$(filter minimal, $(variants)))
dh_installdocs -pgdb-minimal \
gdb/NEWS gdb/README gdb/doc/refcard.tex \
$(if $(filter yes, $(nodoc_profile)),, \
$(builddir_default)/gdb/doc/refcard.dvi \
$(builddir_default)/gdb/doc/refcard.ps)
dh_installchangelogs -pgdb-minimal -XChangeLog
endif
dh_installdocs -pgdbserver gdbserver/README
dh_installchangelogs -pgdbserver gdbserver/ChangeLog
install -d debian/gdb-multiarch/usr/share/doc
ln -s gdb debian/gdb-multiarch/usr/share/doc/gdb-multiarch
dh_dwz -a
dh_strip -pgdb$(TS) --dbgsym-migration='gdb-dbg (<< 7.12-1~)'
dh_strip -a -Ngdb$(TS)
dh_compress -a
dh_fixperms -a
dh_installdeb -a
dh_shlibdeps -a
dh_gencontrol -a -- $(gdb_substvars)
dh_md5sums -a
dh_builddeb -a
binary: binary-indep binary-arch
.PHONY: build build-arch build-indep clean binary-indep binary-arch binary install
.PHONY: FORCE
FORCE:
|