libefi: Move EFI ZFS functions to libefi
[unleashed.git] / usr / src / boot / sys / boot / efi / boot1 / Makefile
blob990c519d621d13801888806a3ed853277abab20e
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= boot1.sym
26 MACHINE=$(MACH64)
28 # architecture-specific loader code
29 SRCS= boot1.c self_reloc.c start.S ufs_module.c zfs_module.c devopen.c
30 OBJS= boot1.o self_reloc.o start.o ufs_module.o zfs_module.o devopen.o
32 ASFLAGS=-m64 -fPIC
33 CFLAGS= -O2
34 CPPFLAGS= -nostdinc
35 CPPFLAGS += -I.
36 CPPFLAGS += -I./../include
37 CPPFLAGS += -I./../include/${MACHINE}
38 CPPFLAGS += -I$(SRCTOP)/arch/x86/include/sys/acpi
39 CPPFLAGS += -I./../../../../include
40 CPPFLAGS += -I./../../../sys
41 CPPFLAGS += -I./../../..
42 CPPFLAGS += -I../../../../lib/libstand
43 CPPFLAGS += -DUFS1_ONLY
44 # CPPFLAGS += -DEFI_DEBUG
46 CPPFLAGS += -I./../../zfs/
47 CPPFLAGS += -I./../../../cddl/boot/zfs/
49 # Always add MI sources and REGULAR efi loader bits
50 CPPFLAGS += -I./../../common
52 include ../Makefile.inc
54 FILES= boot1.efi
55 FILEMODE= 0555
56 ROOT_BOOT= $(ROOT)/boot
57 ROOTBOOTFILES=$(FILES:%=$(ROOT_BOOT)/%)
59 LDSCRIPT= ./../loader/arch/${MACHINE}/ldscript.${MACHINE}
60 LDFLAGS= -nostdlib --eh-frame-hdr -znocombreloc
61 LDFLAGS += -shared --hash-style=both --enable-new-dtags
62 LDFLAGS += -T${LDSCRIPT} -Bsymbolic
64 all: boot1.efi
66 install: all $(ROOTBOOTFILES)
68 LIBEFI= ../libefi/libefi.a
70 # Add libstand for the runtime functions used by the compiler - for example
71 # __aeabi_* (arm) or __divdi3 (i386).
72 # as well as required string and memory functions for all platforms.
74 LIBSTAND= ../../libstand/$(MACH64)/libstand.a
75 LIBZFSBOOT= ../../zfs/$(MACH64)/libzfsboot.a
76 DPADD= $(LIBEFI) $(LIBZFSBOOT) $(LIBSTAND)
77 LDADD= -L../libefi -lefi
78 LDADD += -L../../zfs/$(MACH64) -lzfsboot
79 LDADD += -L../../libstand/$(MACH64) -lstand
81 DPADD += ${LDSCRIPT}
83 EFI_TARGET= pei-x86-64
85 boot1.efi: ${PROG}
86 if [ `${OBJDUMP} -t ${PROG} | fgrep '*UND*' | wc -l` != 0 ]; then \
87 ${OBJDUMP} -t ${PROG} | fgrep '*UND*'; \
88 exit 1; \
90 ${OBJCOPY} --readonly-text -j .peheader -j .text -j .sdata -j .data \
91 -j .dynamic -j .dynsym -j .rel.dyn \
92 -j .rela.dyn -j .reloc -j .eh_frame \
93 --output-target=${EFI_TARGET} --subsystem efi-app ${PROG} $@
95 boot1.o: ./../../common/ufsread.c
97 CLEANFILES= boot1.efi ${PROG}
99 ${PROG}: $(OBJS) $(DPADD)
100 $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDADD)
102 CLEANFILES += machine x86
104 machine:
105 $(RM) machine
106 $(SYMLINK) ./../../../${MACHINE}/include machine
108 x86:
109 $(RM) x86
110 $(SYMLINK) ./../../../x86/include x86
112 $(OBJS): machine x86
114 clean clobber:
115 $(RM) $(CLEANFILES) $(OBJS)
117 %.o: ../loader/arch/${MACHINE}/%.S
118 $(COMPILE.S) $<
120 %.o: ../loader/%.c
121 $(COMPILE.c) $<
123 %.o: ../../common/%.c
124 $(COMPILE.c) $<
126 $(ROOT_BOOT)/%: %
127 $(INS.file)