# Configuration fragment for BFD.

# This is almost always correct.

Set selarchs "&bfd_{target_cpu}_arch"
Set defvec ""
Set selvecs ""
Set havevecs ""

If "{target_canonical}" =~ /m68k-apple-macos/
	Set BFD_BACKENDS '"{o}"coff-m68k.c.o "{o}"cofflink.c.o'
	Set defvec m68kcoff_vec
	Set selvecs '&m68kcoff_vec'
	Set havevecs '-d HAVE_m68kcoff_vec'

Else If "{target_canonical}" =~ /powerpc-apple-macos/
	Set BFD_BACKENDS '"{o}"coff-pmac.c.o "{o}"xcofflink.c.o'
	Set defvec pmac_xcoff_vec
	Set selvecs '&pmac_xcoff_vec'
	Set havevecs '-d HAVE_pmac_xcoff_vec'
	Set selarchs "&bfd_powerpc_arch"

Else If "{target_canonical}" =~ /i386-\Option-x-go32/
	Set BFD_BACKENDS '"{o}"coff-i386.c.o'
	Set defvec i386coff_vec
	Set selvecs '&i386coff_vec'
	Set havevecs '-d HAVE_i386coff_vec'

Else If "{target_canonical}" =~ /mips-\Option-x-\Option-x/
	Set BFD_BACKENDS '"{o}"coff-mips.c.o "{o}"ecoff.c.o "{o}"ecofflink.c.o "{o}"elf32.c.o "{o}"elf32-mips.c.o "{o}"elflink.c.o'
	Set defvec ecoff_big_vec
	Set selvecs '&ecoff_big_vec,&ecoff_little_vec,&bfd_elf32_bigmips_vec'
	Set havevecs '-d HAVE_ecoff_big_vec -d HAVE_ecoff_little_vec -d HAVE_bfd_elf32_bigmips_vec'

Else If "{target_canonical}" =~ /sh-\Option-x-hms/
	Set BFD_BACKENDS '"{o}"coff-sh.c.o "{o}"cofflink.c.o'
	Set defvec shcoff_vec
	Set selvecs '&shcoff_vec,&shlcoff_vec'
	Set havevecs '-d HAVE_shcoff_vec -d HAVE_shlcoff_vec'
End If

Set ta `echo {selarchs} | sed -e 's/&bfd_/{o}cpu-/g' -e 's/_arch/.c.o/g'`

Set tdefaults "-d DEFAULT_VECTOR={defvec} -d SELECT_VECS={selvecs} -d SELECT_ARCHITECTURES={selarchs} {havevecs}"

Echo '# From mpw-config.in'				 > "{o}"mk.tmp
Echo 'WORDSIZE = 32'					>> "{o}"mk.tmp
Echo 'BFD_MACHINES = ' {ta}				>> "{o}"mk.tmp
Echo 'BFD_BACKENDS = ' {BFD_BACKENDS}			>> "{o}"mk.tmp
Echo 'TDEFAULTS = ' {tdefaults}				>> "{o}"mk.tmp
Echo 'HDEPFILES = '					>> "{o}"mk.tmp
Echo 'TDEPFILES = '					>> "{o}"mk.tmp
Echo '# End from mpw-config.in'				>> "{o}"mk.tmp

Echo '/* config.h.  Generated by mpw-configure.  */'	 > "{o}"config.new
Echo '#include "mpw.h"'					>> "{o}"config.new

MoveIfChange "{o}"config.new "{o}"config.h

# We can only handle 32-bit targets right now.

sed -e 's/@WORDSIZE@/32/' \Option-d
    -e 's/@wordsize@/32/' \Option-d
    -e "s/@VERSION@/`Catenate {srcdir}VERSION`/" \Option-d
    -e 's/@BFD_HOST_64_BIT_DEFINED@/0/' \Option-d
    -e 's/@BFD_HOST_64_BIT@//' \Option-d
    -e 's/@BFD_HOST_U_64_BIT@//' \Option-d
    -e 's/@BFD_HOST_64BIT_LONG@/0/' \Option-d
    "{srcdir}"bfd-in2.h >"{o}"bfd.h-new

MoveIfChange "{o}"bfd.h-new "{o}"bfd.h

sed -e 's/NN/32/g' "{srcdir}"elfxx-target.h >"{o}"elf32-target.h-new
MoveIfChange "{o}"elf32-target.h-new "{o}"elf32-target.h

# Pre-expand some macros in coffswap.h, so MPW C doesn't choke.

sed -e 's/^  PUT_AOUTHDR_TSIZE (/  bfd_h_put_32 (/' \Option-d
    -e 's/^  PUT_AOUTHDR_DSIZE (/  bfd_h_put_32 (/' \Option-d
    -e 's/^  PUT_AOUTHDR_BSIZE (/  bfd_h_put_32 (/' \Option-d
    -e 's/^  PUT_AOUTHDR_ENTRY (/  bfd_h_put_32 (/' \Option-d
    -e 's/^  PUT_AOUTHDR_TEXT_START (/  bfd_h_put_32 (/' \Option-d
    -e 's/^  PUT_AOUTHDR_DATA_START (/  bfd_h_put_32 (/' \Option-d
    "{srcdir}"coffswap.h >"{o}"coffswap.h-new

MoveIfChange "{o}"coffswap.h-new "{o}"coffswap.h
