]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - package/gdb/gdb.mk
7e86ba0c7e237eafb5c5bea1d4ec798d6ce34e1d
[coffee/buildroot.git] / package / gdb / gdb.mk
1 ################################################################################
2 #
3 # gdb
4 #
5 ################################################################################
6
7 GDB_VERSION = $(call qstrip,$(BR2_GDB_VERSION))
8 GDB_SITE = $(BR2_GNU_MIRROR)/gdb
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 endif
16
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
19
20 # We only want gdbserver and not the entire debugger.
21 ifeq ($(BR2_PACKAGE_GDB_DEBUGGER),)
22 GDB_SUBDIR = gdb/gdbserver
23 HOST_GDB_SUBDIR = .
24 else
25 GDB_DEPENDENCIES = ncurses \
26         $(if $(BR2_PACKAGE_LIBICONV),libiconv)
27 endif
28
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
31 # also need ncurses.
32 HOST_GDB_DEPENDENCIES = host-expat host-ncurses
33
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
39
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)
44 endef
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)
49 endif
50
51 ifeq ($(GDB_FROM_GIT),y)
52 GDB_DEPENDENCIES += host-flex host-bison
53 HOST_GDB_DEPENDENCIES += host-flex host-bison
54 endif
55
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.
59 GDB_DISABLE_BINUTILS_CONF_OPTS = \
60         --disable-binutils \
61         --disable-ld \
62         --disable-gas
63
64 GDB_CONF_ENV = \
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
74
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
87
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
98 # debugger.
99 GDB_CONF_ENV += gdb_cv_prfpregset_t_broken=no
100 GDB_MAKE_ENV += gdb_cv_prfpregset_t_broken=no
101
102 # The shared only build is not supported by gdb, so enable static build for
103 # build-in libraries with --enable-static.
104 GDB_CONF_OPTS = \
105         --without-uiout \
106         --disable-gdbtk \
107         --without-x \
108         --disable-sim \
109         $(GDB_DISABLE_BINUTILS_CONF_OPTS) \
110         $(if $(BR2_PACKAGE_GDB_SERVER),--enable-gdbserver) \
111         --with-curses \
112         --without-included-gettext \
113         --disable-werror \
114         --enable-static
115
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.
119 ifeq ($(BR2_arc),y)
120 GDB_CONF_OPTS += --disable-build-with-cxx
121 endif
122
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
127 endif
128
129 ifeq ($(BR2_PACKAGE_GDB_TUI),y)
130 GDB_CONF_OPTS += --enable-tui
131 else
132 GDB_CONF_OPTS += --disable-tui
133 endif
134
135 ifeq ($(BR2_PACKAGE_GDB_PYTHON),y)
136 GDB_CONF_OPTS += --with-python=$(TOPDIR)/package/gdb/gdb-python-config
137 GDB_DEPENDENCIES += python
138 else
139 GDB_CONF_OPTS += --without-python
140 endif
141
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
146 else
147 GDB_CONF_OPTS += --without-expat
148 endif
149
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
154 else
155 GDB_CONF_OPTS += --without-lzma
156 endif
157
158 ifeq ($(BR2_PACKAGE_ZLIB),y)
159 GDB_CONF_OPTS += --with-zlib
160 GDB_DEPENDENCIES += zlib
161 else
162 GDB_CONF_OPTS += --without-zlib
163 endif
164
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
169 endef
170
171 GDB_POST_INSTALL_TARGET_HOOKS += GDB_REMOVE_UNNEEDED_FILES
172
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
177 # does.
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
181 endef
182
183 ifeq ($(BR2_PACKAGE_GDB_SERVER),y)
184 GDB_POST_INSTALL_TARGET_HOOKS += GDB_SDK_INSTALL_GDBSERVER
185 endif
186
187 # A few notes:
188 #  * --target, because we're doing a cross build rather than a real
189 #    host build.
190 #  * --enable-static because gdb really wants to use libbfd.a
191 HOST_GDB_CONF_OPTS = \
192         --target=$(GNU_TARGET_NAME) \
193         --enable-static \
194         --without-uiout \
195         --disable-gdbtk \
196         --without-x \
197         --enable-threads \
198         --disable-werror \
199         --without-included-gettext \
200         --with-curses \
201         $(GDB_DISABLE_BINUTILS_CONF_OPTS)
202
203 ifeq ($(BR2_PACKAGE_HOST_GDB_TUI),y)
204 HOST_GDB_CONF_OPTS += --enable-tui
205 else
206 HOST_GDB_CONF_OPTS += --disable-tui
207 endif
208
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
212 else
213 HOST_GDB_CONF_OPTS += --without-python
214 endif
215
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
219 endef
220
221 ifeq ($(BR2_PACKAGE_HOST_GDB_SIM),y)
222 HOST_GDB_CONF_OPTS += --enable-sim
223 ifeq ($(BR2_bfin),y)
224 HOST_GDB_PRE_CONFIGURE_HOOKS += HOST_GDB_BFIN_SIM_WORKAROUND
225 endif
226 else
227 HOST_GDB_CONF_OPTS += --disable-sim
228 endif
229
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
234 endef
235
236 HOST_GDB_POST_INSTALL_HOOKS += HOST_GDB_ADD_SYMLINK
237
238 HOST_GDB_POST_INSTALL_HOOKS += gen_gdbinit_file
239
240 $(eval $(autotools-package))
241 $(eval $(host-autotools-package))