2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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
))
18 ROCKS1
:= $(ROCKS1
:%.lua
=)
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
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
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
$@
85 PLUGINLDFLAGS
= $(SHARED_FLAG
) # <-- from Makefile
87 PLUGINLDFLAGS
= -T
$(PLUGINLINK_LDS
) -Wl
,--gc-sections
-Wl
,-Map
,$*.map
88 OVERLAYLDFLAGS
= -T
$(OVERLAYREF_LDS
) -Wl
,--gc-sections
-Wl
,-Map
,$*.refmap
90 PLUGINLDFLAGS
+= $(GLOBAL_LDOPTS
)
93 $(call PRINTS
,LD
$(@F
))$(CC
) $(PLUGINFLAGS
) -o
$(BUILDDIR
)/$*.elf \
96 -lgcc
$(PLUGINLDFLAGS
)
98 $(SILENT
)cp
$(BUILDDIR
)/$*.elf
$@
100 $(SILENT
)$(OC
) -O binary
$(BUILDDIR
)/$*.elf
$@
103 $(BUILDDIR
)/apps
/plugins
/%.lua
: $(ROOTDIR
)/apps
/plugins
/%.lua
104 $(call PRINTS
,CP
$(subst $(ROOTDIR
)/,,$<))cp
$< $(BUILDDIR
)/apps
/plugins
/
106 $(BUILDDIR
)/%.refmap
: $(APPSDIR
)/plugin.h
$(OVERLAYREF_LDS
) $(PLUGINLIB
) $(PLUGINBITMAPLIB
)
107 $(call PRINTS
,LD
$(@F
))$(CC
) $(PLUGINFLAGS
) -o
/dev
/null \
110 -lgcc
$(OVERLAYLDFLAGS
)