Use albumart opt in sliding puzzle manual
[kugel-rb.git] / apps / plugins / plugins.make
blobfebc80ac950f151120e847a6a8d22085f10b861b
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 ROCKS1 := $(ROCKS1:%.lua=)
20 # libplugin.a
21 PLUGINLIB := $(BUILDDIR)/apps/plugins/libplugin.a
22 PLUGINLIB_SRC = $(call preprocess, $(APPSDIR)/plugins/lib/SOURCES)
23 OTHER_SRC += $(PLUGINLIB_SRC)
25 PLUGINLIB_OBJ := $(PLUGINLIB_SRC:.c=.o)
26 PLUGINLIB_OBJ := $(PLUGINLIB_OBJ:.S=.o)
27 PLUGINLIB_OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(PLUGINLIB_OBJ))
29 ### build data / rules
30 ifndef SIMVER
31 CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h
32 PLUGIN_LDS := $(APPSDIR)/plugins/plugin.lds
33 PLUGINLINK_LDS := $(BUILDDIR)/apps/plugins/plugin.link
34 OVERLAYREF_LDS := $(BUILDDIR)/apps/plugins/overlay_ref.link
35 endif
37 # multifile plugins (subdirs):
38 PLUGINSUBDIRS := $(call preprocess, $(APPSDIR)/plugins/SUBDIRS)
40 # include <dir>.make from each subdir (yay!)
41 $(foreach dir,$(PLUGINSUBDIRS),$(eval include $(dir)/$(notdir $(dir)).make))
43 OTHER_INC += -I$(APPSDIR)/plugins -I$(APPSDIR)/plugins/lib
45 # special compile flags for plugins:
46 PLUGINFLAGS = -I$(APPSDIR)/plugins -DPLUGIN $(CFLAGS)
48 # single-file plugins depend on their respective .o
49 $(ROCKS1): $(BUILDDIR)/%.rock: $(BUILDDIR)/%.o
51 # dependency for all plugins
52 $(ROCKS): $(APPSDIR)/plugin.h $(PLUGINLINK_LDS) $(PLUGINLIB) $(PLUGINBITMAPLIB)
54 $(PLUGINLIB): $(PLUGINLIB_OBJ)
55 $(SILENT)$(shell rm -f $@)
56 $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null
58 $(PLUGINLINK_LDS): $(PLUGIN_LDS) $(CONFIGFILE)
59 $(call PRINTS,PP $(@F))
60 $(shell mkdir -p $(dir $@))
61 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
63 $(OVERLAYREF_LDS): $(PLUGIN_LDS)
64 $(call PRINTS,PP $(@F))
65 $(shell mkdir -p $(dir $@))
66 $(call preprocess2file,$<,$@,-DOVERLAY_OFFSET=0)
68 $(BUILDDIR)/credits.raw credits.raw: $(DOCSDIR)/CREDITS
69 $(call PRINTS,Create credits.raw)perl $(APPSDIR)/plugins/credits.pl < $< > $(BUILDDIR)/$(@F)
71 # special dependencies
72 $(BUILDDIR)/apps/plugins/wav2wv.rock: $(BUILDDIR)/apps/codecs/libwavpack.a $(PLUGINLIB)
74 # special pattern rule for compiling plugin lib (with function and data sections)
75 $(BUILDDIR)/apps/plugins/lib/%.o: $(ROOTDIR)/apps/plugins/lib/%.c
76 $(SILENT)mkdir -p $(dir $@)
77 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -ffunction-sections -fdata-sections -c $< -o $@
79 # special pattern rule for compiling plugins with extra flags
80 $(BUILDDIR)/apps/plugins/%.o: $(ROOTDIR)/apps/plugins/%.c
81 $(SILENT)mkdir -p $(dir $@)
82 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -c $< -o $@
84 ifdef SIMVER
85 PLUGINLDFLAGS = $(SHARED_FLAG) # <-- from Makefile
86 else
87 PLUGINLDFLAGS = -T$(PLUGINLINK_LDS) -Wl,--gc-sections -Wl,-Map,$*.map
88 OVERLAYLDFLAGS = -T$(OVERLAYREF_LDS) -Wl,--gc-sections -Wl,-Map,$*.refmap
89 endif
91 $(BUILDDIR)/%.rock:
92 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(BUILDDIR)/$*.elf \
93 $(filter %.o, $^) \
94 $(filter %.a, $+) \
95 -lgcc $(PLUGINLDFLAGS)
96 ifdef SIMVER
97 $(SILENT)cp $(BUILDDIR)/$*.elf $@
98 else
99 $(SILENT)$(OC) -O binary $(BUILDDIR)/$*.elf $@
100 endif
102 $(BUILDDIR)/apps/plugins/%.lua: $(ROOTDIR)/apps/plugins/%.lua
103 $(call PRINTS,CP $(subst $(ROOTDIR)/,,$<))cp $< $(BUILDDIR)/apps/plugins/
105 $(BUILDDIR)/%.refmap: $(APPSDIR)/plugin.h $(OVERLAYREF_LDS) $(PLUGINLIB) $(PLUGINBITMAPLIB)
106 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o /dev/null \
107 $(filter %.o, $^) \
108 $(filter %.a, $+) \
109 -lgcc $(OVERLAYLDFLAGS)