Enable plugins in the pandora port
[maemo-rb.git] / apps / plugins / plugins.make
bloba7630ea46f6e9b008131272d93768a15f27f0ccd
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 # single-file plugins:
11 ifdef APP_TYPE
12 PLUGINS_SRC = $(call preprocess, $(APPSDIR)/plugins/SOURCES.app_build)
13 else
14 PLUGINS_SRC = $(call preprocess, $(APPSDIR)/plugins/SOURCES)
15 endif
16 OTHER_SRC += $(PLUGINS_SRC)
17 ROCKS1 := $(PLUGINS_SRC:.c=.rock)
18 ROCKS1 := $(subst $(ROOTDIR),$(BUILDDIR),$(ROCKS1))
20 ROCKS := $(ROCKS1)
22 ROCKS1 := $(ROCKS1:%.lua=)
24 # libplugin.a
25 PLUGINLIB := $(BUILDDIR)/apps/plugins/libplugin.a
26 PLUGINLIB_SRC = $(call preprocess, $(APPSDIR)/plugins/lib/SOURCES)
27 OTHER_SRC += $(PLUGINLIB_SRC)
29 PLUGINLIB_OBJ := $(PLUGINLIB_SRC:.c=.o)
30 PLUGINLIB_OBJ := $(PLUGINLIB_OBJ:.S=.o)
31 PLUGINLIB_OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(PLUGINLIB_OBJ))
33 ### build data / rules
34 ifndef APP_TYPE
35 CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h
36 PLUGIN_LDS := $(APPSDIR)/plugins/plugin.lds
37 PLUGINLINK_LDS := $(BUILDDIR)/apps/plugins/plugin.link
38 OVERLAYREF_LDS := $(BUILDDIR)/apps/plugins/overlay_ref.link
39 endif
40 OTHER_SRC += $(ROOTDIR)/apps/plugins/plugin_crt0.c
41 PLUGIN_CRT0 := $(BUILDDIR)/apps/plugins/plugin_crt0.o
42 # multifile plugins (subdirs):
43 ifdef APP_TYPE
44 PLUGINSUBDIRS := $(call preprocess, $(APPSDIR)/plugins/SUBDIRS.app_build)
45 else
46 PLUGINSUBDIRS := $(call preprocess, $(APPSDIR)/plugins/SUBDIRS)
47 endif
49 # include <dir>.make from each subdir (yay!)
50 $(foreach dir,$(PLUGINSUBDIRS),$(eval include $(dir)/$(notdir $(dir)).make))
52 OTHER_INC += -I$(APPSDIR)/plugins -I$(APPSDIR)/plugins/lib
54 # special compile flags for plugins:
55 PLUGINFLAGS = -I$(APPSDIR)/plugins -DPLUGIN $(CFLAGS)
57 # single-file plugins depend on their respective .o
58 $(ROCKS1): $(BUILDDIR)/%.rock: $(BUILDDIR)/%.o
60 # dependency for all plugins
61 $(ROCKS): $(APPSDIR)/plugin.h $(PLUGINLINK_LDS) $(PLUGINLIB) $(PLUGINBITMAPLIB) $(PLUGIN_CRT0) $(LIBSETJMP)
63 $(PLUGINLIB): $(PLUGINLIB_OBJ)
64 $(SILENT)$(shell rm -f $@)
65 $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null
67 $(PLUGINLINK_LDS): $(PLUGIN_LDS) $(CONFIGFILE)
68 $(call PRINTS,PP $(@F))
69 $(shell mkdir -p $(dir $@))
70 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
72 $(OVERLAYREF_LDS): $(PLUGIN_LDS)
73 $(call PRINTS,PP $(@F))
74 $(shell mkdir -p $(dir $@))
75 $(call preprocess2file,$<,$@,-DOVERLAY_OFFSET=0)
77 $(BUILDDIR)/credits.raw credits.raw: $(DOCSDIR)/CREDITS
78 $(call PRINTS,Create credits.raw)perl $(APPSDIR)/plugins/credits.pl < $< > $(BUILDDIR)/$(@F)
80 # special dependencies
81 $(BUILDDIR)/apps/plugins/wav2wv.rock: $(BUILDDIR)/apps/codecs/libwavpack.a $(PLUGINLIB)
83 # special pattern rule for compiling plugin lib (with function and data sections)
84 $(BUILDDIR)/apps/plugins/lib/%.o: $(ROOTDIR)/apps/plugins/lib/%.c
85 $(SILENT)mkdir -p $(dir $@)
86 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -ffunction-sections -fdata-sections -c $< -o $@
88 # special pattern rule for compiling plugins with extra flags
89 $(BUILDDIR)/apps/plugins/%.o: $(ROOTDIR)/apps/plugins/%.c
90 $(SILENT)mkdir -p $(dir $@)
91 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -c $< -o $@
93 ifdef APP_TYPE
94 PLUGINLDFLAGS = $(SHARED_FLAG) # <-- from Makefile
95 else
96 PLUGINLDFLAGS = -T$(PLUGINLINK_LDS) -Wl,--gc-sections -Wl,-Map,$*.map
97 OVERLAYLDFLAGS = -T$(OVERLAYREF_LDS) -Wl,--gc-sections -Wl,-Map,$*.refmap
98 endif
99 PLUGINLDFLAGS += $(GLOBAL_LDOPTS)
101 $(BUILDDIR)/%.rock:
102 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(BUILDDIR)/$*.elf \
103 $(filter %.o, $^) \
104 $(filter %.a, $+) \
105 -lgcc $(PLUGINLDFLAGS)
106 ifdef APP_TYPE
107 $(SILENT)cp $(BUILDDIR)/$*.elf $@
108 else
109 $(SILENT)$(OC) -O binary $(BUILDDIR)/$*.elf $@
110 endif
112 $(BUILDDIR)/apps/plugins/%.lua: $(ROOTDIR)/apps/plugins/%.lua
113 $(call PRINTS,CP $(subst $(ROOTDIR)/,,$<))cp $< $(BUILDDIR)/apps/plugins/
115 $(BUILDDIR)/%.refmap: $(APPSDIR)/plugin.h $(OVERLAYREF_LDS) $(PLUGINLIB) $(PLUGINBITMAPLIB) $(LIBSETJMP) $(PLUGIN_CRT0)
116 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o /dev/null \
117 $(filter %.o, $^) \
118 $(filter %.a, $+) \
119 -lgcc $(OVERLAYLDFLAGS)