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