mknative-gdb revision 1.8
11.1Snathanw#!/bin/sh
21.8Schristos#	$NetBSD: mknative-gdb,v 1.8 2019/05/29 01:56:06 christos Exp $
31.1Snathanw#
41.1Snathanw# Shell script for generating all the constants needed for a native
51.3Schristos# platform build of src/external/gpl3/gdb
61.1Snathanw#
71.1Snathanw
81.1Snathanw# initialise
91.1Snathanw
101.1Snathanw_TMPDIR=$2
111.1Snathanw_TOP=$3
121.1Snathanw_PLATFORM=$4
131.7Smrg_MACHINE_SUBDIR=$5
141.1Snathanw_VPATH=`grep VPATH ${_TMPDIR}/Makefile | sed 's,^.*=[ 	]*,,'`
151.3Schristos_GDB=external/gpl3/gdb
161.1Snathanw
171.1Snathanw. $_TOP/tools/gcc/mknative.common
181.1Snathanw
191.3Schristos##### gdb/lib/libbfd #####
201.1Snathanw
211.1Snathanwget_gdb_libbfd () {
221.3Schristos	local _BFD=$_GDB/lib/libbfd
231.7Smrg	mkdir -p $_TOP/$_BFD/arch/$_MACHINE_SUBDIR
241.1Snathanw
251.1Snathanw	{
261.1Snathanw		getvars bfd/Makefile \
271.1Snathanw			libbfd_la_DEPENDENCIES libbfd_la_OBJECTS DEFS \
281.1Snathanw			INCLUDES TDEFAULTS
291.7Smrg	} | write_mk $_BFD/arch/$_MACHINE_SUBDIR/defs.mk
301.1Snathanw
311.3Schristos	for i in bfd-in3.h bfd_stdint.h config.h bfd.h bfdver.h targmatch.h 
321.3Schristos	do
331.7Smrg	    write_c $_BFD/arch/$_MACHINE_SUBDIR/$i <$_TMPDIR/bfd/$i
341.3Schristos	done
351.1Snathanw}
361.1Snathanw
371.3Schristos##### gdb/lib/libopcodes #####
381.1Snathanw
391.1Snathanwget_gdb_libopcodes () {
401.3Schristos	local _OPCODES=$_GDB/lib/libopcodes
411.7Smrg	mkdir -p $_TOP/$_OPCODES/arch/$_MACHINE_SUBDIR
421.1Snathanw
431.1Snathanw	{
441.1Snathanw		getvars opcodes/Makefile \
451.1Snathanw			archdefs BFD_MACHINES libopcodes_la_SOURCES
461.7Smrg	} | write_mk $_GDB/lib/libopcodes//arch/$_MACHINE_SUBDIR/defs.mk
471.1Snathanw
481.1Snathanw	{
491.1Snathanw		cat $_TMPDIR/opcodes/config.h
501.7Smrg	} | write_c $_OPCODES/arch/$_MACHINE_SUBDIR/config.h
511.1Snathanw}
521.1Snathanw
531.3Schristos##### gdb/lib/libiberty #####
541.1Snathanw
551.1Snathanwget_gdb_libiberty () {
561.3Schristos	local _IBERTY=$_GDB/lib/libiberty
571.7Smrg	mkdir -p $_TOP/$_IBERTY/arch/$_MACHINE_SUBDIR
581.1Snathanw
591.1Snathanw	getvars libiberty/Makefile \
601.1Snathanw		ALLOCA EXTRA_OFILES LIBOBJS REQUIRED_OFILES \
611.7Smrg		| write_mk $_IBERTY/arch/$_MACHINE_SUBDIR/defs.mk
621.1Snathanw
631.7Smrg	write_c $_IBERTY/arch/$_MACHINE_SUBDIR/config.h \
641.1Snathanw		<$_TMPDIR/libiberty/config.h
651.1Snathanw}
661.1Snathanw
671.3Schristos##### gdb/lib/libreadline #####
681.1Snathanw
691.1Snathanwget_gdb_libreadline () {
701.3Schristos	local _READLINE=$_GDB/lib/libreadline
711.7Smrg	mkdir -p $_TOP/$_READLINE/arch/$_MACHINE_SUBDIR
721.1Snathanw
731.1Snathanw	{
741.1Snathanw		getvars readline/Makefile \
751.1Snathanw			CCFLAGS OBJECTS
761.7Smrg	} | write_mk $_READLINE/arch/$_MACHINE_SUBDIR/defs.mk
771.3Schristos
781.7Smrg	write_c $_READLINE/arch/$_MACHINE_SUBDIR/config.h \
791.3Schristos		<$_TMPDIR/readline/config.h
801.3Schristos}
811.3Schristos
821.3Schristos##### gdb/lib/libdecnumber #####
831.3Schristos
841.3Schristosget_gdb_libdecnumber () {
851.3Schristos	local _DECNUMBER=$_GDB/lib/libdecnumber
861.7Smrg	mkdir -p $_TOP/$_DECNUMBER/arch/$_MACHINE_SUBDIR
871.3Schristos
881.3Schristos	getvars libdecnumber/Makefile \
891.3Schristos		libdecnumber_a_OBJS |
901.3Schristos	sed -e s/libdecnumber_a_// |
911.7Smrg	write_mk $_DECNUMBER/arch/$_MACHINE_SUBDIR/defs.mk
921.1Snathanw
931.7Smrg	write_c $_DECNUMBER/arch/$_MACHINE_SUBDIR/config.h \
941.1Snathanw		<$_TMPDIR/readline/config.h
951.3Schristos
961.7Smrg	write_c $_DECNUMBER/arch/$_MACHINE_SUBDIR/gstdint.h \
971.3Schristos		< $_TMPDIR/libdecnumber/gstdint.h
981.1Snathanw}
991.1Snathanw
1001.3Schristos##### gdb/lib/libgdb #####
1011.1Snathanw
1021.3Schristosget_gdb_libgdb () {
1031.3Schristos	local _GDBP=$_GDB/lib/libgdb
1041.7Smrg	mkdir -p $_TOP/$_GDBP/arch/$_MACHINE_SUBDIR/build-gnulib
1051.1Snathanw
1061.1Snathanw	{
1071.1Snathanw		getvars gdb/Makefile \
1081.1Snathanw			INTERNAL_CFLAGS LIBGDB_OBS SIM_OBS
1091.8Schristos	} | sed -e s@arch/@@g -e s@cli/@@g -e s@common/agent@common-agent@ \
1101.8Schristos		-e s@common/@@g -e s@compile/@@g -e s@guile/@@g -e s@mi/@@g \
1111.8Schristos		-e s@nat/@@g -e s@python/@@g -e s@target/@@g \
1121.8Schristos		-e s@tui/@@g | write_mk $_GDBP/arch/$_MACHINE_SUBDIR/defs.mk
1131.1Snathanw
1141.1Snathanw#	getvars gdb/gdbserver/Makefile \
1151.1Snathanw#		INTERNAL_CFLAGS OBS \
1161.7Smrg#		| write_mk $_GDB/bin/gdb/arch/$_MACHINE_SUBDIR/gdbserver.mk
1171.1Snathanw
1181.8Schristos	for i in config.h version.c init.c \
1191.6Schristos	    xml-builtin.c build-gnulib/config.h jit-reader.h
1201.3Schristos	do
1211.7Smrg	    write_c $_GDBP/arch/$_MACHINE_SUBDIR/$i \
1221.3Schristos		< $_TMPDIR/gdb/$i
1231.1Snathanw	done
1241.1Snathanw
1251.1Snathanw	for f in nm tm xm; do
1261.1Snathanw		if [ -f $_TMPDIR/gdb/$f.h ]; then 
1271.1Snathanw			ls -l $_TMPDIR/gdb/$f.h | sed 's,^.*->.*/gdb/,,;s,^,#include <,;s,$,>,' \
1281.7Smrg				| write_c $_GDBP/arch/$_MACHINE_SUBDIR/$f.h
1291.1Snathanw		fi
1301.1Snathanw	done
1311.1Snathanw
1321.3Schristos	local _LIBSIM=$_GDB/lib/libsim
1331.7Smrg	case $_MACHINE_SUBDIR in
1341.1Snathanw	powerpc*)
1351.7Smrg		mkdir -p $_TOP/$_LIBSIM/arch/$_MACHINE_SUBDIR
1361.7Smrg		write_c $_LIBSIM/arch/$_MACHINE_SUBDIR/config.h \
1371.1Snathanw			<$_TMPDIR/sim/ppc/config.h
1381.7Smrg		write_c $_LIBSIM/arch/$_MACHINE_SUBDIR/build-config.h \
1391.4Schristos			<$_TMPDIR/sim/ppc/build-config.h
1401.7Smrg		#write_c $_LIBSIM/arch/$_MACHINE_SUBDIR/cconfig.h \
1411.7Smrg		#	<$_TMPDIR/sim/common/cconfig.h
1421.1Snathanw		;;
1431.5Schristos	xxmips*)	# Disabled for now
1441.7Smrg		mkdir -p $_TOP/$_LIBSIM/arch/$_MACHINE_SUBDIR
1451.7Smrg		write_c $_LIBSIM/arch/$_MACHINE_SUBDIR/config.h \
1461.1Snathanw			<$_TMPDIR/sim/mips/config.h
1471.7Smrg		#write_c $_LIBSIM/arch/$_MACHINE_SUBDIR/cconfig.h \
1481.7Smrg		#	<$_TMPDIR/sim/common/cconfig.h
1491.1Snathanw		{
1501.1Snathanw			getvars sim/mips/Makefile \
1511.1Snathanw				LIB_OBJS CONFIG_CFLAGS \
1521.1Snathanw			    	BUILT_SRC_FROM_IGEN IGEN_OBJS
1531.7Smrg		} | write_mk $_LIBSIM/arch/$_MACHINE_SUBDIR/defs.mk
1541.1Snathanw		;;
1551.1Snathanw	*)
1561.1Snathanw		;;
1571.1Snathanw	esac
1581.1Snathanw}
1591.1Snathanw
1601.1Snathanw##### main #####
1611.1Snathanw
1621.1Snathanwcase $1 in
1631.1Snathanwall|gdb)	# everything (uses "canadian cross" temp environment)
1641.3Schristos	get_gdb_libgdb
1651.1Snathanw	get_gdb_libbfd
1661.1Snathanw	get_gdb_libopcodes
1671.1Snathanw	get_gdb_libiberty
1681.1Snathanw	get_gdb_libreadline
1691.3Schristos	get_gdb_libdecnumber
1701.1Snathanw	exit 0
1711.1Snathanw	;;
1721.1Snathanw
1731.1Snathanw*)	echo invalid arguments; exit 1;;
1741.1Snathanwesac
175