Makefile revision 281002
133965Sjdp#-
278828Sobrien# Copyright (c) 2013-2014 Robert N. M. Watson
333965Sjdp# All rights reserved.
433965Sjdp#
533965Sjdp# This software was developed by SRI International and the University of
633965Sjdp# Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
733965Sjdp# ("CTSRD"), as part of the DARPA CRASH research programme.
833965Sjdp#
933965Sjdp# Redistribution and use in source and binary forms, with or without
1033965Sjdp# modification, are permitted provided that the following conditions
1133965Sjdp# are met:
1233965Sjdp# 1. Redistributions of source code must retain the above copyright
1333965Sjdp#    notice, this list of conditions and the following disclaimer.
1433965Sjdp# 2. Redistributions in binary form must reproduce the above copyright
1533965Sjdp#    notice, this list of conditions and the following disclaimer in the
16218822Sdim#    documentation and/or other materials provided with the distribution.
1733965Sjdp#
1833965Sjdp# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1933965Sjdp# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2033965Sjdp# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2133965Sjdp# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2233965Sjdp# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2333965Sjdp# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2433965Sjdp# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2533965Sjdp# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2633965Sjdp# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2733965Sjdp# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2833965Sjdp# SUCH DAMAGE.
2933965Sjdp#
3033965Sjdp# $FreeBSD: head/sys/boot/mips/beri/loader/Makefile 281002 2015-04-02 20:07:05Z jkim $
3133965Sjdp
3233965Sjdp.include <src.opts.mk>
3333965SjdpMK_SSP=		no
3433965Sjdp
3533965SjdpPROG?=		loader
3633965SjdpNEWVERSWHAT=	"BERI loader" ${MACHINE_CPUARCH}
3733965SjdpINSTALLFLAGS=	-b
3833965Sjdp
3933965Sjdp# Architecture-specific loader code
4033965SjdpSRCS=		start.S						\
4133965Sjdp		main.c						\
4233965Sjdp		devicename.c					\
4333965Sjdp		exec.c						\
4433965Sjdp		metadata.c					\
4533965Sjdp		vers.c						\
4633965Sjdp		arch.c
4733965Sjdp
4833965Sjdp# libstand front-ends for shared driver code
4933965SjdpSRCS+=		beri_console.c					\
5033965Sjdp		beri_disk_cfi.c					\
5133965Sjdp		beri_disk_sdcard.c
5233965Sjdp
5333965Sjdp# Common code with boot2
5433965SjdpSRCS+=		altera_jtag_uart.c				\
5533965Sjdp		cfi.c						\
5633965Sjdp		sdcard.c
5733965Sjdp
5833965Sjdp# Since we don't have a backward compatibility issue, default to this on BERI.
5933965SjdpCFLAGS+=	-DBOOT_PROMPT_123
6033965Sjdp
6133965SjdpCFLAGS+=	-DLOADER_DISK_SUPPORT
6233965SjdpCFLAGS+=	-DLOADER_UFS_SUPPORT
6333965SjdpCFLAGS+=	-DLOADER_GZIP_SUPPORT
6433965SjdpCFLAGS+=	-DLOADER_BZIP2_SUPPORT
6533965Sjdp
6633965Sjdp#CFLAGS+=	-DLOADER_NET_SUPPORT
67#CFLAGS+=	-DLOADER_NFS_SUPPORT
68#CFLAGS+=	-DLOADER_TFTP_SUPPORT
69
70.if ${MK_FORTH} != "no"
71# Enable BootForth
72BOOT_FORTH=	yes
73CFLAGS+=	-DBOOT_FORTH -I${.CURDIR}/../../../ficl
74CFLAGS+=	-I${.CURDIR}/../../../ficl/mips
75LIBFICL=	${.OBJDIR}/../../../ficl/libficl.a
76.endif
77
78# Common code across BERI boot loader parts
79.PATH:		${.CURDIR}/../common
80CFLAGS+=	-I${.CURDIR}/../common
81
82# Always add MI sources
83.PATH:		${.CURDIR}/../../../common
84.include	"${.CURDIR}/../../../common/Makefile.inc"
85CFLAGS+=	-I${.CURDIR}/../../../common
86
87# BERI files common to boot2 and loader
88.PATH:		${.CURDIR}/../common
89CFLAGS+=	-I${.CURDIR}/../common
90
91# Loader-specific MD headers
92CFLAGS+=	-I${.CURDIR}
93
94CLEANFILES+=	vers.c loader.help
95
96# Generate code appropriate for the loader environment
97CFLAGS+=	-G0					\
98		-fno-pic				\
99		-mno-abicalls				\
100		-msoft-float				\
101		-g
102
103LDFLAGS=	-nostdlib				\
104		-static					\
105		-T ${.CURDIR}/loader.ldscript		\
106		-L${.CURDIR}				\
107		-e __start
108
109# where to get libstand from
110CFLAGS+=	-I${.CURDIR}/../../../../../lib/libstand/
111LIBSTAND=	${.OBJDIR}/../../../../../lib/libstand/libstand.a
112
113DPADD=		${LIBFICL} ${LIBSTAND}
114LDADD=		${LIBFICL} ${LIBSTAND}
115
116vers.c: ${.CURDIR}/../../../common/newvers.sh ${.CURDIR}/version
117	sh ${.CURDIR}/../../../common/newvers.sh ${.CURDIR}/version	\
118	    ${NEWVERSWHAT}
119
120loader.help: help.common help.mips
121	cat ${.ALLSRC} | \
122	    awk -f ${.CURDIR}/../../../common/merge_help.awk > ${.TARGET}
123
124.include	"${.CURDIR}/../../forth/Makefile.inc"
125
126.if !exists(${DESTDIR}/boot/loader.rc)
127FILES+= loader.rc
128.endif
129
130.if !exists(${DESTDIR}/boot/menu.rc)
131FILES+= menu.rc
132.endif
133
134.if defined(LOADER_USB_SUPPORT)
135# Do garbage collection
136CFLAGS+= -ffunction-sections -fdata-sections
137CFLAGS+= -Wl,--gc-sections
138# Link USB BOOT library
139LDADD+= ${.OBJDIR}/../../../usb/libusbboot.a
140CFLAGS+= -I${.CURDIR}/../../../usb
141# Define USB SUPPORT
142CFLAGS+= -DLOADER_USB_SUPPORT
143.endif
144
145all: loader
146
147.include <bsd.prog.mk>
148