Initial revision
[openwrt.git] / toolchain / gdb / gdb.mk
1 ######################################################################
2 #
3 # gdb
4 #
5 ######################################################################
6 GDB_VERSION:=$(strip $(GDB_VERSION))
7
8 GDB_SITE:=http://ftp.gnu.org/gnu/gdb
9
10 ifeq ($(GDB_VERSION),5.3)
11 GDB_SOURCE:=gdb-$(GDB_VERSION).tar.gz
12 GDB_CAT:=zcat
13 else
14 GDB_SOURCE:=gdb-$(GDB_VERSION).tar.bz2
15 GDB_CAT:=bzcat
16 endif
17
18 GDB_DIR:=$(TOOL_BUILD_DIR)/gdb-$(GDB_VERSION)
19
20 $(DL_DIR)/$(GDB_SOURCE):
21         $(WGET) -P $(DL_DIR) $(GDB_SITE)/$(GDB_SOURCE)
22
23 $(GDB_DIR)/.unpacked: $(DL_DIR)/$(GDB_SOURCE)
24         $(GDB_CAT) $(DL_DIR)/$(GDB_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
25         toolchain/patch-kernel.sh $(GDB_DIR) toolchain/gdb/$(GDB_VERSION) \*.patch
26         # Copy a config.sub from gcc.  This is only necessary until
27         # gdb's config.sub supports <arch>-linux-uclibc tuples.
28         # Should probably integrate this into the patch.
29 ifeq ($(GDB_VERSION),5.3)
30         chmod u+x $(GDB_DIR)/gdb/gdbserver/configure
31         cp $(GCC_DIR)/config.sub $(GDB_DIR)
32         cp $(GCC_DIR)/config.sub $(GDB_DIR)/readline/support/
33 endif
34         touch  $(GDB_DIR)/.unpacked
35
36 ######################################################################
37 #
38 # gdb target
39 #
40 ######################################################################
41
42 GDB_TARGET_DIR:=$(BUILD_DIR)/gdb-$(GDB_VERSION)-target
43
44 GDB_TARGET_CONFIGURE_VARS:= \
45         ac_cv_type_uintptr_t=yes \
46         gt_cv_func_gettext_libintl=yes \
47         ac_cv_func_dcgettext=yes \
48         gdb_cv_func_sigsetjmp=yes \
49         bash_cv_func_strcoll_broken=no \
50         bash_cv_must_reinstall_sighandlers=no \
51         bash_cv_func_sigsetjmp=present \
52         bash_cv_have_mbstate_t=yes
53
54 $(GDB_TARGET_DIR)/.configured: $(GDB_DIR)/.unpacked
55         mkdir -p $(GDB_TARGET_DIR)
56         (cd $(GDB_TARGET_DIR); \
57                 gdb_cv_func_sigsetjmp=yes \
58                 $(TARGET_CONFIGURE_OPTS) \
59                 CFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" \
60                 $(GDB_TARGET_CONFIGURE_VARS) \
61                 $(GDB_DIR)/configure \
62                 --build=$(GNU_HOST_NAME) \
63                 --host=$(REAL_GNU_TARGET_NAME) \
64                 --target=$(REAL_GNU_TARGET_NAME) \
65                 --prefix=/usr \
66                 $(DISABLE_NLS) \
67                 --without-uiout --disable-gdbmi \
68                 --disable-tui --disable-gdbtk --without-x \
69                 --disable-sim --enable-gdbserver \
70                 --without-included-gettext \
71         );
72 ifeq ($(ENABLE_LOCALE),true)
73         -$(SED) "s,^INTL *=.*,INTL = -lintl,g;" $(GDB_DIR)/gdb/Makefile
74 endif
75         touch  $(GDB_TARGET_DIR)/.configured
76
77 $(GDB_TARGET_DIR)/gdb/gdb: $(GDB_TARGET_DIR)/.configured
78         $(MAKE) CC=$(TARGET_CC) MT_CFLAGS="$(TARGET_CFLAGS)" \
79                 -C $(GDB_TARGET_DIR)
80         $(STRIP) $(GDB_TARGET_DIR)/gdb/gdb
81
82 $(TARGET_DIR)/usr/bin/gdb: $(GDB_TARGET_DIR)/gdb/gdb
83         install -c $(GDB_TARGET_DIR)/gdb/gdb $(TARGET_DIR)/usr/bin/gdb
84
85 gdb_target: ncurses-headers $(TARGET_DIR)/usr/bin/gdb
86
87 gdb_target-source: $(DL_DIR)/$(GDB_SOURCE)
88
89 gdb_target-clean:
90         $(MAKE) -C $(GDB_DIR) clean
91
92 gdb_target-dirclean:
93         rm -rf $(GDB_DIR)
94
95 ######################################################################
96 #
97 # gdbserver
98 #
99 ######################################################################
100
101 GDB_SERVER_DIR:=$(BUILD_DIR)/gdbserver-$(GDB_VERSION)
102
103 $(GDB_SERVER_DIR)/.configured: $(GDB_DIR)/.unpacked
104         mkdir -p $(GDB_SERVER_DIR)
105         (cd $(GDB_SERVER_DIR); \
106                 $(TARGET_CONFIGURE_OPTS) \
107                 gdb_cv_func_sigsetjmp=yes \
108                 $(GDB_DIR)/gdb/gdbserver/configure \
109                 --build=$(GNU_HOST_NAME) \
110                 --host=$(REAL_GNU_TARGET_NAME) \
111                 --target=$(REAL_GNU_TARGET_NAME) \
112                 --prefix=/usr \
113                 --exec-prefix=/usr \
114                 --bindir=/usr/bin \
115                 --sbindir=/usr/sbin \
116                 --libexecdir=/usr/lib \
117                 --sysconfdir=/etc \
118                 --datadir=/usr/share \
119                 --localstatedir=/var \
120                 --mandir=/usr/man \
121                 --infodir=/usr/info \
122                 --includedir=$(STAGING_DIR)/include \
123                 $(DISABLE_NLS) \
124                 --without-uiout --disable-gdbmi \
125                 --disable-tui --disable-gdbtk --without-x \
126                 --without-included-gettext \
127         );
128         touch  $(GDB_SERVER_DIR)/.configured
129
130 $(GDB_SERVER_DIR)/gdbserver: $(GDB_SERVER_DIR)/.configured
131         $(MAKE) CC=$(TARGET_CC) MT_CFLAGS="$(TARGET_CFLAGS)" \
132                 -C $(GDB_SERVER_DIR)
133         $(STRIP) $(GDB_SERVER_DIR)/gdbserver
134
135 $(TARGET_DIR)/usr/bin/gdbserver: $(GDB_SERVER_DIR)/gdbserver
136         install -c $(GDB_SERVER_DIR)/gdbserver $(TARGET_DIR)/usr/bin/gdbserver
137
138 gdbserver: ncurses-headers $(TARGET_DIR)/usr/bin/gdbserver
139
140 gdbserver-clean:
141         $(MAKE) -C $(GDB_SERVER_DIR) clean
142
143 gdbserver-dirclean:
144         rm -rf $(GDB_SERVER_DIR)
145
146 ######################################################################
147 #
148 # gdb client
149 #
150 ######################################################################
151
152 GDB_CLIENT_DIR:=$(TOOL_BUILD_DIR)/gdbclient-$(GDB_VERSION)
153
154 $(GDB_CLIENT_DIR)/.configured: $(GDB_DIR)/.unpacked
155         mkdir -p $(GDB_CLIENT_DIR)
156         (cd $(GDB_CLIENT_DIR); \
157                 gdb_cv_func_sigsetjmp=yes \
158                 $(GDB_DIR)/configure \
159                 --prefix=$(STAGING_DIR) \
160                 --build=$(GNU_HOST_NAME) \
161                 --host=$(GNU_HOST_NAME) \
162                 --target=$(REAL_GNU_TARGET_NAME) \
163                 $(DISABLE_NLS) \
164                 --without-uiout --disable-gdbmi \
165                 --disable-tui --disable-gdbtk --without-x \
166                 --without-included-gettext \
167                 --enable-threads \
168         );
169         touch  $(GDB_CLIENT_DIR)/.configured
170
171 $(GDB_CLIENT_DIR)/gdb/gdb: $(GDB_CLIENT_DIR)/.configured
172         $(MAKE) -C $(GDB_CLIENT_DIR)
173         strip $(GDB_CLIENT_DIR)/gdb/gdb
174
175 $(TARGET_CROSS)gdb: $(GDB_CLIENT_DIR)/gdb/gdb
176         install -c $(GDB_CLIENT_DIR)/gdb/gdb $(TARGET_CROSS)gdb
177         ln -s ../../bin/$(REAL_GNU_TARGET_NAME)-gdb \
178                 $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/bin/gdb
179
180 gdbclient: $(TARGET_CROSS)gdb
181
182 gdbclient-clean:
183         $(MAKE) -C $(GDB_CLIENT_DIR) clean
184
185 gdbclient-dirclean:
186         rm -rf $(GDB_CLIENT_DIR)
187
188
189