1# $FreeBSD$
2
3.include <bsd.own.mk>
4
5PROG=		ubldr
6NEWVERSWHAT=	"U-Boot loader" ${MACHINE_ARCH}
7BINDIR?=	/boot
8INSTALLFLAGS=	-b
9WARNS?=		1
10# Address at which ubldr will be loaded.
11# This varies for different boards and SOCs.
12UBLDR_LOADADDR?=	0x1000000
13
14# Architecture-specific loader code
15SRCS=		start.S conf.c vers.c
16
17.if !defined(LOADER_NO_DISK_SUPPORT)
18LOADER_DISK_SUPPORT?=	yes
19.else
20LOADER_DISK_SUPPORT=	no
21.endif
22LOADER_UFS_SUPPORT?=	yes
23LOADER_CD9660_SUPPORT?=	no
24LOADER_EXT2FS_SUPPORT?=	no
25.if ${MK_NAND} != "no"
26LOADER_NANDFS_SUPPORT?= yes
27.else
28LOADER_NANDFS_SUPPORT?= no
29.endif
30LOADER_NET_SUPPORT?=	yes
31LOADER_NFS_SUPPORT?=	yes
32LOADER_TFTP_SUPPORT?=	no
33LOADER_GZIP_SUPPORT?=	no
34LOADER_BZIP2_SUPPORT?=	no
35.if ${MK_FDT} != "no"
36LOADER_FDT_SUPPORT=	yes
37.else
38LOADER_FDT_SUPPORT=	no
39.endif
40
41.if ${LOADER_DISK_SUPPORT} == "yes"
42CFLAGS+=	-DLOADER_DISK_SUPPORT
43.endif
44.if ${LOADER_UFS_SUPPORT} == "yes"
45CFLAGS+=	-DLOADER_UFS_SUPPORT
46.endif
47.if ${LOADER_CD9660_SUPPORT} == "yes"
48CFLAGS+=	-DLOADER_CD9660_SUPPORT
49.endif
50.if ${LOADER_EXT2FS_SUPPORT} == "yes"
51CFLAGS+=	-DLOADER_EXT2FS_SUPPORT
52.endif
53.if ${LOADER_NANDFS_SUPPORT} == "yes"
54CFLAGS+=	-DLOADER_NANDFS_SUPPORT
55.endif
56.if ${LOADER_GZIP_SUPPORT} == "yes"
57CFLAGS+=	-DLOADER_GZIP_SUPPORT
58.endif
59.if ${LOADER_BZIP2_SUPPORT} == "yes"
60CFLAGS+=	-DLOADER_BZIP2_SUPPORT
61.endif
62.if ${LOADER_NET_SUPPORT} == "yes"
63CFLAGS+=	-DLOADER_NET_SUPPORT
64.endif
65.if ${LOADER_NFS_SUPPORT} == "yes"
66CFLAGS+=	-DLOADER_NFS_SUPPORT
67.endif
68.if ${LOADER_TFTP_SUPPORT} == "yes"
69CFLAGS+=	-DLOADER_TFTP_SUPPORT
70.endif
71.if ${LOADER_FDT_SUPPORT} == "yes"
72CFLAGS+=	-I${.CURDIR}/../../fdt
73CFLAGS+=	-I${.OBJDIR}/../../fdt
74CFLAGS+=	-DLOADER_FDT_SUPPORT
75LIBFDT=		${.OBJDIR}/../../fdt/libfdt.a
76.endif
77
78.if !defined(NO_FORTH)
79# Enable BootForth
80BOOT_FORTH=	yes
81CFLAGS+=	-DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/arm
82LIBFICL=	${.OBJDIR}/../../ficl/libficl.a
83.endif
84
85# Always add MI sources
86.PATH:		${.CURDIR}/../../common
87.include	"${.CURDIR}/../../common/Makefile.inc"
88CFLAGS+=	-I${.CURDIR}/../../common
89CFLAGS+=	-I.
90
91CLEANFILES+=	vers.c loader.help
92
93CFLAGS+=	-ffreestanding -msoft-float
94
95LDFLAGS=	-nostdlib -static
96LDFLAGS+=	-T ldscript.generated
97LDFLAGS+=	-T ${.CURDIR}/ldscript.${MACHINE_CPUARCH}
98
99# Pull in common loader code
100.PATH:		${.CURDIR}/../../uboot/common
101.include	"${.CURDIR}/../../uboot/common/Makefile.inc"
102CFLAGS+=	-I${.CURDIR}/../../uboot/common
103
104# U-Boot standalone support library
105LIBUBOOT=	${.OBJDIR}/../../uboot/lib/libuboot.a
106CFLAGS+=	-I${.CURDIR}/../../uboot/lib
107CFLAGS+=	-I${.OBJDIR}/../../uboot/lib
108
109# where to get libstand from
110CFLAGS+=	-I${.CURDIR}/../../../../lib/libstand/
111
112# clang doesn't understand %D as a specifier to printf
113NO_WERROR.clang=
114
115DPADD=		${LIBFICL} ${LIBUBOOT} ${LIBFDT} ${LIBSTAND}
116LDADD=		${LIBFICL} ${LIBUBOOT} ${LIBFDT} -lstand
117
118vers.c:	${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
119	sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
120
121loader.help: help.common help.uboot ${.CURDIR}/../../fdt/help.fdt
122	cat ${.ALLSRC} | \
123	    awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
124
125${PROG}: ldscript.generated ${.CURDIR}/ldscript.${MACHINE_CPUARCH}
126
127ldscript.generated::
128	rm -f ldscript.generated.tmp
129	echo "UBLDR_LOADADDR = ${UBLDR_LOADADDR};" >ldscript.generated.tmp
130	if diff ldscript.generated ldscript.generated.tmp > /dev/null; then \
131		true; \
132	else \
133		rm -f ldscript.generated; \
134		mv ldscript.generated.tmp ldscript.generated; \
135	fi
136
137.if !defined(LOADER_ONLY)
138.PATH: ${.CURDIR}/../../forth
139FILES+=	loader.help loader.4th support.4th loader.conf
140FILES+=	screen.4th frames.4th beastie.4th
141FILES+=	brand.4th check-password.4th color.4th delay.4th
142FILES+=	menu.4th menu-commands.4th menusets.4th shortcuts.4th version.4th
143FILESDIR_loader.conf=	/boot/defaults
144
145# Put sample loader.rc and menu.rc on disk but don't enable them
146# by default.
147FILES+=	loader.rc
148FILESNAME_loader.rc=	loader.rc.sample
149FILES+=	menu.rc
150FILESNAME_menu.rc=	menu.rc.sample
151.endif
152
153.include <bsd.prog.mk>
154