1262197Srwatson#-
2262197Srwatson# Copyright (c) 2013-2014 Robert N. M. Watson
3262197Srwatson# All rights reserved.
4262197Srwatson#
5262197Srwatson# This software was developed by SRI International and the University of
6262197Srwatson# Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
7262197Srwatson# ("CTSRD"), as part of the DARPA CRASH research programme.
8262197Srwatson#
9262198Srwatson# Redistribution and use in source and binary forms, with or without
10262198Srwatson# modification, are permitted provided that the following conditions
11262198Srwatson# are met:
12262198Srwatson# 1. Redistributions of source code must retain the above copyright
13262198Srwatson#    notice, this list of conditions and the following disclaimer.
14262198Srwatson# 2. Redistributions in binary form must reproduce the above copyright
15262198Srwatson#    notice, this list of conditions and the following disclaimer in the
16262198Srwatson#    documentation and/or other materials provided with the distribution.
17262197Srwatson#
18262198Srwatson# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19262198Srwatson# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20262198Srwatson# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21262198Srwatson# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22262198Srwatson# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23262198Srwatson# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24262198Srwatson# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25262198Srwatson# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26262198Srwatson# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27262198Srwatson# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28262198Srwatson# SUCH DAMAGE.
29262197Srwatson#
30262197Srwatson# $FreeBSD: releng/11.0/sys/boot/mips/beri/loader/Makefile 296079 2016-02-26 08:06:25Z sgalabov $
31262197Srwatson
32265420Simp.include <src.opts.mk>
33262197SrwatsonMK_SSP=		no
34284597SbaptMAN=
35262197Srwatson
36262197SrwatsonPROG?=		loader
37262197SrwatsonNEWVERSWHAT=	"BERI loader" ${MACHINE_CPUARCH}
38262197SrwatsonINSTALLFLAGS=	-b
39262197Srwatson
40262197Srwatson# Architecture-specific loader code
41262197SrwatsonSRCS=		start.S						\
42262197Srwatson		main.c						\
43262197Srwatson		devicename.c					\
44262197Srwatson		exec.c						\
45262197Srwatson		metadata.c					\
46262197Srwatson		vers.c						\
47262197Srwatson		arch.c
48262197Srwatson
49262197Srwatson# libstand front-ends for shared driver code
50262197SrwatsonSRCS+=		beri_console.c					\
51262197Srwatson		beri_disk_cfi.c					\
52262197Srwatson		beri_disk_sdcard.c
53262197Srwatson
54262197Srwatson# Common code with boot2
55262197SrwatsonSRCS+=		altera_jtag_uart.c				\
56262197Srwatson		cfi.c						\
57262197Srwatson		sdcard.c
58262197Srwatson
59262197Srwatson# Since we don't have a backward compatibility issue, default to this on BERI.
60262197SrwatsonCFLAGS+=	-DBOOT_PROMPT_123
61262197Srwatson
62262197SrwatsonCFLAGS+=	-DLOADER_DISK_SUPPORT
63262197SrwatsonCFLAGS+=	-DLOADER_UFS_SUPPORT
64262197SrwatsonCFLAGS+=	-DLOADER_GZIP_SUPPORT
65262197SrwatsonCFLAGS+=	-DLOADER_BZIP2_SUPPORT
66262197Srwatson
67262197Srwatson#CFLAGS+=	-DLOADER_NET_SUPPORT
68262197Srwatson#CFLAGS+=	-DLOADER_NFS_SUPPORT
69262197Srwatson#CFLAGS+=	-DLOADER_TFTP_SUPPORT
70262197Srwatson
71262197Srwatson.if ${MK_FORTH} != "no"
72262197Srwatson# Enable BootForth
73262197SrwatsonBOOT_FORTH=	yes
74262197SrwatsonCFLAGS+=	-DBOOT_FORTH -I${.CURDIR}/../../../ficl
75296079SsgalabovCFLAGS+=	-I${.CURDIR}/../../../ficl/mips64
76262197SrwatsonLIBFICL=	${.OBJDIR}/../../../ficl/libficl.a
77262197Srwatson.endif
78262197Srwatson
79262197Srwatson# Common code across BERI boot loader parts
80262197Srwatson.PATH:		${.CURDIR}/../common
81262197SrwatsonCFLAGS+=	-I${.CURDIR}/../common
82262197Srwatson
83262197Srwatson# Always add MI sources
84262197Srwatson.PATH:		${.CURDIR}/../../../common
85262197Srwatson.include	"${.CURDIR}/../../../common/Makefile.inc"
86262197SrwatsonCFLAGS+=	-I${.CURDIR}/../../../common
87262197Srwatson
88262197Srwatson# BERI files common to boot2 and loader
89262197Srwatson.PATH:		${.CURDIR}/../common
90262197SrwatsonCFLAGS+=	-I${.CURDIR}/../common
91262197Srwatson
92262197Srwatson# Loader-specific MD headers
93262197SrwatsonCFLAGS+=	-I${.CURDIR}
94262197Srwatson
95262197SrwatsonCLEANFILES+=	vers.c loader.help
96262197Srwatson
97262197Srwatson# Generate code appropriate for the loader environment
98262197SrwatsonCFLAGS+=	-G0					\
99262197Srwatson		-fno-pic				\
100262197Srwatson		-mno-abicalls				\
101262197Srwatson		-msoft-float				\
102262197Srwatson		-g
103262197Srwatson
104262197SrwatsonLDFLAGS=	-nostdlib				\
105262197Srwatson		-static					\
106262197Srwatson		-T ${.CURDIR}/loader.ldscript		\
107262197Srwatson		-L${.CURDIR}				\
108262197Srwatson		-e __start
109262197Srwatson
110262197Srwatson# where to get libstand from
111262197SrwatsonCFLAGS+=	-I${.CURDIR}/../../../../../lib/libstand/
112262197SrwatsonLIBSTAND=	${.OBJDIR}/../../../../../lib/libstand/libstand.a
113262197Srwatson
114262197SrwatsonDPADD=		${LIBFICL} ${LIBSTAND}
115262197SrwatsonLDADD=		${LIBFICL} ${LIBSTAND}
116262197Srwatson
117262197Srwatsonvers.c: ${.CURDIR}/../../../common/newvers.sh ${.CURDIR}/version
118262197Srwatson	sh ${.CURDIR}/../../../common/newvers.sh ${.CURDIR}/version	\
119262197Srwatson	    ${NEWVERSWHAT}
120262197Srwatson
121262197Srwatsonloader.help: help.common help.mips
122262197Srwatson	cat ${.ALLSRC} | \
123262197Srwatson	    awk -f ${.CURDIR}/../../../common/merge_help.awk > ${.TARGET}
124262197Srwatson
125281009Sjkim.PATH: ${.CURDIR}/../../../forth
126281010Sjkim.include	"${.CURDIR}/../../../forth/Makefile.inc"
127262197Srwatson
128286368SallanjudeFILES+= loader.rc menu.rc
129262197Srwatson
130266893Shselasky.if defined(LOADER_USB_SUPPORT)
131266893Shselasky# Do garbage collection
132266893ShselaskyCFLAGS+= -ffunction-sections -fdata-sections
133266893ShselaskyCFLAGS+= -Wl,--gc-sections
134266893Shselasky# Link USB BOOT library
135266893ShselaskyLDADD+= ${.OBJDIR}/../../../usb/libusbboot.a
136266893ShselaskyCFLAGS+= -I${.CURDIR}/../../../usb
137266893Shselasky# Define USB SUPPORT
138266893ShselaskyCFLAGS+= -DLOADER_USB_SUPPORT
139266893Shselasky.endif
140266893Shselasky
141262197Srwatsonall: loader
142262197Srwatson
143262197Srwatson.include <bsd.prog.mk>
144