9664 loader: need UEFI32 support
[unleashed.git] / usr / src / boot / sys / boot / i386 / loader / Makefile
blobec9c6123aabf3496c2c1759d6b9b034af617b009
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 2015 Toomas Soome <tsoome@me.com>
14 # Copyright 2016 RackTop Systems.
17 include $(SRC)/Makefile.master
18 include $(SRC)/boot/Makefile.version
20 CFLAGS= -O2 -fno-reorder-functions
21 CPPFLAGS= -D_STANDALONE -nostdinc -I../../../../include -I../../..
22 CPPFLAGS += -I$(SRC)/uts/intel/sys/acpi
23 LOADER= loader
24 NEWVERSWHAT= "ZFS enabled bootstrap loader" x86
26 # Set by loader Makefile
27 CPPFLAGS += -DLOADER_ZFS_SUPPORT -I../../zfs
28 CPPFLAGS += -I../libi386
29 LIBZFSBOOT= ../../zfs/$(MACH)/libzfsboot.a
30 LIBI386= ../libi386/libi386.a
32 # loader.help build needs better awk
33 AWK= /usr/xpg4/bin/awk
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)/%)
45 FILEMODE=0444
47 all: ${LOADER} loader.help
49 install: all $(ROOTBOOTLOADER)
51 PROG= ${LOADER}.sym
52 INTERNALPROG=
54 # architecture-specific loader code
55 SRCS= main.c conf.c vers.c chain.c
57 CPPFLAGS += -DLOADER_GZIP_SUPPORT
59 # Enable BootForth
60 CPPFLAGS += -DBOOT_FORTH -I$(SRC)/common/ficl -I../../libficl
61 LIBFICL= ../../libficl/$(MACH)/libficl.a
63 # Always add MI sources
64 SRCS += boot.c commands.c console.c devopen.c interp.c
65 SRCS += interp_backslash.c interp_parse.c ls.c misc.c
66 SRCS += module.c panic.c linenoise.c multiboot2.c
68 SRCS += load_elf32.c load_elf32_obj.c reloc_elf32.c
69 SRCS += load_elf64.c load_elf64_obj.c reloc_elf64.c
71 SRCS += dev_net.c
73 SRCS += disk.c part.c
74 CPPFLAGS += -DLOADER_DISK_SUPPORT
75 SRCS += crc32.c
76 CPPFLAGS += -DLOADER_GPT_SUPPORT
77 CPPFLAGS += -DLOADER_MBR_SUPPORT
79 SRCS += bcache.c
81 SRCS += isapnp.c
82 SRCS += pnp.c
84 # Forth interpreter
85 SRCS += interp_forth.c
87 CPPFLAGS += -I../../common
88 CPPFLAGS += -I.
90 CLEANFILES= vers.c ${LOADER} ${LOADER}.sym ${LOADER}.bin loader.help
92 CFLAGS += -Wall
93 LDFLAGS= -static -Ttext 0x0
95 # i386 standalone support library
96 CPPFLAGS += -I.. -I../../../../lib/libstand
97 LIBSTAND= ../../libstand/$(MACH)/libstand.a
99 # BTX components
100 CPPFLAGS += -I../btx/lib
102 # Debug me!
103 #CFLAGS+= -g
104 #LDFLAGS+= -g
106 include ../Makefile.inc
108 # For multiboot2.h, must be last, to avoid conflicts
109 CPPFLAGS += -I$(SRC)/uts/common
111 vers.c: ../../common/newvers.sh $(SRC)/boot/Makefile.version
112 $(SH) ../../common/newvers.sh ${LOADER_VERSION} ${NEWVERSWHAT}
114 ${LOADER}: ${LOADER}.bin ${BTXLDR} ${BTXKERN}
115 $(BTXLD) -f aout -e ${LOADER_ADDRESS} -o $@ -l ${BTXLDR} \
116 -b ${BTXKERN} ${LOADER}.bin
118 ${LOADER}.bin: ${LOADER}.sym
119 $(CP) $^ $@
120 $(GSTRIP) -R .comment -R .note $@
122 loader.help: ../../common/help.common help.i386
123 $(CAT) $^ | $(AWK) -f ../../common/merge_help.awk > $@
125 FILES= ${LOADER} loader.help
127 include ../../forth/Makefile.inc
128 FORTH += pcibios.4th
130 FILES += loader.rc
131 FORTH += menu.rc
133 # XXX crt0.o needs to be first for pxeboot(8) to work
135 DPADD= ${LIBFICL} ${LIBZFSBOOT} ${LIBI386} ${LIBSTAND}
136 LDADD= ${LIBFICL} ${LIBZFSBOOT} ${LIBI386} ${LIBSTAND}
138 CLEANFILES += machine x86
140 machine:
141 $(RM) machine
142 $(SYMLINK) ../../../i386/include machine
144 x86:
145 $(RM) x86
146 $(SYMLINK) ../../../x86/include x86
148 OBJS= $(SRCS:%.c=%.o)
150 ${OBJS}: machine x86
152 ${PROG}: ${OBJS} $(LDADD)
153 $(LD) $(LDFLAGS) -o $@ $(BTXCRT) $(OBJS) $(LDADD)
155 clean: clobber
156 clobber:
157 $(RM) $(CLEANFILES) $(OBJS)
159 install: all $(ROOT_BOOT_DEFAULTS) $(ROOT_BOOT_FORTH) \
160 $(ROOTBOOTFILES) $(ROOTBOOTDEFAULTS) $(ROOT_BOOT_CONF) $(ROOTBOOTFORTH)
162 %.o: ../../common/%.c
163 $(COMPILE.c) -o $@ $<
165 %.o: ../../common/linenoise/%.c
166 $(COMPILE.c) -o $@ $<
168 $(ROOT_BOOT)/%: ../../forth/%
169 $(INS.file)
171 $(ROOT_BOOT_DEFAULTS)/%: ../../forth/%
172 $(INS.file)
174 $(ROOT_BOOT_FORTH)/%: ../../forth/%
175 $(INS.file)
177 $(ROOT_BOOT_DEFAULTS) $(ROOT_BOOT_CONF) $(ROOT_BOOT_FORTH):
178 $(INS.dir)