gdb.mk 7.57 KB
Newer Older
1
################################################################################
2
3
4
#
# gdb
#
5
################################################################################
6
7

GDB_VERSION = $(call qstrip,$(BR2_GDB_VERSION))
8
GDB_SITE = $(BR2_GNU_MIRROR)/gdb
Gustavo Zacarias's avatar
Gustavo Zacarias committed
9
GDB_SOURCE = gdb-$(GDB_VERSION).tar.xz
10

11
ifeq ($(BR2_arc),y)
12
GDB_SITE = $(call github,foss-for-synopsys-dwc-arc-processors,binutils-gdb,$(GDB_VERSION))
13
GDB_SOURCE = gdb-$(GDB_VERSION).tar.gz
14
GDB_FROM_GIT = y
15
16
endif

17
18
19
ifeq ($(BR2_microblaze),y)
GDB_SITE = $(call github,Xilinx,gdb,$(GDB_VERSION))
GDB_SOURCE = gdb-$(GDB_VERSION).tar.gz
20
GDB_FROM_GIT = y
21
22
endif

23
GDB_LICENSE = GPL-2.0+, LGPL-2.0+, GPL-3.0+, LGPL-3.0+
24
25
26
27
28
29
30
GDB_LICENSE_FILES = COPYING COPYING.LIB COPYING3 COPYING3.LIB

# We only want gdbserver and not the entire debugger.
ifeq ($(BR2_PACKAGE_GDB_DEBUGGER),)
GDB_SUBDIR = gdb/gdbserver
HOST_GDB_SUBDIR = .
else
31
32
GDB_DEPENDENCIES = ncurses \
	$(if $(BR2_PACKAGE_LIBICONV),libiconv)
33
34
35
endif

# For the host variant, we really want to build with XML support,
36
37
38
# which is needed to read XML descriptions of target architectures. We
# also need ncurses.
HOST_GDB_DEPENDENCIES = host-expat host-ncurses
39

40
41
# Disable building documentation
GDB_MAKE_OPTS += MAKEINFO=true
42
GDB_INSTALL_TARGET_OPTS += MAKEINFO=true DESTDIR=$(TARGET_DIR) install
43
HOST_GDB_MAKE_OPTS += MAKEINFO=true
44
HOST_GDB_INSTALL_OPTS += MAKEINFO=true install
45

46
# Apply the Xtensa specific patches
47
ifneq ($(ARCH_XTENSA_OVERLAY_FILE),)
48
define GDB_XTENSA_OVERLAY_EXTRACT
49
	$(call arch-xtensa-overlay-extract,$(@D),gdb)
50
endef
51
GDB_POST_EXTRACT_HOOKS += GDB_XTENSA_OVERLAY_EXTRACT
52
GDB_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL)
53
HOST_GDB_POST_EXTRACT_HOOKS += GDB_XTENSA_OVERLAY_EXTRACT
54
HOST_GDB_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL)
55
56
endif

57
ifeq ($(GDB_FROM_GIT),y)
58
59
GDB_DEPENDENCIES += host-flex host-bison
HOST_GDB_DEPENDENCIES += host-flex host-bison
60
endif
61

62
63
64
# When gdb sources are fetched from the binutils-gdb repository, they
# also contain the binutils sources, but binutils shouldn't be built,
# so we disable it.
65
GDB_DISABLE_BINUTILS_CONF_OPTS = \
66
67
68
69
	--disable-binutils \
	--disable-ld \
	--disable-gas

70
71
72
73
74
75
76
77
78
GDB_CONF_ENV = \
	ac_cv_type_uintptr_t=yes \
	gt_cv_func_gettext_libintl=yes \
	ac_cv_func_dcgettext=yes \
	gdb_cv_func_sigsetjmp=yes \
	bash_cv_func_strcoll_broken=no \
	bash_cv_must_reinstall_sighandlers=no \
	bash_cv_func_sigsetjmp=present \
	bash_cv_have_mbstate_t=yes \
79
80
81
82
83
84
85
86
	gdb_cv_func_sigsetjmp=yes

# Starting with gdb 7.11, the bundled gnulib tries to use
# rpl_gettimeofday (gettimeofday replacement) due to the code being
# unable to determine if the replacement function should be used or
# not when cross-compiling with uClibc or musl as C libraries. So use
# gl_cv_func_gettimeofday_clobber=no to not use rpl_gettimeofday,
# assuming musl and uClibc have a properly working gettimeofday
87
88
89
90
91
# implementation. It needs to be passed to GDB_CONF_ENV to build
# gdbserver only but also to GDB_MAKE_ENV, because otherwise it does
# not get passed to the configure script of nested packages while
# building gdbserver with full debugger.
GDB_CONF_ENV += gl_cv_func_gettimeofday_clobber=no
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
GDB_MAKE_ENV += gl_cv_func_gettimeofday_clobber=no

# Starting with glibc 2.25, the proc_service.h header has been copied
# from gdb to glibc so other tools can use it. However, that makes it
# necessary to make sure that declaration of prfpregset_t declaration
# is consistent between gdb and glibc. In gdb, however, there is a
# workaround for a broken prfpregset_t declaration in glibc 2.3 which
# uses AC_TRY_RUN to detect if it's needed, which doesn't work in
# cross-compilation. So pass the cache option to configure.
# It needs to be passed to GDB_CONF_ENV to build gdbserver only but
# also to GDB_MAKE_ENV, because otherwise it does not get passed to the
# configure script of nested packages while building gdbserver with full
# debugger.
GDB_CONF_ENV += gdb_cv_prfpregset_t_broken=no
GDB_MAKE_ENV += gdb_cv_prfpregset_t_broken=no
107

108
109
# The shared only build is not supported by gdb, so enable static build for
# build-in libraries with --enable-static.
110
GDB_CONF_OPTS = \
111
112
113
114
	--without-uiout \
	--disable-gdbtk \
	--without-x \
	--disable-sim \
115
	$(GDB_DISABLE_BINUTILS_CONF_OPTS) \
116
117
118
	$(if $(BR2_PACKAGE_GDB_SERVER),--enable-gdbserver) \
	--with-curses \
	--without-included-gettext \
119
120
	--disable-werror \
	--enable-static
121

122
123
124
125
126
127
128
# When gdb is built as C++ application for ARC it segfaults at runtime
# So we pass --disable-build-with-cxx config option to force gdb not to
# be built as C++ app.
ifeq ($(BR2_arc),y)
GDB_CONF_OPTS += --disable-build-with-cxx
endif

129
130
131
132
133
134
# gdb 7.12+ by default builds with a C++ compiler, which doesn't work
# when we don't have C++ support in the toolchain
ifneq ($(BR2_INSTALL_LIBSTDCPP),y)
GDB_CONF_OPTS += --disable-build-with-cxx
endif

135
ifeq ($(BR2_PACKAGE_GDB_TUI),y)
136
GDB_CONF_OPTS += --enable-tui
137
else
138
GDB_CONF_OPTS += --disable-tui
139
140
endif

141
ifeq ($(BR2_PACKAGE_GDB_PYTHON),y)
142
143
GDB_CONF_OPTS += --with-python=$(TOPDIR)/package/gdb/gdb-python-config
GDB_DEPENDENCIES += python
144
else
145
GDB_CONF_OPTS += --without-python
146
147
endif

148
149
ifeq ($(BR2_PACKAGE_EXPAT),y)
GDB_CONF_OPTS += --with-expat
Doug Kehn's avatar
Doug Kehn committed
150
GDB_CONF_OPTS += --with-libexpat-prefix=$(STAGING_DIR)/usr
151
152
153
154
155
GDB_DEPENDENCIES += expat
else
GDB_CONF_OPTS += --without-expat
endif

156
157
ifeq ($(BR2_PACKAGE_XZ),y)
GDB_CONF_OPTS += --with-lzma
158
GDB_CONF_OPTS += --with-liblzma-prefix=$(STAGING_DIR)/usr
159
160
161
162
163
GDB_DEPENDENCIES += xz
else
GDB_CONF_OPTS += --without-lzma
endif

164
165
166
167
168
169
170
ifeq ($(BR2_PACKAGE_ZLIB),y)
GDB_CONF_OPTS += --with-zlib
GDB_DEPENDENCIES += zlib
else
GDB_CONF_OPTS += --without-zlib
endif

171
172
173
174
175
176
177
178
# This removes some unneeded Python scripts and XML target description
# files that are not useful for a normal usage of the debugger.
define GDB_REMOVE_UNNEEDED_FILES
	$(RM) -rf $(TARGET_DIR)/usr/share/gdb
endef

GDB_POST_INSTALL_TARGET_HOOKS += GDB_REMOVE_UNNEEDED_FILES

179
180
181
182
183
184
185
# This installs the gdbserver somewhere into the $(HOST_DIR) so that
# it becomes an integral part of the SDK, if the toolchain generated
# by Buildroot is later used as an external toolchain. We install it
# in debug-root/usr/bin/gdbserver so that it matches what Crosstool-NG
# does.
define GDB_SDK_INSTALL_GDBSERVER
	$(INSTALL) -D -m 0755 $(TARGET_DIR)/usr/bin/gdbserver \
186
		$(HOST_DIR)/$(GNU_TARGET_NAME)/debug-root/usr/bin/gdbserver
187
188
189
190
191
192
endef

ifeq ($(BR2_PACKAGE_GDB_SERVER),y)
GDB_POST_INSTALL_TARGET_HOOKS += GDB_SDK_INSTALL_GDBSERVER
endif

193
194
195
196
# A few notes:
#  * --target, because we're doing a cross build rather than a real
#    host build.
#  * --enable-static because gdb really wants to use libbfd.a
197
HOST_GDB_CONF_OPTS = \
198
	--target=$(GNU_TARGET_NAME) \
Yann E. MORIN's avatar
Yann E. MORIN committed
199
	--enable-static \
200
201
202
203
204
205
	--without-uiout \
	--disable-gdbtk \
	--without-x \
	--enable-threads \
	--disable-werror \
	--without-included-gettext \
206
	--with-curses \
207
	$(GDB_DISABLE_BINUTILS_CONF_OPTS)
208

209
ifeq ($(BR2_PACKAGE_HOST_GDB_TUI),y)
210
HOST_GDB_CONF_OPTS += --enable-tui
211
else
212
HOST_GDB_CONF_OPTS += --disable-tui
213
214
endif

215
ifeq ($(BR2_PACKAGE_HOST_GDB_PYTHON),y)
216
HOST_GDB_CONF_OPTS += --with-python=$(HOST_DIR)/bin/python2
217
HOST_GDB_DEPENDENCIES += host-python
218
else
219
HOST_GDB_CONF_OPTS += --without-python
220
221
endif

222
223
224
225
226
227
228
229
230
231
232
233
234
235
# workaround a bug if in-tree build is used for bfin sim
define HOST_GDB_BFIN_SIM_WORKAROUND
	$(RM) $(@D)/sim/common/tconfig.h
endef

ifeq ($(BR2_PACKAGE_HOST_GDB_SIM),y)
HOST_GDB_CONF_OPTS += --enable-sim
ifeq ($(BR2_bfin),y)
HOST_GDB_PRE_CONFIGURE_HOOKS += HOST_GDB_BFIN_SIM_WORKAROUND
endif
else
HOST_GDB_CONF_OPTS += --disable-sim
endif

236
237
# legacy $arch-linux-gdb symlink
define HOST_GDB_ADD_SYMLINK
238
	cd $(HOST_DIR)/bin && \
239
240
241
242
243
		ln -snf $(GNU_TARGET_NAME)-gdb $(ARCH)-linux-gdb
endef

HOST_GDB_POST_INSTALL_HOOKS += HOST_GDB_ADD_SYMLINK

244
245
HOST_GDB_POST_INSTALL_HOOKS += gen_gdbinit_file

246
247
$(eval $(autotools-package))
$(eval $(host-autotools-package))