xref: /illumos-gate/usr/src/boot/efi/loader/Makefile.com (revision 9b9d39d2a32ff806d2431dbcc50968ef1e6d46b2)
1#
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.
6#
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.
10#
11
12#
13# Copyright 2016 Toomas Soome <tsoome@me.com>
14#
15
16include $(SRC)/boot/Makefile.version
17include $(SRC)/boot/Makefile.inc
18
19PROG=		loader.sym
20
21# architecture-specific loader code
22OBJS=	\
23	acpi.o \
24	autoload.o \
25	bootinfo.o \
26	conf.o \
27	copy.o \
28	efi_main.o \
29	font.o \
30	$(FONT).o \
31	framebuffer.o \
32	main.o \
33	memmap.o \
34	mb_header.o \
35	multiboot2.o \
36	nvstore.o \
37	self_reloc.o \
38	tem.o \
39	vers.o
40
41module.o := CPPFLAGS += -I$(CRYPTOSRC)
42tem.o := CPPFLAGS += $(DEFAULT_CONSOLE_COLOR)
43main.o := CPPFLAGS += -I$(SRC)/uts/common/fs/zfs
44
45CPPFLAGS += -I../../../include -I../../../sys
46CPPFLAGS += -I../../../libsa
47
48include ../../Makefile.inc
49
50include ../arch/$(MACHINE)/Makefile.inc
51
52CPPFLAGS +=	-I. -I..
53CPPFLAGS +=	-I../../include
54CPPFLAGS +=	-I../../include/$(MACHINE)
55CPPFLAGS +=	-I$(ZFSSRC)
56CPPFLAGS +=	-I../../../sys/cddl/boot/zfs
57CPPFLAGS +=	-I$(SRC)/uts/intel/sys/acpi
58CPPFLAGS +=	-I$(PNGLITE)
59CPPFLAGS +=	-DNO_PCI -DEFI
60
61DPLIBSA=	../../../libsa/$(MACHINE)/libsa_pics.a
62LIBSA=	-L../../../libsa/$(MACHINE) -lsa_pics
63
64BOOT_FORTH=	yes
65CPPFLAGS +=	-DBOOT_FORTH
66CPPFLAGS +=	-I$(SRC)/common/ficl
67CPPFLAGS +=	-I../../../libficl
68DPLIBFICL=	../../../libficl/$(MACHINE)/libficl_pics.a
69LIBFICL=	-L../../../libficl/$(MACHINE) -lficl_pics
70
71# Always add MI sources
72#
73OBJS += boot.o commands.o console.o devopen.o interp.o \
74	interp_backslash.o interp_parse.o ls.o misc.o \
75	module.o linenoise.o zfs_cmd.o
76
77OBJS += load_elf32.o load_elf32_obj.o reloc_elf32.o \
78	load_elf64.o load_elf64_obj.o reloc_elf64.o
79
80OBJS += disk.o part.o dev_net.o vdisk.o
81CPPFLAGS += -DLOADER_DISK_SUPPORT
82CPPFLAGS += -DLOADER_GPT_SUPPORT
83CPPFLAGS += -DLOADER_MBR_SUPPORT
84
85part.o := CPPFLAGS += -I$(ZLIB)
86
87OBJS +=  bcache.o
88
89# Forth interpreter
90OBJS +=	interp_forth.o
91CPPFLAGS +=	-I../../../common
92
93# For multiboot2.h, must be last, to avoid conflicts
94CPPFLAGS +=	-I$(SRC)/uts/common
95
96FILES=		$(EFIPROG)
97FILEMODE=	0555
98ROOT_BOOT=	$(ROOT)/boot
99ROOTBOOTFILES=$(FILES:%=$(ROOT_BOOT)/%)
100
101LDSCRIPT=	../arch/$(MACHINE)/ldscript.$(MACHINE)
102LDFLAGS =	-nostdlib --eh-frame-hdr
103LDFLAGS +=	-shared --hash-style=both --enable-new-dtags
104LDFLAGS +=	-T$(LDSCRIPT) -Bsymbolic
105
106CLEANFILES=	$(EFIPROG) loader.sym loader.bin
107CLEANFILES +=	$(FONT).c vers.c
108
109NEWVERSWHAT=	"EFI loader" $(MACHINE)
110
111install: all $(ROOTBOOTFILES)
112
113vers.c:	../../../common/newvers.sh $(SRC)/boot/Makefile.version
114	$(SH) ../../../common/newvers.sh $(LOADER_VERSION) $(NEWVERSWHAT)
115
116$(EFIPROG): loader.bin
117	$(BTXLD) -V $(BOOT_VERSION) -o $@ loader.bin
118
119loader.bin: loader.sym
120	if [ `$(OBJDUMP) -t loader.sym | fgrep '*UND*' | wc -l` != 0 ]; then \
121		$(OBJDUMP) -t loader.sym | fgrep '*UND*'; \
122		exit 1; \
123	fi
124	$(OBJCOPY) --readonly-text -j .peheader -j .text -j .sdata -j .data \
125		-j .dynamic -j .dynsym -j .rel.dyn \
126		-j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
127		-j set_Xficl_compile_set \
128		--output-target=$(EFI_TARGET) --subsystem efi-app loader.sym $@
129
130DPLIBEFI=	../../libefi/$(MACHINE)/libefi.a
131LIBEFI=		-L../../libefi/$(MACHINE) -lefi
132
133DPADD=		$(DPLIBFICL) $(DPLIBEFI) $(DPLIBSA) $(LDSCRIPT)
134LDADD=		$(LIBFICL) $(LIBEFI) $(LIBSA)
135
136loader.sym:	$(OBJS) $(DPADD)
137	$(GLD) $(LDFLAGS) -o $@ $(OBJS) $(LDADD)
138
139machine:
140	$(RM) machine
141	$(SYMLINK) ../../../sys/$(MACHINE)/include machine
142
143x86:
144	$(RM) x86
145	$(SYMLINK) ../../../sys/x86/include x86
146
147clean clobber:
148	$(RM) $(CLEANFILES) $(OBJS) machine x86
149
150%.o:	../%.c
151	$(COMPILE.c) $<
152
153%.o:	../arch/$(MACHINE)/%.c
154	$(COMPILE.c) $<
155
156#
157# using -W to silence gas here, as for 32bit build, it will generate warning
158# for start.S because hand crafted .reloc section does not have group name
159#
160%.o:	../arch/$(MACHINE)/%.S
161	$(COMPILE.S) -Wa,-W $<
162
163%.o:	../../../common/%.S
164	$(COMPILE.S) $<
165
166%.o:	../../../common/%.c
167	$(COMPILE.c) $<
168
169%.o:	../../../common/linenoise/%.c
170	$(COMPILE.c) $<
171
172%.o: $(SRC)/common/font/%.c
173	$(COMPILE.c) $<
174
175$(FONT).c: $(FONT_DIR)/$(FONT_SRC)
176	$(VTFONTCVT) -f compressed-source -o $@ $(FONT_DIR)/$(FONT_SRC)
177
178$(ROOT_BOOT)/%: %
179	$(INS.file)
180