167204Sobrien# $FreeBSD$
267204Sobrien
3156813Sru.include <bsd.own.mk>
4188895SruMK_SSP=		no
5156813Sru
6125634SgrehanPROG=		loader
7174930SmarcelNEWVERSWHAT=	"Open Firmware loader" ${MACHINE_ARCH}
867204SobrienBINDIR?=	/boot
983368SruINSTALLFLAGS=	-b
1067204Sobrien
11125634Sgrehan# Architecture-specific loader code
12123375SgrehanSRCS=		conf.c metadata.c vers.c start.c
13209920SnwhitehornSRCS+=		ucmpdi2.c
14123375Sgrehan
1568548SbennoLOADER_DISK_SUPPORT?=	yes
16123375SgrehanLOADER_UFS_SUPPORT?=	yes
17123375SgrehanLOADER_CD9660_SUPPORT?=	yes
18123375SgrehanLOADER_EXT2FS_SUPPORT?=	no
1968548SbennoLOADER_NET_SUPPORT?=	yes
20123375SgrehanLOADER_NFS_SUPPORT?=	yes
21176185SrajLOADER_TFTP_SUPPORT?=	no
22123375SgrehanLOADER_GZIP_SUPPORT?=	yes
23123375SgrehanLOADER_BZIP2_SUPPORT?=	no
2467204Sobrien
25125634Sgrehan.if ${LOADER_DISK_SUPPORT} == "yes"
2667204SobrienCFLAGS+=	-DLOADER_DISK_SUPPORT
2768548Sbenno.endif
28123375Sgrehan.if ${LOADER_UFS_SUPPORT} == "yes"
29123375SgrehanCFLAGS+=	-DLOADER_UFS_SUPPORT
30123375Sgrehan.endif
31123375Sgrehan.if ${LOADER_CD9660_SUPPORT} == "yes"
32123375SgrehanCFLAGS+=	-DLOADER_CD9660_SUPPORT
33123375Sgrehan.endif
34123375Sgrehan.if ${LOADER_EXT2FS_SUPPORT} == "yes"
35123375SgrehanCFLAGS+=	-DLOADER_EXT2FS_SUPPORT
36123375Sgrehan.endif
37125634Sgrehan.if ${LOADER_GZIP_SUPPORT} == "yes"
38125634SgrehanCFLAGS+=	-DLOADER_GZIP_SUPPORT
39125634Sgrehan.endif
40125634Sgrehan.if ${LOADER_BZIP2_SUPPORT} == "yes"
41125634SgrehanCFLAGS+=	-DLOADER_BZIP2_SUPPORT
42125634Sgrehan.endif
43125634Sgrehan.if ${LOADER_NET_SUPPORT} == "yes"
4468548SbennoCFLAGS+=	-DLOADER_NET_SUPPORT
4568548Sbenno.endif
46123375Sgrehan.if ${LOADER_NFS_SUPPORT} == "yes"
47123375SgrehanCFLAGS+=	-DLOADER_NFS_SUPPORT
48123375Sgrehan.endif
49123375Sgrehan.if ${LOADER_TFTP_SUPPORT} == "yes"
50123375SgrehanCFLAGS+=	-DLOADER_TFTP_SUPPORT
51123375Sgrehan.endif
5267204Sobrien
53156813Sru.if ${MK_FORTH} != "no"
54123375Sgrehan# Enable BootForth
55123375SgrehanBOOT_FORTH=	yes
56123375SgrehanCFLAGS+=	-DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/powerpc
57123375SgrehanLIBFICL=	${.OBJDIR}/../../ficl/libficl.a
58123375Sgrehan.endif
5967204Sobrien
60204129Snwhitehorn# Avoid the open-close-dance for every file access as some firmwares perform
61204129Snwhitehorn# an auto-negotiation on every open of the network interface and thus causes
62204129Snwhitehorn# netbooting to take horribly long.
63204129SnwhitehornCFLAGS+=	-DNETIF_OPEN_CLOSE_ONCE
64204129Snwhitehorn
65125634Sgrehan# Always add MI sources
66209920Snwhitehorn.PATH:		${.CURDIR}/../../common ${.CURDIR}/../../../libkern
67125634Sgrehan.include	"${.CURDIR}/../../common/Makefile.inc"
68209920SnwhitehornCFLAGS+=	-I${.CURDIR}/../../common -I${.CURDIR}/../../..
69125634SgrehanCFLAGS+=	-I.
7067204Sobrien
71125634SgrehanCLEANFILES+=	vers.c loader.help
7267204Sobrien
73176479SmarcelCFLAGS+=	-ffreestanding -msoft-float
74131811Sgrehan# load address. set in linker script
75123375SgrehanRELOC?=		0x1C00000
76123375SgrehanCFLAGS+=	-DRELOC=${RELOC}
7767204Sobrien
78131811SgrehanLDFLAGS=	-nostdlib -static -T ${.CURDIR}/ldscript.powerpc
79131811Sgrehan
80132997Sgrehan# 64-bit bridge extensions
81132997SgrehanCFLAGS+= -Wa,-mppc64bridge
82132997Sgrehan
83123375Sgrehan# Pull in common loader code
84123375Sgrehan.PATH:		${.CURDIR}/../../ofw/common
85125634Sgrehan.include	"${.CURDIR}/../../ofw/common/Makefile.inc"
86123375Sgrehan
87133862Smarius# Open Firmware standalone support library
8867204SobrienLIBOFW=		${.OBJDIR}/../../ofw/libofw/libofw.a
8967204SobrienCFLAGS+=	-I${.CURDIR}/../../ofw/libofw
9067204Sobrien
9167204Sobrien# where to get libstand from
92271130SemasteLIBSTAND=	${.OBJDIR}/../../libstand32/libstand.a
9367204SobrienCFLAGS+=	-I${.CURDIR}/../../../../lib/libstand/
9467204Sobrien
95125634SgrehanDPADD=		${LIBFICL} ${LIBOFW} ${LIBSTAND}
96271130SemasteLDADD=		${LIBFICL} ${LIBOFW} ${LIBSTAND}
9767204Sobrien
98123375Sgrehanvers.c:	${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
9967204Sobrien	sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
10067204Sobrien
101125634Sgrehanloader.help: help.common help.ofw
102123375Sgrehan	cat ${.ALLSRC} | \
103123375Sgrehan	    awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
10467204Sobrien
105123375Sgrehan.PATH: ${.CURDIR}/../../forth
106125634SgrehanFILES=	loader.help loader.4th support.4th loader.conf
107222450SandreastFILES+=	screen.4th frames.4th
108222417SjulianFILES+=	beastie.4th brand.4th check-password.4th color.4th delay.4th
109242688SdteskeFILES+=	menu.4th menu-commands.4th menusets.4th shortcuts.4th version.4th
110123375SgrehanFILESDIR_loader.conf=	/boot/defaults
111123375Sgrehan
11267204Sobrien.if !exists(${DESTDIR}/boot/loader.rc)
113123375SgrehanFILES+= loader.rc
11467204Sobrien.endif
11567204Sobrien
116222417Sjulian.if !exists(${DESTDIR}/boot/menu.rc)
117222417SjulianFILES+= menu.rc
118222417Sjulian.endif
119222417Sjulian
12067204Sobrien.include <bsd.prog.mk>
121