We have a 3.9 release, update builds.pm
[maemo-rb.git] / apps / plugins / plugins.make
blob0c667aaf24c83f11b33c20aba7499093517287e1
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 # single-file plugins:
11 is_app_build =
12 ifdef APP_TYPE
13 ifneq ($(APP_TYPE),sdl-sim)
14 is_app_build = yes
15 endif
16 endif
18 ifdef is_app_build
19 PLUGINS_SRC = $(call preprocess, $(APPSDIR)/plugins/SOURCES.app_build)
20 else
21 PLUGINS_SRC = $(call preprocess, $(APPSDIR)/plugins/SOURCES)
22 endif
23 OTHER_SRC += $(PLUGINS_SRC)
24 ROCKS1 := $(PLUGINS_SRC:.c=.rock)
25 ROCKS1 := $(subst $(ROOTDIR),$(BUILDDIR),$(ROCKS1))
27 ROCKS := $(ROCKS1)
29 ROCKS1 := $(ROCKS1:%.lua=)
31 # libplugin.a
32 PLUGINLIB := $(BUILDDIR)/apps/plugins/libplugin.a
33 PLUGINLIB_SRC = $(call preprocess, $(APPSDIR)/plugins/lib/SOURCES)
34 OTHER_SRC += $(PLUGINLIB_SRC)
36 PLUGINLIB_OBJ := $(PLUGINLIB_SRC:.c=.o)
37 PLUGINLIB_OBJ := $(PLUGINLIB_OBJ:.S=.o)
38 PLUGINLIB_OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(PLUGINLIB_OBJ))
40 ### build data / rules
41 ifndef APP_TYPE
42 CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h
43 PLUGIN_LDS := $(APPSDIR)/plugins/plugin.lds
44 PLUGINLINK_LDS := $(BUILDDIR)/apps/plugins/plugin.link
45 OVERLAYREF_LDS := $(BUILDDIR)/apps/plugins/overlay_ref.link
46 endif
47 OTHER_SRC += $(ROOTDIR)/apps/plugins/plugin_crt0.c
48 PLUGIN_CRT0 := $(BUILDDIR)/apps/plugins/plugin_crt0.o
49 # multifile plugins (subdirs):
50 ifdef is_app_build
51 PLUGINSUBDIRS := $(call preprocess, $(APPSDIR)/plugins/SUBDIRS.app_build)
52 else
53 PLUGINSUBDIRS := $(call preprocess, $(APPSDIR)/plugins/SUBDIRS)
54 endif
56 # include <dir>.make from each subdir (yay!)
57 $(foreach dir,$(PLUGINSUBDIRS),$(eval include $(dir)/$(notdir $(dir)).make))
59 OTHER_INC += -I$(APPSDIR)/plugins -I$(APPSDIR)/plugins/lib
61 # special compile flags for plugins:
62 PLUGINFLAGS = -I$(APPSDIR)/plugins -DPLUGIN $(CFLAGS)
64 # single-file plugins depend on their respective .o
65 $(ROCKS1): $(BUILDDIR)/%.rock: $(BUILDDIR)/%.o
67 # dependency for all plugins
68 $(ROCKS): $(APPSDIR)/plugin.h $(PLUGINLINK_LDS) $(PLUGINLIB) $(PLUGINBITMAPLIB) $(PLUGIN_CRT0) $(LIBSETJMP)
70 $(PLUGINLIB): $(PLUGINLIB_OBJ)
71 $(SILENT)$(shell rm -f $@)
72 $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null
74 $(PLUGINLINK_LDS): $(PLUGIN_LDS) $(CONFIGFILE)
75 $(call PRINTS,PP $(@F))
76 $(shell mkdir -p $(dir $@))
77 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
79 $(OVERLAYREF_LDS): $(PLUGIN_LDS)
80 $(call PRINTS,PP $(@F))
81 $(shell mkdir -p $(dir $@))
82 $(call preprocess2file,$<,$@,-DOVERLAY_OFFSET=0)
84 $(BUILDDIR)/credits.raw credits.raw: $(DOCSDIR)/CREDITS
85 $(call PRINTS,Create credits.raw)perl $(APPSDIR)/plugins/credits.pl < $< > $(BUILDDIR)/$(@F)
87 # special dependencies
88 $(BUILDDIR)/apps/plugins/wav2wv.rock: $(BUILDDIR)/apps/codecs/libwavpack.a $(PLUGINLIB)
90 # special pattern rule for compiling plugin lib (with function and data sections)
91 $(BUILDDIR)/apps/plugins/lib/%.o: $(ROOTDIR)/apps/plugins/lib/%.c
92 $(SILENT)mkdir -p $(dir $@)
93 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -ffunction-sections -fdata-sections -c $< -o $@
95 # special pattern rule for compiling plugins with extra flags
96 $(BUILDDIR)/apps/plugins/%.o: $(ROOTDIR)/apps/plugins/%.c
97 $(SILENT)mkdir -p $(dir $@)
98 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -c $< -o $@
100 ifdef APP_TYPE
101 PLUGINLDFLAGS = $(SHARED_LDFLAG) # <-- from Makefile
102 PLUGINFLAGS += $(SHARED_CFLAGS) # <-- from Makefile
103 else
104 PLUGINLDFLAGS = -T$(PLUGINLINK_LDS) -Wl,--gc-sections -Wl,-Map,$*.map
105 OVERLAYLDFLAGS = -T$(OVERLAYREF_LDS) -Wl,--gc-sections -Wl,-Map,$*.refmap
106 endif
107 PLUGINLDFLAGS += $(GLOBAL_LDOPTS)
109 $(BUILDDIR)/%.rock:
110 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(BUILDDIR)/$*.elf \
111 $(filter %.o, $^) \
112 $(filter %.a, $+) \
113 -lgcc $(PLUGINLDFLAGS)
114 ifdef APP_TYPE
115 $(SILENT)cp $(BUILDDIR)/$*.elf $@
116 else
117 $(SILENT)$(OC) -O binary $(BUILDDIR)/$*.elf $@
118 endif
120 $(BUILDDIR)/apps/plugins/%.lua: $(ROOTDIR)/apps/plugins/%.lua
121 $(call PRINTS,CP $(subst $(ROOTDIR)/,,$<))cp $< $(BUILDDIR)/apps/plugins/
123 $(BUILDDIR)/%.refmap: $(APPSDIR)/plugin.h $(OVERLAYREF_LDS) $(PLUGINLIB) $(PLUGINBITMAPLIB) $(LIBSETJMP) $(PLUGIN_CRT0)
124 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o /dev/null \
125 $(filter %.o, $^) \
126 $(filter %.a, $+) \
127 -lgcc $(OVERLAYLDFLAGS)