summaryrefslogtreecommitdiff
path: root/apps/plugins/Makefile
blob: 367103be67ed415ee38d4cd8d655a4c374acc6d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#             __________               __   ___.
#   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
#   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
#   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
#   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
#                     \/            \/     \/    \/            \/
# $Id$
#

CC    = sh-elf-gcc
OC    = sh-elf-objcopy

FIRMWARE = ../../firmware

INCLUDES = -I$(FIRMWARE)/include -I$(FIRMWARE)/export -I$(FIRMWARE)/common \
-I$(FIRMWARE)/drivers -I.. -Ilib
CFLAGS = -O -W -Wall -m1 -nostdlib -ffreestanding -Wstrict-prototypes	\
$(INCLUDES) $(TARGET) $(EXTRA_DEFINES) -DMEM=${MEM}

LDS := plugin.lds
LINKFILE := $(OBJDIR)/pluginlink.lds

SRC := $(wildcard *.c)
ROCKS := $(SRC:%.c=$(OBJDIR)/%.rock)

ifndef OBJDIR
no_configure:
	@echo "Don't run make here. Run the tools/configure script from your own build"
	@echo "directory, then run make there."
	@echo
	@echo "More help on how to build rockbox can be found here:"
	@echo "http://rockbox.haxx.se/docs/how_to_compile.html"
endif

$(OBJDIR)/%.elf: $(OBJDIR)/%.o $(LINKFILE) $(OBJDIR)/libplugin.a
	$(CC) -O -nostdlib -o $@ $< -L$(OBJDIR) -lplugin -lgcc -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/$*.map

$(OBJDIR)/%.rock : $(OBJDIR)/%.elf
	$(OC) -O binary $< $@

$(OBJDIR)/%.o: %.c  ../plugin.h Makefile
	$(CC) $(CFLAGS) -c $< -o $@

all: $(OBJDIR)/libplugin.a $(ROCKS)
	echo "done"

$(OBJDIR)/libplugin.a:
	$(MAKE) -C lib TARGET=$(TARGET) DEBUG=$(DEBUG) OBJDIR=$(OBJDIR) VERSION=$(VERSION) EXTRA_DEFINES="$(EXTRA_DEFINES)" MEM=${MEM}

# MEM should be passed on to this makefile with the chosen memory size given
# in number of MB
$(LINKFILE): $(LDS)
	$(CC) -DMEMORYSIZE=$(MEM) $(DEFINES) -x c -E -P $< >$@

clean:
	-rm -f $(ROCKS) $(LINKFILE) $(OBJDIR)/*.rock
	$(MAKE) -C lib clean