Merge commit '37e84ab74e939caf52150fc3352081786ecc0c29' into merges
[unleashed.git] / usr / src / boot / sys / boot / efi / boot1 / Makefile
blob9fa3d997d3189a9e3560a31239836a4e87967424
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 += -DEFI_UFS_BOOT -DUFS1_ONLY
44 # CPPFLAGS += -DEFI_DEBUG
46 CPPFLAGS += -I./../../zfs/
47 CPPFLAGS += -I./../../../cddl/boot/zfs/
48 CPPFLAGS += -DEFI_ZFS_BOOT
50 # Always add MI sources and REGULAR efi loader bits
51 CPPFLAGS += -I./../../common
53 include ../Makefile.inc
55 FILES= boot1.efi
56 FILEMODE= 0555
57 ROOT_BOOT= $(ROOT)/boot
58 ROOTBOOTFILES=$(FILES:%=$(ROOT_BOOT)/%)
60 LDSCRIPT= ./../loader/arch/${MACHINE}/ldscript.${MACHINE}
61 LDFLAGS= -nostdlib --eh-frame-hdr -znocombreloc
62 LDFLAGS += -shared --hash-style=both --enable-new-dtags
63 LDFLAGS += -T${LDSCRIPT} -Bsymbolic
65 all: boot1.efi
67 install: all $(ROOTBOOTFILES)
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= ${LIBSTAND} ${LIBZFSBOOT}
77 LDADD= -L../../zfs/$(MACH64) -lzfsboot -L../../libstand/$(MACH64) -lstand
79 DPADD += ${LDSCRIPT}
81 EFI_TARGET= pei-x86-64
83 boot1.efi: ${PROG}
84 if [ `${OBJDUMP} -t ${PROG} | fgrep '*UND*' | wc -l` != 0 ]; then \
85 ${OBJDUMP} -t ${PROG} | fgrep '*UND*'; \
86 exit 1; \
88 ${OBJCOPY} --readonly-text -j .peheader -j .text -j .sdata -j .data \
89 -j .dynamic -j .dynsym -j .rel.dyn \
90 -j .rela.dyn -j .reloc -j .eh_frame \
91 --output-target=${EFI_TARGET} --subsystem efi-app ${PROG} $@
93 boot1.o: ./../../common/ufsread.c
95 CLEANFILES= boot1.efi ${PROG}
97 ${PROG}: $(OBJS) $(DPADD)
98 $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDADD)
100 CLEANFILES += machine x86
102 machine:
103 $(RM) machine
104 $(SYMLINK) ./../../../${MACHINE}/include machine
106 x86:
107 $(RM) x86
108 $(SYMLINK) ./../../../x86/include x86
110 $(OBJS): machine x86
112 clean clobber:
113 $(RM) $(CLEANFILES) $(OBJS)
115 %.o: ../loader/arch/${MACHINE}/%.S
116 $(COMPILE.S) $<
118 %.o: ../loader/%.c
119 $(COMPILE.c) $<
121 %.o: ../../common/%.c
122 $(COMPILE.c) $<
124 $(ROOT_BOOT)/%: %
125 $(INS.file)