CC = /usr/local/sh-tools/bin/sh-elf-gcc
AS = /usr/local/sh-tools/bin/sh-elf-as
LD = /usr/local/sh-tools/bin/sh-elf-ld
OBJCPY = /usr/local/sh-tools/bin/sh-elf-objcopy

all : startup_b.o gcc_sample_b.o startup_l.o gcc_sample_l.o
	$(LD) -EB startup_b.o gcc_sample_b.o -T memory_b.def -o gcc_sample_b -Map gcc_sample_b.map
	$(LD) -EL startup_l.o gcc_sample_l.o -T memory_l.def -o gcc_sample_l -Map gcc_sample_l.map
	$(OBJCPY) -O ihex gcc_sample_l gcc_sample_l.hex
	$(OBJCPY) -O srec gcc_sample_l gcc_sample_l.mot
	$(OBJCPY) -O binary gcc_sample_l gcc_sample_l.bin
	$(OBJCPY) -O ihex gcc_sample_b gcc_sample_b.hex
	$(OBJCPY) -O srec gcc_sample_b gcc_sample_b.mot
	$(OBJCPY) -O binary gcc_sample_b gcc_sample_b.bin
startup_l.o : startup.s
	$(AS) -little --defsym CONFIG_LITTLE_ENDIAN=1 startup.s -o startup_l.o
gcc_sample_l.o : gcc_sample.c
	$(CC) -ml -m4 -c -g $< -o gcc_sample_l.o
startup_b.o : startup.s
	$(AS) startup.s -o startup_b.o
gcc_sample_b.o : gcc_sample.c
	$(CC) -m4 -c -g $< -o gcc_sample_b.o
clean:
	rm -f *.o gcc_sample_l gcc_sample_b  *.map *.mot *.hex *.bin
