blob: d395c00e82e78619b9fc85a85fea13f8dc4aa7a3 [file] [log] [blame]
Björn Stenbergc6b3d382008-11-20 11:27:31 +00001# __________ __ ___.
2# Open \______ \ ____ ____ | | _\_ |__ _______ ___
3# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6# \/ \/ \/ \/ \/
Björn Stenberga091d202008-11-25 19:54:23 +00007# $Id$
Björn Stenbergc6b3d382008-11-20 11:27:31 +00008#
9
10# single-file plugins:
Thomas Jarosche3a3e2c2011-02-24 23:35:16 +000011is_app_build =
12ifdef APP_TYPE
13ifneq ($(APP_TYPE),sdl-sim)
Simon Rothen0b5ad602014-08-30 13:15:53 +020014 is_app_build = yes
15endif
Thomas Jarosche3a3e2c2011-02-24 23:35:16 +000016endif
Thomas Jarosche3a3e2c2011-02-24 23:35:16 +000017
18ifdef is_app_build
19PLUGINS_SRC = $(call preprocess, $(APPSDIR)/plugins/SOURCES.app_build)
20else
Björn Stenbergc6b3d382008-11-20 11:27:31 +000021PLUGINS_SRC = $(call preprocess, $(APPSDIR)/plugins/SOURCES)
Thomas Jarosche3a3e2c2011-02-24 23:35:16 +000022endif
Björn Stenbergc6b3d382008-11-20 11:27:31 +000023OTHER_SRC += $(PLUGINS_SRC)
Jens Arnoldf82c9442009-03-04 23:41:58 +000024ROCKS1 := $(PLUGINS_SRC:.c=.rock)
Vencislav Atanasov7f9fc202019-07-28 19:44:23 +030025ROCKS1 := $(call full_path_subst,$(ROOTDIR)/%,$(BUILDDIR)/%,$(ROCKS1))
Jens Arnoldf82c9442009-03-04 23:41:58 +000026
27ROCKS := $(ROCKS1)
Björn Stenbergc6b3d382008-11-20 11:27:31 +000028
Maurus Cuelenaere21bca652009-10-28 22:48:22 +000029ROCKS1 := $(ROCKS1:%.lua=)
30
Björn Stenbergc6b3d382008-11-20 11:27:31 +000031# libplugin.a
32PLUGINLIB := $(BUILDDIR)/apps/plugins/libplugin.a
33PLUGINLIB_SRC = $(call preprocess, $(APPSDIR)/plugins/lib/SOURCES)
34OTHER_SRC += $(PLUGINLIB_SRC)
35
36PLUGINLIB_OBJ := $(PLUGINLIB_SRC:.c=.o)
37PLUGINLIB_OBJ := $(PLUGINLIB_OBJ:.S=.o)
Vencislav Atanasov7f9fc202019-07-28 19:44:23 +030038PLUGINLIB_OBJ := $(call full_path_subst,$(ROOTDIR)/%,$(BUILDDIR)/%,$(PLUGINLIB_OBJ))
Björn Stenbergc6b3d382008-11-20 11:27:31 +000039
Jens Arnoldc21e2e62009-03-02 00:16:44 +000040### build data / rules
Thomas Martitz57613ea2010-07-10 13:49:49 +000041ifndef APP_TYPE
Rafaël Carréa9e2a712010-01-24 15:32:23 +000042CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h
Jens Arnoldc21e2e62009-03-02 00:16:44 +000043PLUGIN_LDS := $(APPSDIR)/plugins/plugin.lds
44PLUGINLINK_LDS := $(BUILDDIR)/apps/plugins/plugin.link
45OVERLAYREF_LDS := $(BUILDDIR)/apps/plugins/overlay_ref.link
46endif
Teruaki Kawashima2edeb562010-10-17 11:40:39 +000047OTHER_SRC += $(ROOTDIR)/apps/plugins/plugin_crt0.c
Thomas Martitzcae4ae22010-08-24 14:30:46 +000048PLUGIN_CRT0 := $(BUILDDIR)/apps/plugins/plugin_crt0.o
Björn Stenbergc6b3d382008-11-20 11:27:31 +000049# multifile plugins (subdirs):
Thomas Jarosche3a3e2c2011-02-24 23:35:16 +000050ifdef is_app_build
51PLUGINSUBDIRS := $(call preprocess, $(APPSDIR)/plugins/SUBDIRS.app_build)
52else
Björn Stenbergc6b3d382008-11-20 11:27:31 +000053PLUGINSUBDIRS := $(call preprocess, $(APPSDIR)/plugins/SUBDIRS)
Thomas Jarosche3a3e2c2011-02-24 23:35:16 +000054endif
Björn Stenbergc6b3d382008-11-20 11:27:31 +000055
Michael Sevakis95e23de2013-04-16 17:47:58 -040056PLUGIN_LIBS := $(PLUGINLIB) $(PLUGINBITMAPLIB) $(SETJMPLIB) $(FIXEDPOINTLIB)
Thomas Martitzf269aa02012-03-26 22:24:57 +020057
Björn Stenbergc6b3d382008-11-20 11:27:31 +000058# include <dir>.make from each subdir (yay!)
59$(foreach dir,$(PLUGINSUBDIRS),$(eval include $(dir)/$(notdir $(dir)).make))
60
Björn Stenberg52320b82009-01-12 21:56:46 +000061OTHER_INC += -I$(APPSDIR)/plugins -I$(APPSDIR)/plugins/lib
Björn Stenbergc6b3d382008-11-20 11:27:31 +000062
63# special compile flags for plugins:
Jens Arnoldc21e2e62009-03-02 00:16:44 +000064PLUGINFLAGS = -I$(APPSDIR)/plugins -DPLUGIN $(CFLAGS)
Björn Stenbergc6b3d382008-11-20 11:27:31 +000065
Jens Arnoldf82c9442009-03-04 23:41:58 +000066# single-file plugins depend on their respective .o
67$(ROCKS1): $(BUILDDIR)/%.rock: $(BUILDDIR)/%.o
68
69# dependency for all plugins
Thomas Martitzf269aa02012-03-26 22:24:57 +020070$(ROCKS): $(APPSDIR)/plugin.h $(PLUGINLINK_LDS) $(PLUGIN_LIBS) $(PLUGIN_CRT0)
Björn Stenbergc6b3d382008-11-20 11:27:31 +000071
72$(PLUGINLIB): $(PLUGINLIB_OBJ)
Björn Stenberg303b4552008-11-20 16:49:55 +000073 $(SILENT)$(shell rm -f $@)
Jens Arnold6421f942009-03-01 09:04:15 +000074 $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null
Björn Stenbergc6b3d382008-11-20 11:27:31 +000075
Rafaël Carréa9e2a712010-01-24 15:32:23 +000076$(PLUGINLINK_LDS): $(PLUGIN_LDS) $(CONFIGFILE)
Björn Stenbergc6b3d382008-11-20 11:27:31 +000077 $(call PRINTS,PP $(@F))
Björn Stenberg7167a7a2008-11-20 16:07:01 +000078 $(shell mkdir -p $(dir $@))
Björn Stenbergc6b3d382008-11-20 11:27:31 +000079 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
80
Jens Arnoldc21e2e62009-03-02 00:16:44 +000081$(OVERLAYREF_LDS): $(PLUGIN_LDS)
82 $(call PRINTS,PP $(@F))
83 $(shell mkdir -p $(dir $@))
84 $(call preprocess2file,$<,$@,-DOVERLAY_OFFSET=0)
85
Björn Stenbergc6b3d382008-11-20 11:27:31 +000086$(BUILDDIR)/credits.raw credits.raw: $(DOCSDIR)/CREDITS
87 $(call PRINTS,Create credits.raw)perl $(APPSDIR)/plugins/credits.pl < $< > $(BUILDDIR)/$(@F)
88
89# special dependencies
Sean Bartellf40bfc92011-06-25 21:32:25 -040090$(BUILDDIR)/apps/plugins/wav2wv.rock: $(RBCODEC_BLD)/codecs/libwavpack.a $(PLUGIN_LIBS)
Björn Stenbergc6b3d382008-11-20 11:27:31 +000091
Andree Buschmann6a989b82011-09-07 19:21:57 +000092# Do not use '-ffunction-sections' and '-fdata-sections' when compiling sdl-sim
93ifeq ($(findstring sdl-sim, $(APP_TYPE)), sdl-sim)
94 PLUGINLIBFLAGS = $(PLUGINFLAGS)
95else
96 PLUGINLIBFLAGS = $(PLUGINFLAGS) -ffunction-sections -fdata-sections
97endif
98
Jens Arnoldf42b9342009-03-03 08:28:50 +000099# special pattern rule for compiling plugin lib (with function and data sections)
Björn Stenbergc6b3d382008-11-20 11:27:31 +0000100$(BUILDDIR)/apps/plugins/lib/%.o: $(ROOTDIR)/apps/plugins/lib/%.c
101 $(SILENT)mkdir -p $(dir $@)
Andree Buschmann6a989b82011-09-07 19:21:57 +0000102 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINLIBFLAGS) -c $< -o $@
Björn Stenbergc6b3d382008-11-20 11:27:31 +0000103
104# special pattern rule for compiling plugins with extra flags
Teruaki Kawashimae3fc65c2010-01-17 13:03:10 +0000105$(BUILDDIR)/apps/plugins/%.o: $(ROOTDIR)/apps/plugins/%.c
Björn Stenbergc6b3d382008-11-20 11:27:31 +0000106 $(SILENT)mkdir -p $(dir $@)
107 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -c $< -o $@
108
Thomas Martitz57613ea2010-07-10 13:49:49 +0000109ifdef APP_TYPE
Thomas Martitz6d192752012-01-17 15:08:08 +0100110 PLUGINLDFLAGS = $(SHARED_LDFLAG) -Wl,-Map,$*.map
Nils Wallménius331b23d2011-06-07 11:56:23 +0000111 PLUGINFLAGS += $(SHARED_CFLAGS) # <-- from Makefile
Björn Stenbergc6b3d382008-11-20 11:27:31 +0000112else
113 PLUGINLDFLAGS = -T$(PLUGINLINK_LDS) -Wl,--gc-sections -Wl,-Map,$*.map
Jens Arnoldc21e2e62009-03-02 00:16:44 +0000114 OVERLAYLDFLAGS = -T$(OVERLAYREF_LDS) -Wl,--gc-sections -Wl,-Map,$*.refmap
Björn Stenbergc6b3d382008-11-20 11:27:31 +0000115endif
Frank Gevaertsb8286d42010-07-03 20:58:22 +0000116PLUGINLDFLAGS += $(GLOBAL_LDOPTS)
Björn Stenbergc6b3d382008-11-20 11:27:31 +0000117
Thomas Martitzcae4ae22010-08-24 14:30:46 +0000118$(BUILDDIR)/%.rock:
Björn Stenbergc6b3d382008-11-20 11:27:31 +0000119 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(BUILDDIR)/$*.elf \
120 $(filter %.o, $^) \
Jens Arnoldc21e2e62009-03-02 00:16:44 +0000121 $(filter %.a, $+) \
Björn Stenbergc6b3d382008-11-20 11:27:31 +0000122 -lgcc $(PLUGINLDFLAGS)
Thomas Martitz4b56ee02012-04-04 21:43:22 +0200123 $(SILENT)$(call objcopy,$(BUILDDIR)/$*.elf,$@)
Jens Arnoldc21e2e62009-03-02 00:16:44 +0000124
Maurus Cuelenaere21bca652009-10-28 22:48:22 +0000125$(BUILDDIR)/apps/plugins/%.lua: $(ROOTDIR)/apps/plugins/%.lua
126 $(call PRINTS,CP $(subst $(ROOTDIR)/,,$<))cp $< $(BUILDDIR)/apps/plugins/
127
Thomas Martitzd26bbb92012-03-26 23:41:38 +0200128$(BUILDDIR)/%.refmap: $(APPSDIR)/plugin.h $(OVERLAYREF_LDS) $(PLUGIN_LIBS) $(PLUGIN_CRT0)
Jens Arnoldc21e2e62009-03-02 00:16:44 +0000129 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o /dev/null \
130 $(filter %.o, $^) \
Jens Arnold6436b392009-03-02 08:16:36 +0000131 $(filter %.a, $+) \
Jens Arnoldc21e2e62009-03-02 00:16:44 +0000132 -lgcc $(OVERLAYLDFLAGS)