diff options
Diffstat (limited to 'apps/plugins/plugins.make')
-rw-r--r-- | apps/plugins/plugins.make | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/apps/plugins/plugins.make b/apps/plugins/plugins.make new file mode 100644 index 0000000000..2e266cb190 --- /dev/null +++ b/apps/plugins/plugins.make | |||
@@ -0,0 +1,76 @@ | |||
1 | # __________ __ ___. | ||
2 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
3 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
4 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
5 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
6 | # \/ \/ \/ \/ \/ | ||
7 | # $Id: Makefile 19082 2008-11-10 23:54:24Z zagor $ | ||
8 | # | ||
9 | |||
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)) | ||
15 | |||
16 | # libplugin.a | ||
17 | PLUGINLIB := $(BUILDDIR)/apps/plugins/libplugin.a | ||
18 | PLUGINLIB_SRC = $(call preprocess, $(APPSDIR)/plugins/lib/SOURCES) | ||
19 | OTHER_SRC += $(PLUGINLIB_SRC) | ||
20 | |||
21 | PLUGINLIB_OBJ := $(PLUGINLIB_SRC:.c=.o) | ||
22 | PLUGINLIB_OBJ := $(PLUGINLIB_OBJ:.S=.o) | ||
23 | PLUGINLIB_OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(PLUGINLIB_OBJ)) | ||
24 | |||
25 | # multifile plugins (subdirs): | ||
26 | PLUGINSUBDIRS := $(call preprocess, $(APPSDIR)/plugins/SUBDIRS) | ||
27 | |||
28 | # include <dir>.make from each subdir (yay!) | ||
29 | $(foreach dir,$(PLUGINSUBDIRS),$(eval include $(dir)/$(notdir $(dir)).make)) | ||
30 | |||
31 | ### build data / rules | ||
32 | PLUGIN_LDS := $(APPSDIR)/plugins/plugin.lds | ||
33 | PLUGINLINK_LDS := $(BUILDDIR)/apps/plugins/plugin.link | ||
34 | |||
35 | OTHER_INC += -I$(APPSDIR)/plugins | ||
36 | |||
37 | # special compile flags for plugins: | ||
38 | PLUGINFLAGS = -I$(APPSDIR)/plugins -DPLUGIN $(CFLAGS) | ||
39 | |||
40 | $(ROCKS): $(PLUGINLIB) $(APPSDIR)/plugin.h $(PLUGINLINK_LDS) $(PLUGINBITMAPLIB) | ||
41 | |||
42 | $(PLUGINLIB): $(PLUGINLIB_OBJ) | ||
43 | $(call PRINTS,AR $(@F))$(AR) rs $@ $^ >/dev/null 2>&1 | ||
44 | |||
45 | $(PLUGINLINK_LDS): $(PLUGIN_LDS) | ||
46 | $(call PRINTS,PP $(@F)) | ||
47 | $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS)) | ||
48 | |||
49 | $(BUILDDIR)/credits.raw credits.raw: $(DOCSDIR)/CREDITS | ||
50 | $(call PRINTS,Create credits.raw)perl $(APPSDIR)/plugins/credits.pl < $< > $(BUILDDIR)/$(@F) | ||
51 | |||
52 | # special dependencies | ||
53 | $(BUILDDIR)/apps/plugins/wav2wv.rock: $(BUILDDIR)/apps/codecs/libwavpack.a | ||
54 | |||
55 | # special pattern rule for compiling plugin lib (with -ffunction-sections) | ||
56 | $(BUILDDIR)/apps/plugins/lib/%.o: $(ROOTDIR)/apps/plugins/lib/%.c | ||
57 | $(SILENT)mkdir -p $(dir $@) | ||
58 | $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -ffunction-sections -c $< -o $@ | ||
59 | |||
60 | # special pattern rule for compiling plugins with extra flags | ||
61 | $(BUILDDIR)/apps/plugins/%.o: $(ROOTDIR)/apps/plugins/%.c $(PLUGINBITMAPLIB) | ||
62 | $(SILENT)mkdir -p $(dir $@) | ||
63 | $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -c $< -o $@ | ||
64 | |||
65 | ifdef SIMVER | ||
66 | PLUGINLDFLAGS = $(SHARED_FLAG) # <-- from Makefile | ||
67 | else | ||
68 | PLUGINLDFLAGS = -T$(PLUGINLINK_LDS) -Wl,--gc-sections -Wl,-Map,$*.map | ||
69 | endif | ||
70 | |||
71 | $(BUILDDIR)/%.rock: $(BUILDDIR)/%.o $(PLUGINLINK_LDS) | ||
72 | $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(BUILDDIR)/$*.elf \ | ||
73 | $(filter %.o, $^) \ | ||
74 | $(filter %.a, $^) \ | ||
75 | -lgcc $(PLUGINLDFLAGS) | ||
76 | $(SILENT)$(OC) -O binary $(BUILDDIR)/$*.elf $@ | ||