Poor mans workaround for hanging SDL app/sim on shutdown.
[maemo-rb.git] / flash / bootloader / Makefile
blobedc32113c6b3aa1b44fcbcc7a7424f63a4524533
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 CC = sh-elf-gcc
11 LD = sh-elf-ld
12 AR = sh-elf-ar
13 AS = sh-elf-as
14 OC = sh-elf-objcopy
16 FIRMWARE := ../../firmware
17 TOOLSDIR=../../tools
19 TARGET = bootloader
20 LDS := $(TARGET).lds
23 ifndef PLATFORM
24 not_configured:
25 @echo "No platform given."
26 @echo "Use make PLATFORM=PLAYER|RECORDER|FM|ONDIO {NO_ROM=1}"
27 ##else
28 ##configured:
29 ## @echo "Building bootloader for platform "$(PLATFORM)
30 endif
33 INCLUDES= -I$(FIRMWARE)/export -I. -I$(OBJDIR)
34 DEFINES= -DPLATFORM_$(PLATFORM)
36 OBJDIR := .
38 CFLAGS = -Os -W -Wall -m1 -nostdlib -ffreestanding -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns $(INCLUDES) $(DEFINES)
39 AFLAGS += -small -relax
42 ifdef DEBUG
43 DEFINES := -DDEBUG
44 CFLAGS += -g
45 endif
47 SRC := $(wildcard *.c)
49 OBJS := $(SRC:%.c=$(OBJDIR)/%.o) $(OBJDIR)/sh_nrv2e_d8.o
51 ifdef NO_ROM
52 LINKFILE = $(OBJDIR)/no_rom.lds
53 ORIGIN = 0
54 DEFINES += -DNO_ROM
55 else
56 LINKFILE = $(OBJDIR)/$(TARGET).lds
57 ORIGIN = FFFF500
58 endif
60 $(OBJDIR)/$(TARGET).bin : $(OBJDIR)/$(TARGET).elf
61 $(OC) -O binary $(OBJDIR)/$(TARGET).elf $(OBJDIR)/$(TARGET).bin
62 $(TOOLSDIR)/sh2d $(OBJDIR)/$(TARGET).bin -o $(ORIGIN) > $(OBJDIR)/$(TARGET).asm
63 ifndef NO_ROM
64 $(TOOLSDIR)/scramble $(OBJDIR)/$(TARGET).bin $(OBJDIR)/$(TARGET).ajz
65 endif
67 $(OBJDIR)/$(TARGET).elf : $(OBJS)
68 $(CC) -Os -nostdlib -o $@ $(OBJS) -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/$(TARGET).map
70 # cross-reference, saves code duplication
71 $(OBJDIR)/sh_nrv2e_d8.o : ../../firmware/decompressor/sh_nrv2e_d8.S
72 $(CC) $(CFLAGS) -c $< -o $@
74 clean:
75 -rm -f \
76 $(OBJS) \
77 $(OBJDIR)/$(TARGET).asm \
78 $(OBJDIR)/$(TARGET).bin \
79 $(OBJDIR)/$(TARGET).ajz \
80 $(OBJDIR)/$(TARGET).elf \
81 $(OBJDIR)/$(TARGET).map