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
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 2015 Toomas Soome <tsoome@me.com>
14 # Copyright 2016 RackTop Systems.
17 include $(SRC
)/Makefile.master
18 include $(SRC
)/boot
/Makefile.version
19 include $(SRC
)/boot
/sys
/boot
/Makefile.inc
21 CFLAGS
= -Os
-fno-reorder-functions
22 CPPFLAGS
= -D_STANDALONE
-nostdinc
-I..
/..
/..
/..
/include -I..
/..
/..
23 CPPFLAGS
+= -I
$(SRCTOP
)/arch
/x86
/include/sys
/acpi
24 CPPFLAGS
+= -I..
/..
/..
/..
/lib
/libz
26 NEWVERSWHAT
= "ZFS enabled bootstrap loader" x86
28 # Set by loader Makefile
29 CPPFLAGS
+= -I..
/..
/zfs
30 CPPFLAGS
+= -I..
/libi386
31 LIBZFSBOOT
= ..
/..
/zfs
/$(MACH
)/libzfsboot.a
32 LIBI386
= ..
/libi386
/libi386.a
34 LD
= $(GNU_ROOT
)/bin
/gld
35 CC
= $(GNUC_ROOT
)/bin
/gcc
36 OBJCOPY
= $(GNU_ROOT
)/bin
/gobjcopy
37 GSTRIP
= $(GNU_ROOT
)/bin
/gstrip
38 ROOT_BOOT
= $(ROOT
)/boot
39 ROOT_BOOT_DEFAULTS
= $(ROOT
)/boot
/defaults
40 ROOT_BOOT_FORTH
= $(ROOT
)/boot
/forth
41 ROOT_BOOT_CONF
= $(ROOT
)/boot
/conf.d
42 ROOTBOOTFILES
=$(FILES
:%=$(ROOT_BOOT
)/%)
43 ROOTBOOTFORTH
=$(FORTH
:%=$(ROOT_BOOT_FORTH
)/%)
44 ROOTBOOTDEFAULTS
=$(DEFFILES
:%=$(ROOT_BOOT_DEFAULTS
)/%)
47 all: ${LOADER} loader.help
49 install: all $(ROOTBOOTLOADER
)
53 # architecture-specific loader code
54 SRCS
= main.c conf.c vers.c chain.c
56 CPPFLAGS
+= -DLOADER_GZIP_SUPPORT
59 CPPFLAGS
+= -DBOOT_FORTH
-I
$(SRC
)/common
/ficl
-I..
/..
/libficl
60 LIBFICL
= ..
/..
/libficl
/$(MACH
)/libficl.a
62 # Always add MI sources
63 SRCS
+= boot.c commands.c console.c devopen.c interp.c
64 SRCS
+= interp_backslash.c interp_parse.c ls.c misc.c
65 SRCS
+= module.c panic.c linenoise.c multiboot2.c
67 SRCS
+= font.c
$(FONT
).c list.c tem.c
69 SRCS
+= load_elf32.c load_elf32_obj.c reloc_elf32.c
70 SRCS
+= load_elf64.c load_elf64_obj.c reloc_elf64.c
75 CPPFLAGS
+= -DLOADER_DISK_SUPPORT
76 CPPFLAGS
+= -DLOADER_GPT_SUPPORT
77 CPPFLAGS
+= -DLOADER_MBR_SUPPORT
85 SRCS
+= interp_forth.c
87 CPPFLAGS
+= -I..
/..
/common
90 CLEANFILES
= vers.c
${LOADER} ${LOADER}.sym
${LOADER}.bin loader.help
91 CLEANFILES
+= $(FONT
).c
94 LDFLAGS
= -static
-Ttext
0x0 -m elf_i386
96 # i386 standalone support library
97 CPPFLAGS
+= -I..
-I..
/..
/..
/..
/lib
/libstand
98 LIBSTAND
= ..
/..
/libstand
/$(MACH
)/libstand.a
99 LIBCRYPTO
= ..
/..
/libcrypto
/$(MACH
)/libcrypto.a
102 CPPFLAGS
+= -I..
/btx
/lib
108 include ..
/Makefile.inc
110 # For multiboot2.h, must be last, to avoid conflicts
111 CPPFLAGS
+= -I
$(SRCTOP
)/include
113 vers.c
: ..
/..
/common
/newvers.sh
$(SRC
)/boot
/Makefile.version
114 $(SH
) ..
/..
/common
/newvers.sh
${LOADER_VERSION} ${NEWVERSWHAT}
116 ${LOADER}: ${LOADER}.bin
${BTXLDR} ${BTXKERN}
117 $(BTXLD
) -f aout
-e
${LOADER_ADDRESS} -o
$@
-l
${BTXLDR} \
118 -b
${BTXKERN} ${LOADER}.bin
120 ${LOADER}.bin
: ${LOADER}.sym
122 $(GSTRIP
) -R .comment
-R .note
$@
124 loader.help
: ..
/..
/common
/help.common help.i386
125 $(CAT
) $^ |
$(AWK
) -f ..
/..
/common
/merge_help.awk
> $@
127 FILES
= ${LOADER} loader.help
129 include ..
/..
/forth
/Makefile.inc
135 # XXX crt0.o needs to be first for pxeboot(8) to work
137 DPADD
= ${LIBFICL} ${LIBZFSBOOT} ${LIBI386} ${LIBCRYPTO} ${LIBSTAND}
138 LDADD
= ${LIBFICL} ${LIBZFSBOOT} ${LIBI386} ${LIBCRYPTO} ${LIBSTAND}
140 CLEANFILES
+= machine x86
144 $(SYMLINK
) ..
/..
/..
/i386
/include machine
148 $(SYMLINK
) ..
/..
/..
/x86
/include x86
150 OBJS
= $(SRCS
:%.c
=%.o
)
156 ${PROG}: ${OBJS} $(LDADD
)
157 $(LD
) $(LDFLAGS
) -o
$@
$(BTXCRT
) $(OBJS
) $(LDADD
)
161 $(RM
) $(CLEANFILES
) $(OBJS
)
163 install: all $(ROOT_BOOT_DEFAULTS
) $(ROOT_BOOT_FORTH
) \
164 $(ROOTBOOTFILES
) $(ROOTBOOTDEFAULTS
) $(ROOT_BOOT_CONF
) $(ROOTBOOTFORTH
)
166 %.o
: ..
/..
/common
/%.c
167 $(COMPILE.c
) -o
$@
$<
169 %.o
: ..
/..
/common
/linenoise
/%.c
170 $(COMPILE.c
) -o
$@
$<
172 %.o
: $(SRC
)/common
/list
/%.c
173 $(COMPILE.c
) -DNDEBUG
$<
175 %.o
: $(SRC
)/common
/font
/%.c
178 $(FONT
).c
: $(FONT_DIR
)/$(FONT_SRC
)
179 $(VTFONTCVT
) -f compressed-source
-o
$@
$(FONT_DIR
)/$(FONT_SRC
)
181 $(ROOT_BOOT
)/%: ..
/..
/forth
/% $(ROOT_BOOT
)
184 $(ROOT_BOOT_DEFAULTS
)/%: ..
/..
/forth
/% $(ROOT_BOOT_DEFAULTS
)
187 $(ROOT_BOOT_FORTH
)/%: ..
/..
/forth
/% $(ROOT_BOOT_FORTH
)
190 $(ROOT_BOOT_DEFAULTS
) $(ROOT_BOOT_CONF
) $(ROOT_BOOT_FORTH
):