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