blob: ec9c6123aabf3496c2c1759d6b9b034af617b009 [file] [log] [blame]
Toomas Soome199767f2015-10-25 00:06:51 +03001#
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>
Andrew Stormonte547e4e2016-10-01 02:09:33 +010014# Copyright 2016 RackTop Systems.
Toomas Soome199767f2015-10-25 00:06:51 +030015#
16
17include $(SRC)/Makefile.master
Toomas Soomef6c94442017-01-03 11:24:09 +020018include $(SRC)/boot/Makefile.version
Toomas Soome199767f2015-10-25 00:06:51 +030019
Toomas Soome83b46712016-08-16 19:02:42 +030020CFLAGS= -O2 -fno-reorder-functions
Toomas Soome68d77042017-12-04 14:00:00 +020021CPPFLAGS= -D_STANDALONE -nostdinc -I../../../../include -I../../..
Toomas Soome14ee0d22016-10-09 17:07:43 +030022CPPFLAGS += -I$(SRC)/uts/intel/sys/acpi
Toomas Soome9fd53712018-08-09 12:03:56 -070023LOADER= loader
Toomas Soome199767f2015-10-25 00:06:51 +030024NEWVERSWHAT= "ZFS enabled bootstrap loader" x86
Toomas Soome199767f2015-10-25 00:06:51 +030025
Toomas Soome9fd53712018-08-09 12:03:56 -070026# Set by loader Makefile
Toomas Soome199767f2015-10-25 00:06:51 +030027CPPFLAGS += -DLOADER_ZFS_SUPPORT -I../../zfs
28CPPFLAGS += -I../libi386
Toomas Soome83b46712016-08-16 19:02:42 +030029LIBZFSBOOT= ../../zfs/$(MACH)/libzfsboot.a
Toomas Soome199767f2015-10-25 00:06:51 +030030LIBI386= ../libi386/libi386.a
31
32# loader.help build needs better awk
33AWK= /usr/xpg4/bin/awk
34LD= $(GNU_ROOT)/bin/gld
Robert Mustacchi7ed54632018-07-28 15:48:38 +000035CC= $(GNUC_ROOT)/bin/gcc
Toomas Soome199767f2015-10-25 00:06:51 +030036OBJCOPY= $(GNU_ROOT)/bin/gobjcopy
37GSTRIP= $(GNU_ROOT)/bin/gstrip
38ROOT_BOOT= $(ROOT)/boot
39ROOT_BOOT_DEFAULTS= $(ROOT)/boot/defaults
40ROOT_BOOT_FORTH= $(ROOT)/boot/forth
41ROOT_BOOT_CONF= $(ROOT)/boot/conf.d
42ROOTBOOTFILES=$(FILES:%=$(ROOT_BOOT)/%)
43ROOTBOOTFORTH=$(FORTH:%=$(ROOT_BOOT_FORTH)/%)
44ROOTBOOTDEFAULTS=$(DEFFILES:%=$(ROOT_BOOT_DEFAULTS)/%)
45FILEMODE=0444
46
Andrew Stormonte547e4e2016-10-01 02:09:33 +010047all: ${LOADER} loader.help
Toomas Soome199767f2015-10-25 00:06:51 +030048
49install: all $(ROOTBOOTLOADER)
50
51PROG= ${LOADER}.sym
52INTERNALPROG=
53
54# architecture-specific loader code
55SRCS= main.c conf.c vers.c chain.c
56
Toomas Soomeaa617552016-11-09 12:26:44 +020057CPPFLAGS += -DLOADER_GZIP_SUPPORT
Toomas Soome199767f2015-10-25 00:06:51 +030058
59# Enable BootForth
Toomas Soome83b46712016-08-16 19:02:42 +030060CPPFLAGS += -DBOOT_FORTH -I$(SRC)/common/ficl -I../../libficl
61LIBFICL= ../../libficl/$(MACH)/libficl.a
Toomas Soome199767f2015-10-25 00:06:51 +030062
63# Always add MI sources
64SRCS += boot.c commands.c console.c devopen.c interp.c
65SRCS += interp_backslash.c interp_parse.c ls.c misc.c
Toomas Soome14ee0d22016-10-09 17:07:43 +030066SRCS += module.c panic.c linenoise.c multiboot2.c
Toomas Soome199767f2015-10-25 00:06:51 +030067
68SRCS += load_elf32.c load_elf32_obj.c reloc_elf32.c
69SRCS += load_elf64.c load_elf64_obj.c reloc_elf64.c
70
71SRCS += dev_net.c
72
73SRCS += disk.c part.c
74CPPFLAGS += -DLOADER_DISK_SUPPORT
75SRCS += crc32.c
76CPPFLAGS += -DLOADER_GPT_SUPPORT
77CPPFLAGS += -DLOADER_MBR_SUPPORT
78
79SRCS += bcache.c
80
81SRCS += isapnp.c
82SRCS += pnp.c
83
84# Forth interpreter
85SRCS += interp_forth.c
86
Toomas Soome199767f2015-10-25 00:06:51 +030087CPPFLAGS += -I../../common
88CPPFLAGS += -I.
89
90CLEANFILES= vers.c ${LOADER} ${LOADER}.sym ${LOADER}.bin loader.help
91
92CFLAGS += -Wall
93LDFLAGS= -static -Ttext 0x0
94
95# i386 standalone support library
96CPPFLAGS += -I.. -I../../../../lib/libstand
Toomas Soome83b46712016-08-16 19:02:42 +030097LIBSTAND= ../../libstand/$(MACH)/libstand.a
Toomas Soome199767f2015-10-25 00:06:51 +030098
99# BTX components
100CPPFLAGS += -I../btx/lib
101
102# Debug me!
103#CFLAGS+= -g
104#LDFLAGS+= -g
105
106include ../Makefile.inc
107
Toomas Soome14ee0d22016-10-09 17:07:43 +0300108# For multiboot2.h, must be last, to avoid conflicts
109CPPFLAGS += -I$(SRC)/uts/common
110
Toomas Soomef6c94442017-01-03 11:24:09 +0200111vers.c: ../../common/newvers.sh $(SRC)/boot/Makefile.version
112 $(SH) ../../common/newvers.sh ${LOADER_VERSION} ${NEWVERSWHAT}
Toomas Soome199767f2015-10-25 00:06:51 +0300113
114${LOADER}: ${LOADER}.bin ${BTXLDR} ${BTXKERN}
Toomas Soomecce7ee22016-12-14 00:42:41 +0200115 $(BTXLD) -f aout -e ${LOADER_ADDRESS} -o $@ -l ${BTXLDR} \
Toomas Soome199767f2015-10-25 00:06:51 +0300116 -b ${BTXKERN} ${LOADER}.bin
117
118${LOADER}.bin: ${LOADER}.sym
119 $(CP) $^ $@
120 $(GSTRIP) -R .comment -R .note $@
121
122loader.help: ../../common/help.common help.i386
123 $(CAT) $^ | $(AWK) -f ../../common/merge_help.awk > $@
124
125FILES= ${LOADER} loader.help
126
127include ../../forth/Makefile.inc
128FORTH += pcibios.4th
129
130FILES += loader.rc
131FORTH += menu.rc
132
133# XXX crt0.o needs to be first for pxeboot(8) to work
134
135DPADD= ${LIBFICL} ${LIBZFSBOOT} ${LIBI386} ${LIBSTAND}
136LDADD= ${LIBFICL} ${LIBZFSBOOT} ${LIBI386} ${LIBSTAND}
137
138CLEANFILES += machine x86
Toomas Soome199767f2015-10-25 00:06:51 +0300139
140machine:
141 $(RM) machine
142 $(SYMLINK) ../../../i386/include machine
143
144x86:
145 $(RM) x86
146 $(SYMLINK) ../../../x86/include x86
147
148OBJS= $(SRCS:%.c=%.o)
149
Andrew Stormonte547e4e2016-10-01 02:09:33 +0100150${OBJS}: machine x86
151
Toomas Soome199767f2015-10-25 00:06:51 +0300152${PROG}: ${OBJS} $(LDADD)
153 $(LD) $(LDFLAGS) -o $@ $(BTXCRT) $(OBJS) $(LDADD)
154
155clean: clobber
156clobber:
157 $(RM) $(CLEANFILES) $(OBJS)
158
159install: all $(ROOT_BOOT_DEFAULTS) $(ROOT_BOOT_FORTH) \
160 $(ROOTBOOTFILES) $(ROOTBOOTDEFAULTS) $(ROOT_BOOT_CONF) $(ROOTBOOTFORTH)
161
162%.o: ../../common/%.c
163 $(COMPILE.c) -o $@ $<
164
165%.o: ../../common/linenoise/%.c
166 $(COMPILE.c) -o $@ $<
167
168$(ROOT_BOOT)/%: ../../forth/%
169 $(INS.file)
170
171$(ROOT_BOOT_DEFAULTS)/%: ../../forth/%
172 $(INS.file)
173
174$(ROOT_BOOT_FORTH)/%: ../../forth/%
175 $(INS.file)
176
177$(ROOT_BOOT_DEFAULTS) $(ROOT_BOOT_CONF) $(ROOT_BOOT_FORTH):
178 $(INS.dir)