loader: fix command paths
[unleashed.git] / usr / src / boot / sys / boot / efi / loader / Makefile
blob5824a84adaa5093e027f9786a97b02d451bb4f92
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>
16 include $(SRC)/Makefile.master
18 CC= $(GCC_ROOT)/bin/gcc
19 LD= $(GNU_ROOT)/bin/gld
20 OBJCOPY= $(GNU_ROOT)/bin/gobjcopy
21 OBJDUMP= $(GNU_ROOT)/bin/gobjdump
23 PROG= loader.sym
24 MACHINE= $(MACH64)
26 # architecture-specific loader code
27 SRCS= autoload.c bootinfo.c conf.c copy.c devicename.c main.c self_reloc.c \
28 smbios.c biosacpi.c vers.c
29 OBJS= autoload.o bootinfo.o conf.o copy.o devicename.o main.o self_reloc.o \
30 smbios.o biosacpi.o vers.o
32 ASFLAGS=-m64 -fPIC
33 CFLAGS= -O2
34 CPPFLAGS= -nostdinc -I../../../../include -I../../..
35 CPPFLAGS += -I../../../../lib/libstand
37 include ../Makefile.inc
39 include arch/${MACHINE}/Makefile.inc
41 CPPFLAGS += -I.
42 CPPFLAGS += -I./arch/${MACHINE}
43 CPPFLAGS += -I./../include
44 CPPFLAGS += -I./../include/${MACHINE}
45 CPPFLAGS += -I./../../../contrib/dev/acpica/include
46 CPPFLAGS += -I./../../..
47 CPPFLAGS += -I./../../i386/libi386
48 CPPFLAGS += -I./../../zfs
49 CPPFLAGS += -I./../../../cddl/boot/zfs
50 CPPFLAGS += -DEFI_ZFS_BOOT
51 CPPFLAGS += -DNO_PCI -DEFI -DTERM_EMU
53 LIBSTAND= ../../libstand/${MACHINE}/libstand.a
55 BOOT_FORTH= yes
56 CPPFLAGS += -DBOOT_FORTH -DSTAND
57 CPPFLAGS += -I$(SRC)/common/ficl
58 CPPFLAGS += -I../../ficl
59 LIBFICL= ../../ficl/${MACHINE}/libficl.a
61 CPPFLAGS += -I../../zfs
62 LIBZFSBOOT= ../../zfs/${MACHINE}/libzfsboot.a
64 #LOADER_FDT_SUPPORT?= no
65 #.if ${MK_FDT} != "no" && ${LOADER_FDT_SUPPORT} != "no"
66 #CFLAGS+= -I${.CURDIR}/../../fdt
67 #CFLAGS+= -I${.OBJDIR}/../../fdt
68 #CFLAGS+= -DLOADER_FDT_SUPPORT
69 #LIBEFI_FDT= ${.OBJDIR}/../../efi/fdt/libefi_fdt.a
70 #LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a
71 #.endif
73 # Always add MI sources
74 include ./Makefile.common
75 CPPFLAGS += -I../../common
77 FILES= loader.efi
78 FILEMODE= 0555
79 ROOT_BOOT= $(ROOT)/boot
80 ROOTBOOTFILES=$(FILES:%=$(ROOT_BOOT)/%)
82 LDSCRIPT= ./arch/${MACHINE}/ldscript.${MACHINE}
83 LDFLAGS = -nostdlib --eh-frame-hdr -znocombreloc
84 LDFLAGS += -shared --hash-style=both --enable-new-dtags
85 LDFLAGS += -T${LDSCRIPT} -Bsymbolic
87 CLEANFILES= vers.c loader.efi
89 NEWVERSWHAT= "EFI loader" ${MACHINE}
91 all: machine x86 loader.efi
92 install: all $(ROOTBOOTFILES)
94 vers.c: ../../common/newvers.sh ../../efi/loader/version
95 $(SH) ../../common/newvers.sh version ${NEWVERSWHAT}
97 EFI_TARGET= pei-x86-64
99 loader.efi: loader.sym
100 if [ `${OBJDUMP} -t loader.sym | fgrep '*UND*' | wc -l` != 0 ]; then \
101 ${OBJDUMP} -t loader.sym | fgrep '*UND*'; \
102 exit 1; \
104 ${OBJCOPY} --readonly-text -j .peheader -j .text -j .sdata -j .data \
105 -j .dynamic -j .dynsym -j .rel.dyn \
106 -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
107 --output-target=${EFI_TARGET} --subsystem efi-app loader.sym $@
109 LIBEFI= ../libefi/libefi.a
111 DPADD= ${LIBFICL} ${LIBZFSBOOT} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} \
112 ${LIBSTAND} ${LDSCRIPT}
113 LDADD= ${LIBFICL} ${LIBZFSBOOT} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} \
114 ${LIBSTAND}
117 loader.sym: $(OBJS) $(DPADD)
118 $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDADD)
120 beforedepend ${OBJS}: machine
122 CLEANFILES += machine x86
124 machine:
125 $(RM) machine
126 $(SYMLINK) ../../../${MACHINE}/include machine
128 x86:
129 $(RM) x86
130 $(SYMLINK) ../../../x86/include x86
132 clean clobber:
133 $(RM) $(CLEANFILES) $(OBJS) loader.sym loader.efi
135 %.o: %.c
136 $(COMPILE.c) $<
138 %.o: ./arch/${MACHINE}/%.c
139 $(COMPILE.c) $<
141 %.o: ./arch/${MACHINE}/%.S
142 $(COMPILE.S) $<
144 %.o: ../../common/%.c
145 $(COMPILE.c) $<
147 %.o: ../../common/linenoise/%.c
148 $(COMPILE.c) $<
150 %.o: ../../i386/libi386/%.c
151 $(COMPILE.c) $<
153 $(ROOT_BOOT)/%: %
154 $(INS.file)