include $(ROOT)/usr/include/make/SCdefs

TARGETS = boot0.bin boot0.hex boot0.guc

ASFILES = \
    boots.s 

CFILES = \
    bootc.c \
    key.c \
    iv.c

default: $(TARGETS)

install: default
	$(INSTALL) $(TARGETS) $(ROOT)/usr/bin/sc

ifneq ($(filter runtests clean clobber, $(MAKECMDGOALS)),)
SUBDIRS = test
runtests: default
endif

include $(COMMONRULES)

LDIRT += boot0.elf key.c iv.c
LLDLIBS = -lioslibc
LLDOPTS = -Ttext 0x80000 -Xlinker -N
LCOPTS = -mthumb
OPTIMIZER = -Os

boot0.elf: $(OBJECTS)
	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)

boot0.hex: boot0.bin
	$(ROOT)/usr/bin/x86/bin2ihex.py $^ > $@

boot0.guc: boot0.bin
	./guc.py $^ > $@

boot0.rcf: boot0.bin
	./rcf.py $^ > $@

key.c:
	$(ROOT)/usr/bin/x86/ascii2bin.py $(BOOTKEY) | $(ROOT)/usr/bin/x86/bin2c.py -n bootKey -o $@

iv.c:
	$(ROOT)/usr/bin/x86/ascii2bin.py $(BOOTIV) | $(ROOT)/usr/bin/x86/bin2c.py -n bootIv -o $@
