xref: /illumos-gate/usr/src/boot/i386/gptzfsboot/Makefile (revision ff56787d6488797571f1eaba7dcf3ff9903154ba)
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
17#
18
19include $(SRC)/Makefile.master
20include $(SRC)/boot/Makefile.version
21include $(SRC)/boot/Makefile.inc
22
23PROG=		gptzfsboot
24MAN=		gptzfsboot.8
25FILEMODE=0444
26
27BOOT_COMCONSOLE_PORT= 0x3f8
28BOOT_COMCONSOLE_SPEED= 9600
29B2SIOFMT=	0x3
30
31REL1=	0x700
32ORG1=	0x7c00
33ORG2=	0x0
34
35CPPFLAGS += -DBOOTPROG=\"gptzfsboot\" \
36	-DGPT -DBOOT2 \
37	-DLOADER_MBR_SUPPORT -DLOADER_GPT_SUPPORT \
38	-DSIOPRT=$(BOOT_COMCONSOLE_PORT) \
39	-DSIOFMT=$(B2SIOFMT) \
40	-DSIOSPD=$(BOOT_COMCONSOLE_SPEED) \
41	-I../../include \
42	-I../../libsa \
43	-I../../common \
44	-I../common \
45	-I$(ZFSSRC) \
46	-I../../sys/cddl/boot/zfs \
47	-I../btx/lib -I. \
48	-I../../sys \
49	-I../libi386
50AS_CPPFLAGS += $(CPPFLAGS)
51
52LDSCRIPT=	../boot.ldscript
53LD_FLAGS=	-static -N --gc-sections
54LIBI386=	-L ../libi386 -li386
55LIBSTAND=	-L ../../libsa/$(MACH) -lsa
56LIBS=		$(LIBI386) $(LIBSTAND)
57DPADD=		../libi386/libi386.a ../../libsa/$(MACH)/libsa.a
58
59include ../Makefile.inc
60
61.PARALLEL:
62
63all: $(PROG)
64
65install: all $(ROOTBOOTPROG)
66
67OBJS =	mb_header.o zfsboot.o sio.o cons.o devopen.o \
68	part.o disk.o bcache.o zfs_cmd.o
69
70cons.o := CFLAGS += -_gcc14=--param=min-pagesize=0
71zfsboot.o := CFLAGS += -_gcc14=--param=min-pagesize=0
72zfsboot.o := CPPFLAGS += -I$(SRC)/uts/common -I$(SRC)/uts/common/fs/zfs
73zfs_cmd.o := CPPFLAGS += -I$(SRC)/uts/common
74part.o := CPPFLAGS += -I$(ZLIB)
75smbios.o := CPPFLAGS += -DSMBIOS_SERIAL_NUMBERS
76smbios.o := CPPFLAGS += -DSMBIOS_LITTLE_ENDIAN_UUID
77gptldr.out := LD_FLAGS += $(GLDTARGET)
78
79CLEANFILES=	gptzfsboot $(OBJS)
80
81gptzfsboot: gptldr.bin gptzfsboot.bin $(BTXKERN)
82	$(BTXLD) -E $(ORG2) -f bin -b $(BTXKERN) -V $(BOOT_VERSION) -l \
83		gptldr.bin -o $@ gptzfsboot.bin
84
85CLEANFILES +=	gptldr.bin gptldr.out gptldr.o
86
87gptldr.bin: gptldr.out
88	$(OBJCOPY) -S -O binary gptldr.out $@
89
90gptldr.out: gptldr.o
91	$(GLD) $(LD_FLAGS) -e start -Ttext $(ORG1) -o $@ gptldr.o
92
93CLEANFILES +=	gptzfsboot.bin gptzfsboot.out
94
95gptzfsboot.bin: gptzfsboot.out
96	$(OBJCOPY) -S -O binary gptzfsboot.out $@
97
98gptzfsboot.out: $(BTXCRT) $(OBJS) $(DPADD)
99	$(GLD) $(LD_FLAGS) -T $(LDSCRIPT) -o $@ $(BTXCRT) $(OBJS) $(LIBS)
100
101machine:
102	$(RM) machine
103	$(SYMLINK) ../../sys/i386/include machine
104
105x86:
106	$(RM) x86
107	$(SYMLINK) ../../sys/x86/include x86
108
109$(OBJS): machine x86
110
111%.o:	../common/%.c
112	$(COMPILE.c) $<
113
114%.o:	../../common/%.c
115	$(COMPILE.c) $<
116
117%.o: ../../common/%.S
118	$(COMPILE.S) $<
119
120clobber: clean
121
122clean:
123	$(RM) $(CLEANFILES) machine x86
124