xref: /illumos-gate/usr/src/boot/i386/isoboot/Makefile (revision 8226594fdd4479be135127f43632f1f995074654)
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
53
54include ../Makefile.inc
55
56all: $(PROG)
57
58install: all $(ROOTBOOTPROG)
59
60OBJS= mb_header.o isoboot.o sio.o drv.o cons.o gptldr.o
61
62CLEANFILES += isoboot
63
64isoboot: gptldr.bin isoboot.bin $(BTXKERN)
65	$(BTXLD) -v -E $(ORG2) -f bin -b $(BTXKERN) -V $(BOOT_VERSION) -l \
66		gptldr.bin -o $@ isoboot.bin
67	@set -- `ls -l $@`; x=$$(($(ISOBOOTSIZE)-$$5)); \
68	    echo "$$x bytes available"; test $$x -ge 0
69
70CLEANFILES += gptldr.bin gptldr.out gptldr.o
71
72gptldr.bin: gptldr.out
73	$(OBJCOPY) -S -O binary gptldr.out $@
74
75gptldr.out:	gptldr.o
76	$(GLD) $(LD_FLAGS) -e start -Ttext $(ORG1) -o $@ gptldr.o
77
78CLEANFILES += isoboot.bin isoboot.out $(OBJS)
79
80isoboot.bin: isoboot.out
81	$(OBJCOPY) -S -O binary isoboot.out $@
82
83isoboot.out: $(BTXCRT) $(OBJS)
84	$(GLD) $(LD_FLAGS) -T $(LDSCRIPT) -o $@ $(BTXCRT) $(OBJS) $(LIBSTAND)
85
86machine:
87	$(RM) machine
88	$(SYMLINK) ../../sys/i386/include machine
89
90x86:
91	$(RM) x86
92	$(SYMLINK) ../../sys/x86/include x86
93
94$(OBJS): machine x86
95
96%.o:	../gptzfsboot/%.S
97	$(COMPILE.S) $<
98
99%.o:	../../common/%.S
100	$(COMPILE.S) $<
101
102%.o:	../common/%.c
103	$(COMPILE.c) $<
104
105%.o:	../../common/%.c
106	$(COMPILE.c) $<
107
108clobber: clean
109
110clean:
111	$(RM) $(CLEANFILES) machine x86
112