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 46 47# Enable BootForth 48CPPFLAGS += -DBOOT_FORTH -I$(SRC)/common/ficl -I../../libficl 49DPLIBFICL= ../../libficl/$(MACH)/libficl.a 50LIBFICL= -L../../libficl/$(MACH) -lficl 51 52# Always add MI sources 53SRCS += boot.c commands.c console.c devopen.c interp.c 54SRCS += interp_backslash.c interp_parse.c ls.c misc.c 55SRCS += module.c linenoise.c multiboot2.c nvstore.c 56SRCS += zfs_cmd.c 57SRCS += font.c $(FONT).c tem.c 58 59module.o := CPPFLAGS += -I$(CRYPTOSRC) 60tem.o := CPPFLAGS += $(DEFAULT_CONSOLE_COLOR) 61 62SRCS += load_elf32.c load_elf32_obj.c reloc_elf32.c 63SRCS += load_elf64.c load_elf64_obj.c reloc_elf64.c 64 65SRCS += dev_net.c 66 67SRCS += disk.c part.c vdisk.c 68CPPFLAGS += -DLOADER_DISK_SUPPORT 69CPPFLAGS += -DLOADER_GPT_SUPPORT 70CPPFLAGS += -DLOADER_MBR_SUPPORT 71 72SRCS += bcache.c 73 74SRCS += isapnp.c 75SRCS += pnp.c 76 77# Forth interpreter 78SRCS += interp_forth.c 79 80CPPFLAGS += -I../../common 81CPPFLAGS += -I. 82 83CLEANFILES= vers.c $(LOADER) $(LOADER).sym $(LOADER).bin loader.help 84CLEANFILES += $(FONT).c 85 86LDSCRIPT= ldscript.i386 87LDFLAGS= -static -T $(LDSCRIPT) -N --gc-sections 88 89# i386 standalone support library 90CPPFLAGS += -I.. -I../../libsa 91DPLIBSA= ../../libsa/$(MACH)/libsa.a 92LIBSA= -L../../libsa/$(MACH) -lsa 93 94# BTX components 95CPPFLAGS += -I../btx/lib 96 97# Debug me! 98#CFLAGS+= -g 99#LDFLAGS+= -g 100 101include ../Makefile.inc 102 103conf.o := CPPFLAGS += -I../../sys/cddl/boot/zfs 104multiboot2.o := CPPFLAGS += -I../../sys/cddl/boot/zfs 105main.o := CPPFLAGS += -I../../sys/cddl/boot/zfs -I$(SRC)/uts/common/fs/zfs 106zfs_cmd.o := CPPFLAGS += -I../../sys/cddl/boot/zfs 107 108# For multiboot2.h, must be last, to avoid conflicts 109CPPFLAGS += -I$(SRC)/uts/common 110 111vers.c: ../../common/newvers.sh $(SRC)/boot/Makefile.version 112 $(SH) ../../common/newvers.sh $(LOADER_VERSION) $(NEWVERSWHAT) 113 114$(LOADER): $(LOADER).bin $(BTXLDR) $(BTXKERN) 115 $(BTXLD) -f aout -e $(LOADER_ADDRESS) -o $@ -l $(BTXLDR) \ 116 -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 127# XXX crt0.o needs to be first for pxeboot(8) to work 128 129DPADD= $(DPLIBFICL) $(DPLIBI386) $(DPLIBSA) 130LDADD= $(LIBFICL) $(LIBI386) $(LIBSA) 131 132CLEANFILES += machine x86 133 134machine: 135 $(RM) machine 136 $(SYMLINK) ../../sys/i386/include machine 137 138x86: 139 $(RM) x86 140 $(SYMLINK) ../../sys/x86/include x86 141 142OBJS= $(SRCS:%.c=%.o) 143 144$(OBJS): machine x86 145 146$(PROG): $(OBJS) $(DPADD) 147 $(GLD) $(LDFLAGS) -o $@ $(BTXCRT) $(OBJS) $(LDADD) 148 149clean: clobber 150clobber: 151 $(RM) $(CLEANFILES) $(OBJS) 152 153install: all $(ROOTBOOTFILES) 154 155%.o: ../../common/%.c 156 $(COMPILE.c) -o $@ $< 157 158%.o: ../../common/linenoise/%.c 159 $(COMPILE.c) -o $@ $< 160 161%.o: $(SRC)/common/font/%.c 162 $(COMPILE.c) $< 163 164$(FONT).c: $(FONT_DIR)/$(FONT_SRC) 165 $(VTFONTCVT) -f compressed-source -o $@ $(FONT_DIR)/$(FONT_SRC) 166 167$(ROOT_BOOT)/%: ../../forth/% $(ROOT_BOOT) 168 $(INS.file) 169