2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 # single-file plugins:
12 PLUGINS_SRC
= $(call preprocess
, $(APPSDIR
)/plugins
/SOURCES.app_build
)
14 PLUGINS_SRC
= $(call preprocess
, $(APPSDIR
)/plugins
/SOURCES
)
16 OTHER_SRC
+= $(PLUGINS_SRC
)
17 ROCKS1
:= $(PLUGINS_SRC
:.c
=.rock
)
18 ROCKS1
:= $(subst $(ROOTDIR
),$(BUILDDIR
),$(ROCKS1
))
22 ROCKS1
:= $(ROCKS1
:%.lua
=)
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
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
40 OTHER_SRC
+= $(ROOTDIR
)/apps
/plugins
/plugin_crt0.c
41 PLUGIN_CRT0
:= $(BUILDDIR
)/apps
/plugins
/plugin_crt0.o
42 # multifile plugins (subdirs):
44 PLUGINSUBDIRS
:= $(call preprocess
, $(APPSDIR
)/plugins
/SUBDIRS.app_build
)
46 PLUGINSUBDIRS
:= $(call preprocess
, $(APPSDIR
)/plugins
/SUBDIRS
)
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
$@
94 PLUGINLDFLAGS
= $(SHARED_FLAG
) # <-- from Makefile
96 PLUGINLDFLAGS
= -T
$(PLUGINLINK_LDS
) -Wl
,--gc-sections
-Wl
,-Map
,$*.map
97 OVERLAYLDFLAGS
= -T
$(OVERLAYREF_LDS
) -Wl
,--gc-sections
-Wl
,-Map
,$*.refmap
99 PLUGINLDFLAGS
+= $(GLOBAL_LDOPTS
)
102 $(call PRINTS
,LD
$(@F
))$(CC
) $(PLUGINFLAGS
) -o
$(BUILDDIR
)/$*.elf \
105 -lgcc
$(PLUGINLDFLAGS
)
107 $(SILENT
)cp
$(BUILDDIR
)/$*.elf
$@
109 $(SILENT
)$(OC
) -O binary
$(BUILDDIR
)/$*.elf
$@
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 \
119 -lgcc
$(OVERLAYLDFLAGS
)