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