2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 # single-file plugins:
13 ifneq ($(APP_TYPE
),sdl-sim
)
19 PLUGINS_SRC
= $(call preprocess
, $(APPSDIR
)/plugins
/SOURCES.app_build
)
21 PLUGINS_SRC
= $(call preprocess
, $(APPSDIR
)/plugins
/SOURCES
)
23 OTHER_SRC
+= $(PLUGINS_SRC
)
24 ROCKS1
:= $(PLUGINS_SRC
:.c
=.rock
)
25 ROCKS1
:= $(subst $(ROOTDIR
),$(BUILDDIR
),$(ROCKS1
))
29 ROCKS1
:= $(ROCKS1
:%.lua
=)
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
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
47 OTHER_SRC
+= $(ROOTDIR
)/apps
/plugins
/plugin_crt0.c
48 PLUGIN_CRT0
:= $(BUILDDIR
)/apps
/plugins
/plugin_crt0.o
49 # multifile plugins (subdirs):
51 PLUGINSUBDIRS
:= $(call preprocess
, $(APPSDIR
)/plugins
/SUBDIRS.app_build
)
53 PLUGINSUBDIRS
:= $(call preprocess
, $(APPSDIR
)/plugins
/SUBDIRS
)
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
$@
101 PLUGINLDFLAGS
= $(SHARED_FLAG
) # <-- from Makefile
103 PLUGINLDFLAGS
= -T
$(PLUGINLINK_LDS
) -Wl
,--gc-sections
-Wl
,-Map
,$*.map
104 OVERLAYLDFLAGS
= -T
$(OVERLAYREF_LDS
) -Wl
,--gc-sections
-Wl
,-Map
,$*.refmap
106 PLUGINLDFLAGS
+= $(GLOBAL_LDOPTS
)
109 $(call PRINTS
,LD
$(@F
))$(CC
) $(PLUGINFLAGS
) -o
$(BUILDDIR
)/$*.elf \
112 -lgcc
$(PLUGINLDFLAGS
)
114 $(SILENT
)cp
$(BUILDDIR
)/$*.elf
$@
116 $(SILENT
)$(OC
) -O binary
$(BUILDDIR
)/$*.elf
$@
119 $(BUILDDIR
)/apps
/plugins
/%.lua
: $(ROOTDIR
)/apps
/plugins
/%.lua
120 $(call PRINTS
,CP
$(subst $(ROOTDIR
)/,,$<))cp
$< $(BUILDDIR
)/apps
/plugins
/
122 $(BUILDDIR
)/%.refmap
: $(APPSDIR
)/plugin.h
$(OVERLAYREF_LDS
) $(PLUGINLIB
) $(PLUGINBITMAPLIB
) $(LIBSETJMP
) $(PLUGIN_CRT0
)
123 $(call PRINTS
,LD
$(@F
))$(CC
) $(PLUGINFLAGS
) -o
/dev
/null \
126 -lgcc
$(OVERLAYLDFLAGS
)