loader: rename zfsloader to loader
[unleashed.git] / usr / src / boot / sys / boot / i386 / loader / Makefile
blob76c9f151f186c93864aa0b6f98656a9ac7a17b7e
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
21 CPPFLAGS= -D_STANDALONE -nostdinc -I../../../../include -I../../..
22 CPPFLAGS += -I$(SRCTOP)/arch/x86/include/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 LD= $(GNU_ROOT)/bin/gld
33 CC= $(GCC_ROOT)/bin/gcc
34 OBJCOPY= $(GNU_ROOT)/bin/gobjcopy
35 GSTRIP= $(GNU_ROOT)/bin/gstrip
36 ROOT_BOOT= $(ROOT)/boot
37 ROOT_BOOT_DEFAULTS= $(ROOT)/boot/defaults
38 ROOT_BOOT_FORTH= $(ROOT)/boot/forth
39 ROOT_BOOT_CONF= $(ROOT)/boot/conf.d
40 ROOTBOOTFILES=$(FILES:%=$(ROOT_BOOT)/%)
41 ROOTBOOTFORTH=$(FORTH:%=$(ROOT_BOOT_FORTH)/%)
42 ROOTBOOTDEFAULTS=$(DEFFILES:%=$(ROOT_BOOT_DEFAULTS)/%)
43 FILEMODE=0444
45 all: ${LOADER} loader.help
47 install: all $(ROOTBOOTLOADER)
49 PROG= ${LOADER}.sym
50 INTERNALPROG=
52 # architecture-specific loader code
53 SRCS= main.c conf.c vers.c chain.c
55 CPPFLAGS += -DLOADER_GZIP_SUPPORT
57 # Enable BootForth
58 CPPFLAGS += -DBOOT_FORTH -I$(SRC)/common/ficl -I../../libficl
59 LIBFICL= ../../libficl/$(MACH)/libficl.a
61 # Always add MI sources
62 SRCS += boot.c commands.c console.c devopen.c interp.c
63 SRCS += interp_backslash.c interp_parse.c ls.c misc.c
64 SRCS += module.c panic.c linenoise.c multiboot2.c
66 SRCS += load_elf32.c load_elf32_obj.c reloc_elf32.c
67 SRCS += load_elf64.c load_elf64_obj.c reloc_elf64.c
69 SRCS += dev_net.c
71 SRCS += disk.c part.c
72 CPPFLAGS += -DLOADER_DISK_SUPPORT
73 SRCS += crc32.c
74 CPPFLAGS += -DLOADER_GPT_SUPPORT
75 CPPFLAGS += -DLOADER_MBR_SUPPORT
77 SRCS += bcache.c
79 SRCS += isapnp.c
80 SRCS += pnp.c
82 # Forth interpreter
83 SRCS += interp_forth.c
85 CPPFLAGS += -I../../common
86 CPPFLAGS += -I.
88 CLEANFILES= vers.c ${LOADER} ${LOADER}.sym ${LOADER}.bin loader.help
90 CFLAGS += -Wall
91 LDFLAGS= -static -Ttext 0x0
93 # i386 standalone support library
94 CPPFLAGS += -I.. -I../../../../lib/libstand
95 LIBSTAND= ../../libstand/$(MACH)/libstand.a
97 # BTX components
98 CPPFLAGS += -I../btx/lib
100 # Debug me!
101 #CFLAGS+= -g
102 #LDFLAGS+= -g
104 include ../Makefile.inc
106 # For multiboot2.h, must be last, to avoid conflicts
107 CPPFLAGS += -I$(SRCTOP)/include
109 vers.c: ../../common/newvers.sh $(SRC)/boot/Makefile.version
110 $(SH) ../../common/newvers.sh ${LOADER_VERSION} ${NEWVERSWHAT}
112 ${LOADER}: ${LOADER}.bin ${BTXLDR} ${BTXKERN}
113 $(BTXLD) -f aout -e ${LOADER_ADDRESS} -o $@ -l ${BTXLDR} \
114 -b ${BTXKERN} ${LOADER}.bin
116 ${LOADER}.bin: ${LOADER}.sym
117 $(CP) $^ $@
118 $(GSTRIP) -R .comment -R .note $@
120 loader.help: ../../common/help.common help.i386
121 $(CAT) $^ | $(AWK) -f ../../common/merge_help.awk > $@
123 FILES= ${LOADER} loader.help
125 include ../../forth/Makefile.inc
126 FORTH += pcibios.4th
128 FILES += loader.rc
129 FORTH += menu.rc
131 # XXX crt0.o needs to be first for pxeboot(8) to work
133 DPADD= ${LIBFICL} ${LIBZFSBOOT} ${LIBI386} ${LIBSTAND}
134 LDADD= ${LIBFICL} ${LIBZFSBOOT} ${LIBI386} ${LIBSTAND}
136 CLEANFILES += machine x86
138 machine:
139 $(RM) machine
140 $(SYMLINK) ../../../i386/include machine
142 x86:
143 $(RM) x86
144 $(SYMLINK) ../../../x86/include x86
146 OBJS= $(SRCS:%.c=%.o)
148 ${OBJS}: machine x86
150 ${PROG}: ${OBJS} $(LDADD)
151 $(LD) $(LDFLAGS) -o $@ $(BTXCRT) $(OBJS) $(LDADD)
153 clean: clobber
154 clobber:
155 $(RM) $(CLEANFILES) $(OBJS)
157 install: all $(ROOT_BOOT_DEFAULTS) $(ROOT_BOOT_FORTH) \
158 $(ROOTBOOTFILES) $(ROOTBOOTDEFAULTS) $(ROOT_BOOT_CONF) $(ROOTBOOTFORTH)
160 %.o: ../../common/%.c
161 $(COMPILE.c) -o $@ $<
163 %.o: ../../common/linenoise/%.c
164 $(COMPILE.c) -o $@ $<
166 $(ROOT_BOOT)/%: ../../forth/%
167 $(INS.file)
169 $(ROOT_BOOT_DEFAULTS)/%: ../../forth/%
170 $(INS.file)
172 $(ROOT_BOOT_FORTH)/%: ../../forth/%
173 $(INS.file)
175 $(ROOT_BOOT_DEFAULTS) $(ROOT_BOOT_CONF) $(ROOT_BOOT_FORTH):
176 $(INS.dir)