150477Speter# $FreeBSD: releng/11.0/sys/boot/i386/loader/Makefile 296963 2016-03-16 23:12:19Z allanjude $
238465Smsmith
3265420Simp.include <src.opts.mk>
4188895SruMK_SSP=		no
5156813Sru
6199714SrnolandLOADER?=	loader
7199714SrnolandPROG=		${LOADER}.sym
8284590SbaptMAN=	
9125621SruINTERNALPROG=
10212066SdelphijNEWVERSWHAT?=	"bootstrap loader" x86
1138465Smsmith
1239441Smsmith# architecture-specific loader code
13125537SruSRCS=		main.c conf.c vers.c
1439441Smsmith
15170101Ssimokawa# Put LOADER_FIREWIRE_SUPPORT=yes in /etc/make.conf for FireWire/dcons support
16170101Ssimokawa.if defined(LOADER_FIREWIRE_SUPPORT)
17170101SsimokawaCFLAGS+=	-DLOADER_FIREWIRE_SUPPORT
18170101SsimokawaLIBFIREWIRE=	${.OBJDIR}/../libfirewire/libfirewire.a
19170101Ssimokawa.endif
20170101Ssimokawa
21199714Srnoland# Set by zfsloader Makefile
22185029Spjd.if defined(LOADER_ZFS_SUPPORT)
23185029SpjdCFLAGS+=	-DLOADER_ZFS_SUPPORT
24235156SavgLIBZFSBOOT=	${.OBJDIR}/../../zfs/libzfsboot.a
25185029Spjd.endif
26185029Spjd
2759087Sps# Enable PXE TFTP or NFS support, not both.
2868310Sps.if defined(LOADER_TFTP_SUPPORT)
2968310SpsCFLAGS+=	-DLOADER_TFTP_SUPPORT
3068310Sps.else
3159087SpsCFLAGS+=	-DLOADER_NFS_SUPPORT
3268310Sps.endif
3359087Sps
34163893Smarcel# Include bcache code.
35163893SmarcelHAVE_BCACHE=	yes
36163893Smarcel
3739178Smsmith# Enable PnP and ISA-PnP code.
3840555SmsmithHAVE_PNP=	yes
3940555SmsmithHAVE_ISABUS=	yes
4039178Smsmith
41156813Sru.if ${MK_FORTH} != "no"
4240877Smsmith# Enable BootForth
4356903SjhbBOOT_FORTH=	yes
4456903SjhbCFLAGS+=	-DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/i386
45264087Semaste.if ${MACHINE_CPUARCH} == "amd64"
46264087SemasteLIBFICL=	${.OBJDIR}/../../ficl32/libficl.a
47264087Semaste.else
4841107SjkhLIBFICL=	${.OBJDIR}/../../ficl/libficl.a
4941107Sjkh.endif
50264087Semaste.endif
5140877Smsmith
52146874Sobrien.if defined(LOADER_BZIP2_SUPPORT)
5383616SsobomaxCFLAGS+=	-DLOADER_BZIP2_SUPPORT
5483616Ssobomax.endif
5583616Ssobomax.if !defined(LOADER_NO_GZIP_SUPPORT)
5683616SsobomaxCFLAGS+=	-DLOADER_GZIP_SUPPORT
5783616Ssobomax.endif
58235537Sgber.if defined(LOADER_NANDFS_SUPPORT)
59235537SgberCFLAGS+=	-DLOADER_NANDFS_SUPPORT
60235537Sgber.endif
61296963Sallanjude.if !defined(LOADER_NO_GELI_SUPPORT)
62296963SallanjudeCFLAGS+=	-DLOADER_GELI_SUPPORT
63296963SallanjudeLIBGELIBOOT=	${.OBJDIR}/../../geli/libgeliboot.a
64296963Sallanjude.PATH:		${.CURDIR}/../../../opencrypto
65296963SallanjudeSRCS+=		xform_aes_xts.c
66296963SallanjudeCFLAGS+=	-I${.CURDIR}/../../.. -D_STAND
67296963Sallanjude.endif
6883616Ssobomax
69227726Smiwi# Always add MI sources
7038465Smsmith.PATH:		${.CURDIR}/../../common
71125516Sru.include	"${.CURDIR}/../../common/Makefile.inc"
7240338SpeterCFLAGS+=	-I${.CURDIR}/../../common
73125537SruCFLAGS+=	-I.
7438465Smsmith
75199714SrnolandCLEANFILES=	vers.c ${LOADER} ${LOADER}.bin loader.help
7638465Smsmith
7738465SmsmithCFLAGS+=	-Wall
78125621SruLDFLAGS=	-static -Ttext 0x0
7938465Smsmith
8038465Smsmith# i386 standalone support library
8138465SmsmithLIBI386=	${.OBJDIR}/../libi386/libi386.a
8238465SmsmithCFLAGS+=	-I${.CURDIR}/..
8338465Smsmith
84261567SemasteLIBSTAND=	${.OBJDIR}/../../libstand32/libstand.a
85261567Semaste
8639441Smsmith# BTX components
8739646SpeterCFLAGS+=	-I${.CURDIR}/../btx/lib
8839441Smsmith
8939664Smsmith# Debug me!
9040884Smsmith#CFLAGS+=	-g
9140884Smsmith#LDFLAGS+=	-g
9239664Smsmith
93125537Sru# Pick up ../Makefile.inc early.
94125537Sru.include <bsd.init.mk>
95125537Sru
96199714Srnolandvers.c:	${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../loader/version
97199714Srnoland	sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../loader/version \
98199714Srnoland		${NEWVERSWHAT}
9938465Smsmith
100199714Srnoland${LOADER}: ${LOADER}.bin ${BTXLDR} ${BTXKERN}
101102623Sjhb	btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \
102199714Srnoland		-b ${BTXKERN} ${LOADER}.bin
10338465Smsmith
104199714Srnoland${LOADER}.bin: ${LOADER}.sym
10540555Smsmith	cp ${.ALLSRC} ${.TARGET}
10669985Srnordier	strip -R .comment -R .note ${.TARGET}
10740555Smsmith
108125537Sruloader.help: help.common help.i386
10942807Smsmith	cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
11041821Smsmith
111199714SrnolandFILES=	${LOADER}
112199714Srnoland# XXX INSTALLFLAGS_loader= -b
113199714SrnolandFILESMODE_${LOADER}= ${BINMODE} -b
114199714Srnoland
115199714Srnoland.if !defined(LOADER_ONLY)
116281009Sjkim.PATH: ${.CURDIR}/../../forth
117281002Sjkim.include	"${.CURDIR}/../../forth/Makefile.inc"
118281002SjkimFILES+=	pcibios.4th
11994956Sru
120286368SallanjudeFILES+=	loader.rc menu.rc
12145759Sdcs.endif
12241821Smsmith
123126312Sru# XXX crt0.o needs to be first for pxeboot(8) to work
124227726SmiwiOBJS=	${BTXCRT}
12540555Smsmith
126296963SallanjudeDPADD=	${LIBFICL} ${LIBFIREWIRE} ${LIBZFSBOOT} ${LIBI386} ${LIBSTAND} ${LIBGELIBOOT}
127296963SallanjudeLDADD=	${LIBFICL} ${LIBFIREWIRE} ${LIBZFSBOOT} ${LIBI386} ${LIBSTAND} ${LIBGELIBOOT}
128126312Sru
129125621Sru.include <bsd.prog.mk>
13039441Smsmith
131211677Simp.if ${MACHINE_CPUARCH} == "amd64"
132125581Srubeforedepend ${OBJS}: machine
133125537SruCLEANFILES+=	machine
134241068SaeCFLAGS+=	-DLOADER_PREFER_AMD64
135296706Sbdrewerymachine: .NOMETA
13640338Speter	ln -sf ${.CURDIR}/../../../i386/include machine
13740555Smsmith.endif
138