2 # This file and its contents are supplied under the terms of the
3 # Common Development and Distribution License ("CDDL"), version 1.0.
4 # You may only use this file in accordance with the terms of version
7 # A full copy of the text of the CDDL should have accompanied this
8 # source. A copy of the CDDL is also available via the Internet at
9 # http://www.illumos.org/license/CDDL.
13 # Copyright 2016 Toomas Soome <tsoome@me.com>
14 # Copyright 2016 RackTop Systems.
17 include $(SRC
)/Makefile.master
18 include $(SRC
)/boot
/Makefile.version
20 CC
= $(GCC_ROOT
)/bin
/gcc
21 LD
= $(GNU_ROOT
)/bin
/gld
22 OBJCOPY
= $(GNU_ROOT
)/bin
/gobjcopy
23 OBJDUMP
= $(GNU_ROOT
)/bin
/gobjdump
28 # architecture-specific loader code
29 SRCS
= autoload.c bootinfo.c conf.c copy.c devicename.c main.c self_reloc.c \
30 smbios.c acpi.c vers.c memmap.c multiboot2.c
31 OBJS
= autoload.o bootinfo.o conf.o copy.o devicename.o main.o self_reloc.o \
32 smbios.o acpi.o vers.o memmap.o multiboot2.o
36 CPPFLAGS
= -nostdinc
-I..
/..
/..
/..
/include -I..
/..
/..
37 CPPFLAGS
+= -I..
/..
/..
/..
/lib
/libstand
39 include ..
/Makefile.inc
41 include arch
/${MACHINE}/Makefile.inc
44 CPPFLAGS
+= -I.
/arch
/${MACHINE}
45 CPPFLAGS
+= -I.
/..
/include
46 CPPFLAGS
+= -I.
/..
/include/${MACHINE}
47 CPPFLAGS
+= -I
$(SRCTOP
)/arch
/x86
/include/sys
/acpi
48 CPPFLAGS
+= -I.
/..
/..
/..
49 CPPFLAGS
+= -I.
/..
/..
/i386
/libi386
50 CPPFLAGS
+= -I.
/..
/..
/zfs
51 CPPFLAGS
+= -I.
/..
/..
/..
/cddl
/boot
/zfs
52 CPPFLAGS
+= -DEFI_ZFS_BOOT
53 CPPFLAGS
+= -DNO_PCI
-DEFI
-DTERM_EMU
55 # Export serial numbers, UUID, and asset tag from loader.
56 CPPFLAGS
+= -DSMBIOS_SERIAL_NUMBERS
57 # Use little-endian UUID format as defined in SMBIOS 2.6.
58 CPPFLAGS
+= -DSMBIOS_LITTLE_ENDIAN_UUID
59 # Use network-endian UUID format for backward compatibility.
60 #CPPFLAGS += -DSMBIOS_NETWORK_ENDIAN_UUID
62 LIBSTAND
= ..
/..
/libstand
/${MACHINE}/libstand.a
65 CPPFLAGS
+= -DBOOT_FORTH
-D_STANDALONE
66 CPPFLAGS
+= -I
$(SRC
)/common
/ficl
67 CPPFLAGS
+= -I..
/..
/ficl
68 LIBFICL
= ..
/..
/ficl
/${MACHINE}/libficl.a
70 CPPFLAGS
+= -I..
/..
/zfs
71 LIBZFSBOOT
= ..
/..
/zfs
/${MACHINE}/libzfsboot.a
73 #LOADER_FDT_SUPPORT?= no
74 #.if ${MK_FDT} != "no" && ${LOADER_FDT_SUPPORT} != "no"
75 #CFLAGS+= -I${.CURDIR}/../../fdt
76 #CFLAGS+= -I${.OBJDIR}/../../fdt
77 #CFLAGS+= -DLOADER_FDT_SUPPORT
78 #LIBEFI_FDT= ${.OBJDIR}/../../efi/fdt/libefi_fdt.a
79 #LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a
82 # Always add MI sources
83 include .
/Makefile.common
84 CPPFLAGS
+= -I..
/..
/common
86 # For multiboot2.h, must be last, to avoid conflicts
87 CPPFLAGS
+= -I
$(SRCTOP
)/include
91 ROOT_BOOT
= $(ROOT
)/boot
92 ROOTBOOTFILES
=$(FILES
:%=$(ROOT_BOOT
)/%)
94 LDSCRIPT
= .
/arch
/${MACHINE}/ldscript.
${MACHINE}
95 LDFLAGS
= -nostdlib
--eh-frame-hdr
-znocombreloc
96 LDFLAGS
+= -shared
--hash-style
=both
--enable-new-dtags
97 LDFLAGS
+= -T
${LDSCRIPT} -Bsymbolic
99 CLEANFILES
= vers.c loader.efi
101 NEWVERSWHAT
= "EFI loader" ${MACHINE}
105 install: all $(ROOTBOOTFILES
)
107 vers.c
: ..
/..
/common
/newvers.sh
$(SRC
)/boot
/Makefile.version
108 $(SH
) ..
/..
/common
/newvers.sh
${LOADER_VERSION} ${NEWVERSWHAT}
110 EFI_TARGET
= pei-x86-64
112 loader.efi
: loader.sym
113 if
[ `${OBJDUMP} -t loader.sym | fgrep '*UND*' | wc -l` != 0 ]; then \
114 ${OBJDUMP} -t loader.sym | fgrep
'*UND*'; \
117 ${OBJCOPY} --readonly-text
-j .peheader
-j .text
-j .sdata
-j .data \
118 -j .dynamic
-j .dynsym
-j .rel.dyn \
119 -j .rela.dyn
-j .reloc
-j .eh_frame
-j set_Xcommand_set \
120 -j set_Xficl_compile_set \
121 --output-target
=${EFI_TARGET} --subsystem efi-app loader.sym
$@
123 LIBEFI
= ..
/libefi
/libefi.a
125 DPADD
= ${LIBFICL} ${LIBZFSBOOT} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} \
126 ${LIBSTAND} ${LDSCRIPT}
127 LDADD
= ${LIBFICL} ${LIBZFSBOOT} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} \
131 loader.sym
: $(OBJS
) $(DPADD
)
132 $(LD
) $(LDFLAGS
) -o
$@
$(OBJS
) $(LDADD
)
134 CLEANFILES
+= machine x86
138 $(SYMLINK
) ..
/..
/..
/${MACHINE}/include machine
142 $(SYMLINK
) ..
/..
/..
/x86
/include x86
147 $(RM
) $(CLEANFILES
) $(OBJS
) loader.sym loader.efi
152 %.o
: .
/arch
/${MACHINE}/%.c
155 %.o
: .
/arch
/${MACHINE}/%.S
158 %.o
: ..
/..
/common
/%.c
161 %.o
: ..
/..
/common
/linenoise
/%.c
164 %.o
: ..
/..
/i386
/libi386
/%.c