1 ################################################################################
5 ################################################################################
7 GDB_VERSION = $(call qstrip,$(BR2_GDB_VERSION))
8 GDB_SITE = $(BR2_GNU_MIRROR)/gdb
9 GDB_SOURCE = gdb-$(GDB_VERSION).tar.xz
12 GDB_SITE = $(call github,foss-for-synopsys-dwc-arc-processors,binutils-gdb,$(GDB_VERSION))
13 GDB_SOURCE = gdb-$(GDB_VERSION).tar.gz
17 GDB_LICENSE = GPL-2.0+, LGPL-2.0+, GPL-3.0+, LGPL-3.0+
18 GDB_LICENSE_FILES = COPYING COPYING.LIB COPYING3 COPYING3.LIB
20 # We only want gdbserver and not the entire debugger.
21 ifeq ($(BR2_PACKAGE_GDB_DEBUGGER),)
22 GDB_SUBDIR = gdb/gdbserver
25 GDB_DEPENDENCIES = ncurses \
26 $(if $(BR2_PACKAGE_LIBICONV),libiconv)
29 # For the host variant, we really want to build with XML support,
30 # which is needed to read XML descriptions of target architectures. We
32 HOST_GDB_DEPENDENCIES = host-expat host-ncurses
34 # Disable building documentation
35 GDB_MAKE_OPTS += MAKEINFO=true
36 GDB_INSTALL_TARGET_OPTS += MAKEINFO=true DESTDIR=$(TARGET_DIR) install
37 HOST_GDB_MAKE_OPTS += MAKEINFO=true
38 HOST_GDB_INSTALL_OPTS += MAKEINFO=true install
40 # Apply the Xtensa specific patches
41 ifneq ($(ARCH_XTENSA_OVERLAY_FILE),)
42 define GDB_XTENSA_OVERLAY_EXTRACT
43 $(call arch-xtensa-overlay-extract,$(@D),gdb)
45 GDB_POST_EXTRACT_HOOKS += GDB_XTENSA_OVERLAY_EXTRACT
46 GDB_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL)
47 HOST_GDB_POST_EXTRACT_HOOKS += GDB_XTENSA_OVERLAY_EXTRACT
48 HOST_GDB_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL)
51 ifeq ($(GDB_FROM_GIT),y)
52 GDB_DEPENDENCIES += host-flex host-bison
53 HOST_GDB_DEPENDENCIES += host-flex host-bison
56 # When gdb sources are fetched from the binutils-gdb repository, they
57 # also contain the binutils sources, but binutils shouldn't be built,
59 GDB_DISABLE_BINUTILS_CONF_OPTS = \
65 ac_cv_type_uintptr_t=yes \
66 gt_cv_func_gettext_libintl=yes \
67 ac_cv_func_dcgettext=yes \
68 gdb_cv_func_sigsetjmp=yes \
69 bash_cv_func_strcoll_broken=no \
70 bash_cv_must_reinstall_sighandlers=no \
71 bash_cv_func_sigsetjmp=present \
72 bash_cv_have_mbstate_t=yes \
73 gdb_cv_func_sigsetjmp=yes
75 # Starting with gdb 7.11, the bundled gnulib tries to use
76 # rpl_gettimeofday (gettimeofday replacement) due to the code being
77 # unable to determine if the replacement function should be used or
78 # not when cross-compiling with uClibc or musl as C libraries. So use
79 # gl_cv_func_gettimeofday_clobber=no to not use rpl_gettimeofday,
80 # assuming musl and uClibc have a properly working gettimeofday
81 # implementation. It needs to be passed to GDB_CONF_ENV to build
82 # gdbserver only but also to GDB_MAKE_ENV, because otherwise it does
83 # not get passed to the configure script of nested packages while
84 # building gdbserver with full debugger.
85 GDB_CONF_ENV += gl_cv_func_gettimeofday_clobber=no
86 GDB_MAKE_ENV += gl_cv_func_gettimeofday_clobber=no
88 # Starting with glibc 2.25, the proc_service.h header has been copied
89 # from gdb to glibc so other tools can use it. However, that makes it
90 # necessary to make sure that declaration of prfpregset_t declaration
91 # is consistent between gdb and glibc. In gdb, however, there is a
92 # workaround for a broken prfpregset_t declaration in glibc 2.3 which
93 # uses AC_TRY_RUN to detect if it's needed, which doesn't work in
94 # cross-compilation. So pass the cache option to configure.
95 # It needs to be passed to GDB_CONF_ENV to build gdbserver only but
96 # also to GDB_MAKE_ENV, because otherwise it does not get passed to the
97 # configure script of nested packages while building gdbserver with full
99 GDB_CONF_ENV += gdb_cv_prfpregset_t_broken=no
100 GDB_MAKE_ENV += gdb_cv_prfpregset_t_broken=no
102 # The shared only build is not supported by gdb, so enable static build for
103 # build-in libraries with --enable-static.
109 $(GDB_DISABLE_BINUTILS_CONF_OPTS) \
110 $(if $(BR2_PACKAGE_GDB_SERVER),--enable-gdbserver) \
112 --without-included-gettext \
116 # When gdb is built as C++ application for ARC it segfaults at runtime
117 # So we pass --disable-build-with-cxx config option to force gdb not to
118 # be built as C++ app.
120 GDB_CONF_OPTS += --disable-build-with-cxx
123 # gdb 7.12+ by default builds with a C++ compiler, which doesn't work
124 # when we don't have C++ support in the toolchain
125 ifneq ($(BR2_INSTALL_LIBSTDCPP),y)
126 GDB_CONF_OPTS += --disable-build-with-cxx
129 ifeq ($(BR2_PACKAGE_GDB_TUI),y)
130 GDB_CONF_OPTS += --enable-tui
132 GDB_CONF_OPTS += --disable-tui
135 ifeq ($(BR2_PACKAGE_GDB_PYTHON),y)
136 GDB_CONF_OPTS += --with-python=$(TOPDIR)/package/gdb/gdb-python-config
137 GDB_DEPENDENCIES += python
139 GDB_CONF_OPTS += --without-python
142 ifeq ($(BR2_PACKAGE_EXPAT),y)
143 GDB_CONF_OPTS += --with-expat
144 GDB_CONF_OPTS += --with-libexpat-prefix=$(STAGING_DIR)/usr
145 GDB_DEPENDENCIES += expat
147 GDB_CONF_OPTS += --without-expat
150 ifeq ($(BR2_PACKAGE_XZ),y)
151 GDB_CONF_OPTS += --with-lzma
152 GDB_CONF_OPTS += --with-liblzma-prefix=$(STAGING_DIR)/usr
153 GDB_DEPENDENCIES += xz
155 GDB_CONF_OPTS += --without-lzma
158 ifeq ($(BR2_PACKAGE_ZLIB),y)
159 GDB_CONF_OPTS += --with-zlib
160 GDB_DEPENDENCIES += zlib
162 GDB_CONF_OPTS += --without-zlib
165 # This removes some unneeded Python scripts and XML target description
166 # files that are not useful for a normal usage of the debugger.
167 define GDB_REMOVE_UNNEEDED_FILES
168 $(RM) -rf $(TARGET_DIR)/usr/share/gdb
171 GDB_POST_INSTALL_TARGET_HOOKS += GDB_REMOVE_UNNEEDED_FILES
173 # This installs the gdbserver somewhere into the $(HOST_DIR) so that
174 # it becomes an integral part of the SDK, if the toolchain generated
175 # by Buildroot is later used as an external toolchain. We install it
176 # in debug-root/usr/bin/gdbserver so that it matches what Crosstool-NG
178 define GDB_SDK_INSTALL_GDBSERVER
179 $(INSTALL) -D -m 0755 $(TARGET_DIR)/usr/bin/gdbserver \
180 $(HOST_DIR)/$(GNU_TARGET_NAME)/debug-root/usr/bin/gdbserver
183 ifeq ($(BR2_PACKAGE_GDB_SERVER),y)
184 GDB_POST_INSTALL_TARGET_HOOKS += GDB_SDK_INSTALL_GDBSERVER
188 # * --target, because we're doing a cross build rather than a real
190 # * --enable-static because gdb really wants to use libbfd.a
191 HOST_GDB_CONF_OPTS = \
192 --target=$(GNU_TARGET_NAME) \
199 --without-included-gettext \
201 $(GDB_DISABLE_BINUTILS_CONF_OPTS)
203 ifeq ($(BR2_PACKAGE_HOST_GDB_TUI),y)
204 HOST_GDB_CONF_OPTS += --enable-tui
206 HOST_GDB_CONF_OPTS += --disable-tui
209 ifeq ($(BR2_PACKAGE_HOST_GDB_PYTHON),y)
210 HOST_GDB_CONF_OPTS += --with-python=$(HOST_DIR)/bin/python2
211 HOST_GDB_DEPENDENCIES += host-python
213 HOST_GDB_CONF_OPTS += --without-python
216 # workaround a bug if in-tree build is used for bfin sim
217 define HOST_GDB_BFIN_SIM_WORKAROUND
218 $(RM) $(@D)/sim/common/tconfig.h
221 ifeq ($(BR2_PACKAGE_HOST_GDB_SIM),y)
222 HOST_GDB_CONF_OPTS += --enable-sim
224 HOST_GDB_PRE_CONFIGURE_HOOKS += HOST_GDB_BFIN_SIM_WORKAROUND
227 HOST_GDB_CONF_OPTS += --disable-sim
230 # legacy $arch-linux-gdb symlink
231 define HOST_GDB_ADD_SYMLINK
232 cd $(HOST_DIR)/bin && \
233 ln -snf $(GNU_TARGET_NAME)-gdb $(ARCH)-linux-gdb
236 HOST_GDB_POST_INSTALL_HOOKS += HOST_GDB_ADD_SYMLINK
238 HOST_GDB_POST_INSTALL_HOOKS += gen_gdbinit_file
240 $(eval $(autotools-package))
241 $(eval $(host-autotools-package))