xref: /illumos-gate/usr/src/boot/i386/gptzfsboot/Makefile (revision 3fe80ca4a1f8a033d672a9a2e6e4babac651205a)
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
70zfsboot.o := CPPFLAGS += -I$(SRC)/uts/common -I$(SRC)/uts/common/fs/zfs
71zfs_cmd.o := CPPFLAGS += -I$(SRC)/uts/common
72part.o := CPPFLAGS += -I$(ZLIB)
73smbios.o := CPPFLAGS += -DSMBIOS_SERIAL_NUMBERS
74smbios.o := CPPFLAGS += -DSMBIOS_LITTLE_ENDIAN_UUID
75gptldr.out := LD_FLAGS += $(GLDTARGET)
76
77CLEANFILES=	gptzfsboot $(OBJS)
78
79gptzfsboot: gptldr.bin gptzfsboot.bin $(BTXKERN)
80	$(BTXLD) -E $(ORG2) -f bin -b $(BTXKERN) -V $(BOOT_VERSION) -l \
81		gptldr.bin -o $@ gptzfsboot.bin
82
83CLEANFILES +=	gptldr.bin gptldr.out gptldr.o
84
85gptldr.bin: gptldr.out
86	$(OBJCOPY) -S -O binary gptldr.out $@
87
88gptldr.out: gptldr.o
89	$(GLD) $(LD_FLAGS) -e start -Ttext $(ORG1) -o $@ gptldr.o
90
91CLEANFILES +=	gptzfsboot.bin gptzfsboot.out
92
93gptzfsboot.bin: gptzfsboot.out
94	$(OBJCOPY) -S -O binary gptzfsboot.out $@
95
96gptzfsboot.out: $(BTXCRT) $(OBJS) $(DPADD)
97	$(GLD) $(LD_FLAGS) -T $(LDSCRIPT) -o $@ $(BTXCRT) $(OBJS) $(LIBS)
98
99machine:
100	$(RM) machine
101	$(SYMLINK) ../../sys/i386/include machine
102
103x86:
104	$(RM) x86
105	$(SYMLINK) ../../sys/x86/include x86
106
107$(OBJS): machine x86
108
109%.o:	../common/%.c
110	$(COMPILE.c) $<
111
112%.o:	../../common/%.c
113	$(COMPILE.c) $<
114
115%.o: ../../common/%.S
116	$(COMPILE.S) $<
117
118clobber: clean
119
120clean:
121	$(RM) $(CLEANFILES) machine x86
122