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
36 OTHER_SRC
+= $(ROOTDIR
)/apps
/plugins
/plugin_crt0.c
37 PLUGIN_CRT0
:= $(BUILDDIR
)/apps
/plugins
/plugin_crt0.o
38 # multifile plugins (subdirs):
39 PLUGINSUBDIRS
:= $(call preprocess
, $(APPSDIR
)/plugins
/SUBDIRS
)
41 # include <dir>.make from each subdir (yay!)
42 $(foreach dir,$(PLUGINSUBDIRS
),$(eval
include $(dir)/$(notdir $(dir)).make
))
44 OTHER_INC
+= -I
$(APPSDIR
)/plugins
-I
$(APPSDIR
)/plugins
/lib
46 # special compile flags for plugins:
47 PLUGINFLAGS
= -I
$(APPSDIR
)/plugins
-DPLUGIN
$(CFLAGS
)
49 # single-file plugins depend on their respective .o
50 $(ROCKS1
): $(BUILDDIR
)/%.rock
: $(BUILDDIR
)/%.o
52 # dependency for all plugins
53 $(ROCKS
): $(APPSDIR
)/plugin.h
$(PLUGINLINK_LDS
) $(PLUGINLIB
) $(PLUGINBITMAPLIB
) $(PLUGIN_CRT0
) $(LIBSETJMP
)
55 $(PLUGINLIB
): $(PLUGINLIB_OBJ
)
56 $(SILENT
)$(shell rm -f
$@
)
57 $(call PRINTS
,AR
$(@F
))$(AR
) rcs
$@
$^
>/dev
/null
59 $(PLUGINLINK_LDS
): $(PLUGIN_LDS
) $(CONFIGFILE
)
60 $(call PRINTS
,PP
$(@F
))
61 $(shell mkdir
-p
$(dir $@
))
62 $(call preprocess2file
,$<,$@
,-DLOADADDRESS
=$(LOADADDRESS
))
64 $(OVERLAYREF_LDS
): $(PLUGIN_LDS
)
65 $(call PRINTS
,PP
$(@F
))
66 $(shell mkdir
-p
$(dir $@
))
67 $(call preprocess2file
,$<,$@
,-DOVERLAY_OFFSET
=0)
69 $(BUILDDIR
)/credits.raw credits.raw
: $(DOCSDIR
)/CREDITS
70 $(call PRINTS
,Create credits.raw
)perl
$(APPSDIR
)/plugins
/credits.pl
< $< > $(BUILDDIR
)/$(@F
)
72 # special dependencies
73 $(BUILDDIR
)/apps
/plugins
/wav2wv.rock
: $(BUILDDIR
)/apps
/codecs
/libwavpack.a
$(PLUGINLIB
)
75 # special pattern rule for compiling plugin lib (with function and data sections)
76 $(BUILDDIR
)/apps
/plugins
/lib
/%.o
: $(ROOTDIR
)/apps
/plugins
/lib
/%.c
77 $(SILENT
)mkdir
-p
$(dir $@
)
78 $(call PRINTS
,CC
$(subst $(ROOTDIR
)/,,$<))$(CC
) -I
$(dir $<) $(PLUGINFLAGS
) -ffunction-sections
-fdata-sections
-c
$< -o
$@
80 # special pattern rule for compiling plugins with extra flags
81 $(BUILDDIR
)/apps
/plugins
/%.o
: $(ROOTDIR
)/apps
/plugins
/%.c
82 $(SILENT
)mkdir
-p
$(dir $@
)
83 $(call PRINTS
,CC
$(subst $(ROOTDIR
)/,,$<))$(CC
) -I
$(dir $<) $(PLUGINFLAGS
) -c
$< -o
$@
86 PLUGINLDFLAGS
= $(SHARED_FLAG
) # <-- from Makefile
88 PLUGINLDFLAGS
= -T
$(PLUGINLINK_LDS
) -Wl
,--gc-sections
-Wl
,-Map
,$*.map
89 OVERLAYLDFLAGS
= -T
$(OVERLAYREF_LDS
) -Wl
,--gc-sections
-Wl
,-Map
,$*.refmap
91 PLUGINLDFLAGS
+= $(GLOBAL_LDOPTS
)
94 $(call PRINTS
,LD
$(@F
))$(CC
) $(PLUGINFLAGS
) -o
$(BUILDDIR
)/$*.elf \
97 -lgcc
$(PLUGINLDFLAGS
)
99 $(SILENT
)cp
$(BUILDDIR
)/$*.elf
$@
101 $(SILENT
)$(OC
) -O binary
$(BUILDDIR
)/$*.elf
$@
104 $(BUILDDIR
)/apps
/plugins
/%.lua
: $(ROOTDIR
)/apps
/plugins
/%.lua
105 $(call PRINTS
,CP
$(subst $(ROOTDIR
)/,,$<))cp
$< $(BUILDDIR
)/apps
/plugins
/
107 $(BUILDDIR
)/%.refmap
: $(APPSDIR
)/plugin.h
$(OVERLAYREF_LDS
) $(PLUGINLIB
) $(PLUGINBITMAPLIB
) $(LIBSETJMP
) $(PLUGIN_CRT0
)
108 $(call PRINTS
,LD
$(@F
))$(CC
) $(PLUGINFLAGS
) -o
/dev
/null \
111 -lgcc
$(OVERLAYLDFLAGS
)