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
58 CPPFLAGS= -nostdinc -I../../../../../include -I../../..../
59 CPPFLAGS += -I../../../../../lib/libstand
60 CPPFLAGS += -I../../../../../lib/libz
62 include ../../Makefile.inc
64 include ../arch/$(MACHINE)/Makefile.inc
67 CPPFLAGS += -I../../include
68 CPPFLAGS += -I../../include/$(MACHINE)
69 CPPFLAGS += -I../../../..
70 CPPFLAGS += -I../../../i386/libi386
71 CPPFLAGS += -I../../../zfs
72 CPPFLAGS += -I../../../../cddl/boot/zfs
73 CPPFLAGS += -I$(SRCTOP)/arch/x86/include/sys/acpi
74 CPPFLAGS += -DEFI_ZFS_BOOT
75 CPPFLAGS += -DNO_PCI -DEFI -DTERM_EMU
77 # Export serial numbers, UUID, and asset tag from loader.
78 smbios.o := CPPFLAGS += -DSMBIOS_SERIAL_NUMBERS
79 # Use little-endian UUID format as defined in SMBIOS 2.6.
80 smbios.o := CPPFLAGS += -DSMBIOS_LITTLE_ENDIAN_UUID
81 # Use network-endian UUID format for backward compatibility.
82 #CPPFLAGS += -DSMBIOS_NETWORK_ENDIAN_UUID
84 LIBSTAND= ../../../libstand/$(MACHINE)/libstand.a
87 CPPFLAGS += -DBOOT_FORTH -D_STANDALONE
88 CPPFLAGS += -I$(SRC)/common/ficl
89 CPPFLAGS += -I../../../libficl
90 LIBFICL= ../../../libficl/$(MACHINE)/libficl.a
92 CPPFLAGS += -I../../../zfs
93 LIBZFSBOOT= ../../../zfs/$(MACHINE)/libzfsboot.a
95 # Always add MI sources
96 include ../Makefile.common
97 CPPFLAGS += -I../../../common
99 # For multiboot2.h, must be last, to avoid conflicts
100 CPPFLAGS += -I$(SRCTOP)/include
104 ROOT_BOOT= $(ROOT)/boot
105 ROOTBOOTFILES=$(FILES:%=$(ROOT_BOOT)/%)
107 LDSCRIPT= ../arch/$(MACHINE)/ldscript.$(MACHINE)
108 LDFLAGS = -nostdlib --eh-frame-hdr
109 LDFLAGS += -shared --hash-style=both --enable-new-dtags
110 LDFLAGS += -T$(LDSCRIPT) -Bsymbolic
112 CLEANFILES= loader.sym loader.bin vers.c
114 NEWVERSWHAT= "EFI loader" $(MACHINE)
116 install: all $(ROOTBOOTFILES)
118 vers.c: ../../../common/newvers.sh $(SRC)/boot/Makefile.version
119 $(SH) ../../../common/newvers.sh $(LOADER_VERSION) $(NEWVERSWHAT)
121 $(EFIPROG): loader.bin
122 $(BTXLD) -V $(BOOT_VERSION) -o $@ loader.bin
124 loader.bin: loader.sym
125 if [ `$(OBJDUMP) -t loader.sym | fgrep '*UND*' | wc -l` != 0 ]; then \
126 $(OBJDUMP) -t loader.sym | fgrep '*UND*'; \
129 $(OBJCOPY) --readonly-text -j .peheader -j .text -j .sdata -j .data \
130 -j .dynamic -j .dynsym -j .rel.dyn \
131 -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
132 -j set_Xficl_compile_set \
133 --output-target=$(EFI_TARGET) --subsystem efi-app loader.sym $@
135 LIBEFI= ../../libefi/$(MACHINE)/libefi.a
137 DPADD= $(LIBFICL) $(LIBZFSBOOT) $(LIBEFI) $(LIBSTAND) $(LDSCRIPT)
138 LDADD= $(LIBFICL) $(LIBZFSBOOT) $(LIBEFI) $(LIBSTAND)
142 loader.sym: $(OBJS) $(DPADD)
143 $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDADD)
147 $(SYMLINK) ../../../../$(MACHINE)/include machine
151 $(SYMLINK) ../../../../x86/include x86
154 $(RM) $(CLEANFILES) $(OBJS)
159 %.o: ../arch/$(MACHINE)/%.c
163 # using -W to silence gas here, as for 32bit build, it will generate warning
164 # for start.S because hand crafted .reloc section does not have group name
166 %.o: ../arch/$(MACHINE)/%.S
167 $(COMPILE.S) -Wa,-W $<
169 %.o: ../../../common/%.S
172 %.o: ../../../common/%.c
175 %.o: ../../../common/linenoise/%.c
178 %.o: ../../../i386/libi386/%.c
181 %.o: $(SRC)/common/list/%.c
182 $(COMPILE.c) -DNDEBUG $<
184 %.o: $(SRC)/uts/common/io/font/%.c