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 19 include $(SRC)/Makefile.master 20 21 AS= $(GNU_ROOT)/bin/gas 22 LD= $(GNU_ROOT)/bin/gld 23 CC= $(GCC_ROOT)/bin/gcc 24 OBJCOPY= $(GNU_ROOT)/bin/gobjcopy 25 26 PROG= gptzfsboot 27 MAN= gptzfsboot.8 28 FILEMODE=0444 29 30 # need to update this to trigger installboot updates. 31 BUILDDATE :sh = TZ=UTC date +%Y%m%dT%H%M%SZ 32 BOOT2_VERSION= 1.1:$(BUILDDATE) 33 34 BOOT_COMCONSOLE_PORT= 0x3f8 35 BOOT_COMCONSOLE_SPEED= 9600 36 B2SIOFMT= 0x3 37 38 REL1= 0x700 39 ORG1= 0x7c00 40 ORG2= 0x0 41 42 CPPFLAGS= 43 CFLAGS= -nostdinc -DBOOTPROG=\"gptzfsboot\" \ 44 -O1 \ 45 -DGPT -DBOOT2 \ 46 -DLOADER_MBR_SUPPORT -DLOADER_GPT_SUPPORT \ 47 -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ 48 -DSIOFMT=${B2SIOFMT} \ 49 -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ 50 -I../../../../include \ 51 -I../../../../lib/libstand \ 52 -I../../common \ 53 -I../common \ 54 -I../../zfs \ 55 -I../../../cddl/boot/zfs \ 56 -I../btx/lib -I. \ 57 -I../../.. \ 58 -I../../../sys \ 59 -I../libi386 \ 60 -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ 61 -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ 62 -Wpointer-arith -Wshadow -Wwrite-strings \ 63 -Winline -Wno-unknown-pragmas 64 65 CFLAGS += --param max-inline-insns-single=100 66 CFLAGS += -fno-reorder-functions 67 68 LD_FLAGS=-static -N --gc-sections 69 CCASFLAGS=-Wa,--divide 70 LIBSTAND= ../../libstand/i386/libstand.a 71 LIBZFSBOOT= ../../zfs/i386/libzfsboot.a 72 73 include ../Makefile.inc 74 75 .PARALLEL: 76 77 all: $(PROG) 78 79 $(PROG): machine x86 80 81 install: all $(ROOTBOOTPROG) 82 83 OBJS = multiboot.o zfsboot.o sio.o cons.o panic.o devopen.o \ 84 part.o biosmem.o smbios.o biosdisk.o devicename.o disk.o bcache.o \ 85 time.o crc32.o 86 87 CLEANFILES= gptzfsboot $(OBJS) 88 89 gptzfsboot: gptldr.bin gptzfsboot.bin ${BTXKERN} 90 $(BTXLD) -v -E ${ORG2} -f bin -b ${BTXKERN} -V ${BOOT2_VERSION} -l \ 91 gptldr.bin -o $@ gptzfsboot.bin 92 93 CLEANFILES += gptldr.bin gptldr.out gptldr.o 94 95 gptldr.bin: gptldr.out 96 ${OBJCOPY} -S -O binary gptldr.out $@ 97 98 gptldr.out: gptldr.o 99 ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o $@ gptldr.o 100 101 CLEANFILES += gptzfsboot.bin gptzfsboot.out 102 103 gptzfsboot.bin: gptzfsboot.out 104 ${OBJCOPY} -S -O binary gptzfsboot.out $@ 105 106 gptzfsboot.out: ${BTXCRT} ${OBJS} ${LIBZFSBOOT} ${LIBSTAND} 107 ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o $@ ${BTXCRT} ${OBJS} \ 108 ${LIBZFSBOOT} ${LIBSTAND} 109 110 machine: 111 $(RM) machine 112 $(SYMLINK) ../../../i386/include machine 113 114 x86: 115 $(RM) x86 116 $(SYMLINK) ../../../x86/include x86 117 118 %.o: ../common/%.c 119 $(COMPILE.c) -o $@ $< 120 121 %.o: ../../common/%.c 122 $(COMPILE.c) -o $@ $< 123 124 biosdisk.o: ../libi386/biosdisk.c 125 $(CC) $(CFLAGS) $(CPPFLAGS) -Dalloca=__builtin_alloca -c -o $@ ../libi386/$*.c 126 127 biosmem.o: ../libi386/biosmem.c 128 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ ../libi386/$*.c 129 130 smbios.o: ../libi386/smbios.c 131 $(CC) $(CFLAGS) $(CPPFLAGS) \ 132 -DSMBIOS_SERIAL_NUMBERS -DSMBIOS_LITTLE_ENDIAN_UUID \ 133 -c -o $@ ../libi386/$*.c 134 135 devicename.o: ../libi386/devicename.c 136 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ ../libi386/$*.c 137 138 time.o: ../libi386/time.c 139 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ ../libi386/$*.c 140 141 .S.o: 142 $(CC) $(CFLAGS) $(CCASFLAGS) -c -o $@ $< 143 144 clobber: clean 145 146 clean: 147 $(RM) $(CLEANFILES) machine x86