Merge illumos-gate
[unleashed.git] / usr / src / boot / sys / boot / efi / loader / Makefile.com
blobd7c6e8ddf553fc46a2126347312909abdd2309d0
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
5 # 1.0 of the CDDL.
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
24 PROG=           loader.sym
26 # architecture-specific loader code
27 SRCS=   acpi.c \
28         autoload.c \
29         bootinfo.c \
30         conf.c \
31         copy.c \
32         efi_main.c \
33         framebuffer.c \
34         main.c \
35         memmap.c \
36         multiboot.S \
37         multiboot2.c \
38         self_reloc.c \
39         smbios.c \
40         vers.c
42 OBJS=   acpi.o \
43         autoload.o \
44         bootinfo.o \
45         conf.o \
46         copy.o \
47         efi_main.o \
48         framebuffer.o \
49         main.o \
50         memmap.o \
51         multiboot.o \
52         multiboot2.o \
53         self_reloc.o \
54         smbios.o \
55         vers.o
57 CFLAGS= -Os
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
66 CPPFLAGS +=     -I. -I..
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
86 BOOT_FORTH=     yes
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
102 FILES=          $(EFIPROG)
103 FILEMODE=       0555
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*'; \
127                 exit 1; \
128         fi
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)
140 .PARALLEL:
142 loader.sym:     $(OBJS) $(DPADD)
143         $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDADD)
145 machine:
146         $(RM) machine
147         $(SYMLINK) ../../../../$(MACHINE)/include machine
149 x86:
150         $(RM) x86
151         $(SYMLINK) ../../../../x86/include x86
153 clean clobber:
154         $(RM) $(CLEANFILES) $(OBJS)
156 %.o:    ../%.c
157         $(COMPILE.c) $<
159 %.o:    ../arch/$(MACHINE)/%.c
160         $(COMPILE.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
170         $(COMPILE.S) $<
172 %.o:    ../../../common/%.c
173         $(COMPILE.c) $<
175 %.o:    ../../../common/linenoise/%.c
176         $(COMPILE.c) $<
178 %.o: ../../../i386/libi386/%.c
179         $(COMPILE.c) $<
181 %.o: $(SRC)/common/list/%.c
182         $(COMPILE.c) -DNDEBUG $<
184 %.o: $(SRC)/uts/common/io/font/%.c
185         $(COMPILE.c) $<
187 $(ROOT_BOOT)/%: %
188         $(INS.file)