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
|
#!/usr/bin/make -f
ALL_BUILDDIR := $(shell pwd)/build
DEB_BUILDDIR := $(ALL_BUILDDIR)/objdir
DEB_DH_INSTALL_SOURCEDIR := $(shell pwd)/debian/tmp
DEB_DH_STRIP_ARGS_GDB := --dbg-package=gdb-dbg
# Override CDBS's default CFLAGS, which also includes -Wall; gdb
# does not handle -Wunused well with -Werror, but defaults to
# -Werror.
DEB_WARNING_FLAGS :=
# This implements the .deb package creation using debhelper.
include /usr/share/cdbs/1/rules/debhelper.mk
# This implements building using a configure script and Makefile.
include /usr/share/cdbs/1/class/autotools.mk
# The top-level configure script fails to pass these down properly ...
export CPPFLAGS
export LDFLAGS
# Always install into debian/tmp, even if we are only building one package.
DEB_DESTDIR := $(shell pwd)/debian/tmp
install = /usr/bin/install -p
# Rather paranoid than sorry. Make the shell exit with an error if an
# untested command fails.
SHELL += -e
DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_GNU_SYSTEM := $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)
DEB_HOST_GNU_CPU := $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
# 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_ARCH := $(shell dpkg-architecture -f \
-a$(GDB_TARGET) -qDEB_HOST_ARCH 2>/dev/null)
DEB_TARGET_GNU_TYPE := $(shell dpkg-architecture -f \
-a$(DEB_TARGET_ARCH) -qDEB_HOST_GNU_TYPE 2>/dev/null)
DEB_TARGET_ALIAS ?= $(DEB_TARGET_GNU_TYPE)
ifneq ($(GDB_TARGET),)
DEB_CONFIGURE_GDB_DATADIR := "\$${prefix}/share/gdb-$(DEB_TARGET_GNU_TYPE)"
DEB_CONFIGURE_PATH_ARGS += --with-gdb-datadir=$(DEB_CONFIGURE_GDB_DATADIR)
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)
CROSS_FORCE = FORCE
else
ifneq (,$(filter $(DEB_HOST_ARCH),i386 powerpc sparc s390))
build64 = yes
CC64 = gcc -m64
CFLAGS64 = $(CFLAGS)
BUILDDIR64 = $(ALL_BUILDDIR)/objdir64
ifeq ($(DEB_HOST_ARCH),i386)
HOST64 = x86_64-linux-gnu
endif
ifeq ($(DEB_HOST_ARCH),powerpc)
HOST64 = powerpc64-linux-gnu
endif
ifeq ($(DEB_HOST_ARCH),sparc)
HOST64 = sparc64-linux-gnu
endif
ifeq ($(DEB_HOST_ARCH),s390)
HOST64 = s390x-linux-gnu
endif
endif
endif
distribution := $(shell lsb_release -is)
deb_version := $(shell dpkg-parsechangelog | awk '/^Version:/ {print $$2}')
BUILDDIRMULTIARCH = $(ALL_BUILDDIR)/objdir-multiarch
run_tests := yes
ifneq (,$(filter nocheck, $(DEB_BUILD_OPTIONS)))
run_tests := no
endif
ifeq (,$(findstring linux, $(DEB_HOST_GNU_SYSTEM)))
run_tests := no
endif
ifeq ($(DEB_HOST_GNU_CPU),ia64)
arch_config_args := --with-libunwind-ia64
endif
ifdef GDB_TARGET
run_tests := no
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
endif
INSTALL = $(install)
export INSTALL
# We pass srcdir explicitly to avoid an extra '/.' at the end of it. That
# causes a harmless, but ugly, testsuite failure in maint.exp.
EXTRA_FLAGS := --disable-gdbtk --disable-shared \
--with-pkgversion='$(distribution) $(deb_version)' \
--srcdir=$(shell pwd) \
--disable-readline --with-system-readline --with-expat \
--without-zlib --without-lzma \
--without-guile \
$(arch_config_args) --build=$(DEB_BUILD_GNU_TYPE)
# Debian does not include 64-bit Python packages, so --with-python
# is here rather than in EXTRA_FLAGS.
DEB_CONFIGURE_EXTRA_FLAGS := --host=$(DEB_HOST_GNU_TYPE) $(EXTRA_FLAGS) \
--enable-tui --with-python=python2 --without-babeltrace \
--with-zlib --with-lzma
# --with-babeltrace
# 64-bit flags
DEB_CONFIGURE_FLAGS_64 := --host=$(HOST64) $(EXTRA_FLAGS) \
--enable-tui
# 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 \
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 \
ppc64-linux-gnu \
s390-linux-gnu \
s390x-linux-gnu \
sh-linux-gnu \
sh64-linux-gnu \
sparc-linux-gnu \
sparc64-linux-gnu \
x86_64-linux-gnu \
m32r-linux-gnu \
spu
# broken, see https://launchpad.net/bugs/1233185
#MULTIARCH_TARGETS := all
# --enable-targets=$(MULTIARCH_TARGETS) \
# multiarch flags
DEB_CONFIGURE_FLAGS_MULTIARCH := $(DEB_CONFIGURE_EXTRA_FLAGS) \
--enable-64-bit-bfd \
--enable-targets=`set -- $(MULTIARCH_TARGETS); IFS=,; echo "$$*"` \
--disable-sim
# Minimal flags
DEB_CONFIGURE_FLAGS_MIN := --host=$(DEB_HOST_GNU_TYPE) $(EXTRA_FLAGS) \
--disable-tui --without-python --without-babeltrace
# Support parallel=<n> in DEB_BUILD_OPTIONS (see #209008)
COMMA = ,
ifneq (,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
NJOBS := -j $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
endif
DEB_MAKE_BUILD_TARGET = $(NJOBS) all
BUILDDIRSOURCE := $(ALL_BUILDDIR)/gdb
BUILDDIRMIN := $(ALL_BUILDDIR)/gdb-minimal
# This should probably be common-post-build-arch, but that runs during
# install, under fakeroot, in CDBS 0.4.21.
build/gdb$(TS):: check-stamp
$(MAKE) -C $(DEB_BUILDDIR) info
$(MAKE) -C $(DEB_BUILDDIR)/gdb/doc refcard.dvi refcard.ps
build/gdb64:: build64-stamp
build64-stamp:
mkdir -p $(BUILDDIR64)
cd $(BUILDDIR64) && CC="$(CC64)" CFLAGS="$(CFLAGS64)" AR=ar \
$(shell pwd)/configure $(DEB_CONFIGURE_NORMAL_ARGS) $(DEB_CONFIGURE_DEBUG_ARGS) $(DEB_CONFIGURE_FLAGS_64)
cd $(BUILDDIR64) && $(DEB_MAKE_ENVVARS) $(MAKE) $(NJOBS)
touch $@
build/gdb-multiarch:: build-multiarch-stamp
build-multiarch-stamp:
mkdir -p $(BUILDDIRMULTIARCH)
cd $(BUILDDIRMULTIARCH) && CFLAGS="$(CFLAGS)" \
$(shell pwd)/configure $(DEB_CONFIGURE_NORMAL_ARGS) $(DEB_CONFIGURE_DEBUG_ARGS) $(DEB_CONFIGURE_FLAGS_MULTIARCH)
cd $(BUILDDIRMULTIARCH) && $(DEB_MAKE_ENVVARS) $(MAKE) $(NJOBS)
touch $@
build/gdb-minimal:: build-minimal-stamp
build-minimal-stamp:
mkdir -p $(BUILDDIRMIN)
cd $(BUILDDIRMIN) && CFLAGS="$(CFLAGS)" \
$(shell pwd)/configure $(DEB_CONFIGURE_NORMAL_ARGS) $(DEB_CONFIGURE_DEBUG_ARGS) $(DEB_CONFIGURE_FLAGS_MIN)
cd $(BUILDDIRMIN) && $(DEB_MAKE_ENVVARS) $(MAKE) $(NJOBS)
touch $@
check-stamp:
ifeq ($(run_tests),yes)
$(MAKE) $(NJOBS) -C $(DEB_BUILDDIR)/gdb check \
|| echo "**Tests failed, of course.**"
endif
touch $@
clean::
rm -f check-stamp build64-stamp build-multiarch-stamp
rm -rf $(ALL_BUILDDIR)
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
binary-post-install/gdb$(TS) ::
if [ -x debian/tmp/usr/bin/run ]; then \
mv debian/tmp/usr/bin/run \
debian/gdb$(TS)/usr/bin/$(DEB_TARGET_ALIAS)-run; \
mv debian/tmp/usr/share/man/man1/run.1 \
debian/gdb$(TS)/usr/share/man/man1/$(DEB_TARGET_ALIAS)-run.1; \
fi
ifeq ($(run_tests),yes)
install -d debian/gdb$(TS)/usr/share/doc/gdb
install -m 644 $(DEB_BUILDDIR)/gdb/testsuite/gdb.sum \
debian/gdb$(TS)/usr/share/doc/gdb/check.log
endif
ifneq ($(DEB_CROSS),yes)
# Only ship a global gdbinit for the native GDB.
install -d debian/gdb$(TS)/etc/gdb
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
binary-post-install/gdb64 ::
install -d debian/gdb64/usr/bin
install -s -m 755 $(BUILDDIR64)/gdb/gdb debian/gdb64/usr/bin/gdb64
rm -rf debian/gdb64/usr/share/doc/gdb64
ln -s gdb debian/gdb64/usr/share/doc/gdb64
binary-post-install/gdb-multiarch ::
install -d debian/gdb-multiarch/usr/bin
install -s -m 755 $(BUILDDIRMULTIARCH)/gdb/gdb debian/gdb-multiarch/usr/bin/gdb-multiarch
rm -rf debian/gdb-multiarch/usr/share/doc/gdb-multiarch
ln -s gdb debian/gdb-multiarch/usr/share/doc/gdb-multiarch
binary-post-install/gdb-minimal ::
install -d debian/gdb-minimal/usr/bin
$(INSTALL) -m 755 -o root -g root \
$(BUILDDIRMIN)/gdb/gdb debian/gdb-minimal/usr/bin/gdb
$(INSTALL) -m 755 -o root -g root \
$(BUILDDIRMIN)/gdb/gcore debian/gdb-minimal/usr/bin/gcore
# Only ship a global gdbinit for the native GDB.
install -d debian/gdb-minimal/etc/gdb
install -m 644 debian/gdbinit debian/gdb-minimal/etc/gdb/
binary-post-install/gdb-source ::
install -d debian/gdb-source/usr/src
mkdir -p $(BUILDDIRSOURCE)
tar --exclude build --exclude .git -cf - . \
| (cd $(BUILDDIRSOURCE) && tar -xf -)
cd $(BUILDDIRSOURCE) && debian/rules clean
cd $(dir $(BUILDDIRSOURCE)) \
&& tar -cjf $(shell pwd)/debian/gdb-source/usr/src/gdb.tar.bz2 \
$(notdir $(BUILDDIRSOURCE))
debian/control:: debian/control.in $(CROSS_FORCE)
cat debian/control.in \
| sed "s/@TS@/$(TS)/g" \
> debian/control
ifeq ($(DEB_CROSS),yes)
sed -i "/Package: gdb64/,\$$ d" -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
# The default changelog is the top level one, which is useless.
DEB_INSTALL_CHANGELOGS_ALL =
DEB_INSTALL_DOCS_gdb$(TS) = gdb/NEWS gdb/README gdb/doc/refcard.tex \
$(DEB_BUILDDIR)/gdb/doc/refcard.dvi \
$(DEB_BUILDDIR)/gdb/doc/refcard.ps \
gdb/contrib/
DEB_INSTALL_CHANGELOGS_gdb$(TS) = gdb/ChangeLog
ifneq ($(DEB_CROSS),yes)
DEB_INSTALL_MANPAGES_gdb$(TS) = debian/gcore.1
endif
DEB_INSTALL_DOCS_gdbserver = gdb/gdbserver/README
DEB_INSTALL_CHANGELOGS_gdbserver = gdb/gdbserver/ChangeLog
DEB_INSTALL_DOCS_gdb-minimal = $(DEB_INSTALL_DOCS_gdb$(TS))
DEB_INSTALL_CHANGELOGS_gdb-minimal = -XChangeLog
.PHONY: FORCE
FORCE:
|