libefi: Move EFI ZFS functions to libefi
[unleashed.git] / usr / src / boot / sys / boot / efi / loader / Makefile
blob9f3820d19792d54044f156e321ca99f4d90d9b97
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>
14 # Copyright 2016 RackTop Systems.
17 include $(SRC)/Makefile.master
18 include $(SRC)/boot/Makefile.version
20 CC= $(GCC_ROOT)/bin/gcc
21 LD= $(GNU_ROOT)/bin/gld
22 OBJCOPY= $(GNU_ROOT)/bin/gobjcopy
23 OBJDUMP= $(GNU_ROOT)/bin/gobjdump
25 PROG= loader.sym
26 MACHINE= $(MACH64)
28 # architecture-specific loader code
29 SRCS= autoload.c bootinfo.c conf.c copy.c devicename.c efi_main.c main.c \
30 self_reloc.c smbios.c acpi.c vers.c memmap.c multiboot2.c
31 OBJS= autoload.o bootinfo.o conf.o copy.o devicename.o efi_main.o main.o \
32 self_reloc.o smbios.o acpi.o vers.o memmap.o multiboot2.o
34 ASFLAGS=-m64 -fPIC
35 CFLAGS= -O2
36 CPPFLAGS= -nostdinc -I../../../../include -I../../..
37 CPPFLAGS += -I../../../../lib/libstand
39 include ../Makefile.inc
41 include arch/${MACHINE}/Makefile.inc
43 CPPFLAGS += -I.
44 CPPFLAGS += -I./arch/${MACHINE}
45 CPPFLAGS += -I./../include
46 CPPFLAGS += -I./../include/${MACHINE}
47 CPPFLAGS += -I$(SRCTOP)/arch/x86/include/sys/acpi
48 CPPFLAGS += -I./../../..
49 CPPFLAGS += -I./../../i386/libi386
50 CPPFLAGS += -I./../../zfs
51 CPPFLAGS += -I./../../../cddl/boot/zfs
52 CPPFLAGS += -DNO_PCI -DEFI -DTERM_EMU
54 # Export serial numbers, UUID, and asset tag from loader.
55 CPPFLAGS += -DSMBIOS_SERIAL_NUMBERS
56 # Use little-endian UUID format as defined in SMBIOS 2.6.
57 CPPFLAGS += -DSMBIOS_LITTLE_ENDIAN_UUID
58 # Use network-endian UUID format for backward compatibility.
59 #CPPFLAGS += -DSMBIOS_NETWORK_ENDIAN_UUID
61 LIBSTAND= ../../libstand/${MACHINE}/libstand.a
63 BOOT_FORTH= yes
64 CPPFLAGS += -DBOOT_FORTH -D_STANDALONE
65 CPPFLAGS += -I$(SRC)/common/ficl
66 CPPFLAGS += -I../../ficl
67 LIBFICL= ../../ficl/${MACHINE}/libficl.a
69 CPPFLAGS += -I../../zfs
70 LIBZFSBOOT= ../../zfs/${MACHINE}/libzfsboot.a
72 #LOADER_FDT_SUPPORT?= no
73 #.if ${MK_FDT} != "no" && ${LOADER_FDT_SUPPORT} != "no"
74 #CFLAGS+= -I${.CURDIR}/../../fdt
75 #CFLAGS+= -I${.OBJDIR}/../../fdt
76 #CFLAGS+= -DLOADER_FDT_SUPPORT
77 #LIBEFI_FDT= ${.OBJDIR}/../../efi/fdt/libefi_fdt.a
78 #LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a
79 #.endif
81 # Always add MI sources
82 include ./Makefile.common
83 CPPFLAGS += -I../../common
85 # For multiboot2.h, must be last, to avoid conflicts
86 CPPFLAGS += -I$(SRCTOP)/include
88 FILES= loader.efi
89 FILEMODE= 0555
90 ROOT_BOOT= $(ROOT)/boot
91 ROOTBOOTFILES=$(FILES:%=$(ROOT_BOOT)/%)
93 LDSCRIPT= ./arch/${MACHINE}/ldscript.${MACHINE}
94 LDFLAGS = -nostdlib --eh-frame-hdr -znocombreloc
95 LDFLAGS += -shared --hash-style=both --enable-new-dtags
96 LDFLAGS += -T${LDSCRIPT} -Bsymbolic
98 CLEANFILES= vers.c loader.efi
100 NEWVERSWHAT= "EFI loader" ${MACHINE}
102 all: loader.efi
104 install: all $(ROOTBOOTFILES)
106 vers.c: ../../common/newvers.sh $(SRC)/boot/Makefile.version
107 $(SH) ../../common/newvers.sh ${LOADER_VERSION} ${NEWVERSWHAT}
109 EFI_TARGET= pei-x86-64
111 loader.efi: loader.sym
112 if [ `${OBJDUMP} -t loader.sym | fgrep '*UND*' | wc -l` != 0 ]; then \
113 ${OBJDUMP} -t loader.sym | fgrep '*UND*'; \
114 exit 1; \
116 ${OBJCOPY} --readonly-text -j .peheader -j .text -j .sdata -j .data \
117 -j .dynamic -j .dynsym -j .rel.dyn \
118 -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
119 -j set_Xficl_compile_set \
120 --output-target=${EFI_TARGET} --subsystem efi-app loader.sym $@
122 LIBEFI= ../libefi/libefi.a
124 DPADD= ${LIBFICL} ${LIBZFSBOOT} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} \
125 ${LIBSTAND} ${LDSCRIPT}
126 LDADD= ${LIBFICL} ${LIBZFSBOOT} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} \
127 ${LIBSTAND}
130 loader.sym: $(OBJS) $(DPADD)
131 $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDADD)
133 CLEANFILES += machine x86
135 machine:
136 $(RM) machine
137 $(SYMLINK) ../../../${MACHINE}/include machine
139 x86:
140 $(RM) x86
141 $(SYMLINK) ../../../x86/include x86
143 $(OBJS): machine x86
145 clean clobber:
146 $(RM) $(CLEANFILES) $(OBJS) loader.sym loader.efi
148 %.o: %.c
149 $(COMPILE.c) $<
151 %.o: ./arch/${MACHINE}/%.c
152 $(COMPILE.c) $<
154 %.o: ./arch/${MACHINE}/%.S
155 $(COMPILE.S) $<
157 %.o: ../../common/%.c
158 $(COMPILE.c) $<
160 %.o: ../../common/linenoise/%.c
161 $(COMPILE.c) $<
163 %.o: ../../i386/libi386/%.c
164 $(COMPILE.c) $<
166 $(ROOT_BOOT)/%: %
167 $(INS.file)