| @@ -1,173 +1,174 @@ | | | @@ -1,173 +1,174 @@ |
1 | # $NetBSD: Makefile.efiboot,v 1.28 2023/06/03 21:26:29 lukem Exp $ | | 1 | # $NetBSD: Makefile.efiboot,v 1.29 2023/06/15 03:20:58 rin Exp $ |
2 | | | 2 | |
3 | S= ${.CURDIR}/../../.. | | 3 | S= ${.CURDIR}/../../.. |
4 | | | 4 | |
5 | NOMAN= # defined | | 5 | NOMAN= # defined |
6 | NOPIE= # defined | | 6 | NOPIE= # defined |
7 | NOLIBCSANITIZER=# defined | | 7 | NOLIBCSANITIZER=# defined |
8 | NOSANITIZER= # defined | | 8 | NOSANITIZER= # defined |
9 | NORELRO= # defined | | 9 | NORELRO= # defined |
10 | PROG?= boot.efi | | 10 | PROG?= boot.efi |
11 | NEWVERSWHAT?= "efiboot" | | 11 | NEWVERSWHAT?= "efiboot" |
12 | | | 12 | |
13 | EFIDIR= ${S}/external/bsd/gnu-efi/dist | | 13 | EFIDIR= ${S}/external/bsd/gnu-efi/dist |
14 | GNUEFIARCH?= ${MACHINE_CPU} | | 14 | GNUEFIARCH?= ${MACHINE_CPU} |
15 | CPPFLAGS+= -I${EFIDIR}/inc -I${EFIDIR}/inc/${GNUEFIARCH} | | 15 | CPPFLAGS+= -I${EFIDIR}/inc -I${EFIDIR}/inc/${GNUEFIARCH} |
16 | CPPFLAGS+= -I${EFIDIR}/inc/protocol | | 16 | CPPFLAGS+= -I${EFIDIR}/inc/protocol |
17 | | | 17 | |
18 | LDSCRIPT?= ${EFIDIR}/gnuefi/elf_${GNUEFIARCH}_efi.lds | | 18 | LDSCRIPT?= ${EFIDIR}/gnuefi/elf_${GNUEFIARCH}_efi.lds |
19 | | | 19 | |
20 | AFLAGS.start.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:} | | 20 | AFLAGS.start.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:} |
21 | | | 21 | |
22 | .PATH: ${EFIDIR}/gnuefi | | 22 | .PATH: ${EFIDIR}/gnuefi |
23 | SOURCES= crt0-efi-${GNUEFIARCH}.S reloc_${GNUEFIARCH}.c | | 23 | SOURCES= crt0-efi-${GNUEFIARCH}.S reloc_${GNUEFIARCH}.c |
24 | SOURCES+= boot.c bootmenu.c conf.c console.c dev_net.c devopen.c exec.c \ | | 24 | SOURCES+= boot.c bootmenu.c conf.c console.c dev_net.c devopen.c exec.c \ |
25 | module.c panic.c prompt.c userconf.c | | 25 | module.c panic.c prompt.c userconf.c |
26 | SOURCES+= efiboot.c efichar.c efidev.c efigetsecs.c \ | | 26 | SOURCES+= efiboot.c efichar.c efidev.c efigetsecs.c \ |
27 | efifile.c efiblock.c efinet.c efipxe.c efirng.c \ | | 27 | efifile.c efiblock.c efinet.c efipxe.c efirng.c \ |
28 | efiwatchdog.c efigop.c smbios.c | | 28 | efiwatchdog.c efigop.c smbios.c |
29 | | | 29 | |
30 | .if ${EFIBOOT_FDT:Uno} == "yes" | | 30 | .if ${EFIBOOT_FDT:Uno} == "yes" |
31 | CPPFLAGS+= -DEFIBOOT_FDT | | 31 | CPPFLAGS+= -DEFIBOOT_FDT |
32 | SOURCES+= efifdt.c overlay.c | | 32 | SOURCES+= efifdt.c overlay.c |
33 | .PATH: ${S}/external/bsd/libfdt/dist | | 33 | .PATH: ${S}/external/bsd/libfdt/dist |
34 | CPPFLAGS+= -I${S}/external/bsd/libfdt/dist | | 34 | CPPFLAGS+= -I${S}/external/bsd/libfdt/dist |
35 | SOURCES+= fdt.c fdt_addresses.c fdt_empty_tree.c fdt_overlay.c | | 35 | SOURCES+= fdt.c fdt_addresses.c fdt_empty_tree.c fdt_overlay.c |
36 | SOURCES+= fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c fdt_wip.c | | 36 | SOURCES+= fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c fdt_wip.c |
37 | .endif | | 37 | .endif |
38 | | | 38 | |
39 | .if ${EFIBOOT_ACPI:Uno} == "yes" | | 39 | .if ${EFIBOOT_ACPI:Uno} == "yes" |
40 | CPPFLAGS+= -DEFIBOOT_ACPI | | 40 | CPPFLAGS+= -DEFIBOOT_ACPI |
41 | SOURCES+= efiacpi.c | | 41 | SOURCES+= efiacpi.c |
42 | .endif | | 42 | .endif |
43 | | | 43 | |
44 | SRCS= ${SOURCES} ${EXTRA_SOURCES} | | 44 | SRCS= ${SOURCES} ${EXTRA_SOURCES} |
45 | | | 45 | |
46 | .include <bsd.init.mk> | | 46 | .include <bsd.init.mk> |
47 | | | 47 | |
48 | STRIPFLAG= # nothing | | 48 | STRIPFLAG= # nothing |
49 | | | 49 | |
50 | LIBCRT0= # nothing | | 50 | LIBCRT0= # nothing |
51 | LIBCRTI= # nothing | | 51 | LIBCRTI= # nothing |
52 | LIBCRTBEGIN= # nothing | | 52 | LIBCRTBEGIN= # nothing |
53 | LIBCRTEND= # nothing | | 53 | LIBCRTEND= # nothing |
54 | LIBC= # nothing | | 54 | LIBC= # nothing |
55 | | | 55 | |
56 | BINDIR=/usr/mdec | | 56 | BINDIR=/usr/mdec |
57 | BINMODE=444 | | 57 | BINMODE=444 |
58 | | | 58 | |
59 | .PATH: ${.CURDIR} ${.CURDIR}/.. | | 59 | .PATH: ${.CURDIR} ${.CURDIR}/.. |
60 | .PATH: ${.CURDIR}/../../lib | | 60 | .PATH: ${.CURDIR}/../../lib |
61 | | | 61 | |
62 | LDFLAGS+= --no-dynamic-linker --noinhibit-exec | | 62 | LDFLAGS+= --no-dynamic-linker --noinhibit-exec |
63 | LDFLAGS+= -nostdlib -T${LDSCRIPT} -Bsymbolic -shared | | 63 | LDFLAGS+= -nostdlib -T${LDSCRIPT} -Bsymbolic -shared |
64 | CPPFLAGS+= -I$S -I${.CURDIR} -I${.CURDIR}/../common -I$S/lib/libsa | | 64 | CPPFLAGS+= -I$S -I${.CURDIR} -I${.CURDIR}/../common -I$S/lib/libsa |
65 | CPPFLAGS+= -I${.OBJDIR} | | 65 | CPPFLAGS+= -I${.OBJDIR} |
66 | CPPFLAGS+= -I${.CURDIR}/../../lib | | 66 | CPPFLAGS+= -I${.CURDIR}/../../lib |
67 | CPPFLAGS+= -I${S}/../common/include | | 67 | CPPFLAGS+= -I${S}/../common/include |
68 | | | 68 | |
69 | COPTS+= -fpic -g -O2 | | 69 | COPTS+= -fpic -g -O2 |
70 | COPTS+= -fshort-wchar -fno-strict-aliasing | | 70 | COPTS+= -fshort-wchar -fno-strict-aliasing |
71 | COPTS+= -ffreestanding -fno-stack-protector | | 71 | COPTS+= -ffreestanding -fno-stack-protector |
72 | LDFLAGS+= --defsym=EFI_SUBSYSTEM=0xa | | 72 | LDFLAGS+= --defsym=EFI_SUBSYSTEM=0xa |
73 | | | 73 | |
74 | | | 74 | |
75 | COPTS+= ${${ACTIVE_CC} == "gcc":? -Wno-error=unused-but-set-variable :} | | 75 | COPTS+= ${${ACTIVE_CC} == "gcc":? -Wno-error=unused-but-set-variable :} |
76 | CPPFLAGS+= -nostdinc -D_STANDALONE | | 76 | CPPFLAGS+= -nostdinc -D_STANDALONE |
77 | CPPFLAGS+= -DEFIBOOT | | 77 | CPPFLAGS+= -DEFIBOOT |
78 | CPPFLAGS+= -DPROGRESS_FN=efi_progress | | 78 | CPPFLAGS+= -DPROGRESS_FN=efi_progress |
79 | | | 79 | |
80 | CPPFLAGS+= -Wall -Wmissing-prototypes | | 80 | CPPFLAGS+= -Wall -Wmissing-prototypes |
81 | CPPFLAGS+= -Wno-pointer-sign | | 81 | CPPFLAGS+= -Wno-pointer-sign |
82 | | | 82 | |
83 | CPPFLAGS+= -DHEAP_VARIABLE | | 83 | CPPFLAGS+= -DHEAP_VARIABLE |
84 | CPPFLAGS+= -DSUPPORT_CD9660 | | 84 | CPPFLAGS+= -DSUPPORT_CD9660 |
85 | CPPFLAGS+= -D"devb2cdb(bno)=(bno)" | | 85 | CPPFLAGS+= -D"devb2cdb(bno)=(bno)" |
86 | CPPFLAGS+= -DSUPPORT_DOSFS | | 86 | CPPFLAGS+= -DSUPPORT_DOSFS |
87 | #CPPFLAGS+= -DSUPPORT_EXT2FS | | 87 | #CPPFLAGS+= -DSUPPORT_EXT2FS |
88 | CPPFLAGS+= -DSUPPORT_BOOTP | | 88 | CPPFLAGS+= -DSUPPORT_BOOTP |
89 | CPPFLAGS+= -DSUPPORT_DHCP | | 89 | CPPFLAGS+= -DSUPPORT_DHCP |
90 | #CPPFLAGS+= -DSUPPORT_NFS | | 90 | #CPPFLAGS+= -DSUPPORT_NFS |
91 | CPPFLAGS+= -DSUPPORT_TFTP | | 91 | CPPFLAGS+= -DSUPPORT_TFTP |
92 | CPPFLAGS+= -DLIBSA_ENABLE_LS_OP | | 92 | CPPFLAGS+= -DLIBSA_ENABLE_LS_OP |
93 | CPPFLAGS+= -DLIBSA_FFS_EI | | 93 | CPPFLAGS+= -DLIBSA_FFS_EI |
94 | CPPFLAGS+= -DLIBSA_DISKLABEL_EI | | 94 | CPPFLAGS+= -DLIBSA_DISKLABEL_EI |
95 | CPPFLAGS+= -DDEFAULT_TIMEOUT=5 | | 95 | CPPFLAGS+= -DDEFAULT_TIMEOUT=5 |
96 | | | 96 | |
97 | #CPPFLAGS+= -DEFIBOOT_DEBUG | | 97 | #CPPFLAGS+= -DEFIBOOT_DEBUG |
98 | #CPPFLAGS+= -DARP_DEBUG | | 98 | #CPPFLAGS+= -DARP_DEBUG |
99 | #CPPFLAGS+= -DBOOTP_DEBUG | | 99 | #CPPFLAGS+= -DBOOTP_DEBUG |
100 | #CPPFLAGS+= -DNET_DEBUG | | 100 | #CPPFLAGS+= -DNET_DEBUG |
101 | #CPPFLAGS+= -DNETIF_DEBUG | | 101 | #CPPFLAGS+= -DNETIF_DEBUG |
102 | #CPPFLAGS+= -DNFS_DEBUG | | 102 | #CPPFLAGS+= -DNFS_DEBUG |
103 | #CPPFLAGS+= -DRARP_DEBUG | | 103 | #CPPFLAGS+= -DRARP_DEBUG |
104 | #CPPFLAGS+= -DRPC_DEBUG | | 104 | #CPPFLAGS+= -DRPC_DEBUG |
105 | | | 105 | |
106 | # Follow the suit of Makefile.kern.inc; needed for the lfs64 union | | 106 | # Follow the suit of Makefile.kern.inc; needed for the lfs64 union |
107 | # accessors -- they don't actually dereference the resulting pointer, | | 107 | # accessors -- they don't actually dereference the resulting pointer, |
108 | # just use it for type-checking. | | 108 | # just use it for type-checking. |
109 | CWARNFLAGS+= ${CC_WNO_ADDRESS_OF_PACKED_MEMBER} | | 109 | CWARNFLAGS+= ${CC_WNO_ADDRESS_OF_PACKED_MEMBER} |
110 | | | 110 | |
111 | SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT | | 111 | SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT |
112 | SAMISCCPPFLAGS+= -DLIBSA_PRINTF_WIDTH_SUPPORT | | 112 | SAMISCCPPFLAGS+= -DLIBSA_PRINTF_WIDTH_SUPPORT |
113 | SAMISCCPPFLAGS+= -D"cdb2devb(bno)=(bno)" | | 113 | SAMISCCPPFLAGS+= -D"cdb2devb(bno)=(bno)" |
114 | | | 114 | |
115 | ### find out what to use for libsa | | 115 | ### find out what to use for libsa |
116 | SA_AS= library | | 116 | SA_AS= library |
117 | SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" | | 117 | SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" |
118 | SAMISCMAKEFLAGS+="SA_USE_CREAD=yes" | | 118 | SAMISCMAKEFLAGS+="SA_USE_CREAD=yes" |
119 | SAMISCMAKEFLAGS+="SA_INCLUDE_NET=yes" | | 119 | SAMISCMAKEFLAGS+="SA_INCLUDE_NET=yes" |
120 | SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes" | | 120 | SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes" |
121 | SAMISCMAKEFLAGS+="SA_ENABLE_BIENDIAN=yes" | | 121 | SAMISCMAKEFLAGS+="SA_ENABLE_BIENDIAN=yes" |
122 | .include "${S}/lib/libsa/Makefile.inc" | | 122 | .include "${S}/lib/libsa/Makefile.inc" |
123 | LIBSA= ${SALIB} | | 123 | LIBSA= ${SALIB} |
124 | | | 124 | |
125 | ### find out what to use for libkern | | 125 | ### find out what to use for libkern |
126 | KERN_AS= library | | 126 | KERN_AS= library |
127 | LIBKERN_ARCH?= ${MACHINE_ARCH} | | 127 | LIBKERN_ARCH?= ${MACHINE_ARCH} |
128 | KERNMISCMAKEFLAGS+="LIBKERN_ARCH=${LIBKERN_ARCH}" | | 128 | KERNMISCMAKEFLAGS+="LIBKERN_ARCH=${LIBKERN_ARCH}" |
129 | .include "${S}/lib/libkern/Makefile.inc" | | 129 | .include "${S}/lib/libkern/Makefile.inc" |
130 | LIBKERN= ${KERNLIB} | | 130 | LIBKERN= ${KERNLIB} |
131 | | | 131 | |
132 | ### find out what to use for libz | | 132 | ### find out what to use for libz |
133 | Z_AS= library | | 133 | Z_AS= library |
134 | .include "${S}/lib/libz/Makefile.inc" | | 134 | .include "${S}/lib/libz/Makefile.inc" |
| | | 135 | CPPFLAGS+= -I${S}/lib/libz -I${S}/../common/dist/zlib |
135 | LIBZ= ${ZLIB} | | 136 | LIBZ= ${ZLIB} |
136 | | | 137 | |
137 | ### find out what to use for libgnuefi | | 138 | ### find out what to use for libgnuefi |
138 | GNUEFI_AS= library | | 139 | GNUEFI_AS= library |
139 | LIBGNUEFI_ARCH?= ${MACHINE_ARCH} | | 140 | LIBGNUEFI_ARCH?= ${MACHINE_ARCH} |
140 | GNUEFIMISCMAKEFLAGS+="LIBGNUEFI_ARCH=${LIBGNUEFI_ARCH}" | | 141 | GNUEFIMISCMAKEFLAGS+="LIBGNUEFI_ARCH=${LIBGNUEFI_ARCH}" |
141 | GNUEFIMISCCPPFLAGS+= -I${EFIDIR}/lib | | 142 | GNUEFIMISCCPPFLAGS+= -I${EFIDIR}/lib |
142 | .include "${S}/lib/libgnuefi/Makefile.inc" | | 143 | .include "${S}/lib/libgnuefi/Makefile.inc" |
143 | LIBGNUEFI= ${GNUEFILIB} | | 144 | LIBGNUEFI= ${GNUEFILIB} |
144 | | | 145 | |
145 | cleandir distclean: .WAIT cleanlibdir | | 146 | cleandir distclean: .WAIT cleanlibdir |
146 | | | 147 | |
147 | cleanlibdir: | | 148 | cleanlibdir: |
148 | -rm -rf lib | | 149 | -rm -rf lib |
149 | | | 150 | |
150 | LIBLIST= ${LIBGNUEFI} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBSA} | | 151 | LIBLIST= ${LIBGNUEFI} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBSA} |
151 | | | 152 | |
152 | VERSIONMACHINE=${MACHINE} | | 153 | VERSIONMACHINE=${MACHINE} |
153 | .include "${S}/conf/newvers_stand.mk" | | 154 | .include "${S}/conf/newvers_stand.mk" |
154 | | | 155 | |
155 | CLEANFILES+= ${PROG}.so ${PROG}.tmp | | 156 | CLEANFILES+= ${PROG}.so ${PROG}.tmp |
156 | | | 157 | |
157 | ${PROG}: ${PROG}.so | | 158 | ${PROG}: ${PROG}.so |
158 | ${OBJCOPY} -j .text -j .sdata -j .data -j .dynamic -j .dynsym \ | | 159 | ${OBJCOPY} -j .text -j .sdata -j .data -j .dynamic -j .dynsym \ |
159 | -j .rela -j .rel.* -j .rela.* -j .rel* -j .rela* \ | | 160 | -j .rela -j .rel.* -j .rela.* -j .rel* -j .rela* \ |
160 | -j .reloc ${OBJCOPY_FORMAT} ${PROG}.so ${.TARGET} | | 161 | -j .reloc ${OBJCOPY_FORMAT} ${PROG}.so ${.TARGET} |
161 | | | 162 | |
162 | .include <bsd.prog.mk> | | 163 | .include <bsd.prog.mk> |
163 | | | 164 | |
164 | ${PROG}.so: ${OBJS} ${LIBLIST} ${LDSCRIPT} ${.CURDIR}/../Makefile.efiboot | | 165 | ${PROG}.so: ${OBJS} ${LIBLIST} ${LDSCRIPT} ${.CURDIR}/../Makefile.efiboot |
165 | ${LD} ${LDFLAGS} -o ${.TARGET}.tmp ${OBJS} ${LIBLIST} | | 166 | ${LD} ${LDFLAGS} -o ${.TARGET}.tmp ${OBJS} ${LIBLIST} |
166 | @if ${OBJDUMP} -t ${.TARGET}.tmp | grep 'UND'; then \ | | 167 | @if ${OBJDUMP} -t ${.TARGET}.tmp | grep 'UND'; then \ |
167 | (echo Undefined symbols; false); \ | | 168 | (echo Undefined symbols; false); \ |
168 | fi | | 169 | fi |
169 | rm -f ${.TARGET} | | 170 | rm -f ${.TARGET} |
170 | mv ${.TARGET}.tmp ${.TARGET} | | 171 | mv ${.TARGET}.tmp ${.TARGET} |
171 | | | 172 | |
172 | KLINK_MACHINE?= ${MACHINE} | | 173 | KLINK_MACHINE?= ${MACHINE} |
173 | .include <bsd.klinks.mk> | | 174 | .include <bsd.klinks.mk> |