2014-04-13 01:14:25 +00:00
|
|
|
# $FreeBSD$
|
|
|
|
|
2014-04-25 19:25:05 +00:00
|
|
|
MAN=
|
2014-04-13 01:14:25 +00:00
|
|
|
|
2016-01-15 01:22:36 +00:00
|
|
|
.include <src.opts.mk>
|
2014-04-13 01:14:25 +00:00
|
|
|
|
|
|
|
MK_SSP= no
|
|
|
|
|
2015-09-17 18:32:51 +00:00
|
|
|
PROG= boot1.sym
|
2014-04-13 01:14:25 +00:00
|
|
|
INTERNALPROG=
|
2016-01-12 02:17:39 +00:00
|
|
|
WARNS?= 6
|
2014-04-13 01:14:25 +00:00
|
|
|
|
2016-01-15 02:33:47 +00:00
|
|
|
.if ${MK_ZFS} != "no"
|
|
|
|
# Disable warnings that are currently incompatible with the zfs boot code
|
|
|
|
CWARNFLAGS.zfs_module.c += -Wno-array-bounds
|
|
|
|
CWARNFLAGS.zfs_module.c += -Wno-cast-align
|
|
|
|
CWARNFLAGS.zfs_module.c += -Wno-cast-qual
|
|
|
|
CWARNFLAGS.zfs_module.c += -Wno-missing-prototypes
|
|
|
|
CWARNFLAGS.zfs_module.c += -Wno-sign-compare
|
|
|
|
CWARNFLAGS.zfs_module.c += -Wno-unused-parameter
|
|
|
|
CWARNFLAGS.zfs_module.c += -Wno-unused-function
|
|
|
|
.endif
|
|
|
|
|
2014-04-13 01:14:25 +00:00
|
|
|
# architecture-specific loader code
|
2016-01-15 01:22:36 +00:00
|
|
|
SRCS= boot1.c self_reloc.c start.S ufs_module.c
|
2016-01-15 02:33:47 +00:00
|
|
|
.if ${MK_ZFS} != "no"
|
|
|
|
SRCS+= zfs_module.c
|
|
|
|
.endif
|
2014-04-13 01:14:25 +00:00
|
|
|
|
|
|
|
CFLAGS+= -I.
|
2015-04-01 08:30:40 +00:00
|
|
|
CFLAGS+= -I${.CURDIR}/../include
|
2015-04-14 10:40:37 +00:00
|
|
|
CFLAGS+= -I${.CURDIR}/../include/${MACHINE}
|
2014-04-13 01:14:25 +00:00
|
|
|
CFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica/include
|
|
|
|
CFLAGS+= -I${.CURDIR}/../../..
|
2016-01-15 01:22:36 +00:00
|
|
|
CFLAGS+= -DEFI_UFS_BOOT
|
2014-04-13 01:14:25 +00:00
|
|
|
|
2016-01-15 02:33:47 +00:00
|
|
|
.if ${MK_ZFS} != "no"
|
|
|
|
CFLAGS+= -I${.CURDIR}/../../zfs/
|
|
|
|
CFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs/
|
|
|
|
CFLAGS+= -DEFI_ZFS_BOOT
|
|
|
|
.endif
|
|
|
|
|
2014-04-13 06:24:01 +00:00
|
|
|
# Always add MI sources and REGULAR efi loader bits
|
2015-04-14 10:40:37 +00:00
|
|
|
.PATH: ${.CURDIR}/../loader/arch/${MACHINE}
|
2015-04-07 21:34:49 +00:00
|
|
|
.PATH: ${.CURDIR}/../loader
|
|
|
|
.PATH: ${.CURDIR}/../../common
|
2014-04-13 01:14:25 +00:00
|
|
|
CFLAGS+= -I${.CURDIR}/../../common
|
|
|
|
|
2014-04-26 16:34:22 +00:00
|
|
|
FILES= boot1.efi boot1.efifat
|
2014-04-13 01:14:25 +00:00
|
|
|
FILESMODE_boot1.efi= ${BINMODE}
|
|
|
|
|
2015-04-14 10:40:37 +00:00
|
|
|
LDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE}
|
2015-04-03 15:25:59 +00:00
|
|
|
LDFLAGS= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared
|
|
|
|
|
2015-05-05 11:00:50 +00:00
|
|
|
.if ${MACHINE_CPUARCH} == "aarch64"
|
|
|
|
CFLAGS+= -msoft-float -mgeneral-regs-only
|
|
|
|
.endif
|
2015-04-03 15:25:59 +00:00
|
|
|
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
|
2015-04-09 10:08:10 +00:00
|
|
|
CFLAGS+= -fPIC
|
2015-04-03 15:25:59 +00:00
|
|
|
LDFLAGS+= -Wl,-znocombreloc
|
|
|
|
.endif
|
2014-04-13 01:14:25 +00:00
|
|
|
|
2015-04-06 15:50:20 +00:00
|
|
|
#
|
2015-04-07 21:41:26 +00:00
|
|
|
# Add libstand for the runtime functions used by the compiler - for example
|
|
|
|
# __aeabi_* (arm) or __divdi3 (i386).
|
2016-01-09 03:20:01 +00:00
|
|
|
# as well as required string and memory functions for all platforms.
|
2015-04-06 15:50:20 +00:00
|
|
|
#
|
|
|
|
DPADD+= ${LIBSTAND}
|
|
|
|
LDADD+= -lstand
|
|
|
|
|
2015-09-17 18:32:51 +00:00
|
|
|
DPADD+= ${LDSCRIPT}
|
2014-04-13 01:14:25 +00:00
|
|
|
|
|
|
|
OBJCOPY?= objcopy
|
|
|
|
OBJDUMP?= objdump
|
|
|
|
|
|
|
|
.if ${MACHINE_CPUARCH} == "amd64"
|
|
|
|
EFI_TARGET= efi-app-x86_64
|
2015-04-01 08:30:40 +00:00
|
|
|
.elif ${MACHINE_CPUARCH} == "i386"
|
2014-04-13 01:14:25 +00:00
|
|
|
EFI_TARGET= efi-app-ia32
|
2015-04-06 15:50:20 +00:00
|
|
|
.else
|
|
|
|
EFI_TARGET= binary
|
2014-04-13 01:14:25 +00:00
|
|
|
.endif
|
|
|
|
|
2015-09-17 18:32:51 +00:00
|
|
|
boot1.efi: ${PROG}
|
2014-04-13 01:14:25 +00:00
|
|
|
if [ `${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*' | wc -l` != 0 ]; then \
|
|
|
|
${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*'; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
2015-04-06 15:50:20 +00:00
|
|
|
${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \
|
2014-04-13 01:14:25 +00:00
|
|
|
-j .dynamic -j .dynsym -j .rel.dyn \
|
2015-09-17 18:32:51 +00:00
|
|
|
-j .rela.dyn -j .reloc -j .eh_frame \
|
2014-12-23 15:58:45 +00:00
|
|
|
--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
|
2014-04-13 01:14:25 +00:00
|
|
|
|
2014-04-13 14:50:52 +00:00
|
|
|
boot1.o: ${.CURDIR}/../../common/ufsread.c
|
|
|
|
|
2015-09-17 18:32:51 +00:00
|
|
|
# The following inserts our objects into a template FAT file system
|
2014-04-26 16:34:22 +00:00
|
|
|
# created by generate-fat.sh
|
|
|
|
|
|
|
|
.include "${.CURDIR}/Makefile.fat"
|
2016-01-08 16:37:22 +00:00
|
|
|
BOOT1_MAXSIZE?= 131072
|
2014-04-26 16:34:22 +00:00
|
|
|
|
|
|
|
boot1.efifat: boot1.efi
|
2016-01-08 16:37:22 +00:00
|
|
|
@set -- `ls -l boot1.efi`; \
|
|
|
|
x=$$(($$5-${BOOT1_MAXSIZE})); \
|
|
|
|
if [ $$x -ge 0 ]; then \
|
|
|
|
echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\
|
|
|
|
exit 1; \
|
|
|
|
fi
|
2014-04-26 16:34:22 +00:00
|
|
|
echo ${.OBJDIR}
|
2015-04-14 10:40:37 +00:00
|
|
|
uudecode ${.CURDIR}/fat-${MACHINE}.tmpl.bz2.uu
|
|
|
|
mv fat-${MACHINE}.tmpl.bz2 ${.TARGET}.bz2
|
2014-04-26 16:34:22 +00:00
|
|
|
bzip2 -f -d ${.TARGET}.bz2
|
|
|
|
dd if=boot1.efi of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc
|
|
|
|
|
2015-04-05 18:57:58 +00:00
|
|
|
CLEANFILES= boot1.efi boot1.efifat
|
2014-04-26 16:34:22 +00:00
|
|
|
|
2014-04-13 01:14:25 +00:00
|
|
|
.include <bsd.prog.mk>
|
|
|
|
|
2015-04-13 16:00:09 +00:00
|
|
|
beforedepend ${OBJS}: machine
|
2014-04-13 01:14:25 +00:00
|
|
|
|
2015-04-13 16:00:09 +00:00
|
|
|
CLEANFILES+= machine
|
2014-04-13 01:14:25 +00:00
|
|
|
|
|
|
|
machine:
|
2015-04-13 16:00:09 +00:00
|
|
|
ln -sf ${.CURDIR}/../../../${MACHINE}/include machine
|
|
|
|
|
|
|
|
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
|
|
|
|
beforedepend ${OBJS}: x86
|
|
|
|
CLEANFILES+= x86
|
2014-04-13 01:14:25 +00:00
|
|
|
|
|
|
|
x86:
|
|
|
|
ln -sf ${.CURDIR}/../../../x86/include x86
|
2015-04-03 15:25:59 +00:00
|
|
|
.endif
|