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>
16 include $(SRC)/Makefile.master
17 include $(SRC)/boot/Makefile.version
19 CC= $(GNUC_ROOT)/bin/gcc
20 LD= $(GNU_ROOT)/bin/gld
21 OBJCOPY= $(GNU_ROOT)/bin/gobjcopy
22 OBJDUMP= $(GNU_ROOT)/bin/gobjdump
26 # architecture-specific loader code
27 SRCS= autoload.c bootinfo.c conf.c copy.c efi_main.c framebuffer.c main.c \
28 self_reloc.c smbios.c acpi.c vers.c memmap.c multiboot2.c
30 OBJS= autoload.o bootinfo.o conf.o copy.o efi_main.o framebuffer.o main.o \
31 self_reloc.o smbios.o acpi.o vers.o memmap.o multiboot2.o
34 CPPFLAGS= -nostdinc -I../../../../../include -I../../..../
35 CPPFLAGS += -I../../../../../lib/libstand
37 include ../../Makefile.inc
39 include ../arch/$(MACHINE)/Makefile.inc
42 CPPFLAGS += -I../../include
43 CPPFLAGS += -I../../include/$(MACHINE)
44 CPPFLAGS += -I../../../..
45 CPPFLAGS += -I../../../i386/libi386
46 CPPFLAGS += -I../../../zfs
47 CPPFLAGS += -I../../../../cddl/boot/zfs
48 CPPFLAGS += -I$(SRC)/uts/intel/sys/acpi
49 CPPFLAGS += -DEFI_ZFS_BOOT
50 CPPFLAGS += -DNO_PCI -DEFI -DTERM_EMU
52 # Export serial numbers, UUID, and asset tag from loader.
53 CPPFLAGS += -DSMBIOS_SERIAL_NUMBERS
54 # Use little-endian UUID format as defined in SMBIOS 2.6.
55 CPPFLAGS += -DSMBIOS_LITTLE_ENDIAN_UUID
56 # Use network-endian UUID format for backward compatibility.
57 #CPPFLAGS += -DSMBIOS_NETWORK_ENDIAN_UUID
59 LIBSTAND= ../../../libstand/$(MACHINE)/libstand.a
62 CPPFLAGS += -DBOOT_FORTH -D_STANDALONE
63 CPPFLAGS += -I$(SRC)/common/ficl
64 CPPFLAGS += -I../../../libficl
65 LIBFICL= ../../../libficl/$(MACHINE)/libficl.a
67 CPPFLAGS += -I../../../zfs
68 LIBZFSBOOT= ../../../zfs/$(MACHINE)/libzfsboot.a
70 # Always add MI sources
71 include ../Makefile.common
72 CPPFLAGS += -I../../../common
74 # For multiboot2.h, must be last, to avoid conflicts
75 CPPFLAGS += -I$(SRC)/uts/common
79 ROOT_BOOT= $(ROOT)/boot
80 ROOTBOOTFILES=$(FILES:%=$(ROOT_BOOT)/%)
82 LDSCRIPT= ../arch/$(MACHINE)/ldscript.$(MACHINE)
83 LDFLAGS = -nostdlib --eh-frame-hdr
84 LDFLAGS += -shared --hash-style=both --enable-new-dtags
85 LDFLAGS += -T$(LDSCRIPT) -Bsymbolic
87 CLEANFILES= 8x16.c vers.c
89 NEWVERSWHAT= "EFI loader" $(MACHINE)
91 install: all $(ROOTBOOTFILES)
93 vers.c: ../../../common/newvers.sh $(SRC)/boot/Makefile.version
94 $(SH) ../../../common/newvers.sh $(LOADER_VERSION) $(NEWVERSWHAT)
96 $(EFIPROG): loader.sym
97 if [ `$(OBJDUMP) -t loader.sym | fgrep '*UND*' | wc -l` != 0 ]; then \
98 $(OBJDUMP) -t loader.sym | fgrep '*UND*'; \
101 $(OBJCOPY) --readonly-text -j .peheader -j .text -j .sdata -j .data \
102 -j .dynamic -j .dynsym -j .rel.dyn \
103 -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
104 -j set_Xficl_compile_set \
105 --output-target=$(EFI_TARGET) --subsystem efi-app loader.sym $@
107 LIBEFI= ../../libefi/$(MACHINE)/libefi.a
109 DPADD= $(LIBFICL) $(LIBZFSBOOT) $(LIBEFI) $(LIBSTAND) $(LDSCRIPT)
110 LDADD= $(LIBFICL) $(LIBZFSBOOT) $(LIBEFI) $(LIBSTAND)
113 loader.sym: $(OBJS) $(DPADD)
114 $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDADD)
118 $(SYMLINK) ../../../../$(MACHINE)/include machine
122 $(SYMLINK) ../../../../x86/include x86
125 $(RM) $(CLEANFILES) $(OBJS) loader.sym
130 %.o: ../arch/$(MACHINE)/%.c
134 # using -W to silence gas here, as for 32bit build, it will generate warning
135 # for start.S because hand crafted .reloc section does not have group name
137 %.o: ../arch/$(MACHINE)/%.S
138 $(COMPILE.S) -Wa,-W $<
140 %.o: ../../../common/%.c
143 %.o: ../../../common/linenoise/%.c
146 %.o: ../../../i386/libi386/%.c
149 %.o: $(SRC)/common/list/%.c
150 $(COMPILE.c) -DNDEBUG $<
152 %.o: $(SRC)/uts/common/io/font/%.c