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 PLUGIN_LDS
:= $(APPSDIR
)/plugins
/plugin.lds
32 PLUGINLINK_LDS
:= $(BUILDDIR
)/apps
/plugins
/plugin.link
33 OVERLAYREF_LDS
:= $(BUILDDIR
)/apps
/plugins
/overlay_ref.link
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 # single-file plugins depend on their respective .o
48 $(ROCKS1
): $(BUILDDIR
)/%.rock
: $(BUILDDIR
)/%.o
50 # dependency for all plugins
51 $(ROCKS
): $(APPSDIR
)/plugin.h
$(PLUGINLINK_LDS
) $(PLUGINLIB
) $(PLUGINBITMAPLIB
)
53 $(PLUGINLIB
): $(PLUGINLIB_OBJ
)
54 $(SILENT
)$(shell rm -f
$@
)
55 $(call PRINTS
,AR
$(@F
))$(AR
) rcs
$@
$^
>/dev
/null
57 $(PLUGINLINK_LDS
): $(PLUGIN_LDS
)
58 $(call PRINTS
,PP
$(@F
))
59 $(shell mkdir
-p
$(dir $@
))
60 $(call preprocess2file
,$<,$@
,-DLOADADDRESS
=$(LOADADDRESS
))
62 $(OVERLAYREF_LDS
): $(PLUGIN_LDS
)
63 $(call PRINTS
,PP
$(@F
))
64 $(shell mkdir
-p
$(dir $@
))
65 $(call preprocess2file
,$<,$@
,-DOVERLAY_OFFSET
=0)
67 $(BUILDDIR
)/credits.raw credits.raw
: $(DOCSDIR
)/CREDITS
68 $(call PRINTS
,Create credits.raw
)perl
$(APPSDIR
)/plugins
/credits.pl
< $< > $(BUILDDIR
)/$(@F
)
70 # special dependencies
71 $(BUILDDIR
)/apps
/plugins
/wav2wv.rock
: $(BUILDDIR
)/apps
/codecs
/libwavpack.a
$(PLUGINLIB
)
73 # special pattern rule for compiling plugin lib (with function and data sections)
74 $(BUILDDIR
)/apps
/plugins
/lib
/%.o
: $(ROOTDIR
)/apps
/plugins
/lib
/%.c
75 $(SILENT
)mkdir
-p
$(dir $@
)
76 $(call PRINTS
,CC
$(subst $(ROOTDIR
)/,,$<))$(CC
) -I
$(dir $<) $(PLUGINFLAGS
) -ffunction-sections
-fdata-sections
-c
$< -o
$@
78 # special pattern rule for compiling plugins with extra flags
79 $(BUILDDIR
)/apps
/plugins
/%.o
: $(ROOTDIR
)/apps
/plugins
/%.c
$(PLUGINBITMAPLIB
)
80 $(SILENT
)mkdir
-p
$(dir $@
)
81 $(call PRINTS
,CC
$(subst $(ROOTDIR
)/,,$<))$(CC
) -I
$(dir $<) $(PLUGINFLAGS
) -c
$< -o
$@
84 PLUGINLDFLAGS
= $(SHARED_FLAG
) # <-- from Makefile
86 PLUGINLDFLAGS
= -T
$(PLUGINLINK_LDS
) -Wl
,--gc-sections
-Wl
,-Map
,$*.map
87 OVERLAYLDFLAGS
= -T
$(OVERLAYREF_LDS
) -Wl
,--gc-sections
-Wl
,-Map
,$*.refmap
91 $(call PRINTS
,LD
$(@F
))$(CC
) $(PLUGINFLAGS
) -o
$(BUILDDIR
)/$*.elf \
94 -lgcc
$(PLUGINLDFLAGS
)
96 $(SILENT
)cp
$(BUILDDIR
)/$*.elf
$@
98 $(SILENT
)$(OC
) -O binary
$(BUILDDIR
)/$*.elf
$@
101 $(BUILDDIR
)/apps
/plugins
/%.lua
: $(ROOTDIR
)/apps
/plugins
/%.lua
102 $(call PRINTS
,CP
$(subst $(ROOTDIR
)/,,$<))cp
$< $(BUILDDIR
)/apps
/plugins
/
104 $(BUILDDIR
)/%.refmap
: $(APPSDIR
)/plugin.h
$(OVERLAYREF_LDS
) $(PLUGINLIB
) $(PLUGINBITMAPLIB
)
105 $(call PRINTS
,LD
$(@F
))$(CC
) $(PLUGINFLAGS
) -o
/dev
/null \
108 -lgcc
$(OVERLAYLDFLAGS
)