Don't force double-buffering for sd devices. They apparently are not faster with...
[kugel-rb.git] / apps / plugins / plugins.make
blobc4fe43c007f48aba61c7f7aeabf23559c678b2ed
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 # single-file plugins:
11 PLUGINS_SRC = $(call preprocess, $(APPSDIR)/plugins/SOURCES)
12 OTHER_SRC += $(PLUGINS_SRC)
13 ROCKS1 := $(PLUGINS_SRC:.c=.rock)
14 ROCKS1 := $(subst $(ROOTDIR),$(BUILDDIR),$(ROCKS1))
16 ROCKS := $(ROCKS1)
18 # libplugin.a
19 PLUGINLIB := $(BUILDDIR)/apps/plugins/libplugin.a
20 PLUGINLIB_SRC = $(call preprocess, $(APPSDIR)/plugins/lib/SOURCES)
21 OTHER_SRC += $(PLUGINLIB_SRC)
23 PLUGINLIB_OBJ := $(PLUGINLIB_SRC:.c=.o)
24 PLUGINLIB_OBJ := $(PLUGINLIB_OBJ:.S=.o)
25 PLUGINLIB_OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(PLUGINLIB_OBJ))
27 ### build data / rules
28 ifndef SIMVER
29 PLUGIN_LDS := $(APPSDIR)/plugins/plugin.lds
30 PLUGINLINK_LDS := $(BUILDDIR)/apps/plugins/plugin.link
31 OVERLAYREF_LDS := $(BUILDDIR)/apps/plugins/overlay_ref.link
32 endif
34 # multifile plugins (subdirs):
35 PLUGINSUBDIRS := $(call preprocess, $(APPSDIR)/plugins/SUBDIRS)
37 # include <dir>.make from each subdir (yay!)
38 $(foreach dir,$(PLUGINSUBDIRS),$(eval include $(dir)/$(notdir $(dir)).make))
40 OTHER_INC += -I$(APPSDIR)/plugins -I$(APPSDIR)/plugins/lib
42 # special compile flags for plugins:
43 PLUGINFLAGS = -I$(APPSDIR)/plugins -DPLUGIN $(CFLAGS)
45 # single-file plugins depend on their respective .o
46 $(ROCKS1): $(BUILDDIR)/%.rock: $(BUILDDIR)/%.o
48 # dependency for all plugins
49 $(ROCKS): $(APPSDIR)/plugin.h $(PLUGINLINK_LDS) $(PLUGINLIB) $(PLUGINBITMAPLIB)
51 $(PLUGINLIB): $(PLUGINLIB_OBJ)
52 $(SILENT)$(shell rm -f $@)
53 $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null
55 $(PLUGINLINK_LDS): $(PLUGIN_LDS)
56 $(call PRINTS,PP $(@F))
57 $(shell mkdir -p $(dir $@))
58 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
60 $(OVERLAYREF_LDS): $(PLUGIN_LDS)
61 $(call PRINTS,PP $(@F))
62 $(shell mkdir -p $(dir $@))
63 $(call preprocess2file,$<,$@,-DOVERLAY_OFFSET=0)
65 $(BUILDDIR)/credits.raw credits.raw: $(DOCSDIR)/CREDITS
66 $(call PRINTS,Create credits.raw)perl $(APPSDIR)/plugins/credits.pl < $< > $(BUILDDIR)/$(@F)
68 # special dependencies
69 $(BUILDDIR)/apps/plugins/wav2wv.rock: $(BUILDDIR)/apps/codecs/libwavpack.a $(PLUGINLIB)
71 # special pattern rule for compiling plugin lib (with function and data sections)
72 $(BUILDDIR)/apps/plugins/lib/%.o: $(ROOTDIR)/apps/plugins/lib/%.c
73 $(SILENT)mkdir -p $(dir $@)
74 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -ffunction-sections -fdata-sections -c $< -o $@
76 # special pattern rule for compiling plugins with extra flags
77 $(BUILDDIR)/apps/plugins/%.o: $(ROOTDIR)/apps/plugins/%.c $(PLUGINBITMAPLIB)
78 $(SILENT)mkdir -p $(dir $@)
79 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -c $< -o $@
81 ifdef SIMVER
82 PLUGINLDFLAGS = $(SHARED_FLAG) # <-- from Makefile
83 else
84 PLUGINLDFLAGS = -T$(PLUGINLINK_LDS) -Wl,--gc-sections -Wl,-Map,$*.map
85 OVERLAYLDFLAGS = -T$(OVERLAYREF_LDS) -Wl,--gc-sections -Wl,-Map,$*.refmap
86 endif
88 $(BUILDDIR)/%.rock:
89 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(BUILDDIR)/$*.elf \
90 $(filter %.o, $^) \
91 $(filter %.a, $+) \
92 -lgcc $(PLUGINLDFLAGS)
93 ifdef SIMVER
94 $(SILENT)cp $(BUILDDIR)/$*.elf $@
95 else
96 $(SILENT)$(OC) -O binary $(BUILDDIR)/$*.elf $@
97 endif
99 $(BUILDDIR)/%.refmap: $(APPSDIR)/plugin.h $(OVERLAYREF_LDS) $(PLUGINLIB) $(PLUGINBITMAPLIB)
100 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o /dev/null \
101 $(filter %.o, $^) \
102 $(filter %.a, $+) \
103 -lgcc $(OVERLAYLDFLAGS)