xref: /titanic_51/usr/src/boot/sys/boot/i386/loader/Makefile (revision 8b96bc0de81576a5859f89b3df31cc9645daee3f)
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
19
20CFLAGS=		-O2
21CPPFLAGS=	-D_STANDALONE -nostdinc -I../../../../include -I../../..
22CPPFLAGS +=	-I$(SRC)/uts/intel/sys/acpi
23LOADER=		zfsloader
24NEWVERSWHAT=	"ZFS enabled bootstrap loader" x86
25MAN=
26
27# Set by zfsloader Makefile
28CPPFLAGS +=	-DLOADER_ZFS_SUPPORT -I../../zfs
29CPPFLAGS +=	-I../libi386
30LIBZFSBOOT=	../../zfs/i386/libzfsboot.a
31LIBI386=        ../libi386/libi386.a
32
33# loader.help build needs better awk
34AWK=		/usr/xpg4/bin/awk
35LD=		$(GNU_ROOT)/bin/gld
36CC=		$(GCC_ROOT)/bin/gcc
37OBJCOPY=	$(GNU_ROOT)/bin/gobjcopy
38GSTRIP=		$(GNU_ROOT)/bin/gstrip
39ROOT_BOOT=	$(ROOT)/boot
40ROOT_BOOT_DEFAULTS=	$(ROOT)/boot/defaults
41ROOT_BOOT_FORTH=	$(ROOT)/boot/forth
42ROOT_BOOT_CONF=		$(ROOT)/boot/conf.d
43ROOTBOOTFILES=$(FILES:%=$(ROOT_BOOT)/%)
44ROOTBOOTFORTH=$(FORTH:%=$(ROOT_BOOT_FORTH)/%)
45ROOTBOOTDEFAULTS=$(DEFFILES:%=$(ROOT_BOOT_DEFAULTS)/%)
46FILEMODE=0444
47
48all: ${LOADER} loader.help
49
50install: all $(ROOTBOOTLOADER)
51
52PROG=		${LOADER}.sym
53INTERNALPROG=
54
55# architecture-specific loader code
56SRCS=		main.c conf.c vers.c chain.c
57
58CPPFLAGS +=	-DLOADER_GZIP_SUPPORT
59
60# Enable BootForth
61CPPFLAGS +=	-DBOOT_FORTH -I$(SRC)/common/ficl -I../../ficl
62LIBFICL=	../../ficl/i386/libficl.a
63
64# Always add MI sources
65SRCS +=	boot.c commands.c console.c devopen.c interp.c
66SRCS +=	interp_backslash.c interp_parse.c ls.c misc.c
67SRCS +=	module.c panic.c linenoise.c multiboot2.c
68
69SRCS +=	load_elf32.c load_elf32_obj.c reloc_elf32.c
70SRCS +=	load_elf64.c load_elf64_obj.c reloc_elf64.c
71
72SRCS +=	dev_net.c
73
74SRCS +=	disk.c part.c
75CPPFLAGS += -DLOADER_DISK_SUPPORT
76SRCS +=	crc32.c
77CPPFLAGS += -DLOADER_GPT_SUPPORT
78CPPFLAGS += -DLOADER_MBR_SUPPORT
79
80SRCS +=  bcache.c
81
82SRCS +=	isapnp.c
83SRCS +=	pnp.c
84
85# Forth interpreter
86SRCS +=	interp_forth.c
87
88MAN +=	loader.8
89MAN +=	zfsloader.8
90CPPFLAGS +=	-I../../common
91CPPFLAGS +=	-I.
92
93CLEANFILES=	vers.c ${LOADER} ${LOADER}.sym ${LOADER}.bin loader.help
94
95CFLAGS +=	-Wall
96LDFLAGS=	-static -Ttext 0x0
97
98# i386 standalone support library
99CPPFLAGS +=	-I.. -I../../../../lib/libstand
100LIBSTAND=	../../libstand/i386/libstand.a
101
102# BTX components
103CPPFLAGS +=	-I../btx/lib
104
105# Debug me!
106#CFLAGS+=	-g
107#LDFLAGS+=	-g
108
109include ../Makefile.inc
110
111# For multiboot2.h, must be last, to avoid conflicts
112CPPFLAGS +=	-I$(SRC)/uts/common
113
114vers.c:	../../common/newvers.sh $(SRC)/boot/Makefile.version
115	$(SH) ../../common/newvers.sh ${LOADER_VERSION} ${NEWVERSWHAT}
116
117${LOADER}: ${LOADER}.bin ${BTXLDR} ${BTXKERN}
118	$(BTXLD) -f aout -e ${LOADER_ADDRESS} -o $@ -l ${BTXLDR} \
119		-b ${BTXKERN} ${LOADER}.bin
120
121${LOADER}.bin: ${LOADER}.sym
122	$(CP) $^ $@
123	$(GSTRIP) -R .comment -R .note $@
124
125loader.help: ../../common/help.common help.i386
126	$(CAT) $^ | $(AWK) -f ../../common/merge_help.awk > $@
127
128FILES=	${LOADER} loader.help
129
130include	../../forth/Makefile.inc
131FORTH +=	pcibios.4th
132
133FILES +=	loader.rc
134FILES +=	loader.conf
135FORTH +=	menu.rc
136
137# XXX crt0.o needs to be first for pxeboot(8) to work
138
139DPADD=	${LIBFICL} ${LIBZFSBOOT} ${LIBI386} ${LIBSTAND}
140LDADD=	${LIBFICL} ${LIBZFSBOOT} ${LIBI386} ${LIBSTAND}
141
142CLEANFILES +=	machine x86
143
144machine:
145	$(RM) machine
146	$(SYMLINK) ../../../i386/include machine
147
148x86:
149	$(RM) x86
150	$(SYMLINK) ../../../x86/include x86
151
152OBJS=		$(SRCS:%.c=%.o)
153
154${OBJS}: machine x86
155
156${PROG}: ${OBJS} $(LDADD)
157	$(LD) $(LDFLAGS) -o $@ $(BTXCRT) $(OBJS) $(LDADD)
158
159clean: clobber
160clobber:
161	$(RM) $(CLEANFILES) $(OBJS)
162
163install: all $(ROOT_BOOT_DEFAULTS) $(ROOT_BOOT_FORTH) \
164	$(ROOTBOOTFILES) $(ROOTBOOTDEFAULTS) $(ROOT_BOOT_CONF) $(ROOTBOOTFORTH)
165
166%.o:	../../common/%.c
167	$(COMPILE.c) -o $@ $<
168
169%.o:	../../common/linenoise/%.c
170	$(COMPILE.c) -o $@ $<
171
172$(ROOT_BOOT)/%: ../../forth/%
173	$(INS.file)
174
175$(ROOT_BOOT_DEFAULTS)/%: ../../forth/%
176	$(INS.file)
177
178$(ROOT_BOOT_FORTH)/%: ../../forth/%
179	$(INS.file)
180
181$(ROOT_BOOT_DEFAULTS) $(ROOT_BOOT_CONF) $(ROOT_BOOT_FORTH):
182	$(INS.dir)
183