blob: 0850767f5894be4679bcd4b6716504a68e89f61f [file] [log] [blame]
Björn Stenbergd42d78f2002-04-15 08:35:08 +00001# __________ __ ___.
2# Open \______ \ ____ ____ | | _\_ |__ _______ ___
3# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6# \/ \/ \/ \/ \/
7# $Id$
8#
Linus Nielsen Feltzing1dc42d12003-05-17 00:31:50 +00009
Tomasz Malesinski2aabc872006-01-25 01:43:07 +000010ifeq ($(ARCHOS),ifp7xx)
11
12INCLUDES= -I$(FIRMDIR)/include -I$(FIRMDIR)/export -I. -I$(OBJDIR) \
13 -I$(BUILDDIR)
14
15DEPFILE = $(OBJDIR)/dep-stub
16LDS := linker.cfg
17
18SRC := $(shell cat SOURCES | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P -include "config.h" - )
19DIRS = .
20
21ifdef APPEXTRA
22 DIRS += $(subst :, ,$(APPEXTRA))
23 INCLUDES += $(patsubst %,-I%,$(subst :, ,$(APPEXTRA)))
24endif
25
26ifndef VERSION
27VERSION=$(shell date +%y%m%d-%H%M)
28endif
29
30CFLAGS = $(GCCOPTS) $(INCLUDES) $(TARGET) $(DEFINES) \
31 -DAPPSVERSION=\"$(VERSION)\" $(EXTRA_DEFINES) -DMEM=${MEMORYSIZE}
32
33OBJS := $(SRC:%.c=$(OBJDIR)/%.o)
34SOURCES = $(SRC)
35LINKFILE = $(OBJDIR)/linkage.lds
36
37LIBROCKBOX = $(BUILDDIR)/librockbox.a
38
39all: $(BUILDDIR)/$(BINARY) $(FLASHFILE)
40
41dep: $(DEPFILE)
42
43$(LINKFILE): $(LDS)
Jens Arnoldf40f0de2006-10-30 01:40:20 +000044 $(call PRINTS,Build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@
Tomasz Malesinski2aabc872006-01-25 01:43:07 +000045
46$(OBJDIR)/stub.elf : $(OBJS) $(LINKFILE) $(DEPFILE) $(LIBROCKBOX)
Jens Arnoldf40f0de2006-10-30 01:40:20 +000047 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJS) -L$(BUILDDIR) -L$(BUILDDIR)/firmware -lrockbox -lgcc -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/stub.map
Tomasz Malesinski2aabc872006-01-25 01:43:07 +000048
49$(OBJDIR)/stub.bin : $(OBJDIR)/stub.elf
Jens Arnoldf40f0de2006-10-30 01:40:20 +000050 $(call PRINTS,OBJCOPY $(@F))$(OC) -O binary $< $@
Tomasz Malesinski2aabc872006-01-25 01:43:07 +000051
52$(BUILDDIR)/$(BINARY) : $(OBJDIR)/stub.bin
Jens Arnoldf40f0de2006-10-30 01:40:20 +000053 $(call PRINTS,Build stub file)$(MKFIRMWARE) $< $@
Tomasz Malesinski2aabc872006-01-25 01:43:07 +000054
55include $(TOOLSDIR)/make.inc
56
57clean:
Jens Arnoldf40f0de2006-10-30 01:40:20 +000058 $(call PRINTS,cleaning stub)-rm -f $(OBJS) $(BUILDDIR)/$(BINARY) \
Tomasz Malesinski2aabc872006-01-25 01:43:07 +000059 $(OBJDIR)/stub.bin $(OBJDIR)/stub.elf $(OBJDIR)/*.map \
60 $(LINKFILE) $(DEPFILE)
61
62-include $(DEPFILE)
63
64else # not ifp7xx
65
Linus Nielsen Feltzing1dc42d12003-05-17 00:31:50 +000066ifdef RECORDER
67EXTRA = -DRECORDER
68EXT = ajz
69else
70EXT = mod
71endif
72
Björn Stenbergd42d78f2002-04-15 08:35:08 +000073TARGET = stub
Linus Nielsen Feltzing1dc42d12003-05-17 00:31:50 +000074OBJS = start.o sh-stub.o setjmp.o
Björn Stenbergd42d78f2002-04-15 08:35:08 +000075LIBS = -lgcc
76
77.s.o:
78 sh-elf-as -o $@ $<
79
80.c.o:
Linus Nielsen Feltzing1dc42d12003-05-17 00:31:50 +000081 sh-elf-gcc -O $(EXTRA) -I../firmware/export -I../firmware/include -m1 -Wall -Wstrict-prototypes -c -o $@ $<
Björn Stenbergd42d78f2002-04-15 08:35:08 +000082
Linus Nielsen Feltzing1dc42d12003-05-17 00:31:50 +000083.S.o:
84 sh-elf-gcc -O -I../firmware/export -I../firmware/include -m1 -Wall -Wstrict-prototypes -c -o $@ $<
85
86$(TARGET).$(EXT): $(TARGET).elf
Björn Stenbergd42d78f2002-04-15 08:35:08 +000087 sh-elf-objcopy -O binary $(TARGET).elf $(TARGET).out
Linus Nielsen Feltzing1dc42d12003-05-17 00:31:50 +000088 ../tools/scramble $(TARGET).out $(TARGET).$(EXT)
Jörg Hohensohn09e42d52003-06-29 21:56:32 +000089 ../tools/sh2d $(TARGET).out -o 09000000 > $(TARGET).asm
Björn Stenbergd42d78f2002-04-15 08:35:08 +000090
91$(TARGET).elf: $(OBJS)
Linus Nielsen Feltzing1dc42d12003-05-17 00:31:50 +000092 sh-elf-gcc -nostartfiles $(OBJS) -nostdlib -Wl,-Map,$(TARGET).map -o $(TARGET).elf -Tlinker.cfg
Björn Stenbergd42d78f2002-04-15 08:35:08 +000093
94clean:
Linus Nielsen Feltzing1dc42d12003-05-17 00:31:50 +000095 rm $(OBJS) $(TARGET).map $(TARGET).elf $(TARGET).out $(TARGET).mod $(TARGET).ajz
Björn Stenbergd42d78f2002-04-15 08:35:08 +000096
Tomasz Malesinski2aabc872006-01-25 01:43:07 +000097start.o: start.s
Linus Nielsen Feltzing7958ea42002-05-11 20:04:48 +000098sh-stub.o: sh-stub.c
Linus Nielsen Feltzing1dc42d12003-05-17 00:31:50 +000099setjmp.o: setjmp.S
Tomasz Malesinski2aabc872006-01-25 01:43:07 +0000100
101endif