diff options
-rw-r--r-- | apps/Makefile | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/apps/Makefile b/apps/Makefile index f535921df5..4fea03db47 100644 --- a/apps/Makefile +++ b/apps/Makefile | |||
@@ -22,6 +22,9 @@ INCLUDES= -I$(FIRMWARE) -I$(FIRMWARE)/common -I$(FIRMWARE)/drivers | |||
22 | TARGET = -DARCHOS_PLAYER_OLD=1 | 22 | TARGET = -DARCHOS_PLAYER_OLD=1 |
23 | #TARGET = -DARCHOS_RECORDER=1 | 23 | #TARGET = -DARCHOS_RECORDER=1 |
24 | 24 | ||
25 | # store output files in this directory: | ||
26 | OBJDIR = . | ||
27 | |||
25 | ifdef DEBUG | 28 | ifdef DEBUG |
26 | DEFINES := -DDEBUG | 29 | DEFINES := -DDEBUG |
27 | LDS := $(FIRMWARE)/gdb.lds | 30 | LDS := $(FIRMWARE)/gdb.lds |
@@ -38,21 +41,28 @@ ifeq ($(TARGET),-DARCHOS_RECORDER) | |||
38 | SRC += $(wildcard recorder/*.c) | 41 | SRC += $(wildcard recorder/*.c) |
39 | endif | 42 | endif |
40 | 43 | ||
41 | OBJS := $(SRC:%.c=%.o) | 44 | OBJS := $(SRC:%.c=$(OBJDIR)/%.o) |
45 | |||
46 | all : $(OBJDIR)/archos.mod # archos.asm | ||
47 | |||
48 | $(OBJDIR)/librockbox.a: | ||
49 | make -C $FIRMWARE OBJDIR=$(OBJDIR) | ||
42 | 50 | ||
43 | all : archos.mod # archos.asm | 51 | $(OBJDIR)/archos.elf : $(OBJS) $(LDS) $(OBJDIR)/librockbox.a |
52 | $(CC) -Os -nostdlib -o $(OBJDIR)/archos.elf $(OBJS) -lrockbox -lgcc -lc -L$(FIRMWARE) -T$(LDS) -Wl,-Map,archos.map | ||
44 | 53 | ||
45 | archos.elf : $(OBJS) $(LDS) $(FIRMWARE)/librockbox.a | 54 | $(OBJDIR)/archos.bin : $(OBJDIR)/archos.elf |
46 | $(CC) -Os -nostdlib -o archos.elf $(OBJS) -lrockbox -lgcc -lc -L$(FIRMWARE) -T$(LDS) -Wl,-Map,archos.map | 55 | $(OC) -O binary $(OBJDIR)/archos.elf $(OBJDIR)/archos.bin |
47 | 56 | ||
48 | archos.bin : archos.elf | 57 | $(OBJDIR)/archos.asm: $(OBJDIR)/archos.bin |
49 | $(OC) -O binary archos.elf archos.bin | 58 | ../tools/sh2d -sh1 $(OBJDIR)/archos.bin > $(OBJDIR)/archos.asm |
50 | 59 | ||
51 | archos.asm: archos.bin | 60 | $(OBJDIR)/archos.mod : $(OBJDIR)/archos.bin |
52 | ../tools/sh2d -sh1 archos.bin > archos.asm | 61 | ../tools/scramble $(OBJDIR)/archos.bin $(OBJDIR)/archos.mod |
53 | 62 | ||
54 | archos.mod : archos.bin | 63 | $(OBJDIR)/%.o: %.c |
55 | ../tools/scramble archos.bin archos.mod | 64 | @mkdir -p `dirname $@` |
65 | $(CC) $(CFLAGS) -c $< -o $@ | ||
56 | 66 | ||
57 | dist: | 67 | dist: |
58 | tar czvf dist.tar.gz Makefile main.c start.s app.lds | 68 | tar czvf dist.tar.gz Makefile main.c start.s app.lds |
@@ -62,13 +72,13 @@ clean: | |||
62 | -$(RM) -r $(DEPS) | 72 | -$(RM) -r $(DEPS) |
63 | 73 | ||
64 | DEPS:=.deps | 74 | DEPS:=.deps |
65 | DEPDIRS:=$(DEPS) $(DEPS)/drivers $(DEPS)/common | 75 | DEPDIRS:=$(DEPS) $(DEPS)/recorder |
66 | 76 | ||
67 | $(DEPS)/%.d: %.c | 77 | $(OBJDIR)/$(DEPS)/%.d: %.c |
68 | @$(SHELL) -c 'for d in $(DEPDIRS); do { if [ ! -d $$d ]; then mkdir $$d; fi; }; done' | 78 | @$(SHELL) -c 'for d in $(DEPDIRS); do { if [ ! -d $(OBJDIR)/$$d ]; then mkdir $(OBJDIR)/$$d; fi; }; done' |
69 | @echo "Updating dependencies for $<" | 79 | @echo "Updating dependencies for $(OBJDIR)/$<" |
70 | @$(SHELL) -ec '$(CC) -MM $(CFLAGS) $< \ | 80 | @$(SHELL) -ec '$(CC) -MM $(CFLAGS) $< \ |
71 | |sed '\''s|\($*\)\.o[ :]*|\1.o $(<:%.c=%.d) : |g'\'' > $@; \ | 81 | |sed '\''s|\($*\)\.o[ :]*|$(OBJDIR)/\1.o $(<:%.c=%.d) : |g'\'' > $@; \ |
72 | [ -s $@ ] || rm -f $@' | 82 | [ -s $@ ] || rm -f $@' |
73 | 83 | ||
74 | -include $(SRC:%.c=$(DEPS)/%.d) | 84 | -include $(SRC:%.c=$(OBJDIR)/$(DEPS)/%.d) |