xref: /illumos-gate/usr/src/boot/i386/loader/Makefile (revision 957246c9e6c47389c40079995d73eebcc659fb29)
1#
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.
6#
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.
10#
11
12#
13# Copyright 2015 Toomas Soome <tsoome@me.com>
14# Copyright 2016 RackTop Systems.
15#
16
17include $(SRC)/Makefile.master
18include $(SRC)/boot/Makefile.version
19include $(SRC)/boot/Makefile.inc
20
21CPPFLAGS +=	-I../../include -I../../sys
22CPPFLAGS +=	-I$(SRC)/uts/intel/sys/acpi
23CPPFLAGS +=	-I$(ZLIB)
24LOADER=		loader
25NEWVERSWHAT=	"ZFS enabled bootstrap loader" x86
26
27# Set by loader Makefile
28CPPFLAGS +=	-I$(ZFSSRC)
29CPPFLAGS +=	-I../libi386
30DPLIBI386=	../libi386/libi386.a
31LIBI386=	-L../libi386 -li386
32
33ROOT_BOOT=	$(ROOT)/boot
34ROOTBOOTFILES=$(FILES:%=$(ROOT_BOOT)/%)
35FILEMODE=0444
36
37all: $(LOADER) loader.help
38
39install: all $(ROOTBOOTLOADER)
40
41PROG=		$(LOADER).sym
42
43# architecture-specific loader code
44SRCS=		main.c conf.c vers.c chain.c
45
46CPPFLAGS +=	-DLOADER_GZIP_SUPPORT
47
48# Enable BootForth
49CPPFLAGS +=	-DBOOT_FORTH -I$(SRC)/common/ficl -I../../libficl
50DPLIBFICL=	../../libficl/$(MACH)/libficl.a
51LIBFICL=	-L../../libficl/$(MACH) -lficl
52
53# Always add MI sources
54SRCS +=	boot.c commands.c console.c devopen.c interp.c
55SRCS +=	interp_backslash.c interp_parse.c ls.c misc.c
56SRCS +=	module.c linenoise.c multiboot2.c nvstore.c
57SRCS +=	zfs_cmd.c
58SRCS +=	font.c $(FONT).c tem.c
59
60module.o := CPPFLAGS += -I$(CRYPTOSRC)
61tem.o := CPPFLAGS += $(DEFAULT_CONSOLE_COLOR)
62
63SRCS +=	load_elf32.c load_elf32_obj.c reloc_elf32.c
64SRCS +=	load_elf64.c load_elf64_obj.c reloc_elf64.c
65
66SRCS +=	dev_net.c
67
68SRCS +=	disk.c part.c vdisk.c
69CPPFLAGS += -DLOADER_DISK_SUPPORT
70CPPFLAGS += -DLOADER_GPT_SUPPORT
71CPPFLAGS += -DLOADER_MBR_SUPPORT
72
73SRCS +=  bcache.c
74
75SRCS +=	isapnp.c
76SRCS +=	pnp.c
77
78# Forth interpreter
79SRCS +=	interp_forth.c
80
81CPPFLAGS +=	-I../../common
82CPPFLAGS +=	-I.
83
84CLEANFILES=	vers.c $(LOADER) $(LOADER).sym $(LOADER).bin loader.help
85CLEANFILES +=	$(FONT).c
86
87LDSCRIPT=	ldscript.i386
88LDFLAGS=	-static -T $(LDSCRIPT) -N --gc-sections
89
90# i386 standalone support library
91CPPFLAGS +=	-I.. -I../../libsa
92DPLIBSA=	../../libsa/$(MACH)/libsa.a
93LIBSA=	-L../../libsa/$(MACH) -lsa
94
95# BTX components
96CPPFLAGS +=	-I../btx/lib
97
98# Debug me!
99#CFLAGS+=	-g
100#LDFLAGS+=	-g
101
102include ../Makefile.inc
103
104conf.o := CPPFLAGS += -I../../sys/cddl/boot/zfs
105multiboot2.o := CPPFLAGS += -I../../sys/cddl/boot/zfs
106main.o := CPPFLAGS += -I../../sys/cddl/boot/zfs -I$(SRC)/uts/common/fs/zfs
107zfs_cmd.o := CPPFLAGS += -I../../sys/cddl/boot/zfs
108
109# For multiboot2.h, must be last, to avoid conflicts
110CPPFLAGS +=	-I$(SRC)/uts/common
111
112vers.c:	../../common/newvers.sh $(SRC)/boot/Makefile.version
113	$(SH) ../../common/newvers.sh $(LOADER_VERSION) $(NEWVERSWHAT)
114
115$(LOADER): $(LOADER).bin $(BTXLDR) $(BTXKERN)
116	$(BTXLD) -f aout -e $(LOADER_ADDRESS) -o $@ -l $(BTXLDR) \
117		-b $(BTXKERN) $(LOADER).bin
118
119$(LOADER).bin: $(LOADER).sym
120	$(CP) $^ $@
121	$(GSTRIP) -R .comment -R .note $@
122
123loader.help: ../../common/help.common help.i386
124	$(CAT) $^ | $(AWK) -f ../../common/merge_help.awk > $@
125
126FILES=	$(LOADER) loader.help
127
128# XXX crt0.o needs to be first for pxeboot(8) to work
129
130DPADD=	$(DPLIBFICL) $(DPLIBI386) $(DPLIBSA)
131LDADD=	$(LIBFICL) $(LIBI386) $(LIBSA)
132
133CLEANFILES +=	machine x86
134
135machine:
136	$(RM) machine
137	$(SYMLINK) ../../sys/i386/include machine
138
139x86:
140	$(RM) x86
141	$(SYMLINK) ../../sys/x86/include x86
142
143OBJS=		$(SRCS:%.c=%.o)
144
145$(OBJS): machine x86
146
147$(PROG): $(OBJS) $(DPADD)
148	$(LD) $(LDFLAGS) -o $@ $(BTXCRT) $(OBJS) $(LDADD)
149
150clean: clobber
151clobber:
152	$(RM) $(CLEANFILES) $(OBJS)
153
154install: all $(ROOTBOOTFILES)
155
156%.o:	../../common/%.c
157	$(COMPILE.c) -o $@ $<
158
159%.o:	../../common/linenoise/%.c
160	$(COMPILE.c) -o $@ $<
161
162%.o: $(SRC)/common/font/%.c
163	$(COMPILE.c) $<
164
165$(FONT).c: $(FONT_DIR)/$(FONT_SRC)
166	$(VTFONTCVT) -f compressed-source -o $@ $(FONT_DIR)/$(FONT_SRC)
167
168$(ROOT_BOOT)/%: ../../forth/% $(ROOT_BOOT)
169	$(INS.file)
170