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
36 CPPFLAGS += -I../../../../../lib/libz
38 include ../../Makefile.inc
40 include ../arch/$(MACHINE)/Makefile.inc
43 CPPFLAGS += -I../../include
44 CPPFLAGS += -I../../include/$(MACHINE)
45 CPPFLAGS += -I../../../..
46 CPPFLAGS += -I../../../i386/libi386
47 CPPFLAGS += -I../../../zfs
48 CPPFLAGS += -I../../../../cddl/boot/zfs
49 CPPFLAGS += -I$(SRCTOP)/arch/x86/include/sys/acpi
50 CPPFLAGS += -DEFI_ZFS_BOOT
51 CPPFLAGS += -DNO_PCI -DEFI -DTERM_EMU
53 # Export serial numbers, UUID, and asset tag from loader.
54 CPPFLAGS += -DSMBIOS_SERIAL_NUMBERS
55 # Use little-endian UUID format as defined in SMBIOS 2.6.
56 CPPFLAGS += -DSMBIOS_LITTLE_ENDIAN_UUID
57 # Use network-endian UUID format for backward compatibility.
58 #CPPFLAGS += -DSMBIOS_NETWORK_ENDIAN_UUID
60 LIBSTAND= ../../../libstand/$(MACHINE)/libstand.a
63 CPPFLAGS += -DBOOT_FORTH -D_STANDALONE
64 CPPFLAGS += -I$(SRC)/common/ficl
65 CPPFLAGS += -I../../../libficl
66 LIBFICL= ../../../libficl/$(MACHINE)/libficl.a
68 CPPFLAGS += -I../../../zfs
69 LIBZFSBOOT= ../../../zfs/$(MACHINE)/libzfsboot.a
71 # Always add MI sources
72 include ../Makefile.common
73 CPPFLAGS += -I../../../common
75 # For multiboot2.h, must be last, to avoid conflicts
76 CPPFLAGS += -I$(SRCTOP)/include
80 ROOT_BOOT= $(ROOT)/boot
81 ROOTBOOTFILES=$(FILES:%=$(ROOT_BOOT)/%)
83 LDSCRIPT= ../arch/$(MACHINE)/ldscript.$(MACHINE)
84 LDFLAGS = -nostdlib --eh-frame-hdr
85 LDFLAGS += -shared --hash-style=both --enable-new-dtags
86 LDFLAGS += -T$(LDSCRIPT) -Bsymbolic
88 CLEANFILES= 8x16.c vers.c
90 NEWVERSWHAT= "EFI loader" $(MACHINE)
92 install: all $(ROOTBOOTFILES)
94 vers.c: ../../../common/newvers.sh $(SRC)/boot/Makefile.version
95 $(SH) ../../../common/newvers.sh $(LOADER_VERSION) $(NEWVERSWHAT)
97 $(EFIPROG): loader.sym
98 if [ `$(OBJDUMP) -t loader.sym | fgrep '*UND*' | wc -l` != 0 ]; then \
99 $(OBJDUMP) -t loader.sym | fgrep '*UND*'; \
102 $(OBJCOPY) --readonly-text -j .peheader -j .text -j .sdata -j .data \
103 -j .dynamic -j .dynsym -j .rel.dyn \
104 -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
105 -j set_Xficl_compile_set \
106 --output-target=$(EFI_TARGET) --subsystem efi-app loader.sym $@
108 LIBEFI= ../../libefi/$(MACHINE)/libefi.a
110 DPADD= $(LIBFICL) $(LIBZFSBOOT) $(LIBEFI) $(LIBSTAND) $(LDSCRIPT)
111 LDADD= $(LIBFICL) $(LIBZFSBOOT) $(LIBEFI) $(LIBSTAND)
114 loader.sym: $(OBJS) $(DPADD)
115 $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDADD)
119 $(SYMLINK) ../../../../$(MACHINE)/include machine
123 $(SYMLINK) ../../../../x86/include x86
126 $(RM) $(CLEANFILES) $(OBJS) loader.sym
131 %.o: ../arch/$(MACHINE)/%.c
135 # using -W to silence gas here, as for 32bit build, it will generate warning
136 # for start.S because hand crafted .reloc section does not have group name
138 %.o: ../arch/$(MACHINE)/%.S
139 $(COMPILE.S) -Wa,-W $<
141 %.o: ../../../common/%.c
144 %.o: ../../../common/linenoise/%.c
147 %.o: ../../../i386/libi386/%.c
150 %.o: $(SRC)/common/list/%.c
151 $(COMPILE.c) -DNDEBUG $<
153 %.o: $(SRC)/uts/common/io/font/%.c