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