Add "elfzip" target to make which creates a zip of all elf files, as mapzip does...
[maemo-rb.git] / apps / plugins / plugins.make
blob30cf26f621644b3af059bfb48ccb0d2be1d6480d
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 APP_TYPE
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
36 OTHER_SRC += $(ROOTDIR)/apps/plugins/plugin_crt0.c
37 PLUGIN_CRT0 := $(BUILDDIR)/apps/plugins/plugin_crt0.o
38 # multifile plugins (subdirs):
39 PLUGINSUBDIRS := $(call preprocess, $(APPSDIR)/plugins/SUBDIRS)
41 # include <dir>.make from each subdir (yay!)
42 $(foreach dir,$(PLUGINSUBDIRS),$(eval include $(dir)/$(notdir $(dir)).make))
44 OTHER_INC += -I$(APPSDIR)/plugins -I$(APPSDIR)/plugins/lib
46 # special compile flags for plugins:
47 PLUGINFLAGS = -I$(APPSDIR)/plugins -DPLUGIN $(CFLAGS)
49 # single-file plugins depend on their respective .o
50 $(ROCKS1): $(BUILDDIR)/%.rock: $(BUILDDIR)/%.o
52 # dependency for all plugins
53 $(ROCKS): $(APPSDIR)/plugin.h $(PLUGINLINK_LDS) $(PLUGINLIB) $(PLUGINBITMAPLIB) $(PLUGIN_CRT0) $(LIBSETJMP)
55 $(PLUGINLIB): $(PLUGINLIB_OBJ)
56 $(SILENT)$(shell rm -f $@)
57 $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null
59 $(PLUGINLINK_LDS): $(PLUGIN_LDS) $(CONFIGFILE)
60 $(call PRINTS,PP $(@F))
61 $(shell mkdir -p $(dir $@))
62 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
64 $(OVERLAYREF_LDS): $(PLUGIN_LDS)
65 $(call PRINTS,PP $(@F))
66 $(shell mkdir -p $(dir $@))
67 $(call preprocess2file,$<,$@,-DOVERLAY_OFFSET=0)
69 $(BUILDDIR)/credits.raw credits.raw: $(DOCSDIR)/CREDITS
70 $(call PRINTS,Create credits.raw)perl $(APPSDIR)/plugins/credits.pl < $< > $(BUILDDIR)/$(@F)
72 # special dependencies
73 $(BUILDDIR)/apps/plugins/wav2wv.rock: $(BUILDDIR)/apps/codecs/libwavpack.a $(PLUGINLIB)
75 # special pattern rule for compiling plugin lib (with function and data sections)
76 $(BUILDDIR)/apps/plugins/lib/%.o: $(ROOTDIR)/apps/plugins/lib/%.c
77 $(SILENT)mkdir -p $(dir $@)
78 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -ffunction-sections -fdata-sections -c $< -o $@
80 # special pattern rule for compiling plugins with extra flags
81 $(BUILDDIR)/apps/plugins/%.o: $(ROOTDIR)/apps/plugins/%.c
82 $(SILENT)mkdir -p $(dir $@)
83 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -c $< -o $@
85 ifdef APP_TYPE
86 PLUGINLDFLAGS = $(SHARED_FLAG) # <-- from Makefile
87 else
88 PLUGINLDFLAGS = -T$(PLUGINLINK_LDS) -Wl,--gc-sections -Wl,-Map,$*.map
89 OVERLAYLDFLAGS = -T$(OVERLAYREF_LDS) -Wl,--gc-sections -Wl,-Map,$*.refmap
90 endif
91 PLUGINLDFLAGS += $(GLOBAL_LDOPTS)
93 $(BUILDDIR)/%.rock:
94 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(BUILDDIR)/$*.elf \
95 $(filter %.o, $^) \
96 $(filter %.a, $+) \
97 -lgcc $(PLUGINLDFLAGS)
98 ifdef APP_TYPE
99 $(SILENT)cp $(BUILDDIR)/$*.elf $@
100 else
101 $(SILENT)$(OC) -O binary $(BUILDDIR)/$*.elf $@
102 endif
104 $(BUILDDIR)/apps/plugins/%.lua: $(ROOTDIR)/apps/plugins/%.lua
105 $(call PRINTS,CP $(subst $(ROOTDIR)/,,$<))cp $< $(BUILDDIR)/apps/plugins/
107 $(BUILDDIR)/%.refmap: $(APPSDIR)/plugin.h $(OVERLAYREF_LDS) $(PLUGINLIB) $(PLUGINBITMAPLIB) $(LIBSETJMP) $(PLUGIN_CRT0)
108 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o /dev/null \
109 $(filter %.o, $^) \
110 $(filter %.a, $+) \
111 -lgcc $(OVERLAYLDFLAGS)