boot1.efi: use += to append to LDFLAGS
[freebsd-src.git] / sys / boot / efi / boot1 / Makefile
blobc4c92cba893254645693724e825b3cad95b34b07
1 # $FreeBSD$
3 MAN=
5 .include <src.opts.mk>
7 MK_SSP= no
9 PROG= boot1.sym
10 INTERNALPROG=
11 WARNS?= 6
13 .if ${MK_ZFS} != "no"
14 # Disable warnings that are currently incompatible with the zfs boot code
15 CWARNFLAGS.zfs_module.c += -Wno-array-bounds
16 CWARNFLAGS.zfs_module.c += -Wno-cast-align
17 CWARNFLAGS.zfs_module.c += -Wno-cast-qual
18 CWARNFLAGS.zfs_module.c += -Wno-missing-prototypes
19 CWARNFLAGS.zfs_module.c += -Wno-sign-compare
20 CWARNFLAGS.zfs_module.c += -Wno-unused-parameter
21 CWARNFLAGS.zfs_module.c += -Wno-unused-function
22 .endif
24 # architecture-specific loader code
25 SRCS= boot1.c self_reloc.c start.S ufs_module.c
26 .if ${MK_ZFS} != "no"
27 SRCS+= zfs_module.c
28 .endif
30 CFLAGS+= -I.
31 CFLAGS+= -I${.CURDIR}/../include
32 CFLAGS+= -I${.CURDIR}/../include/${MACHINE}
33 CFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica/include
34 CFLAGS+= -I${.CURDIR}/../../..
35 CFLAGS+= -DEFI_UFS_BOOT
36 .ifdef(EFI_DEBUG)
37 CFLAGS+= -DEFI_DEBUG
38 .endif
40 .if ${MK_ZFS} != "no"
41 CFLAGS+= -I${.CURDIR}/../../zfs/
42 CFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs/
43 CFLAGS+= -DEFI_ZFS_BOOT
44 .endif
46 # Always add MI sources and REGULAR efi loader bits
47 .PATH: ${.CURDIR}/../loader/arch/${MACHINE}
48 .PATH: ${.CURDIR}/../loader
49 .PATH: ${.CURDIR}/../../common
50 CFLAGS+= -I${.CURDIR}/../../common
52 FILES= boot1.efi boot1.efifat
53 FILESMODE_boot1.efi= ${BINMODE}
55 LDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE}
56 LDFLAGS+= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared
58 .if ${MACHINE_CPUARCH} == "aarch64"
59 CFLAGS+= -msoft-float -mgeneral-regs-only
60 .endif
61 .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
62 CFLAGS+= -fPIC
63 LDFLAGS+= -Wl,-znocombreloc
64 .endif
67 # Add libstand for the runtime functions used by the compiler - for example
68 # __aeabi_* (arm) or __divdi3 (i386).
69 # as well as required string and memory functions for all platforms.
71 DPADD+= ${LIBSTAND}
72 LDADD+= -lstand
74 DPADD+= ${LDSCRIPT}
76 OBJCOPY?= objcopy
77 OBJDUMP?= objdump
79 .if ${MACHINE_CPUARCH} == "amd64"
80 EFI_TARGET= efi-app-x86_64
81 .elif ${MACHINE_CPUARCH} == "i386"
82 EFI_TARGET= efi-app-ia32
83 .else
84 EFI_TARGET= binary
85 .endif
87 boot1.efi: ${PROG}
88 if [ `${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*' | wc -l` != 0 ]; then \
89 ${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*'; \
90 exit 1; \
92 ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \
93 -j .dynamic -j .dynsym -j .rel.dyn \
94 -j .rela.dyn -j .reloc -j .eh_frame \
95 --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
97 boot1.o: ${.CURDIR}/../../common/ufsread.c
99 # The following inserts our objects into a template FAT file system
100 # created by generate-fat.sh
102 .include "${.CURDIR}/Makefile.fat"
103 BOOT1_MAXSIZE?= 131072
105 boot1.efifat: boot1.efi
106 @set -- `ls -l boot1.efi`; \
107 x=$$(($$5-${BOOT1_MAXSIZE})); \
108 if [ $$x -ge 0 ]; then \
109 echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\
110 exit 1; \
112 echo ${.OBJDIR}
113 uudecode ${.CURDIR}/fat-${MACHINE}.tmpl.bz2.uu
114 mv fat-${MACHINE}.tmpl.bz2 ${.TARGET}.bz2
115 bzip2 -f -d ${.TARGET}.bz2
116 dd if=boot1.efi of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc \
117 status=none
119 CLEANFILES= boot1.efi boot1.efifat
121 .include <bsd.prog.mk>
123 beforedepend ${OBJS}: machine
125 CLEANFILES+= machine
127 machine:
128 ln -sf ${.CURDIR}/../../../${MACHINE}/include machine
130 .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
131 beforedepend ${OBJS}: x86
132 CLEANFILES+= x86
134 x86:
135 ln -sf ${.CURDIR}/../../../x86/include x86
136 .endif