#	$NetBSD: Makefile.assym,v 1.6 2018/01/24 09:04:45 skrll Exp $

DPSRCS+=	assym.h
CLEANFILES+=	assym.h

.if (${MACHINE_ARCH} == "powerpc")
.if (${MACHINE} == "macppc" || ${MACHINE} == "ofppc" || ${MACHINE} == "prep")
# use oea
GENASSYM_DIR= $S/arch/${MACHINE_ARCH}/oea
CPPFLAGS+=	-DPPC_OEA
.endif
.endif

.if (!empty(MACHINE_ARCH:Mearm*) || !empty(MACHINE_ARCH:Marm*))
GENASSYM_DIR= $S/arch/arm/arm32
.endif

.if exists($S/arch/${MACHINE}/${MACHINE}/genassym.cf)
GENASSYM_DIR?= $S/arch/${MACHINE}/${MACHINE}
.elif exists($S/arch/${MACHINE_CPU}/${MACHINE_CPU}/genassym.cf)
GENASSYM_DIR?= $S/arch/${MACHINE_CPU}/${MACHINE_CPU}
.else
GENASSYM_DIR?=
.endif

assym.h:
#	 ${GENASSYM_DIR}/genassym.cf
	@echo ${S}
	${TOOL_GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${PROF} \
		${GENASSYM_CPPFLAGS} < ${GENASSYM_DIR}/genassym.cf \
		> assym.h.tmp && \
	mv -f assym.h.tmp assym.h