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,
58 # so we disable it (additionally the option --disable-install-libbfd
59 # prevents the un-wanted installation of libobcodes.so and libbfd.so).
60 GDB_DISABLE_BINUTILS_CONF_OPTS = \
62 --disable-install-libbfd \
67 ac_cv_type_uintptr_t=yes \
68 gt_cv_func_gettext_libintl=yes \
69 ac_cv_func_dcgettext=yes \
70 gdb_cv_func_sigsetjmp=yes \
71 bash_cv_func_strcoll_broken=no \
72 bash_cv_must_reinstall_sighandlers=no \
73 bash_cv_func_sigsetjmp=present \
74 bash_cv_have_mbstate_t=yes \
75 gdb_cv_func_sigsetjmp=yes
77 # Starting with gdb 7.11, the bundled gnulib tries to use
78 # rpl_gettimeofday (gettimeofday replacement) due to the code being
79 # unable to determine if the replacement function should be used or
80 # not when cross-compiling with uClibc or musl as C libraries. So use
81 # gl_cv_func_gettimeofday_clobber=no to not use rpl_gettimeofday,
82 # assuming musl and uClibc have a properly working gettimeofday
83 # implementation. It needs to be passed to GDB_CONF_ENV to build
84 # gdbserver only but also to GDB_MAKE_ENV, because otherwise it does
85 # not get passed to the configure script of nested packages while
86 # building gdbserver with full debugger.
87 GDB_CONF_ENV += gl_cv_func_gettimeofday_clobber=no
88 GDB_MAKE_ENV += gl_cv_func_gettimeofday_clobber=no
90 # Starting with glibc 2.25, the proc_service.h header has been copied
91 # from gdb to glibc so other tools can use it. However, that makes it
92 # necessary to make sure that declaration of prfpregset_t declaration
93 # is consistent between gdb and glibc. In gdb, however, there is a
94 # workaround for a broken prfpregset_t declaration in glibc 2.3 which
95 # uses AC_TRY_RUN to detect if it's needed, which doesn't work in
96 # cross-compilation. So pass the cache option to configure.
97 # It needs to be passed to GDB_CONF_ENV to build gdbserver only but
98 # also to GDB_MAKE_ENV, because otherwise it does not get passed to the
99 # configure script of nested packages while building gdbserver with full
101 GDB_CONF_ENV += gdb_cv_prfpregset_t_broken=no
102 GDB_MAKE_ENV += gdb_cv_prfpregset_t_broken=no
104 # The shared only build is not supported by gdb, so enable static build for
105 # build-in libraries with --enable-static.
111 $(GDB_DISABLE_BINUTILS_CONF_OPTS) \
112 $(if $(BR2_PACKAGE_GDB_SERVER),--enable-gdbserver) \
114 --without-included-gettext \
118 # When gdb is built as C++ application for ARC it segfaults at runtime
119 # So we pass --disable-build-with-cxx config option to force gdb not to
120 # be built as C++ app.
122 GDB_CONF_OPTS += --disable-build-with-cxx
125 # gdb 7.12+ by default builds with a C++ compiler, which doesn't work
126 # when we don't have C++ support in the toolchain
127 ifneq ($(BR2_INSTALL_LIBSTDCPP),y)
128 GDB_CONF_OPTS += --disable-build-with-cxx
131 ifeq ($(BR2_PACKAGE_GDB_TUI),y)
132 GDB_CONF_OPTS += --enable-tui
134 GDB_CONF_OPTS += --disable-tui
137 ifeq ($(BR2_PACKAGE_GDB_PYTHON),y)
138 GDB_CONF_OPTS += --with-python=$(TOPDIR)/package/gdb/gdb-python-config
139 GDB_DEPENDENCIES += python
141 GDB_CONF_OPTS += --without-python
144 ifeq ($(BR2_PACKAGE_EXPAT),y)
145 GDB_CONF_OPTS += --with-expat
146 GDB_CONF_OPTS += --with-libexpat-prefix=$(STAGING_DIR)/usr
147 GDB_DEPENDENCIES += expat
149 GDB_CONF_OPTS += --without-expat
152 ifeq ($(BR2_PACKAGE_XZ),y)
153 GDB_CONF_OPTS += --with-lzma
154 GDB_CONF_OPTS += --with-liblzma-prefix=$(STAGING_DIR)/usr
155 GDB_DEPENDENCIES += xz
157 GDB_CONF_OPTS += --without-lzma
160 ifeq ($(BR2_PACKAGE_ZLIB),y)
161 GDB_CONF_OPTS += --with-zlib
162 GDB_DEPENDENCIES += zlib
164 GDB_CONF_OPTS += --without-zlib
167 ifeq ($(BR2_PACKAGE_GDB_PYTHON),)
168 # This removes some unneeded Python scripts and XML target description
169 # files that are not useful for a normal usage of the debugger.
170 define GDB_REMOVE_UNNEEDED_FILES
171 $(RM) -rf $(TARGET_DIR)/usr/share/gdb
174 GDB_POST_INSTALL_TARGET_HOOKS += GDB_REMOVE_UNNEEDED_FILES
177 # This installs the gdbserver somewhere into the $(HOST_DIR) so that
178 # it becomes an integral part of the SDK, if the toolchain generated
179 # by Buildroot is later used as an external toolchain. We install it
180 # in debug-root/usr/bin/gdbserver so that it matches what Crosstool-NG
182 define GDB_SDK_INSTALL_GDBSERVER
183 $(INSTALL) -D -m 0755 $(TARGET_DIR)/usr/bin/gdbserver \
184 $(HOST_DIR)/$(GNU_TARGET_NAME)/debug-root/usr/bin/gdbserver
187 ifeq ($(BR2_PACKAGE_GDB_SERVER),y)
188 GDB_POST_INSTALL_TARGET_HOOKS += GDB_SDK_INSTALL_GDBSERVER
192 # * --target, because we're doing a cross build rather than a real
194 # * --enable-static because gdb really wants to use libbfd.a
195 HOST_GDB_CONF_OPTS = \
196 --target=$(GNU_TARGET_NAME) \
203 --without-included-gettext \
205 $(GDB_DISABLE_BINUTILS_CONF_OPTS)
207 ifeq ($(BR2_PACKAGE_HOST_GDB_TUI),y)
208 HOST_GDB_CONF_OPTS += --enable-tui
210 HOST_GDB_CONF_OPTS += --disable-tui
213 ifeq ($(BR2_PACKAGE_HOST_GDB_PYTHON),y)
214 HOST_GDB_CONF_OPTS += --with-python=$(HOST_DIR)/bin/python2
215 HOST_GDB_DEPENDENCIES += host-python
217 HOST_GDB_CONF_OPTS += --without-python
220 ifeq ($(BR2_PACKAGE_HOST_GDB_SIM),y)
221 HOST_GDB_CONF_OPTS += --enable-sim
223 HOST_GDB_CONF_OPTS += --disable-sim
226 # legacy $arch-linux-gdb symlink
227 define HOST_GDB_ADD_SYMLINK
228 cd $(HOST_DIR)/bin && \
229 ln -snf $(GNU_TARGET_NAME)-gdb $(ARCH)-linux-gdb
232 HOST_GDB_POST_INSTALL_HOOKS += HOST_GDB_ADD_SYMLINK
234 HOST_GDB_POST_INSTALL_HOOKS += gen_gdbinit_file
236 $(eval $(autotools-package))
237 $(eval $(host-autotools-package))