98183206f98e2438bffdff636e771aa3f22fbc85
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / 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 ifeq ($(BR2_microblaze),y)
18 GDB_SITE = $(call github,Xilinx,gdb,$(GDB_VERSION))
19 GDB_SOURCE = gdb-$(GDB_VERSION).tar.gz
20 GDB_FROM_GIT = y
21 endif
22
23 # Use .tar.bz2 for 7.7.x since there was no .tar.xz release back then
24 ifneq ($(filter 7.7.%,$(GDB_VERSION)),)
25 GDB_SOURCE = gdb-$(GDB_VERSION).tar.bz2
26 endif
27
28 GDB_LICENSE = GPLv2+ LGPLv2+ GPLv3+ LGPLv3+
29 GDB_LICENSE_FILES = COPYING COPYING.LIB COPYING3 COPYING3.LIB
30
31 # We only want gdbserver and not the entire debugger.
32 ifeq ($(BR2_PACKAGE_GDB_DEBUGGER),)
33 GDB_SUBDIR = gdb/gdbserver
34 HOST_GDB_SUBDIR = .
35 else
36 GDB_DEPENDENCIES = ncurses
37 endif
38
39 # For the host variant, we really want to build with XML support,
40 # which is needed to read XML descriptions of target architectures. We
41 # also need ncurses.
42 HOST_GDB_DEPENDENCIES = host-expat host-ncurses
43
44 # Apply the Xtensa specific patches
45 XTENSA_CORE_NAME = $(call qstrip, $(BR2_XTENSA_CORE_NAME))
46 ifneq ($(XTENSA_CORE_NAME),)
47 define GDB_XTENSA_PRE_PATCH
48         tar xf $(BR2_XTENSA_OVERLAY_DIR)/xtensa_$(XTENSA_CORE_NAME).tar \
49                 -C $(@D) --strip-components=1 gdb
50 endef
51 GDB_PRE_PATCH_HOOKS += GDB_XTENSA_PRE_PATCH
52 HOST_GDB_PRE_PATCH_HOOKS += GDB_XTENSA_PRE_PATCH
53 endif
54
55 # When gdb sources are fetched from the binutils-gdb repository, they
56 # also contain the binutils sources, but binutils shouldn't be built,
57 # so we disable it.
58 GDB_DISABLE_BINUTILS_CONF_OPTS = \
59         --disable-binutils \
60         --disable-ld \
61         --disable-gas
62
63 GDB_CONF_ENV = \
64         ac_cv_type_uintptr_t=yes \
65         gt_cv_func_gettext_libintl=yes \
66         ac_cv_func_dcgettext=yes \
67         gdb_cv_func_sigsetjmp=yes \
68         bash_cv_func_strcoll_broken=no \
69         bash_cv_must_reinstall_sighandlers=no \
70         bash_cv_func_sigsetjmp=present \
71         bash_cv_have_mbstate_t=yes \
72         gdb_cv_func_sigsetjmp=yes
73
74 # The shared only build is not supported by gdb, so enable static build for
75 # build-in libraries with --enable-static.
76 GDB_CONF_OPTS = \
77         --without-uiout \
78         --disable-gdbtk \
79         --without-x \
80         --disable-sim \
81         $(GDB_DISABLE_BINUTILS_CONF_OPTS) \
82         $(if $(BR2_PACKAGE_GDB_SERVER),--enable-gdbserver) \
83         --with-curses \
84         --without-included-gettext \
85         --disable-werror \
86         --enable-static
87
88 ifeq ($(BR2_PACKAGE_GDB_TUI),y)
89 GDB_CONF_OPTS += --enable-tui
90 else
91 GDB_CONF_OPTS += --disable-tui
92 endif
93
94 ifeq ($(BR2_PACKAGE_GDB_PYTHON),y)
95 GDB_CONF_OPTS += --with-python=$(TOPDIR)/package/gdb/gdb-python-config
96 GDB_DEPENDENCIES += python
97 else
98 GDB_CONF_OPTS += --without-python
99 endif
100
101 # This removes some unneeded Python scripts and XML target description
102 # files that are not useful for a normal usage of the debugger.
103 define GDB_REMOVE_UNNEEDED_FILES
104         $(RM) -rf $(TARGET_DIR)/usr/share/gdb
105 endef
106
107 GDB_POST_INSTALL_TARGET_HOOKS += GDB_REMOVE_UNNEEDED_FILES
108
109 # This installs the gdbserver somewhere into the $(HOST_DIR) so that
110 # it becomes an integral part of the SDK, if the toolchain generated
111 # by Buildroot is later used as an external toolchain. We install it
112 # in debug-root/usr/bin/gdbserver so that it matches what Crosstool-NG
113 # does.
114 define GDB_SDK_INSTALL_GDBSERVER
115         $(INSTALL) -D -m 0755 $(TARGET_DIR)/usr/bin/gdbserver \
116                 $(HOST_DIR)/usr/$(GNU_TARGET_NAME)/debug-root/usr/bin/gdbserver
117 endef
118
119 ifeq ($(BR2_PACKAGE_GDB_SERVER),y)
120 GDB_POST_INSTALL_TARGET_HOOKS += GDB_SDK_INSTALL_GDBSERVER
121 endif
122
123 # A few notes:
124 #  * --target, because we're doing a cross build rather than a real
125 #    host build.
126 #  * --enable-static because gdb really wants to use libbfd.a
127 HOST_GDB_CONF_OPTS = \
128         --target=$(GNU_TARGET_NAME) \
129         --enable-static \
130         --without-uiout \
131         --disable-gdbtk \
132         --without-x \
133         --enable-threads \
134         --disable-werror \
135         --without-included-gettext \
136         $(GDB_DISABLE_BINUTILS_CONF_OPTS) \
137         --disable-sim
138
139 ifeq ($(BR2_PACKAGE_HOST_GDB_TUI),y)
140 HOST_GDB_CONF_OPTS += --enable-tui
141 else
142 HOST_GDB_CONF_OPTS += --disable-tui
143 endif
144
145 ifeq ($(BR2_PACKAGE_HOST_GDB_PYTHON),y)
146 HOST_GDB_CONF_OPTS += --with-python=$(HOST_DIR)/usr/bin/python2
147 HOST_GDB_DEPENDENCIES += host-python
148 else
149 HOST_GDB_CONF_OPTS += --without-python
150 endif
151
152 ifeq ($(GDB_FROM_GIT),y)
153 GDB_DEPENDENCIES += host-texinfo
154 HOST_GDB_DEPENDENCIES += host-texinfo
155 else
156 # don't generate documentation
157 GDB_CONF_ENV += ac_cv_prog_MAKEINFO=missing
158 HOST_GDB_CONF_ENV += ac_cv_prog_MAKEINFO=missing
159 endif
160
161 # legacy $arch-linux-gdb symlink
162 define HOST_GDB_ADD_SYMLINK
163         cd $(HOST_DIR)/usr/bin && \
164                 ln -snf $(GNU_TARGET_NAME)-gdb $(ARCH)-linux-gdb
165 endef
166
167 HOST_GDB_POST_INSTALL_HOOKS += HOST_GDB_ADD_SYMLINK
168
169 HOST_GDB_POST_INSTALL_HOOKS += gen_gdbinit_file
170
171 $(eval $(autotools-package))
172 $(eval $(host-autotools-package))