gdb.mk 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. ################################################################################
  2. #
  3. # gdb
  4. #
  5. ################################################################################
  6. GDB_VERSION = $(call qstrip,$(BR2_GDB_VERSION))
  7. GDB_SITE = $(BR2_GNU_MIRROR)/gdb
  8. GDB_SOURCE = gdb-$(GDB_VERSION).tar.xz
  9. ifeq ($(BR2_arc),y)
  10. GDB_SITE = $(call github,foss-for-synopsys-dwc-arc-processors,binutils-gdb,$(GDB_VERSION))
  11. GDB_SOURCE = gdb-$(GDB_VERSION).tar.gz
  12. GDB_FROM_GIT = y
  13. endif
  14. ifeq ($(BR2_microblaze),y)
  15. GDB_SITE = $(call github,Xilinx,gdb,$(GDB_VERSION))
  16. GDB_SOURCE = gdb-$(GDB_VERSION).tar.gz
  17. GDB_FROM_GIT = y
  18. endif
  19. GDB_LICENSE = GPL-2.0+, LGPL-2.0+, GPL-3.0+, LGPL-3.0+
  20. GDB_LICENSE_FILES = COPYING COPYING.LIB COPYING3 COPYING3.LIB
  21. # We only want gdbserver and not the entire debugger.
  22. ifeq ($(BR2_PACKAGE_GDB_DEBUGGER),)
  23. GDB_SUBDIR = gdb/gdbserver
  24. HOST_GDB_SUBDIR = .
  25. else
  26. GDB_DEPENDENCIES = ncurses \
  27. $(if $(BR2_PACKAGE_LIBICONV),libiconv)
  28. endif
  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. # Disable building documentation
  34. GDB_MAKE_OPTS += MAKEINFO=true
  35. GDB_INSTALL_TARGET_OPTS += MAKEINFO=true DESTDIR=$(TARGET_DIR) install
  36. HOST_GDB_MAKE_OPTS += MAKEINFO=true
  37. HOST_GDB_INSTALL_OPTS += MAKEINFO=true install
  38. # Apply the Xtensa specific patches
  39. ifneq ($(ARCH_XTENSA_CORE_NAME),)
  40. define GDB_XTENSA_OVERLAY_EXTRACT
  41. $(call arch-xtensa-overlay-extract,$(@D),gdb)
  42. endef
  43. GDB_POST_EXTRACT_HOOKS += GDB_XTENSA_OVERLAY_EXTRACT
  44. HOST_GDB_POST_EXTRACT_HOOKS += GDB_XTENSA_OVERLAY_EXTRACT
  45. endif
  46. ifeq ($(GDB_FROM_GIT),y)
  47. GDB_DEPENDENCIES += host-flex host-bison
  48. HOST_GDB_DEPENDENCIES += host-flex host-bison
  49. endif
  50. # When gdb sources are fetched from the binutils-gdb repository, they
  51. # also contain the binutils sources, but binutils shouldn't be built,
  52. # so we disable it.
  53. GDB_DISABLE_BINUTILS_CONF_OPTS = \
  54. --disable-binutils \
  55. --disable-ld \
  56. --disable-gas
  57. GDB_CONF_ENV = \
  58. ac_cv_type_uintptr_t=yes \
  59. gt_cv_func_gettext_libintl=yes \
  60. ac_cv_func_dcgettext=yes \
  61. gdb_cv_func_sigsetjmp=yes \
  62. bash_cv_func_strcoll_broken=no \
  63. bash_cv_must_reinstall_sighandlers=no \
  64. bash_cv_func_sigsetjmp=present \
  65. bash_cv_have_mbstate_t=yes \
  66. gdb_cv_func_sigsetjmp=yes
  67. # Starting with gdb 7.11, the bundled gnulib tries to use
  68. # rpl_gettimeofday (gettimeofday replacement) due to the code being
  69. # unable to determine if the replacement function should be used or
  70. # not when cross-compiling with uClibc or musl as C libraries. So use
  71. # gl_cv_func_gettimeofday_clobber=no to not use rpl_gettimeofday,
  72. # assuming musl and uClibc have a properly working gettimeofday
  73. # implementation. It needs to be passed to GDB_CONF_ENV to build
  74. # gdbserver only but also to GDB_MAKE_ENV, because otherwise it does
  75. # not get passed to the configure script of nested packages while
  76. # building gdbserver with full debugger.
  77. GDB_CONF_ENV += gl_cv_func_gettimeofday_clobber=no
  78. GDB_MAKE_ENV += gl_cv_func_gettimeofday_clobber=no
  79. # Starting with glibc 2.25, the proc_service.h header has been copied
  80. # from gdb to glibc so other tools can use it. However, that makes it
  81. # necessary to make sure that declaration of prfpregset_t declaration
  82. # is consistent between gdb and glibc. In gdb, however, there is a
  83. # workaround for a broken prfpregset_t declaration in glibc 2.3 which
  84. # uses AC_TRY_RUN to detect if it's needed, which doesn't work in
  85. # cross-compilation. So pass the cache option to configure.
  86. # It needs to be passed to GDB_CONF_ENV to build gdbserver only but
  87. # also to GDB_MAKE_ENV, because otherwise it does not get passed to the
  88. # configure script of nested packages while building gdbserver with full
  89. # debugger.
  90. GDB_CONF_ENV += gdb_cv_prfpregset_t_broken=no
  91. GDB_MAKE_ENV += gdb_cv_prfpregset_t_broken=no
  92. # The shared only build is not supported by gdb, so enable static build for
  93. # build-in libraries with --enable-static.
  94. GDB_CONF_OPTS = \
  95. --without-uiout \
  96. --disable-gdbtk \
  97. --without-x \
  98. --disable-sim \
  99. $(GDB_DISABLE_BINUTILS_CONF_OPTS) \
  100. $(if $(BR2_PACKAGE_GDB_SERVER),--enable-gdbserver) \
  101. --with-curses \
  102. --without-included-gettext \
  103. --disable-werror \
  104. --enable-static
  105. # When gdb is built as C++ application for ARC it segfaults at runtime
  106. # So we pass --disable-build-with-cxx config option to force gdb not to
  107. # be built as C++ app.
  108. ifeq ($(BR2_arc),y)
  109. GDB_CONF_OPTS += --disable-build-with-cxx
  110. endif
  111. # gdb 7.12+ by default builds with a C++ compiler, which doesn't work
  112. # when we don't have C++ support in the toolchain
  113. ifneq ($(BR2_INSTALL_LIBSTDCPP),y)
  114. GDB_CONF_OPTS += --disable-build-with-cxx
  115. endif
  116. ifeq ($(BR2_PACKAGE_GDB_TUI),y)
  117. GDB_CONF_OPTS += --enable-tui
  118. else
  119. GDB_CONF_OPTS += --disable-tui
  120. endif
  121. ifeq ($(BR2_PACKAGE_GDB_PYTHON),y)
  122. GDB_CONF_OPTS += --with-python=$(TOPDIR)/package/gdb/gdb-python-config
  123. GDB_DEPENDENCIES += python
  124. else
  125. GDB_CONF_OPTS += --without-python
  126. endif
  127. ifeq ($(BR2_PACKAGE_EXPAT),y)
  128. GDB_CONF_OPTS += --with-expat
  129. GDB_CONF_OPTS += --with-libexpat-prefix=$(STAGING_DIR)/usr
  130. GDB_DEPENDENCIES += expat
  131. else
  132. GDB_CONF_OPTS += --without-expat
  133. endif
  134. ifeq ($(BR2_PACKAGE_XZ),y)
  135. GDB_CONF_OPTS += --with-lzma
  136. GDB_CONF_OPTS += --with-liblzma-prefix=$(STAGING_DIR)/usr
  137. GDB_DEPENDENCIES += xz
  138. else
  139. GDB_CONF_OPTS += --without-lzma
  140. endif
  141. ifeq ($(BR2_PACKAGE_ZLIB),y)
  142. GDB_CONF_OPTS += --with-zlib
  143. GDB_DEPENDENCIES += zlib
  144. else
  145. GDB_CONF_OPTS += --without-zlib
  146. endif
  147. # This removes some unneeded Python scripts and XML target description
  148. # files that are not useful for a normal usage of the debugger.
  149. define GDB_REMOVE_UNNEEDED_FILES
  150. $(RM) -rf $(TARGET_DIR)/usr/share/gdb
  151. endef
  152. GDB_POST_INSTALL_TARGET_HOOKS += GDB_REMOVE_UNNEEDED_FILES
  153. # This installs the gdbserver somewhere into the $(HOST_DIR) so that
  154. # it becomes an integral part of the SDK, if the toolchain generated
  155. # by Buildroot is later used as an external toolchain. We install it
  156. # in debug-root/usr/bin/gdbserver so that it matches what Crosstool-NG
  157. # does.
  158. define GDB_SDK_INSTALL_GDBSERVER
  159. $(INSTALL) -D -m 0755 $(TARGET_DIR)/usr/bin/gdbserver \
  160. $(HOST_DIR)/$(GNU_TARGET_NAME)/debug-root/usr/bin/gdbserver
  161. endef
  162. ifeq ($(BR2_PACKAGE_GDB_SERVER),y)
  163. GDB_POST_INSTALL_TARGET_HOOKS += GDB_SDK_INSTALL_GDBSERVER
  164. endif
  165. # A few notes:
  166. # * --target, because we're doing a cross build rather than a real
  167. # host build.
  168. # * --enable-static because gdb really wants to use libbfd.a
  169. HOST_GDB_CONF_OPTS = \
  170. --target=$(GNU_TARGET_NAME) \
  171. --enable-static \
  172. --without-uiout \
  173. --disable-gdbtk \
  174. --without-x \
  175. --enable-threads \
  176. --disable-werror \
  177. --without-included-gettext \
  178. $(GDB_DISABLE_BINUTILS_CONF_OPTS)
  179. ifeq ($(BR2_PACKAGE_HOST_GDB_TUI),y)
  180. HOST_GDB_CONF_OPTS += --enable-tui
  181. else
  182. HOST_GDB_CONF_OPTS += --disable-tui
  183. endif
  184. ifeq ($(BR2_PACKAGE_HOST_GDB_PYTHON),y)
  185. HOST_GDB_CONF_OPTS += --with-python=$(HOST_DIR)/bin/python2
  186. HOST_GDB_DEPENDENCIES += host-python
  187. else
  188. HOST_GDB_CONF_OPTS += --without-python
  189. endif
  190. # workaround a bug if in-tree build is used for bfin sim
  191. define HOST_GDB_BFIN_SIM_WORKAROUND
  192. $(RM) $(@D)/sim/common/tconfig.h
  193. endef
  194. ifeq ($(BR2_PACKAGE_HOST_GDB_SIM),y)
  195. HOST_GDB_CONF_OPTS += --enable-sim
  196. ifeq ($(BR2_bfin),y)
  197. HOST_GDB_PRE_CONFIGURE_HOOKS += HOST_GDB_BFIN_SIM_WORKAROUND
  198. endif
  199. else
  200. HOST_GDB_CONF_OPTS += --disable-sim
  201. endif
  202. # legacy $arch-linux-gdb symlink
  203. define HOST_GDB_ADD_SYMLINK
  204. cd $(HOST_DIR)/bin && \
  205. ln -snf $(GNU_TARGET_NAME)-gdb $(ARCH)-linux-gdb
  206. endef
  207. HOST_GDB_POST_INSTALL_HOOKS += HOST_GDB_ADD_SYMLINK
  208. HOST_GDB_POST_INSTALL_HOOKS += gen_gdbinit_file
  209. $(eval $(autotools-package))
  210. $(eval $(host-autotools-package))