xref: /illumos-gate/usr/src/boot/i386/loader/Makefile (revision ef86b95d1dbad918184489140320c3b7dd69e4ec)
122028508SToomas Soome#
222028508SToomas Soome# This file and its contents are supplied under the terms of the
322028508SToomas Soome# Common Development and Distribution License ("CDDL"), version 1.0.
422028508SToomas Soome# You may only use this file in accordance with the terms of version
522028508SToomas Soome# 1.0 of the CDDL.
622028508SToomas Soome#
722028508SToomas Soome# A full copy of the text of the CDDL should have accompanied this
822028508SToomas Soome# source.  A copy of the CDDL is also available via the Internet at
922028508SToomas Soome# http://www.illumos.org/license/CDDL.
1022028508SToomas Soome#
1122028508SToomas Soome
1222028508SToomas Soome#
1322028508SToomas Soome# Copyright 2015 Toomas Soome <tsoome@me.com>
1422028508SToomas Soome# Copyright 2016 RackTop Systems.
15*ef86b95dSToomas Soome# Copyright 2024 MNX Cloud, Inc.
1622028508SToomas Soome#
1722028508SToomas Soome
1822028508SToomas Soomeinclude $(SRC)/Makefile.master
1922028508SToomas Soomeinclude $(SRC)/boot/Makefile.version
2022028508SToomas Soomeinclude $(SRC)/boot/Makefile.inc
2122028508SToomas Soome
2222028508SToomas SoomeCPPFLAGS +=	-I../../include -I../../sys
2322028508SToomas SoomeCPPFLAGS +=	-I$(SRC)/uts/intel/sys/acpi
2422028508SToomas SoomeCPPFLAGS +=	-I$(ZLIB)
2522028508SToomas SoomeLOADER=		loader
2622028508SToomas SoomeNEWVERSWHAT=	"ZFS enabled bootstrap loader" x86
2722028508SToomas Soome
2822028508SToomas Soome# Set by loader Makefile
2922028508SToomas SoomeCPPFLAGS +=	-I$(ZFSSRC)
3022028508SToomas SoomeCPPFLAGS +=	-I../libi386
3122028508SToomas SoomeDPLIBI386=	../libi386/libi386.a
3222028508SToomas SoomeLIBI386=	-L../libi386 -li386
3322028508SToomas Soome
3422028508SToomas SoomeROOT_BOOT=	$(ROOT)/boot
3522028508SToomas SoomeROOTBOOTFILES=$(FILES:%=$(ROOT_BOOT)/%)
3622028508SToomas SoomeFILEMODE=0444
3722028508SToomas Soome
3822028508SToomas Soomeall: $(LOADER) loader.help
3922028508SToomas Soome
4022028508SToomas Soomeinstall: all $(ROOTBOOTLOADER)
4122028508SToomas Soome
4222028508SToomas SoomePROG=		$(LOADER).sym
4322028508SToomas Soome
4422028508SToomas Soome# architecture-specific loader code
4522028508SToomas SoomeSRCS=		main.c conf.c vers.c chain.c
4622028508SToomas Soome
4722028508SToomas Soome# Enable BootForth
4822028508SToomas SoomeCPPFLAGS +=	-DBOOT_FORTH -I$(SRC)/common/ficl -I../../libficl
4922028508SToomas SoomeDPLIBFICL=	../../libficl/$(MACH)/libficl.a
5022028508SToomas SoomeLIBFICL=	-L../../libficl/$(MACH) -lficl
5122028508SToomas Soome
5222028508SToomas Soome# Always add MI sources
5322028508SToomas SoomeSRCS +=	boot.c commands.c console.c devopen.c interp.c
5422028508SToomas SoomeSRCS +=	interp_backslash.c interp_parse.c ls.c misc.c
5522028508SToomas SoomeSRCS +=	module.c linenoise.c multiboot2.c nvstore.c
5622028508SToomas SoomeSRCS +=	zfs_cmd.c
5722028508SToomas SoomeSRCS +=	font.c $(FONT).c tem.c
5822028508SToomas Soome
5922028508SToomas Soomemodule.o := CPPFLAGS += -I$(CRYPTOSRC)
6022028508SToomas Soometem.o := CPPFLAGS += $(DEFAULT_CONSOLE_COLOR)
6122028508SToomas Soome
6222028508SToomas SoomeSRCS +=	load_elf32.c load_elf32_obj.c reloc_elf32.c
6322028508SToomas SoomeSRCS +=	load_elf64.c load_elf64_obj.c reloc_elf64.c
6422028508SToomas Soome
6522028508SToomas SoomeSRCS +=	dev_net.c
6622028508SToomas Soome
6722028508SToomas SoomeSRCS +=	disk.c part.c vdisk.c
6822028508SToomas SoomeCPPFLAGS += -DLOADER_DISK_SUPPORT
6922028508SToomas SoomeCPPFLAGS += -DLOADER_GPT_SUPPORT
7022028508SToomas SoomeCPPFLAGS += -DLOADER_MBR_SUPPORT
7122028508SToomas Soome
7222028508SToomas SoomeSRCS +=  bcache.c
7322028508SToomas Soome
7422028508SToomas SoomeSRCS +=	isapnp.c
7522028508SToomas SoomeSRCS +=	pnp.c
7622028508SToomas Soome
7722028508SToomas Soome# Forth interpreter
7822028508SToomas SoomeSRCS +=	interp_forth.c
7922028508SToomas Soome
8022028508SToomas SoomeCPPFLAGS +=	-I../../common
8122028508SToomas SoomeCPPFLAGS +=	-I.
8222028508SToomas Soome
8322028508SToomas SoomeCLEANFILES=	vers.c $(LOADER) $(LOADER).sym $(LOADER).bin loader.help
8422028508SToomas SoomeCLEANFILES +=	$(FONT).c
8522028508SToomas Soome
8622028508SToomas SoomeLDSCRIPT=	ldscript.i386
8722028508SToomas SoomeLDFLAGS=	-static -T $(LDSCRIPT) -N --gc-sections
8822028508SToomas Soome
8922028508SToomas Soome# i386 standalone support library
9022028508SToomas SoomeCPPFLAGS +=	-I.. -I../../libsa
9122028508SToomas SoomeDPLIBSA=	../../libsa/$(MACH)/libsa.a
9222028508SToomas SoomeLIBSA=	-L../../libsa/$(MACH) -lsa
9322028508SToomas Soome
9422028508SToomas Soome# BTX components
9522028508SToomas SoomeCPPFLAGS +=	-I../btx/lib
9622028508SToomas Soome
9722028508SToomas Soome# Debug me!
9822028508SToomas Soome#CFLAGS+=	-g
9922028508SToomas Soome#LDFLAGS+=	-g
10022028508SToomas Soome
10122028508SToomas Soomeinclude ../Makefile.inc
10222028508SToomas Soome
10322028508SToomas Soomeconf.o := CPPFLAGS += -I../../sys/cddl/boot/zfs
10422028508SToomas Soomemultiboot2.o := CPPFLAGS += -I../../sys/cddl/boot/zfs
10522028508SToomas Soomemain.o := CPPFLAGS += -I../../sys/cddl/boot/zfs -I$(SRC)/uts/common/fs/zfs
10622028508SToomas Soomezfs_cmd.o := CPPFLAGS += -I../../sys/cddl/boot/zfs
10722028508SToomas Soome
10822028508SToomas Soome# For multiboot2.h, must be last, to avoid conflicts
10922028508SToomas SoomeCPPFLAGS +=	-I$(SRC)/uts/common
11022028508SToomas Soome
11122028508SToomas Soomevers.c:	../../common/newvers.sh $(SRC)/boot/Makefile.version
11222028508SToomas Soome	$(SH) ../../common/newvers.sh $(LOADER_VERSION) $(NEWVERSWHAT)
11322028508SToomas Soome
11422028508SToomas Soome$(LOADER): $(LOADER).bin $(BTXLDR) $(BTXKERN)
11522028508SToomas Soome	$(BTXLD) -f aout -e $(LOADER_ADDRESS) -o $@ -l $(BTXLDR) \
11622028508SToomas Soome		-b $(BTXKERN) $(LOADER).bin
11722028508SToomas Soome
11822028508SToomas Soome$(LOADER).bin: $(LOADER).sym
11922028508SToomas Soome	$(CP) $^ $@
12022028508SToomas Soome	$(GSTRIP) -R .comment -R .note $@
12122028508SToomas Soome
12222028508SToomas Soomeloader.help: ../../common/help.common help.i386
12322028508SToomas Soome	$(CAT) $^ | $(AWK) -f ../../common/merge_help.awk > $@
12422028508SToomas Soome
12522028508SToomas SoomeFILES=	$(LOADER) loader.help
12622028508SToomas Soome
12722028508SToomas Soome# XXX crt0.o needs to be first for pxeboot(8) to work
12822028508SToomas Soome
12922028508SToomas SoomeDPADD=	$(DPLIBFICL) $(DPLIBI386) $(DPLIBSA)
13022028508SToomas SoomeLDADD=	$(LIBFICL) $(LIBI386) $(LIBSA)
13122028508SToomas Soome
13222028508SToomas SoomeCLEANFILES +=	machine x86
13322028508SToomas Soome
13422028508SToomas Soomemachine:
13522028508SToomas Soome	$(RM) machine
13622028508SToomas Soome	$(SYMLINK) ../../sys/i386/include machine
13722028508SToomas Soome
13822028508SToomas Soomex86:
13922028508SToomas Soome	$(RM) x86
14022028508SToomas Soome	$(SYMLINK) ../../sys/x86/include x86
14122028508SToomas Soome
14222028508SToomas SoomeOBJS=		$(SRCS:%.c=%.o)
14322028508SToomas Soome
14422028508SToomas Soome$(OBJS): machine x86
14522028508SToomas Soome
14622028508SToomas Soome$(PROG): $(OBJS) $(DPADD)
147db1a8debSToomas Soome	$(GLD) $(LDFLAGS) -o $@ $(BTXCRT) $(OBJS) $(LDADD)
14822028508SToomas Soome
14922028508SToomas Soomeclean: clobber
15022028508SToomas Soomeclobber:
15122028508SToomas Soome	$(RM) $(CLEANFILES) $(OBJS)
15222028508SToomas Soome
15322028508SToomas Soomeinstall: all $(ROOTBOOTFILES)
15422028508SToomas Soome
15522028508SToomas Soome%.o:	../../common/%.c
15622028508SToomas Soome	$(COMPILE.c) -o $@ $<
15722028508SToomas Soome
15822028508SToomas Soome%.o:	../../common/linenoise/%.c
15922028508SToomas Soome	$(COMPILE.c) -o $@ $<
16022028508SToomas Soome
16122028508SToomas Soome%.o: $(SRC)/common/font/%.c
16222028508SToomas Soome	$(COMPILE.c) $<
16322028508SToomas Soome
16422028508SToomas Soome$(FONT).c: $(FONT_DIR)/$(FONT_SRC)
16522028508SToomas Soome	$(VTFONTCVT) -f compressed-source -o $@ $(FONT_DIR)/$(FONT_SRC)
16622028508SToomas Soome
16722028508SToomas Soome$(ROOT_BOOT)/%: ../../forth/% $(ROOT_BOOT)
16822028508SToomas Soome	$(INS.file)
169