mknative-gdb revision 1.6
11.1Snathanw#!/bin/sh
21.6Schristos#	$NetBSD: mknative-gdb,v 1.6 2013/10/03 18:58:37 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.1Snathanw_VPATH=`grep VPATH ${_TMPDIR}/Makefile | sed 's,^.*=[ 	]*,,'`
141.3Schristos_GDB=external/gpl3/gdb
151.1Snathanw
161.1Snathanw. $_TOP/tools/gcc/mknative.common
171.1Snathanw
181.3Schristos##### gdb/lib/libbfd #####
191.1Snathanw
201.1Snathanwget_gdb_libbfd () {
211.3Schristos	local _BFD=$_GDB/lib/libbfd
221.3Schristos	mkdir -p $_TOP/$_BFD/arch/$MACHINE_ARCH
231.1Snathanw
241.1Snathanw	{
251.1Snathanw		getvars bfd/Makefile \
261.1Snathanw			libbfd_la_DEPENDENCIES libbfd_la_OBJECTS DEFS \
271.1Snathanw			INCLUDES TDEFAULTS
281.3Schristos	} | write_mk $_BFD/arch/$MACHINE_ARCH/defs.mk
291.1Snathanw
301.3Schristos	for i in bfd-in3.h bfd_stdint.h config.h bfd.h bfdver.h targmatch.h 
311.3Schristos	do
321.3Schristos	    write_c $_BFD/arch/$MACHINE_ARCH/$i <$_TMPDIR/bfd/$i
331.3Schristos	done
341.1Snathanw}
351.1Snathanw
361.3Schristos##### gdb/lib/libopcodes #####
371.1Snathanw
381.1Snathanwget_gdb_libopcodes () {
391.3Schristos	local _OPCODES=$_GDB/lib/libopcodes
401.3Schristos	mkdir -p $_TOP/$_OPCODES/arch/$MACHINE_ARCH
411.1Snathanw
421.1Snathanw	{
431.1Snathanw		getvars opcodes/Makefile \
441.1Snathanw			archdefs BFD_MACHINES libopcodes_la_SOURCES
451.3Schristos	} | write_mk $_GDB/lib/libopcodes//arch/$MACHINE_ARCH/defs.mk
461.1Snathanw
471.1Snathanw	{
481.1Snathanw		cat $_TMPDIR/opcodes/config.h
491.3Schristos	} | write_c $_OPCODES/arch/$MACHINE_ARCH/config.h
501.1Snathanw}
511.1Snathanw
521.3Schristos##### gdb/lib/libiberty #####
531.1Snathanw
541.1Snathanwget_gdb_libiberty () {
551.3Schristos	local _IBERTY=$_GDB/lib/libiberty
561.3Schristos	mkdir -p $_TOP/$_IBERTY/arch/$MACHINE_ARCH
571.1Snathanw
581.1Snathanw	getvars libiberty/Makefile \
591.1Snathanw		ALLOCA EXTRA_OFILES LIBOBJS REQUIRED_OFILES \
601.3Schristos		| write_mk $_IBERTY/arch/$MACHINE_ARCH/defs.mk
611.1Snathanw
621.3Schristos	write_c $_IBERTY/arch/$MACHINE_ARCH/config.h \
631.1Snathanw		<$_TMPDIR/libiberty/config.h
641.1Snathanw}
651.1Snathanw
661.3Schristos##### gdb/lib/libreadline #####
671.1Snathanw
681.1Snathanwget_gdb_libreadline () {
691.3Schristos	local _READLINE=$_GDB/lib/libreadline
701.3Schristos	mkdir -p $_TOP/$_READLINE/arch/$MACHINE_ARCH
711.1Snathanw
721.1Snathanw	{
731.1Snathanw		getvars readline/Makefile \
741.1Snathanw			CCFLAGS OBJECTS
751.3Schristos	} | write_mk $_READLINE/arch/$MACHINE_ARCH/defs.mk
761.3Schristos
771.3Schristos	write_c $_READLINE/arch/$MACHINE_ARCH/config.h \
781.3Schristos		<$_TMPDIR/readline/config.h
791.3Schristos}
801.3Schristos
811.3Schristos##### gdb/lib/libdecnumber #####
821.3Schristos
831.3Schristosget_gdb_libdecnumber () {
841.3Schristos	local _DECNUMBER=$_GDB/lib/libdecnumber
851.3Schristos	mkdir -p $_TOP/$_DECNUMBER/arch/$MACHINE_ARCH
861.3Schristos
871.3Schristos	getvars libdecnumber/Makefile \
881.3Schristos		libdecnumber_a_OBJS |
891.3Schristos	sed -e s/libdecnumber_a_// |
901.3Schristos	write_mk $_DECNUMBER/arch/$MACHINE_ARCH/defs.mk
911.1Snathanw
921.3Schristos	write_c $_DECNUMBER/arch/$MACHINE_ARCH/config.h \
931.1Snathanw		<$_TMPDIR/readline/config.h
941.3Schristos
951.3Schristos	write_c $_DECNUMBER/arch/$MACHINE_ARCH/gstdint.h \
961.3Schristos		< $_TMPDIR/libdecnumber/gstdint.h
971.1Snathanw}
981.1Snathanw
991.3Schristos##### gdb/lib/libgdb #####
1001.1Snathanw
1011.3Schristosget_gdb_libgdb () {
1021.3Schristos	local _GDBP=$_GDB/lib/libgdb
1031.6Schristos	mkdir -p $_TOP/$_GDBP/arch/$MACHINE_ARCH/build-gnulib
1041.1Snathanw
1051.1Snathanw	{
1061.1Snathanw		getvars gdb/Makefile \
1071.1Snathanw			INTERNAL_CFLAGS LIBGDB_OBS SIM_OBS
1081.3Schristos	} | write_mk $_GDBP/arch/$MACHINE_ARCH/defs.mk
1091.1Snathanw
1101.1Snathanw#	getvars gdb/gdbserver/Makefile \
1111.1Snathanw#		INTERNAL_CFLAGS OBS \
1121.3Schristos#		| write_mk $_GDB/bin/gdb/arch/$MACHINE_ARCH/gdbserver.mk
1131.1Snathanw
1141.6Schristos	for i in config.h observer.h observer.inc version.c init.c \
1151.6Schristos	    xml-builtin.c build-gnulib/config.h jit-reader.h
1161.3Schristos	do
1171.3Schristos	    write_c $_GDBP/arch/$MACHINE_ARCH/$i \
1181.3Schristos		< $_TMPDIR/gdb/$i
1191.1Snathanw	done
1201.1Snathanw
1211.1Snathanw	for f in nm tm xm; do
1221.1Snathanw		if [ -f $_TMPDIR/gdb/$f.h ]; then 
1231.1Snathanw			ls -l $_TMPDIR/gdb/$f.h | sed 's,^.*->.*/gdb/,,;s,^,#include <,;s,$,>,' \
1241.3Schristos				| write_c $_GDBP/arch/$MACHINE_ARCH/$f.h
1251.1Snathanw		fi
1261.1Snathanw	done
1271.1Snathanw
1281.3Schristos	local _LIBSIM=$_GDB/lib/libsim
1291.1Snathanw	case $MACHINE_ARCH in
1301.1Snathanw	powerpc*)
1311.5Schristos		mkdir -p $_TOP/$_LIBSIM/arch/$MACHINE_ARCH
1321.3Schristos		write_c $_LIBSIM/arch/$MACHINE_ARCH/config.h \
1331.1Snathanw			<$_TMPDIR/sim/ppc/config.h
1341.4Schristos		write_c $_LIBSIM/arch/$MACHINE_ARCH/build-config.h \
1351.4Schristos			<$_TMPDIR/sim/ppc/build-config.h
1361.3Schristos		write_c $_LIBSIM/arch/$MACHINE_ARCH/cconfig.h \
1371.1Snathanw			<$_TMPDIR/sim/common/cconfig.h
1381.1Snathanw		;;
1391.5Schristos	xxmips*)	# Disabled for now
1401.5Schristos		mkdir -p $_TOP/$_LIBSIM/arch/$MACHINE_ARCH
1411.3Schristos		write_c $_LIBSIM/arch/$MACHINE_ARCH/config.h \
1421.1Snathanw			<$_TMPDIR/sim/mips/config.h
1431.3Schristos		write_c $_LIBSIM/arch/$MACHINE_ARCH/cconfig.h \
1441.1Snathanw			<$_TMPDIR/sim/common/cconfig.h
1451.1Snathanw		{
1461.1Snathanw			getvars sim/mips/Makefile \
1471.1Snathanw				LIB_OBJS CONFIG_CFLAGS \
1481.1Snathanw			    	BUILT_SRC_FROM_IGEN IGEN_OBJS
1491.3Schristos		} | write_mk $_LIBSIM/arch/$MACHINE_ARCH/defs.mk
1501.1Snathanw		;;
1511.1Snathanw	*)
1521.1Snathanw		;;
1531.1Snathanw	esac
1541.1Snathanw}
1551.1Snathanw
1561.1Snathanw##### main #####
1571.1Snathanw
1581.1Snathanwcase $1 in
1591.1Snathanwall|gdb)	# everything (uses "canadian cross" temp environment)
1601.3Schristos	get_gdb_libgdb
1611.1Snathanw	get_gdb_libbfd
1621.1Snathanw	get_gdb_libopcodes
1631.1Snathanw	get_gdb_libiberty
1641.1Snathanw	get_gdb_libreadline
1651.3Schristos	get_gdb_libdecnumber
1661.1Snathanw	exit 0
1671.1Snathanw	;;
1681.1Snathanw
1691.1Snathanw*)	echo invalid arguments; exit 1;;
1701.1Snathanwesac
171