xref: /illumos-gate/usr/src/boot/i386/isoboot/Makefile (revision c2eb74cb09fdf193d963d35bf90bc5d671863177)
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#
15
16include $(SRC)/Makefile.master
17include $(SRC)/boot/Makefile.version
18include $(SRC)/boot/Makefile.inc
19
20PROG= isoboot
21FILEMODE=0444
22
23BOOT_COMCONSOLE_PORT= 0x3f8
24BOOT_COMCONSOLE_SPEED= 9600
25B2SIOFMT= 0x3
26
27ORG1= 0x7c00
28ORG2= 0x0
29
30ISOBOOTSIZE= 30720
31
32CPPFLAGS += -DBOOTPROG=\"isoboot\" \
33	-DSIOPRT=$(BOOT_COMCONSOLE_PORT) \
34	-DSIOFMT=$(B2SIOFMT) \
35	-DSIOSPD=$(BOOT_COMCONSOLE_SPEED) \
36	-I../../include \
37	-I../../libsa \
38	-I. \
39	-I../../sys \
40	-I../common \
41	-I../btx/lib \
42	-I../../common \
43	-I../gptzfsboot
44AS_CPPFLAGS += $(CPPFLAGS)
45
46LDSCRIPT=	../boot.ldscript
47LD_FLAGS=	-static -N --gc-sections
48LIBSTAND=	../../libsa/$(MACH)/libsa.a
49
50gptldr.out := LD_FLAGS += $(GLDTARGET)
51
52isoboot.o := SMOFF += unreachable
53cons.o := CFLAGS += -_gcc14=--param=min-pagesize=0
54isoboot.o := CFLAGS += -_gcc14=--param=min-pagesize=0
55
56include ../Makefile.inc
57
58all: $(PROG)
59
60install: all $(ROOTBOOTPROG)
61
62OBJS= mb_header.o isoboot.o sio.o drv.o cons.o gptldr.o
63
64CLEANFILES += isoboot
65
66isoboot: gptldr.bin isoboot.bin $(BTXKERN)
67	$(BTXLD) -v -E $(ORG2) -f bin -b $(BTXKERN) -V $(BOOT_VERSION) -l \
68		gptldr.bin -o $@ isoboot.bin
69	@set -- `ls -l $@`; x=$$(($(ISOBOOTSIZE)-$$5)); \
70	    echo "$$x bytes available"; test $$x -ge 0
71
72CLEANFILES += gptldr.bin gptldr.out gptldr.o
73
74gptldr.bin: gptldr.out
75	$(OBJCOPY) -S -O binary gptldr.out $@
76
77gptldr.out:	gptldr.o
78	$(GLD) $(LD_FLAGS) -e start -Ttext $(ORG1) -o $@ gptldr.o
79
80CLEANFILES += isoboot.bin isoboot.out $(OBJS)
81
82isoboot.bin: isoboot.out
83	$(OBJCOPY) -S -O binary isoboot.out $@
84
85isoboot.out: $(BTXCRT) $(OBJS)
86	$(GLD) $(LD_FLAGS) -T $(LDSCRIPT) -o $@ $(BTXCRT) $(OBJS) $(LIBSTAND)
87
88machine:
89	$(RM) machine
90	$(SYMLINK) ../../sys/i386/include machine
91
92x86:
93	$(RM) x86
94	$(SYMLINK) ../../sys/x86/include x86
95
96$(OBJS): machine x86
97
98%.o:	../gptzfsboot/%.S
99	$(COMPILE.S) $<
100
101%.o:	../../common/%.S
102	$(COMPILE.S) $<
103
104%.o:	../common/%.c
105	$(COMPILE.c) $<
106
107%.o:	../../common/%.c
108	$(COMPILE.c) $<
109
110clobber: clean
111
112clean:
113	$(RM) $(CLEANFILES) machine x86
114