#	$NetBSD: Makefile.hb68k,v 1.3 2026/08/03 19:24:48 thorpej Exp $

# Makefile for NetBSD
#
# This makefile is constructed from a machine description:
#	config machineid
# Most changes should be made in the machine description
#	/sys/arch/hb68k/conf/``machineid''
# after which you should do
#	config machineid
# Machine generic makefile changes should be made in
#	/sys/arch/hb68k/conf/Makefile.hb68k
# after which config should be rerun for all machines of that type.
#
# To specify debugging, add the config line: makeoptions DEBUG="-g"
# A better way is to specify -g only for a few files.
#
#	makeoptions DEBUGLIST="uvm* trap if_*"

HAVE_M68010!=	grep '\#define[ 	]*M68010' opt_m68k_arch.h 2>/dev/null || echo no

.if ${HAVE_M68010} != "no"
MACHINE_ARCH=m68000
.else
MACHINE_ARCH=m68k
.endif
USETOOLS?=	no
NEED_OWN_INSTALL_TARGET?=no
.include <bsd.own.mk>

##
## (1) port identification
##
HB68K=		$S/arch/hb68k
GENASSYM_CONF=	$S/arch/m68k/m68k/genassym.cf

##
## (2) compile settings
##
CPPFLAGS+=	-Dhb68k
.if !defined(CMACHFLAGS)
.include "$S/arch/m68k/Makefile.cmachflags"
. if ${HAVE_M68010} == "no"
CMACHFLAGS+=	-Wa,-m68030
. endif
.endif

CFLAGS+=	${CMACHFLAGS} -msoft-float
AFLAGS+=	-x assembler-with-cpp

##
## (3) libkern and compat
##
OPT_MODULAR=	%MODULAR%
# MACHINE_ARCH needs to be propagated to lib/libkern/arch/m68k/Makefile.inc.
KERNMISCMAKEFLAGS=	MACHINE_ARCH=${MACHINE_ARCH}

##
## (4) local objects, compile rules, and dependencies
##
.include "$S/arch/m68k/conf/Makefile.kern.m68k.inc"

.if ${MACHINE_ARCH} == "m68k"
# for the Motorola 68040 Floating Point Software Product
.include "$S/arch/m68k/fpsp/Makefile.inc"

# for the Motorola 68060 Software Support Package
.include "$S/arch/m68k/060sp/Makefile.inc"
.endif

MD_OBJS=	locore.o
.if ${MACHINE_ARCH} == "m68k"
MD_LIBS=	${FPSP}
.endif
MD_CFILES=
MD_SFILES=	${HB68K}/hb68k/locore.s

.if defined(STATIC_DEVICE_TREE)
STATIC_DEVICE_TREE_BASENAME= static_device_tree
STATIC_DEVICE_TREE_SFILE= ${STATIC_DEVICE_TREE_BASENAME}.S
STATIC_DEVICE_TREE_OBJ= ${STATIC_DEVICE_TREE_BASENAME}.o
${STATIC_DEVICE_TREE_SFILE}: ${STATIC_DEVICE_TREE}
	${_MKTARGET_CREATE}
	(echo " .section .data.read_mostly"; \
	 ${TOOL_DTC} -O asm -o - ${STATIC_DEVICE_TREE}) | \
	${TOOL_SED} -e '/\.globl.*dt_/b' -e '/\.globl/d' > ${.TARGET}
MD_SFILES+=	${STATIC_DEVICE_TREE_SFILE}
MD_OBJS+=	${STATIC_DEVICE_TREE_OBJ}
CLEANFILES+=	${STATIC_DEVICE_TREE_SFILE}
.endif

locore.o: ${HB68K}/hb68k/locore.s assym.h
	${NORMAL_S}
##
## (5) link settings
##
LINKFORMAT=	-n
TEXTADDR?=	2000

##
## (6) port specific target dependencies
##

# depend on CPU configuration
locore.o sys_machdep.o trap.o: Makefile

copy.o copypage.o lock_stubs.o: assym.h

##
## (7) misc settings
##

##
## (8) config(8) generated machinery
##
%INCLUDES

%OBJS

%CFILES

%SFILES

%LOAD

%RULES

##
## (9) port independent kernel machinery
##
.include "$S/conf/Makefile.kern.inc"

##
## (10) Appending make options.
##
%MAKEOPTIONSAPPEND
