mknative-gdb.old revision 1.3 1 1.1 christos #!/bin/sh
2 1.3 christos # $NetBSD: mknative-gdb.old,v 1.3 2024/08/14 23:56:20 christos Exp $
3 1.1 christos #
4 1.1 christos # Shell script for generating all the constants needed for a native
5 1.3 christos # platform build of src/external/gpl3/gdb
6 1.1 christos #
7 1.1 christos
8 1.1 christos # initialise
9 1.1 christos
10 1.1 christos _TMPDIR=$2
11 1.1 christos _TOP=$3
12 1.1 christos _PLATFORM=$4
13 1.1 christos _MACHINE_SUBDIR=$5
14 1.1 christos _VPATH=`grep VPATH ${_TMPDIR}/Makefile | sed 's,^.*=[ ]*,,'`
15 1.3 christos _GDB=external/gpl3/gdb
16 1.1 christos
17 1.1 christos . $_TOP/tools/gcc/mknative.common
18 1.1 christos
19 1.1 christos ##### gdb/lib/libbfd #####
20 1.1 christos
21 1.1 christos get_gdb_libbfd () {
22 1.1 christos local _BFD=$_GDB/lib/libbfd
23 1.1 christos mkdir -p $_TOP/$_BFD/arch/$_MACHINE_SUBDIR
24 1.1 christos
25 1.1 christos {
26 1.1 christos getvars bfd/Makefile \
27 1.1 christos libbfd_la_DEPENDENCIES libbfd_la_OBJECTS DEFS \
28 1.1 christos INCLUDES TDEFAULTS
29 1.1 christos } | write_mk $_BFD/arch/$_MACHINE_SUBDIR/defs.mk
30 1.1 christos
31 1.3 christos for i in bfd-in3.h config.h bfd.h bfdver.h targmatch.h
32 1.1 christos do
33 1.1 christos write_c $_BFD/arch/$_MACHINE_SUBDIR/$i <$_TMPDIR/bfd/$i
34 1.1 christos done
35 1.1 christos }
36 1.1 christos
37 1.1 christos ##### gdb/lib/libopcodes #####
38 1.1 christos
39 1.1 christos get_gdb_libopcodes () {
40 1.1 christos local _OPCODES=$_GDB/lib/libopcodes
41 1.1 christos mkdir -p $_TOP/$_OPCODES/arch/$_MACHINE_SUBDIR
42 1.1 christos
43 1.1 christos {
44 1.1 christos getvars opcodes/Makefile \
45 1.1 christos archdefs BFD_MACHINES libopcodes_la_SOURCES
46 1.1 christos } | write_mk $_GDB/lib/libopcodes//arch/$_MACHINE_SUBDIR/defs.mk
47 1.1 christos
48 1.1 christos {
49 1.1 christos cat $_TMPDIR/opcodes/config.h
50 1.1 christos } | write_c $_OPCODES/arch/$_MACHINE_SUBDIR/config.h
51 1.1 christos }
52 1.1 christos
53 1.1 christos ##### gdb/lib/libiberty #####
54 1.1 christos
55 1.1 christos get_gdb_libiberty () {
56 1.1 christos local _IBERTY=$_GDB/lib/libiberty
57 1.1 christos mkdir -p $_TOP/$_IBERTY/arch/$_MACHINE_SUBDIR
58 1.1 christos
59 1.1 christos getvars libiberty/Makefile \
60 1.1 christos ALLOCA EXTRA_OFILES LIBOBJS REQUIRED_OFILES \
61 1.1 christos | write_mk $_IBERTY/arch/$_MACHINE_SUBDIR/defs.mk
62 1.1 christos
63 1.1 christos write_c $_IBERTY/arch/$_MACHINE_SUBDIR/config.h \
64 1.1 christos <$_TMPDIR/libiberty/config.h
65 1.1 christos }
66 1.1 christos
67 1.1 christos ##### gdb/lib/libreadline #####
68 1.1 christos
69 1.1 christos get_gdb_libreadline () {
70 1.1 christos local _READLINE=$_GDB/lib/libreadline
71 1.1 christos mkdir -p $_TOP/$_READLINE/arch/$_MACHINE_SUBDIR
72 1.1 christos
73 1.1 christos {
74 1.3 christos getvars readline/readline/Makefile \
75 1.1 christos CCFLAGS OBJECTS
76 1.1 christos } | write_mk $_READLINE/arch/$_MACHINE_SUBDIR/defs.mk
77 1.1 christos
78 1.1 christos write_c $_READLINE/arch/$_MACHINE_SUBDIR/config.h \
79 1.3 christos <$_TMPDIR/readline/readline/config.h
80 1.1 christos }
81 1.1 christos
82 1.1 christos ##### gdb/lib/libdecnumber #####
83 1.1 christos
84 1.1 christos get_gdb_libdecnumber () {
85 1.1 christos local _DECNUMBER=$_GDB/lib/libdecnumber
86 1.1 christos mkdir -p $_TOP/$_DECNUMBER/arch/$_MACHINE_SUBDIR
87 1.1 christos
88 1.3 christos getvars libdecnumber/Makefile libdecnumber_a_OBJS |
89 1.3 christos sed -e s/libdecnumber_a_//g |
90 1.1 christos write_mk $_DECNUMBER/arch/$_MACHINE_SUBDIR/defs.mk
91 1.1 christos
92 1.1 christos write_c $_DECNUMBER/arch/$_MACHINE_SUBDIR/config.h \
93 1.3 christos <$_TMPDIR/readline/readline/config.h
94 1.1 christos
95 1.1 christos write_c $_DECNUMBER/arch/$_MACHINE_SUBDIR/gstdint.h \
96 1.1 christos < $_TMPDIR/libdecnumber/gstdint.h
97 1.1 christos }
98 1.1 christos
99 1.3 christos ##### gdb/lib/libgdbsupport #####
100 1.3 christos
101 1.3 christos get_gdb_libgdbsupport () {
102 1.3 christos local _GDBSUPPORT=$_GDB/lib/libgdbsupport
103 1.3 christos mkdir -p $_TOP/$_GDBSUPPORT/arch/$_MACHINE_SUBDIR/gdbsupport
104 1.3 christos
105 1.3 christos getvars gdbsupport/Makefile libgdbsupport_a_OBJECTS |
106 1.3 christos sed -e s/libgdbsupport_a_//g |
107 1.3 christos write_mk $_GDBSUPPORT/arch/$_MACHINE_SUBDIR/defs.mk
108 1.3 christos
109 1.3 christos write_c $_GDBSUPPORT/arch/$_MACHINE_SUBDIR/gdbsupport/config.h \
110 1.3 christos <$_TMPDIR/gdbsupport/config.h
111 1.3 christos }
112 1.3 christos
113 1.3 christos ##### gdb/lib/libctf #####
114 1.3 christos
115 1.3 christos get_gdb_libctf () {
116 1.3 christos local _CTF=$_GDB/lib/libctf
117 1.3 christos mkdir -p $_TOP/$_CTF/arch/$_MACHINE_SUBDIR
118 1.3 christos
119 1.3 christos getvars libctf/Makefile libctf_la_OBJECTS |
120 1.3 christos sed -e s/libctf_la_//g -e 's/\.lo/.o/g' -e s/libctf_la-//g |
121 1.3 christos write_mk $_CTF/arch/$_MACHINE_SUBDIR/defs.mk
122 1.3 christos
123 1.3 christos write_c $_CTF/arch/$_MACHINE_SUBDIR/config.h \
124 1.3 christos <$_TMPDIR/libctf/config.h
125 1.3 christos }
126 1.3 christos
127 1.3 christos ##### gdb/lib/libbacktrace #####
128 1.3 christos
129 1.3 christos get_gdb_libbacktrace () {
130 1.3 christos local _BACKTRACE=$_GDB/lib/libbacktrace
131 1.3 christos mkdir -p $_TOP/$_BACKTRACE/arch/$_MACHINE_SUBDIR
132 1.3 christos
133 1.3 christos getvars libbacktrace/Makefile libbacktrace_la_OBJECTS \
134 1.3 christos libbacktrace_la_LIBADD |
135 1.3 christos sed -e s/libbacktrace_la_//g -e 's/\.lo/.o/g' -e s/libbacktrace_la-//g |
136 1.3 christos write_mk $_BACKTRACE/arch/$_MACHINE_SUBDIR/defs.mk
137 1.3 christos
138 1.3 christos write_c $_BACKTRACE/arch/$_MACHINE_SUBDIR/config.h \
139 1.3 christos <$_TMPDIR/libbacktrace/config.h
140 1.3 christos write_c $_BACKTRACE/arch/$_MACHINE_SUBDIR/backtrace-supported.h \
141 1.3 christos <$_TMPDIR/libbacktrace/backtrace-supported.h
142 1.3 christos }
143 1.3 christos
144 1.3 christos ##### gdb/lib/libsframe #####
145 1.3 christos
146 1.3 christos get_gdb_libsframe () {
147 1.3 christos local _SFRAME=$_GDB/lib/libsframe
148 1.3 christos mkdir -p $_TOP/$_SFRAME/arch/$_MACHINE_SUBDIR
149 1.3 christos
150 1.3 christos getvars libsframe/Makefile libsframe_la_OBJECTS |
151 1.3 christos sed -e s/libsframe_la_//g -e 's/\.lo/.o/g' -e s/libsframe_la-//g |
152 1.3 christos write_mk $_SFRAME/arch/$_MACHINE_SUBDIR/defs.mk
153 1.3 christos }
154 1.3 christos
155 1.3 christos ##### gdb/lib/libgnulib #####
156 1.3 christos
157 1.3 christos get_gdb_libgnulib () {
158 1.3 christos local _GNULIB=$_GDB/lib/libgnulib
159 1.3 christos mkdir -p $_TOP/$_GNULIB/arch/$_MACHINE_SUBDIR/gnulib/import/malloc
160 1.3 christos
161 1.3 christos (getvars gnulib/Makefile gl_LIBOBJS |
162 1.3 christos sed -e s/gl_LIB//g &&
163 1.3 christos getvars gnulib/import/Makefile libgnu_a_OBJECTS |
164 1.3 christos sed -e s/libgnu_a-//g -e s@glthread/@@g -e s@malloc/@@g) |
165 1.3 christos write_mk $_GNULIB/arch/$_MACHINE_SUBDIR/defs.mk
166 1.3 christos
167 1.3 christos for i in config.h \
168 1.3 christos import/alloca.h import/ctype.h \
169 1.3 christos import/dirent.h import/fcntl.h \
170 1.3 christos import/fnmatch.h import/glob.h \
171 1.3 christos import/glob-libc.gl.h \
172 1.3 christos import/inttypes.h import/limits.h \
173 1.3 christos import/locale.h import/math.h \
174 1.3 christos import/malloc/scratch_buffer.gl.h \
175 1.3 christos import/signal.h import/stdint.h \
176 1.3 christos import/stdio.h import/stdlib.h \
177 1.3 christos import/string.h import/time.h \
178 1.3 christos import/unistd.h import/wchar.h \
179 1.3 christos import/wctype.h
180 1.3 christos do
181 1.3 christos write_c $_GNULIB/arch/$_MACHINE_SUBDIR/gnulib/$i \
182 1.3 christos < $_TMPDIR/gnulib/$i
183 1.3 christos done
184 1.3 christos }
185 1.3 christos
186 1.1 christos ##### gdb/lib/libgdb #####
187 1.1 christos
188 1.1 christos get_gdb_libgdb () {
189 1.1 christos local _GDBP=$_GDB/lib/libgdb
190 1.1 christos
191 1.1 christos {
192 1.1 christos getvars gdb/Makefile \
193 1.1 christos INTERNAL_CFLAGS LIBGDB_OBS SIM_OBS
194 1.1 christos } | sed -e s@arch/@@g -e s@cli/@@g -e s@common/agent@common-agent@ \
195 1.1 christos -e s@common/@@g -e s@compile/@@g -e s@guile/@@g -e s@mi/@@g \
196 1.1 christos -e s@nat/@@g -e s@python/@@g -e s@target/@@g \
197 1.3 christos -e s@dwarf2/@@g -e s@unittests/@@g \
198 1.1 christos -e s@tui/@@g | write_mk $_GDBP/arch/$_MACHINE_SUBDIR/defs.mk
199 1.1 christos
200 1.1 christos # getvars gdb/gdbserver/Makefile \
201 1.1 christos # INTERNAL_CFLAGS OBS \
202 1.1 christos # | write_mk $_GDB/bin/gdb/arch/$_MACHINE_SUBDIR/gdbserver.mk
203 1.1 christos
204 1.1 christos for i in config.h version.c init.c \
205 1.3 christos xml-builtin.c jit-reader.h
206 1.1 christos do
207 1.1 christos write_c $_GDBP/arch/$_MACHINE_SUBDIR/$i \
208 1.1 christos < $_TMPDIR/gdb/$i
209 1.1 christos done
210 1.3 christos
211 1.1 christos
212 1.1 christos for f in nm tm xm; do
213 1.3 christos if [ ! -f $_TMPDIR/gdb/$f.h ]; then
214 1.3 christos continue
215 1.1 christos fi
216 1.3 christos ls -l $_TMPDIR/gdb/$f.h | \
217 1.3 christos sed 's,^.*->.*/gdb/,,;s,^,#include <,;s,$,>,' | \
218 1.3 christos write_c $_GDBP/arch/$_MACHINE_SUBDIR/$f.h
219 1.1 christos done
220 1.1 christos
221 1.1 christos local _LIBSIM=$_GDB/lib/libsim
222 1.1 christos case $_MACHINE_SUBDIR in
223 1.1 christos powerpc*)
224 1.1 christos mkdir -p $_TOP/$_LIBSIM/arch/$_MACHINE_SUBDIR
225 1.1 christos write_c $_LIBSIM/arch/$_MACHINE_SUBDIR/config.h \
226 1.1 christos <$_TMPDIR/sim/ppc/config.h
227 1.1 christos write_c $_LIBSIM/arch/$_MACHINE_SUBDIR/build-config.h \
228 1.1 christos <$_TMPDIR/sim/ppc/build-config.h
229 1.1 christos #write_c $_LIBSIM/arch/$_MACHINE_SUBDIR/cconfig.h \
230 1.1 christos # <$_TMPDIR/sim/common/cconfig.h
231 1.1 christos ;;
232 1.1 christos xxmips*) # Disabled for now
233 1.1 christos mkdir -p $_TOP/$_LIBSIM/arch/$_MACHINE_SUBDIR
234 1.1 christos write_c $_LIBSIM/arch/$_MACHINE_SUBDIR/config.h \
235 1.1 christos <$_TMPDIR/sim/mips/config.h
236 1.1 christos #write_c $_LIBSIM/arch/$_MACHINE_SUBDIR/cconfig.h \
237 1.1 christos # <$_TMPDIR/sim/common/cconfig.h
238 1.1 christos {
239 1.1 christos getvars sim/mips/Makefile \
240 1.1 christos LIB_OBJS CONFIG_CFLAGS \
241 1.1 christos BUILT_SRC_FROM_IGEN IGEN_OBJS
242 1.1 christos } | write_mk $_LIBSIM/arch/$_MACHINE_SUBDIR/defs.mk
243 1.1 christos ;;
244 1.1 christos *)
245 1.1 christos ;;
246 1.1 christos esac
247 1.1 christos }
248 1.1 christos
249 1.3 christos # gdb/bin/gdbserver`
250 1.3 christos
251 1.3 christos get_gdb_bingdbserver () {
252 1.3 christos local _CTF=$_GDB/bin/gdbserver
253 1.3 christos
254 1.3 christos if [ ! -f $_CTF/arch/$_MACHINE_SUBDIR/config.h ]; then
255 1.3 christos return
256 1.3 christos fi
257 1.3 christos mkdir -p $_TOP/$_CTF/arch/$_MACHINE_SUBDIR
258 1.3 christos
259 1.3 christos write_c $_CTF/arch/$_MACHINE_SUBDIR/config.h \
260 1.3 christos <$_TMPDIR/gdbserver/config.h
261 1.3 christos write_c $_CTF/arch/$_MACHINE_SUBDIR/version.cc \
262 1.3 christos <$_TMPDIR/gdbserver/version-generated.cc
263 1.3 christos }
264 1.3 christos
265 1.1 christos ##### main #####
266 1.1 christos
267 1.1 christos case $1 in
268 1.1 christos all|gdb) # everything (uses "canadian cross" temp environment)
269 1.1 christos get_gdb_libgdb
270 1.3 christos get_gdb_libgdbsupport
271 1.3 christos get_gdb_libctf
272 1.3 christos get_gdb_libbacktrace
273 1.3 christos get_gdb_libsframe
274 1.3 christos get_gdb_libgnulib
275 1.1 christos get_gdb_libbfd
276 1.1 christos get_gdb_libopcodes
277 1.1 christos get_gdb_libiberty
278 1.1 christos get_gdb_libreadline
279 1.1 christos get_gdb_libdecnumber
280 1.3 christos get_gdb_bingdbserver
281 1.1 christos exit 0
282 1.1 christos ;;
283 1.1 christos
284 1.1 christos *) echo invalid arguments; exit 1;;
285 1.1 christos esac
286