Added 'keywords' and 'eol-style' properties.
[kugel-rb.git] / apps / plugins / plugins.make
blob0921c0bce2ec84751899a6993055974900869820
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 ROCKS := $(PLUGINS_SRC:.c=.rock)
14 ROCKS := $(subst $(ROOTDIR),$(BUILDDIR),$(ROCKS))
16 # libplugin.a
17 PLUGINLIB := $(BUILDDIR)/apps/plugins/libplugin.a
18 PLUGINLIB_SRC = $(call preprocess, $(APPSDIR)/plugins/lib/SOURCES)
19 OTHER_SRC += $(PLUGINLIB_SRC)
21 PLUGINLIB_OBJ := $(PLUGINLIB_SRC:.c=.o)
22 PLUGINLIB_OBJ := $(PLUGINLIB_OBJ:.S=.o)
23 PLUGINLIB_OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(PLUGINLIB_OBJ))
25 # multifile plugins (subdirs):
26 PLUGINSUBDIRS := $(call preprocess, $(APPSDIR)/plugins/SUBDIRS)
28 # include <dir>.make from each subdir (yay!)
29 $(foreach dir,$(PLUGINSUBDIRS),$(eval include $(dir)/$(notdir $(dir)).make))
31 ### build data / rules
32 PLUGIN_LDS := $(APPSDIR)/plugins/plugin.lds
33 PLUGINLINK_LDS := $(BUILDDIR)/apps/plugins/plugin.link
35 OTHER_INC += -I$(APPSDIR)/plugins
37 # special compile flags for plugins:
38 PLUGINFLAGS = -I$(APPSDIR)/plugins -DPLUGIN $(CFLAGS)
40 $(ROCKS): $(PLUGINLIB) $(APPSDIR)/plugin.h $(PLUGINLINK_LDS) $(PLUGINBITMAPLIB)
42 $(PLUGINLIB): $(PLUGINLIB_OBJ)
43 $(SILENT)$(shell rm -f $@)
44 $(call PRINTS,AR $(@F))$(AR) rs $@ $^ >/dev/null 2>&1
46 $(PLUGINLINK_LDS): $(PLUGIN_LDS)
47 $(call PRINTS,PP $(@F))
48 $(shell mkdir -p $(dir $@))
49 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
51 $(BUILDDIR)/credits.raw credits.raw: $(DOCSDIR)/CREDITS
52 $(call PRINTS,Create credits.raw)perl $(APPSDIR)/plugins/credits.pl < $< > $(BUILDDIR)/$(@F)
54 # special dependencies
55 $(BUILDDIR)/apps/plugins/wav2wv.rock: $(BUILDDIR)/apps/codecs/libwavpack.a
57 # special pattern rule for compiling plugin lib (with -ffunction-sections)
58 $(BUILDDIR)/apps/plugins/lib/%.o: $(ROOTDIR)/apps/plugins/lib/%.c
59 $(SILENT)mkdir -p $(dir $@)
60 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -ffunction-sections -c $< -o $@
62 # special pattern rule for compiling plugins with extra flags
63 $(BUILDDIR)/apps/plugins/%.o: $(ROOTDIR)/apps/plugins/%.c $(PLUGINBITMAPLIB)
64 $(SILENT)mkdir -p $(dir $@)
65 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -c $< -o $@
67 ifdef SIMVER
68 PLUGINLDFLAGS = $(SHARED_FLAG) # <-- from Makefile
69 else
70 PLUGINLDFLAGS = -T$(PLUGINLINK_LDS) -Wl,--gc-sections -Wl,-Map,$*.map
71 endif
73 $(BUILDDIR)/%.rock: $(BUILDDIR)/%.o $(PLUGINLINK_LDS)
74 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(BUILDDIR)/$*.elf \
75 $(filter %.o, $^) \
76 $(filter %.a, $^) \
77 -lgcc $(PLUGINLDFLAGS)
78 ifdef SIMVER
79 $(SILENT)cp $(BUILDDIR)/$*.elf $@
80 else
81 $(SILENT)$(OC) -O binary $(BUILDDIR)/$*.elf $@
82 endif