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