]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - stand/efi/boot1/Makefile
MK_ZFS -> {MK_ZFS|MK_LOADER_ZFS}, this is so we can diable userland / kernel
[FreeBSD/FreeBSD.git] / stand / efi / boot1 / Makefile
1 # $FreeBSD$
2
3 .include <bsd.init.mk>
4
5 PROG=           boot1.sym
6 INTERNALPROG=
7 WARNS?=         6
8
9 CFLAGS+=        -DEFI_BOOT1
10 # We implement a slightly non-standard %S in that it always takes a
11 # CHAR16 that's common in UEFI-land instead of a wchar_t. This only
12 # seems to matter on arm64 where wchar_t defaults to an int instead
13 # of a short. There's no good cast to use here so just ignore the
14 # warnings for now.
15 CWARNFLAGS.boot1.c+=    -Wno-format
16
17 # Disable warnings that are currently incompatible with the zfs boot code
18 CWARNFLAGS.zfs_module.c += -Wno-array-bounds
19 CWARNFLAGS.zfs_module.c += -Wno-cast-align
20 CWARNFLAGS.zfs_module.c += -Wno-cast-qual
21 CWARNFLAGS.zfs_module.c += -Wno-missing-prototypes
22 CWARNFLAGS.zfs_module.c += -Wno-sign-compare
23 CWARNFLAGS.zfs_module.c += -Wno-unused-parameter
24 CWARNFLAGS.zfs_module.c += -Wno-unused-function
25
26 # architecture-specific loader code
27 SRCS=   boot1.c self_reloc.c start.S ufs_module.c
28 .if ${MK_LOADER_ZFS} != "no"
29 SRCS+=          zfs_module.c
30 CFLAGS.zfs_module.c+=   -I${ZFSSRC}
31 CFLAGS.zfs_module.c+=   -I${SYSDIR}/cddl/boot/zfs
32 CFLAGS.zfs_module.c+=   -I${SYSDIR}/crypto/skein
33 CFLAGS+=        -DEFI_ZFS_BOOT
34 .endif
35
36 .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201
37 CWARNFLAGS.self_reloc.c+=       -Wno-error=maybe-uninitialized
38 .endif
39
40 CFLAGS+=        -I${EFIINC}
41 CFLAGS+=        -I${EFIINCMD}
42 CFLAGS+=        -I${SYSDIR}/contrib/dev/acpica/include
43 CFLAGS+=        -DEFI_UFS_BOOT
44 .ifdef(EFI_DEBUG)
45 CFLAGS+=        -DEFI_DEBUG
46 .endif
47
48 # Always add MI sources and REGULAR efi loader bits
49 .PATH:          ${EFISRC}/loader/arch/${MACHINE}
50 .PATH:          ${EFISRC}/loader
51 .PATH:          ${LDRSRC}
52 CFLAGS+=        -I${LDRSRC}
53
54 FILES=  boot1.efi boot1.efifat
55 FILESMODE_boot1.efi=    ${BINMODE}
56
57 LDSCRIPT=       ${EFISRC}/loader/arch/${MACHINE}/ldscript.${MACHINE}
58 LDFLAGS+=       -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -shared
59
60 .if ${MACHINE_CPUARCH} == "aarch64"
61 CFLAGS+=        -mgeneral-regs-only
62 .endif
63 .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
64 CFLAGS+=        -fPIC
65 LDFLAGS+=       -Wl,-znocombreloc
66 .endif
67
68 LIBEFI=         ${BOOTOBJ}/efi/libefi/libefi.a
69
70 #
71 # Add libstand for the runtime functions used by the compiler - for example
72 # __aeabi_* (arm) or __divdi3 (i386).
73 # as well as required string and memory functions for all platforms.
74 #
75 DPADD+=         ${LIBEFI} ${LIBSA}
76 LDADD+=         ${LIBEFI} ${LIBSA}
77
78 DPADD+=         ${LDSCRIPT}
79
80 boot1.efi: ${PROG}
81         if ${NM} ${.ALLSRC} | grep ' U '; then \
82                 echo "Undefined symbols in ${.ALLSRC}"; \
83                 exit 1; \
84         fi
85         SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
86         ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \
87                 -j .dynamic -j .dynsym -j .rel.dyn \
88                 -j .rela.dyn -j .reloc -j .eh_frame \
89                 --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
90
91 # The following inserts our objects into a template FAT file system
92 # created by generate-fat.sh
93
94 .include "Makefile.fat"
95
96 boot1.efifat: boot1.efi
97         @set -- `ls -l ${.ALLSRC}`; \
98         x=$$(($$5-${BOOT1_MAXSIZE})); \
99         if [ $$x -ge 0 ]; then \
100             echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\
101             exit 1; \
102         fi
103         echo ${.OBJDIR}
104         xz -d -c ${BOOTSRC}/efi/boot1/fat-${MACHINE}.tmpl.xz > ${.TARGET}
105         ${DD} if=${.ALLSRC} of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc
106
107 CLEANFILES+= boot1.efi boot1.efifat
108
109 .include <bsd.prog.mk>