# Makefile for sh7045/samples
# Satofumi KAMIMURA
# $Id: Makefile 1043 2009-06-19 14:51:09Z satofumi $

include ../rules.mk

# Compile options
ARCH = sh-elf
LD_ROM_FOR_BUILD = ../aki_sh2_rom.x
LD_LOAD_FOR_BUILD = ../aki_sh2_load.x
START_UP_FILES = ../crt0.S

CFLAGS_FOR_BUILD = -O2 -m2 -Wall -W -Werror $(INCLUDES)
INCLUDES = -I..

LDFLAGS_FOR_BUILD = -nostartfiles $(START_UP_FILES)
#LDFLAGS_FOR_BUILD = -nostartfiles -nostdlib $(START_UP_FILES)
LDLIBS_FOR_BUILD =


# Target
TARGET = \
	hello.mot hello.dis \
	putstr.mot putstr.dis \
	echoback.mot \
	timer1sec.mot timer1sec.dis \

all : $(TARGET)

clean :
	$(RM) *.o *.out $(TARGET)

.PHONY :
######################################################################
REQUIRE_LIBS = ../sh7045.a
$(REQUIRE_LIBS) :
	cd $(@D)/ && $(MAKE) $(@F)

putstr.out echoback.out timer1sec.out : $(REQUIRE_LIBS)

hello.out : hello.S ../aki_sh2_load.x
	sh-elf-as $< -o hello.o
	sh-elf-gcc hello.o -T ../aki_sh2_load.x -nostartfiles -o hello.out

hello.mot : hello.out
	sh-elf-objcopy -S -O srec hello.out hello.mot
	chmod a-x hello.mot

hello.dis : hello.out
	sh-elf-objdump -D --disassemble-zeroes hello.out > hello.dis
