GNUmakefile 3.02 KB
include $(ROOT)/usr/include/make/commondefs
include $(ROOT)/usr/include/make/PRdefs

# XXX: it would be optimal to obtain these from bcp.h
# instead of hard-coding here.
SK_LINK_START_ADDR = 0x9fc00000
SK_LINK_END_ADDR   = 0x9fc10000

TARGETS = sk.aes sk_bpki.aes sk_fpki.aes

CFILES = skapi.c boot.c timer.c cert.c rl.c util.c  handler.c \
         nvram.c skreencrypt.c rand.c

ASFILES = entry.s invaldcache.s

OBJECTS_BETA = $(OBJECTS) rootbeta.o
OBJECTS_FINAL = $(OBJECTS) rootfinal.o
ifdef SK_ROOT_LOCAL
OBJECTS_LOCAL = $(OBJECTS) rootlocal.o
else
OBJECTS_LOCAL = $(OBJECTS_BETA)
endif

OBJCOPY              = mips-linux-objcopy
OBJCOPY_REMOVE_SECTS = -R .reginfo -R .note -R .comment -R .mdebug
OBJCOPY_PAD          = --pad-to $(SK_LINK_END_ADDR)
OBJCOPY_FLAGS        = $(OBJCOPY_PAD) -O binary -S $(OBJCOPY_REMOVE_SECTS)

OPTIMIZER=
LCOPTS += -Wall -fno-builtin 
LASOPTS += 

LCOPTS += -mips2 -G 0
LASOPTS += -mips2 -G 0

ifdef DEBUG
LCOPTS += -DDEBUG -g
LASOPTS += -DDEBUG -g
else
LCOPTS += -Os -g
LASOPTS +=-Os -g
endif

ifdef SK_LOG_MEM
LCOPTS += -DSK_LOG_MEM
LASOPTS += -DSK_LOG_MEM

else

ifdef SK_LOG_IDE
LCOPTS += -DSK_LOG_IDE
LASOPTS += -DSK_LOG_IDE
endif

ifdef SK_LOG_RDB
LCOPTS += -DSK_LOG_RDB
LASOPTS += -DSK_LOG_RDB
endif

endif

LLDOPTS += -Ttext $(SK_LINK_START_ADDR) -N

LLDLIBS += -lcrypto

LDIRT += cpu.log*
LDIRT += sk*.elf sk*.bin sk*.hex
LDIRT += bbcdbbcb.* j.j *.bin flash.img ticket.sys v2.hex romsimos.elf virage2.in virage2_bpki.in virage2_fpki.in final/*.bin


.PRECIOUS: %.bin %.hex

# arrange rules in this way to control SK_DEVELOP define.
# ONLY the local (sk.elf) sk will be built with SK_DEVELOP.
# to produce such a build use "make LCDEFS=-DSK_DEVELOP".
default: cleansk
	make sk.aes
	rm -f skapi.o
	make LCDEFS= sk_bpki.aes
	make LCDEFS= sk_fpki.aes

sk.elf: $(OBJECTS_LOCAL)
	$(CCF) -o $@ $(OBJECTS_LOCAL) $(LDFLAGS)
	@if [ `size sk.elf | tail -1 | awk '{print $$4}'` -gt 65536 ]; then \
	    echo "SECURE KERNEL TOO LARGE"; \
	    size sk.elf; \
	    rm -f sk.elf; \
	    exit 1; \
	fi \

sk_bpki.elf: $(OBJECTS_BETA)
	$(CCF) -o $@ $(OBJECTS_BETA) $(LDFLAGS)

sk_fpki.elf: $(OBJECTS_FINAL)
	$(CCF) -o $@ $(OBJECTS_FINAL) $(LDFLAGS)

%.bin: %.elf
	$(OBJCOPY) $(OBJCOPY_FLAGS) $< $@

%.hex: %.bin
	od -v -w4 -An -tx1 $< | tr -d " " > $@

AES_TOOL=$(ROOT)/usr/sbin/aes_encode
SK_IV=-i a438b3410298747b0c089d8f6d2991a8
SK_KEY=-k a81902767e25db170f3449c5d94b162f
%.aes: %.hex
	$(AES_TOOL) $(SK_IV) $(SK_KEY) $*.bin $@

cleansk:
	rm -f sk.hex sk.bin

include $(COMMONRULES)

headers:

V2CONST_TOOL=$(ROOT)/usr/sbin/v2Const
exports install: final/sk.bin final/sk_bpki.bin final/sk_fpki.bin
	$(V2CONST_TOOL) -e final/sk.bin virage2.in 
	$(V2CONST_TOOL) -e final/sk_bpki.bin virage2_beta.in 
	$(V2CONST_TOOL) -e final/sk_fpki.bin virage2_final.in 
	$(INSTALL) -m 444 -F /usr/host_data virage2.in
	$(INSTALL) -m 444 -F /usr/host_data virage2_beta.in
	$(INSTALL) -m 444 -F /usr/host_data virage2_final.in
	$(INSTALL) -m 444 -F /usr/host_data final/sk.aes
	$(INSTALL) -m 444 -F /usr/host_data final/sk_bpki.aes
	$(INSTALL) -m 444 -F /usr/host_data final/sk_fpki.aes