Makefile revision 284597
1#-
2# Copyright (c) 2013-2014 Robert N. M. Watson
3# All rights reserved.
4#
5# This software was developed by SRI International and the University of
6# Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
7# ("CTSRD"), as part of the DARPA CRASH research programme.
8#
9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions
11# are met:
12# 1. Redistributions of source code must retain the above copyright
13#    notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright
15#    notice, this list of conditions and the following disclaimer in the
16#    documentation and/or other materials provided with the distribution.
17#
18# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28# SUCH DAMAGE.
29#
30# $FreeBSD: head/sys/boot/mips/beri/loader/Makefile 284597 2015-06-19 14:20:21Z bapt $
31
32.include <src.opts.mk>
33MK_SSP=		no
34MAN=
35
36PROG?=		loader
37NEWVERSWHAT=	"BERI loader" ${MACHINE_CPUARCH}
38INSTALLFLAGS=	-b
39
40# Architecture-specific loader code
41SRCS=		start.S						\
42		main.c						\
43		devicename.c					\
44		exec.c						\
45		metadata.c					\
46		vers.c						\
47		arch.c
48
49# libstand front-ends for shared driver code
50SRCS+=		beri_console.c					\
51		beri_disk_cfi.c					\
52		beri_disk_sdcard.c
53
54# Common code with boot2
55SRCS+=		altera_jtag_uart.c				\
56		cfi.c						\
57		sdcard.c
58
59# Since we don't have a backward compatibility issue, default to this on BERI.
60CFLAGS+=	-DBOOT_PROMPT_123
61
62CFLAGS+=	-DLOADER_DISK_SUPPORT
63CFLAGS+=	-DLOADER_UFS_SUPPORT
64CFLAGS+=	-DLOADER_GZIP_SUPPORT
65CFLAGS+=	-DLOADER_BZIP2_SUPPORT
66
67#CFLAGS+=	-DLOADER_NET_SUPPORT
68#CFLAGS+=	-DLOADER_NFS_SUPPORT
69#CFLAGS+=	-DLOADER_TFTP_SUPPORT
70
71.if ${MK_FORTH} != "no"
72# Enable BootForth
73BOOT_FORTH=	yes
74CFLAGS+=	-DBOOT_FORTH -I${.CURDIR}/../../../ficl
75CFLAGS+=	-I${.CURDIR}/../../../ficl/mips
76LIBFICL=	${.OBJDIR}/../../../ficl/libficl.a
77.endif
78
79# Common code across BERI boot loader parts
80.PATH:		${.CURDIR}/../common
81CFLAGS+=	-I${.CURDIR}/../common
82
83# Always add MI sources
84.PATH:		${.CURDIR}/../../../common
85.include	"${.CURDIR}/../../../common/Makefile.inc"
86CFLAGS+=	-I${.CURDIR}/../../../common
87
88# BERI files common to boot2 and loader
89.PATH:		${.CURDIR}/../common
90CFLAGS+=	-I${.CURDIR}/../common
91
92# Loader-specific MD headers
93CFLAGS+=	-I${.CURDIR}
94
95CLEANFILES+=	vers.c loader.help
96
97# Generate code appropriate for the loader environment
98CFLAGS+=	-G0					\
99		-fno-pic				\
100		-mno-abicalls				\
101		-msoft-float				\
102		-g
103
104LDFLAGS=	-nostdlib				\
105		-static					\
106		-T ${.CURDIR}/loader.ldscript		\
107		-L${.CURDIR}				\
108		-e __start
109
110# where to get libstand from
111CFLAGS+=	-I${.CURDIR}/../../../../../lib/libstand/
112LIBSTAND=	${.OBJDIR}/../../../../../lib/libstand/libstand.a
113
114DPADD=		${LIBFICL} ${LIBSTAND}
115LDADD=		${LIBFICL} ${LIBSTAND}
116
117vers.c: ${.CURDIR}/../../../common/newvers.sh ${.CURDIR}/version
118	sh ${.CURDIR}/../../../common/newvers.sh ${.CURDIR}/version	\
119	    ${NEWVERSWHAT}
120
121loader.help: help.common help.mips
122	cat ${.ALLSRC} | \
123	    awk -f ${.CURDIR}/../../../common/merge_help.awk > ${.TARGET}
124
125.PATH: ${.CURDIR}/../../../forth
126.include	"${.CURDIR}/../../../forth/Makefile.inc"
127
128.if !exists(${DESTDIR}/boot/loader.rc)
129FILES+= loader.rc
130.endif
131
132.if !exists(${DESTDIR}/boot/menu.rc)
133FILES+= menu.rc
134.endif
135
136.if defined(LOADER_USB_SUPPORT)
137# Do garbage collection
138CFLAGS+= -ffunction-sections -fdata-sections
139CFLAGS+= -Wl,--gc-sections
140# Link USB BOOT library
141LDADD+= ${.OBJDIR}/../../../usb/libusbboot.a
142CFLAGS+= -I${.CURDIR}/../../../usb
143# Define USB SUPPORT
144CFLAGS+= -DLOADER_USB_SUPPORT
145.endif
146
147all: loader
148
149.include <bsd.prog.mk>
150