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