#	$NetBSD: Makefile,v 1.6 1999/07/30 04:07:25 mycroft Exp $

#
#	This make file is a modified version of the Makefile for ld
#	which will sett things up to generate a cross-linker.
#
#	When making, TARGET_ARCH should be set to the desired target's
#	architecture type. This will be set from MACHINE_ARCH if not set
#	(which is appropriate for building within a cross-build environment).
#

TARGET_ARCH?=	${MACHINE_ARCH}
.if	(${TARGET_ARCH} == "m68k") || \
	(${TARGET_ARCH} == "sparc")
TBO=	BIG
.else
TBO=	LITTLE
.endif

HOST_ARCH!=	uname -p
.if	(${HOST_ARCH} == "m68k")    || \
	(${HOST_ARCH} == "mipseb")  || \
	(${HOST_ARCH} == "powerpc") || \
	(${HOST_ARCH} == "sparc")   || \
	(${HOST_ARCH} == "sparc64")
HBO?=	BIG
.else
HBO?=	LITTLE
.endif

# Now figure out NEED_SWAP

CPPFLAGS+=-DCROSS_LINKER

.if	(${TBO} != ${HBO})
CPPFLAGS+=-DNEED_SWAP
.endif

PROG=	ld.${TARGET_ARCH}
SRCS=	ld.c symbol.c lib.c shlib.c warnings.c rrs.c xbits.c md.c

.if defined(DEBUG)
CPPFLAGS+=-DDEBUG
.endif

.PATH: ${.CURDIR}/arch/${TARGET_ARCH}
CPPFLAGS+=-nostdinc -I${.CURDIR} -I${.CURDIR}/arch/${TARGET_ARCH} -I/usr/include

MAN=	ld.1

.include <bsd.prog.mk>
