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# Copyright 2024 MNX Cloud, Inc. 16# 17 18include $(SRC)/Makefile.master 19include $(SRC)/boot/Makefile.version 20include $(SRC)/boot/Makefile.inc 21 22CPPFLAGS += -I../../include -I../../sys 23CPPFLAGS += -I$(SRC)/uts/intel/sys/acpi 24CPPFLAGS += -I$(ZLIB) 25LOADER= loader 26NEWVERSWHAT= "ZFS enabled bootstrap loader" x86 27 28# Set by loader Makefile 29CPPFLAGS += -I$(ZFSSRC) 30CPPFLAGS += -I../libi386 31DPLIBI386= ../libi386/libi386.a 32LIBI386= -L../libi386 -li386 33 34ROOT_BOOT= $(ROOT)/boot 35ROOTBOOTFILES=$(FILES:%=$(ROOT_BOOT)/%) 36FILEMODE=0444 37 38all: $(LOADER) loader.help 39 40install: all $(ROOTBOOTLOADER) 41 42PROG= $(LOADER).sym 43 44# architecture-specific loader code 45SRCS= main.c conf.c vers.c chain.c panic_action.c 46 47panic_action.o := CFLAGS += -_gcc14=--param=min-pagesize=0 48panic_action.o := CFLAGS += -_gcc15=--param=min-pagesize=0 49 50# Enable BootForth 51CPPFLAGS += -DBOOT_FORTH -I$(SRC)/common/ficl -I../../libficl 52DPLIBFICL= ../../libficl/$(MACH)/libficl.a 53LIBFICL= -L../../libficl/$(MACH) -lficl 54 55# Always add MI sources 56SRCS += boot.c commands.c console.c devopen.c interp.c 57SRCS += interp_backslash.c interp_parse.c ls.c misc.c 58SRCS += module.c linenoise.c multiboot2.c nvstore.c 59SRCS += zfs_cmd.c 60SRCS += font.c $(FONT).c tem.c 61 62module.o := CPPFLAGS += -I$(CRYPTOSRC) 63tem.o := CPPFLAGS += $(DEFAULT_CONSOLE_COLOR) 64 65SRCS += load_elf32.c load_elf32_obj.c reloc_elf32.c 66SRCS += load_elf64.c load_elf64_obj.c reloc_elf64.c 67 68SRCS += dev_net.c 69 70SRCS += disk.c part.c vdisk.c 71CPPFLAGS += -DLOADER_DISK_SUPPORT 72CPPFLAGS += -DLOADER_GPT_SUPPORT 73CPPFLAGS += -DLOADER_MBR_SUPPORT 74 75SRCS += bcache.c 76 77SRCS += isapnp.c 78SRCS += pnp.c 79 80# Forth interpreter 81SRCS += interp_forth.c 82 83CPPFLAGS += -I../../common 84CPPFLAGS += -I. 85 86CLEANFILES= vers.c $(LOADER) $(LOADER).sym $(LOADER).bin loader.help 87CLEANFILES += $(FONT).c 88 89LDSCRIPT= ldscript.i386 90LDFLAGS= -static -T $(LDSCRIPT) -N --gc-sections 91 92# i386 standalone support library 93CPPFLAGS += -I.. -I../../libsa 94DPLIBSA= ../../libsa/$(MACH)/libsa.a 95LIBSA= -L../../libsa/$(MACH) -lsa 96 97# BTX components 98CPPFLAGS += -I../btx/lib 99 100# Debug me! 101#CFLAGS+= -g 102#LDFLAGS+= -g 103 104include ../Makefile.inc 105 106conf.o := CPPFLAGS += -I../../sys/cddl/boot/zfs 107multiboot2.o := CPPFLAGS += -I../../sys/cddl/boot/zfs 108main.o := CPPFLAGS += -I../../sys/cddl/boot/zfs -I$(SRC)/uts/common/fs/zfs 109zfs_cmd.o := CPPFLAGS += -I../../sys/cddl/boot/zfs 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 130# XXX crt0.o needs to be first for pxeboot(8) to work 131 132DPADD= $(DPLIBFICL) $(DPLIBI386) $(DPLIBSA) 133LDADD= $(LIBFICL) $(LIBI386) $(LIBSA) 134 135CLEANFILES += machine x86 136 137machine: 138 $(RM) machine 139 $(SYMLINK) ../../sys/i386/include machine 140 141x86: 142 $(RM) x86 143 $(SYMLINK) ../../sys/x86/include x86 144 145OBJS= $(SRCS:%.c=%.o) 146 147$(OBJS): machine x86 148 149$(PROG): $(OBJS) $(DPADD) 150 $(GLD) $(LDFLAGS) -o $@ $(BTXCRT) $(OBJS) $(LDADD) 151 152clean: clobber 153clobber: 154 $(RM) $(CLEANFILES) $(OBJS) 155 156install: all $(ROOTBOOTFILES) 157 158%.o: ../../common/%.c 159 $(COMPILE.c) -o $@ $< 160 161%.o: ../../common/linenoise/%.c 162 $(COMPILE.c) -o $@ $< 163 164%.o: $(SRC)/common/font/%.c 165 $(COMPILE.c) $< 166 167$(FONT).c: $(FONT_DIR)/$(FONT_SRC) 168 $(VTFONTCVT) -f compressed-source -o $@ $(FONT_DIR)/$(FONT_SRC) 169 170$(ROOT_BOOT)/%: ../../forth/% $(ROOT_BOOT) 171 $(INS.file) 172