Fix some slight inconsistencies.
[kugel-rb.git] / apps / plugins / plugins.make
blob58e05473e717212b61ba032235827c232e8278cb
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)
20 # include gcc-support routines for linking first if in SOURCES
21 ifneq "$(findstring gcc-support.c,$(PLUGINLIB_SRC))" ""
22 GCCSUPPORT_OBJ := $(BUILDDIR)/apps/plugins/lib/gcc-support.o
23 endif
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 PLUGIN_LDS := $(APPSDIR)/plugins/plugin.lds
32 PLUGINLINK_LDS := $(BUILDDIR)/apps/plugins/plugin.link
33 OVERLAYREF_LDS := $(BUILDDIR)/apps/plugins/overlay_ref.link
34 endif
36 # multifile plugins (subdirs):
37 PLUGINSUBDIRS := $(call preprocess, $(APPSDIR)/plugins/SUBDIRS)
39 # include <dir>.make from each subdir (yay!)
40 $(foreach dir,$(PLUGINSUBDIRS),$(eval include $(dir)/$(notdir $(dir)).make))
42 OTHER_INC += -I$(APPSDIR)/plugins -I$(APPSDIR)/plugins/lib
44 # special compile flags for plugins:
45 PLUGINFLAGS = -I$(APPSDIR)/plugins -DPLUGIN $(CFLAGS)
47 $(ROCKS): $(APPSDIR)/plugin.h $(PLUGINLINK_LDS) $(PLUGINLIB) $(PLUGINBITMAPLIB)
49 $(PLUGINLIB): $(PLUGINLIB_OBJ)
50 $(SILENT)$(shell rm -f $@)
51 $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null
53 $(PLUGINLINK_LDS): $(PLUGIN_LDS)
54 $(call PRINTS,PP $(@F))
55 $(shell mkdir -p $(dir $@))
56 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
58 $(OVERLAYREF_LDS): $(PLUGIN_LDS)
59 $(call PRINTS,PP $(@F))
60 $(shell mkdir -p $(dir $@))
61 $(call preprocess2file,$<,$@,-DOVERLAY_OFFSET=0)
63 $(BUILDDIR)/credits.raw credits.raw: $(DOCSDIR)/CREDITS
64 $(call PRINTS,Create credits.raw)perl $(APPSDIR)/plugins/credits.pl < $< > $(BUILDDIR)/$(@F)
66 # special dependencies
67 $(BUILDDIR)/apps/plugins/wav2wv.rock: $(BUILDDIR)/apps/codecs/libwavpack.a $(PLUGINLIB)
69 # special pattern rule for compiling plugin lib (with -ffunction-sections)
70 $(BUILDDIR)/apps/plugins/lib/%.o: $(ROOTDIR)/apps/plugins/lib/%.c
71 $(SILENT)mkdir -p $(dir $@)
72 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -ffunction-sections -c $< -o $@
74 # special pattern rule for compiling plugins with extra flags
75 $(BUILDDIR)/apps/plugins/%.o: $(ROOTDIR)/apps/plugins/%.c $(PLUGINBITMAPLIB)
76 $(SILENT)mkdir -p $(dir $@)
77 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -c $< -o $@
79 ifdef SIMVER
80 PLUGINLDFLAGS = $(SHARED_FLAG) # <-- from Makefile
81 else
82 PLUGINLDFLAGS = -T$(PLUGINLINK_LDS) -Wl,--gc-sections -Wl,-Map,$*.map
83 OVERLAYLDFLAGS = -T$(OVERLAYREF_LDS) -Wl,--gc-sections -Wl,-Map,$*.refmap
84 endif
86 $(BUILDDIR)/%.rock: $(BUILDDIR)/%.o
87 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(BUILDDIR)/$*.elf \
88 $(filter %.o, $^) \
89 $(filter %.a, $+) \
90 -lgcc $(PLUGINLDFLAGS)
91 ifdef SIMVER
92 $(SILENT)cp $(BUILDDIR)/$*.elf $@
93 else
94 $(SILENT)$(OC) -O binary $(BUILDDIR)/$*.elf $@
95 endif
97 $(BUILDDIR)/%.refmap: $(BUILDDIR)/%.o $(APPSDIR)/plugin.h $(OVERLAYREF_LDS) $(PLUGINLIB) $(PLUGINBITMAPLIB)
98 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o /dev/null \
99 $(filter %.o, $^) \
100 $(filter %.a, $+) \
101 -lgcc $(OVERLAYLDFLAGS)