]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - package/gdb/gdb.mk
215f473cc01ec188d7ef3184ce6e1d375ea35edd
[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 (additionally the option --disable-install-libbfd
59 # prevents the un-wanted installation of libobcodes.so and libbfd.so).
60 GDB_DISABLE_BINUTILS_CONF_OPTS = \
61         --disable-binutils \
62         --disable-install-libbfd \
63         --disable-ld \
64         --disable-gas
65
66 GDB_CONF_ENV = \
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
76
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
89
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
100 # debugger.
101 GDB_CONF_ENV += gdb_cv_prfpregset_t_broken=no
102 GDB_MAKE_ENV += gdb_cv_prfpregset_t_broken=no
103
104 # The shared only build is not supported by gdb, so enable static build for
105 # build-in libraries with --enable-static.
106 GDB_CONF_OPTS = \
107         --without-uiout \
108         --disable-gdbtk \
109         --without-x \
110         --disable-sim \
111         $(GDB_DISABLE_BINUTILS_CONF_OPTS) \
112         $(if $(BR2_PACKAGE_GDB_SERVER),--enable-gdbserver) \
113         --with-curses \
114         --without-included-gettext \
115         --disable-werror \
116         --enable-static
117
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.
121 ifeq ($(BR2_arc),y)
122 GDB_CONF_OPTS += --disable-build-with-cxx
123 endif
124
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
129 endif
130
131 ifeq ($(BR2_PACKAGE_GDB_TUI),y)
132 GDB_CONF_OPTS += --enable-tui
133 else
134 GDB_CONF_OPTS += --disable-tui
135 endif
136
137 ifeq ($(BR2_PACKAGE_GDB_PYTHON),y)
138 GDB_CONF_OPTS += --with-python=$(TOPDIR)/package/gdb/gdb-python-config
139 GDB_DEPENDENCIES += python
140 else
141 GDB_CONF_OPTS += --without-python
142 endif
143
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
148 else
149 GDB_CONF_OPTS += --without-expat
150 endif
151
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
156 else
157 GDB_CONF_OPTS += --without-lzma
158 endif
159
160 ifeq ($(BR2_PACKAGE_ZLIB),y)
161 GDB_CONF_OPTS += --with-zlib
162 GDB_DEPENDENCIES += zlib
163 else
164 GDB_CONF_OPTS += --without-zlib
165 endif
166
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
172 endef
173
174 GDB_POST_INSTALL_TARGET_HOOKS += GDB_REMOVE_UNNEEDED_FILES
175 endif
176
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
181 # does.
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
185 endef
186
187 ifeq ($(BR2_PACKAGE_GDB_SERVER),y)
188 GDB_POST_INSTALL_TARGET_HOOKS += GDB_SDK_INSTALL_GDBSERVER
189 endif
190
191 # A few notes:
192 #  * --target, because we're doing a cross build rather than a real
193 #    host build.
194 #  * --enable-static because gdb really wants to use libbfd.a
195 HOST_GDB_CONF_OPTS = \
196         --target=$(GNU_TARGET_NAME) \
197         --enable-static \
198         --without-uiout \
199         --disable-gdbtk \
200         --without-x \
201         --enable-threads \
202         --disable-werror \
203         --without-included-gettext \
204         --with-curses \
205         $(GDB_DISABLE_BINUTILS_CONF_OPTS)
206
207 ifeq ($(BR2_PACKAGE_HOST_GDB_TUI),y)
208 HOST_GDB_CONF_OPTS += --enable-tui
209 else
210 HOST_GDB_CONF_OPTS += --disable-tui
211 endif
212
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
216 else
217 HOST_GDB_CONF_OPTS += --without-python
218 endif
219
220 ifeq ($(BR2_PACKAGE_HOST_GDB_SIM),y)
221 HOST_GDB_CONF_OPTS += --enable-sim
222 else
223 HOST_GDB_CONF_OPTS += --disable-sim
224 endif
225
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
230 endef
231
232 HOST_GDB_POST_INSTALL_HOOKS += HOST_GDB_ADD_SYMLINK
233
234 HOST_GDB_POST_INSTALL_HOOKS += gen_gdbinit_file
235
236 $(eval $(autotools-package))
237 $(eval $(host-autotools-package))