199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome# This file and its contents are supplied under the terms of the
199767f8919635c4928607450d9e0abb932109ceToomas Soome# Common Development and Distribution License ("CDDL"), version 1.0.
199767f8919635c4928607450d9e0abb932109ceToomas Soome# You may only use this file in accordance with the terms of version
199767f8919635c4928607450d9e0abb932109ceToomas Soome# 1.0 of the CDDL.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome# A full copy of the text of the CDDL should have accompanied this
199767f8919635c4928607450d9e0abb932109ceToomas Soome# source. A copy of the CDDL is also available via the Internet at
199767f8919635c4928607450d9e0abb932109ceToomas Soome# http://www.illumos.org/license/CDDL.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome# Copyright 2015 Toomas Soome <tsoome@me.com>
e547e4e8adbc4f31e3fac2e9d89d20e99911227cAndrew Stormont# Copyright 2016 RackTop Systems.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomeinclude $(SRC)/Makefile.master
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas SoomeAS= $(GNU_ROOT)/bin/gas
199767f8919635c4928607450d9e0abb932109ceToomas SoomeLD= $(GNU_ROOT)/bin/gld
199767f8919635c4928607450d9e0abb932109ceToomas SoomeCC= $(GCC_ROOT)/bin/gcc
199767f8919635c4928607450d9e0abb932109ceToomas SoomeOBJCOPY= $(GNU_ROOT)/bin/gobjcopy
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas SoomePROG= gptzfsboot
199767f8919635c4928607450d9e0abb932109ceToomas SoomeMAN= gptzfsboot.8
199767f8919635c4928607450d9e0abb932109ceToomas SoomeFILEMODE=0444
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome# need to update this to trigger installboot updates.
199767f8919635c4928607450d9e0abb932109ceToomas SoomeBUILDDATE :sh = TZ=UTC date +%Y%m%dT%H%M%SZ
199767f8919635c4928607450d9e0abb932109ceToomas SoomeBOOT2_VERSION= 1.1:$(BUILDDATE)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas SoomeBOOT_COMCONSOLE_PORT= 0x3f8
199767f8919635c4928607450d9e0abb932109ceToomas SoomeBOOT_COMCONSOLE_SPEED= 9600
199767f8919635c4928607450d9e0abb932109ceToomas SoomeB2SIOFMT= 0x3
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas SoomeREL1= 0x700
199767f8919635c4928607450d9e0abb932109ceToomas SoomeORG1= 0x7c00
199767f8919635c4928607450d9e0abb932109ceToomas SoomeORG2= 0x0
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas SoomeCPPFLAGS=
199767f8919635c4928607450d9e0abb932109ceToomas SoomeCFLAGS= -nostdinc -DBOOTPROG=\"gptzfsboot\" \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -O1 \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -DGPT -DBOOT2 \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -DLOADER_MBR_SUPPORT -DLOADER_GPT_SUPPORT \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -DSIOPRT=${BOOT_COMCONSOLE_PORT} \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -DSIOFMT=${B2SIOFMT} \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -I../../../../include \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -I../../../../lib/libstand \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -I../../common \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -I../common \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -I../../zfs \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -I../../../cddl/boot/zfs \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -I../btx/lib -I. \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -I../../.. \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -I../../../sys \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -I../libi386 \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -Wpointer-arith -Wshadow -Wwrite-strings \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -Winline -Wno-unknown-pragmas
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas SoomeCFLAGS += --param max-inline-insns-single=100
199767f8919635c4928607450d9e0abb932109ceToomas SoomeCFLAGS += -fno-reorder-functions
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas SoomeLD_FLAGS=-static -N --gc-sections
199767f8919635c4928607450d9e0abb932109ceToomas SoomeCCASFLAGS=-Wa,--divide
199767f8919635c4928607450d9e0abb932109ceToomas SoomeLIBSTAND= ../../libstand/i386/libstand.a
199767f8919635c4928607450d9e0abb932109ceToomas SoomeLIBZFSBOOT= ../../zfs/i386/libzfsboot.a
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomeinclude ../Makefile.inc
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome.PARALLEL:
199767f8919635c4928607450d9e0abb932109ceToomas Soome
e547e4e8adbc4f31e3fac2e9d89d20e99911227cAndrew Stormontall: $(PROG)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomeinstall: all $(ROOTBOOTPROG)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas SoomeOBJS = multiboot.o zfsboot.o sio.o cons.o panic.o devopen.o \
199767f8919635c4928607450d9e0abb932109ceToomas Soome part.o biosmem.o smbios.o biosdisk.o devicename.o disk.o bcache.o \
199767f8919635c4928607450d9e0abb932109ceToomas Soome time.o crc32.o
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas SoomeCLEANFILES= gptzfsboot $(OBJS)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomegptzfsboot: gptldr.bin gptzfsboot.bin ${BTXKERN}
199767f8919635c4928607450d9e0abb932109ceToomas Soome $(BTXLD) -v -E ${ORG2} -f bin -b ${BTXKERN} -V ${BOOT2_VERSION} -l \
199767f8919635c4928607450d9e0abb932109ceToomas Soome gptldr.bin -o $@ gptzfsboot.bin
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas SoomeCLEANFILES += gptldr.bin gptldr.out gptldr.o
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomegptldr.bin: gptldr.out
199767f8919635c4928607450d9e0abb932109ceToomas Soome ${OBJCOPY} -S -O binary gptldr.out $@
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomegptldr.out: gptldr.o
199767f8919635c4928607450d9e0abb932109ceToomas Soome ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o $@ gptldr.o
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas SoomeCLEANFILES += gptzfsboot.bin gptzfsboot.out
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomegptzfsboot.bin: gptzfsboot.out
199767f8919635c4928607450d9e0abb932109ceToomas Soome ${OBJCOPY} -S -O binary gptzfsboot.out $@
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomegptzfsboot.out: ${BTXCRT} ${OBJS} ${LIBZFSBOOT} ${LIBSTAND}
199767f8919635c4928607450d9e0abb932109ceToomas Soome ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o $@ ${BTXCRT} ${OBJS} \
199767f8919635c4928607450d9e0abb932109ceToomas Soome ${LIBZFSBOOT} ${LIBSTAND}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomemachine:
199767f8919635c4928607450d9e0abb932109ceToomas Soome $(RM) machine
199767f8919635c4928607450d9e0abb932109ceToomas Soome $(SYMLINK) ../../../i386/include machine
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomex86:
199767f8919635c4928607450d9e0abb932109ceToomas Soome $(RM) x86
199767f8919635c4928607450d9e0abb932109ceToomas Soome $(SYMLINK) ../../../x86/include x86
199767f8919635c4928607450d9e0abb932109ceToomas Soome
e547e4e8adbc4f31e3fac2e9d89d20e99911227cAndrew Stormont$(OBJS): machine x86
e547e4e8adbc4f31e3fac2e9d89d20e99911227cAndrew Stormont
199767f8919635c4928607450d9e0abb932109ceToomas Soome%.o: ../common/%.c
199767f8919635c4928607450d9e0abb932109ceToomas Soome $(COMPILE.c) -o $@ $<
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome%.o: ../../common/%.c
199767f8919635c4928607450d9e0abb932109ceToomas Soome $(COMPILE.c) -o $@ $<
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomebiosdisk.o: ../libi386/biosdisk.c
199767f8919635c4928607450d9e0abb932109ceToomas Soome $(CC) $(CFLAGS) $(CPPFLAGS) -Dalloca=__builtin_alloca -c -o $@ ../libi386/$*.c
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomebiosmem.o: ../libi386/biosmem.c
199767f8919635c4928607450d9e0abb932109ceToomas Soome $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ ../libi386/$*.c
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomesmbios.o: ../libi386/smbios.c
199767f8919635c4928607450d9e0abb932109ceToomas Soome $(CC) $(CFLAGS) $(CPPFLAGS) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -DSMBIOS_SERIAL_NUMBERS -DSMBIOS_LITTLE_ENDIAN_UUID \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -c -o $@ ../libi386/$*.c
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomedevicename.o: ../libi386/devicename.c
199767f8919635c4928607450d9e0abb932109ceToomas Soome $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ ../libi386/$*.c
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soometime.o: ../libi386/time.c
199767f8919635c4928607450d9e0abb932109ceToomas Soome $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ ../libi386/$*.c
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome.S.o:
199767f8919635c4928607450d9e0abb932109ceToomas Soome $(CC) $(CFLAGS) $(CCASFLAGS) -c -o $@ $<
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomeclobber: clean
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomeclean:
199767f8919635c4928607450d9e0abb932109ceToomas Soome $(RM) $(CLEANFILES) machine x86