Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 1 | # __________ __ ___. |
| 2 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 3 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 4 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 5 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 6 | # \/ \/ \/ \/ \/ |
Björn Stenberg | a091d20 | 2008-11-25 19:54:23 +0000 | [diff] [blame] | 7 | # $Id$ |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 8 | # |
| 9 | |
| 10 | # single-file plugins: |
Thomas Jarosch | e3a3e2c | 2011-02-24 23:35:16 +0000 | [diff] [blame] | 11 | is_app_build = |
| 12 | ifdef APP_TYPE |
| 13 | ifneq ($(APP_TYPE),sdl-sim) |
Simon Rothen | 0b5ad60 | 2014-08-30 13:15:53 +0200 | [diff] [blame] | 14 | is_app_build = yes |
| 15 | endif |
Thomas Jarosch | e3a3e2c | 2011-02-24 23:35:16 +0000 | [diff] [blame] | 16 | endif |
Thomas Jarosch | e3a3e2c | 2011-02-24 23:35:16 +0000 | [diff] [blame] | 17 | |
| 18 | ifdef is_app_build |
| 19 | PLUGINS_SRC = $(call preprocess, $(APPSDIR)/plugins/SOURCES.app_build) |
| 20 | else |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 21 | PLUGINS_SRC = $(call preprocess, $(APPSDIR)/plugins/SOURCES) |
Thomas Jarosch | e3a3e2c | 2011-02-24 23:35:16 +0000 | [diff] [blame] | 22 | endif |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 23 | OTHER_SRC += $(PLUGINS_SRC) |
Jens Arnold | f82c944 | 2009-03-04 23:41:58 +0000 | [diff] [blame] | 24 | ROCKS1 := $(PLUGINS_SRC:.c=.rock) |
Vencislav Atanasov | 7f9fc20 | 2019-07-28 19:44:23 +0300 | [diff] [blame^] | 25 | ROCKS1 := $(call full_path_subst,$(ROOTDIR)/%,$(BUILDDIR)/%,$(ROCKS1)) |
Jens Arnold | f82c944 | 2009-03-04 23:41:58 +0000 | [diff] [blame] | 26 | |
| 27 | ROCKS := $(ROCKS1) |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 28 | |
Maurus Cuelenaere | 21bca65 | 2009-10-28 22:48:22 +0000 | [diff] [blame] | 29 | ROCKS1 := $(ROCKS1:%.lua=) |
| 30 | |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 31 | # libplugin.a |
| 32 | PLUGINLIB := $(BUILDDIR)/apps/plugins/libplugin.a |
| 33 | PLUGINLIB_SRC = $(call preprocess, $(APPSDIR)/plugins/lib/SOURCES) |
| 34 | OTHER_SRC += $(PLUGINLIB_SRC) |
| 35 | |
| 36 | PLUGINLIB_OBJ := $(PLUGINLIB_SRC:.c=.o) |
| 37 | PLUGINLIB_OBJ := $(PLUGINLIB_OBJ:.S=.o) |
Vencislav Atanasov | 7f9fc20 | 2019-07-28 19:44:23 +0300 | [diff] [blame^] | 38 | PLUGINLIB_OBJ := $(call full_path_subst,$(ROOTDIR)/%,$(BUILDDIR)/%,$(PLUGINLIB_OBJ)) |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 39 | |
Jens Arnold | c21e2e6 | 2009-03-02 00:16:44 +0000 | [diff] [blame] | 40 | ### build data / rules |
Thomas Martitz | 57613ea | 2010-07-10 13:49:49 +0000 | [diff] [blame] | 41 | ifndef APP_TYPE |
Rafaël Carré | a9e2a71 | 2010-01-24 15:32:23 +0000 | [diff] [blame] | 42 | CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h |
Jens Arnold | c21e2e6 | 2009-03-02 00:16:44 +0000 | [diff] [blame] | 43 | PLUGIN_LDS := $(APPSDIR)/plugins/plugin.lds |
| 44 | PLUGINLINK_LDS := $(BUILDDIR)/apps/plugins/plugin.link |
| 45 | OVERLAYREF_LDS := $(BUILDDIR)/apps/plugins/overlay_ref.link |
| 46 | endif |
Teruaki Kawashima | 2edeb56 | 2010-10-17 11:40:39 +0000 | [diff] [blame] | 47 | OTHER_SRC += $(ROOTDIR)/apps/plugins/plugin_crt0.c |
Thomas Martitz | cae4ae2 | 2010-08-24 14:30:46 +0000 | [diff] [blame] | 48 | PLUGIN_CRT0 := $(BUILDDIR)/apps/plugins/plugin_crt0.o |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 49 | # multifile plugins (subdirs): |
Thomas Jarosch | e3a3e2c | 2011-02-24 23:35:16 +0000 | [diff] [blame] | 50 | ifdef is_app_build |
| 51 | PLUGINSUBDIRS := $(call preprocess, $(APPSDIR)/plugins/SUBDIRS.app_build) |
| 52 | else |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 53 | PLUGINSUBDIRS := $(call preprocess, $(APPSDIR)/plugins/SUBDIRS) |
Thomas Jarosch | e3a3e2c | 2011-02-24 23:35:16 +0000 | [diff] [blame] | 54 | endif |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 55 | |
Michael Sevakis | 95e23de | 2013-04-16 17:47:58 -0400 | [diff] [blame] | 56 | PLUGIN_LIBS := $(PLUGINLIB) $(PLUGINBITMAPLIB) $(SETJMPLIB) $(FIXEDPOINTLIB) |
Thomas Martitz | f269aa0 | 2012-03-26 22:24:57 +0200 | [diff] [blame] | 57 | |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 58 | # include <dir>.make from each subdir (yay!) |
| 59 | $(foreach dir,$(PLUGINSUBDIRS),$(eval include $(dir)/$(notdir $(dir)).make)) |
| 60 | |
Björn Stenberg | 52320b8 | 2009-01-12 21:56:46 +0000 | [diff] [blame] | 61 | OTHER_INC += -I$(APPSDIR)/plugins -I$(APPSDIR)/plugins/lib |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 62 | |
| 63 | # special compile flags for plugins: |
Jens Arnold | c21e2e6 | 2009-03-02 00:16:44 +0000 | [diff] [blame] | 64 | PLUGINFLAGS = -I$(APPSDIR)/plugins -DPLUGIN $(CFLAGS) |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 65 | |
Jens Arnold | f82c944 | 2009-03-04 23:41:58 +0000 | [diff] [blame] | 66 | # single-file plugins depend on their respective .o |
| 67 | $(ROCKS1): $(BUILDDIR)/%.rock: $(BUILDDIR)/%.o |
| 68 | |
| 69 | # dependency for all plugins |
Thomas Martitz | f269aa0 | 2012-03-26 22:24:57 +0200 | [diff] [blame] | 70 | $(ROCKS): $(APPSDIR)/plugin.h $(PLUGINLINK_LDS) $(PLUGIN_LIBS) $(PLUGIN_CRT0) |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 71 | |
| 72 | $(PLUGINLIB): $(PLUGINLIB_OBJ) |
Björn Stenberg | 303b455 | 2008-11-20 16:49:55 +0000 | [diff] [blame] | 73 | $(SILENT)$(shell rm -f $@) |
Jens Arnold | 6421f94 | 2009-03-01 09:04:15 +0000 | [diff] [blame] | 74 | $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 75 | |
Rafaël Carré | a9e2a71 | 2010-01-24 15:32:23 +0000 | [diff] [blame] | 76 | $(PLUGINLINK_LDS): $(PLUGIN_LDS) $(CONFIGFILE) |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 77 | $(call PRINTS,PP $(@F)) |
Björn Stenberg | 7167a7a | 2008-11-20 16:07:01 +0000 | [diff] [blame] | 78 | $(shell mkdir -p $(dir $@)) |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 79 | $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS)) |
| 80 | |
Jens Arnold | c21e2e6 | 2009-03-02 00:16:44 +0000 | [diff] [blame] | 81 | $(OVERLAYREF_LDS): $(PLUGIN_LDS) |
| 82 | $(call PRINTS,PP $(@F)) |
| 83 | $(shell mkdir -p $(dir $@)) |
| 84 | $(call preprocess2file,$<,$@,-DOVERLAY_OFFSET=0) |
| 85 | |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 86 | $(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 Bartell | f40bfc9 | 2011-06-25 21:32:25 -0400 | [diff] [blame] | 90 | $(BUILDDIR)/apps/plugins/wav2wv.rock: $(RBCODEC_BLD)/codecs/libwavpack.a $(PLUGIN_LIBS) |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 91 | |
Andree Buschmann | 6a989b8 | 2011-09-07 19:21:57 +0000 | [diff] [blame] | 92 | # Do not use '-ffunction-sections' and '-fdata-sections' when compiling sdl-sim |
| 93 | ifeq ($(findstring sdl-sim, $(APP_TYPE)), sdl-sim) |
| 94 | PLUGINLIBFLAGS = $(PLUGINFLAGS) |
| 95 | else |
| 96 | PLUGINLIBFLAGS = $(PLUGINFLAGS) -ffunction-sections -fdata-sections |
| 97 | endif |
| 98 | |
Jens Arnold | f42b934 | 2009-03-03 08:28:50 +0000 | [diff] [blame] | 99 | # special pattern rule for compiling plugin lib (with function and data sections) |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 100 | $(BUILDDIR)/apps/plugins/lib/%.o: $(ROOTDIR)/apps/plugins/lib/%.c |
| 101 | $(SILENT)mkdir -p $(dir $@) |
Andree Buschmann | 6a989b8 | 2011-09-07 19:21:57 +0000 | [diff] [blame] | 102 | $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINLIBFLAGS) -c $< -o $@ |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 103 | |
| 104 | # special pattern rule for compiling plugins with extra flags |
Teruaki Kawashima | e3fc65c | 2010-01-17 13:03:10 +0000 | [diff] [blame] | 105 | $(BUILDDIR)/apps/plugins/%.o: $(ROOTDIR)/apps/plugins/%.c |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 106 | $(SILENT)mkdir -p $(dir $@) |
| 107 | $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -c $< -o $@ |
| 108 | |
Thomas Martitz | 57613ea | 2010-07-10 13:49:49 +0000 | [diff] [blame] | 109 | ifdef APP_TYPE |
Thomas Martitz | 6d19275 | 2012-01-17 15:08:08 +0100 | [diff] [blame] | 110 | PLUGINLDFLAGS = $(SHARED_LDFLAG) -Wl,-Map,$*.map |
Nils Wallménius | 331b23d | 2011-06-07 11:56:23 +0000 | [diff] [blame] | 111 | PLUGINFLAGS += $(SHARED_CFLAGS) # <-- from Makefile |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 112 | else |
| 113 | PLUGINLDFLAGS = -T$(PLUGINLINK_LDS) -Wl,--gc-sections -Wl,-Map,$*.map |
Jens Arnold | c21e2e6 | 2009-03-02 00:16:44 +0000 | [diff] [blame] | 114 | OVERLAYLDFLAGS = -T$(OVERLAYREF_LDS) -Wl,--gc-sections -Wl,-Map,$*.refmap |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 115 | endif |
Frank Gevaerts | b8286d4 | 2010-07-03 20:58:22 +0000 | [diff] [blame] | 116 | PLUGINLDFLAGS += $(GLOBAL_LDOPTS) |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 117 | |
Thomas Martitz | cae4ae2 | 2010-08-24 14:30:46 +0000 | [diff] [blame] | 118 | $(BUILDDIR)/%.rock: |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 119 | $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(BUILDDIR)/$*.elf \ |
| 120 | $(filter %.o, $^) \ |
Jens Arnold | c21e2e6 | 2009-03-02 00:16:44 +0000 | [diff] [blame] | 121 | $(filter %.a, $+) \ |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 122 | -lgcc $(PLUGINLDFLAGS) |
Thomas Martitz | 4b56ee0 | 2012-04-04 21:43:22 +0200 | [diff] [blame] | 123 | $(SILENT)$(call objcopy,$(BUILDDIR)/$*.elf,$@) |
Jens Arnold | c21e2e6 | 2009-03-02 00:16:44 +0000 | [diff] [blame] | 124 | |
Maurus Cuelenaere | 21bca65 | 2009-10-28 22:48:22 +0000 | [diff] [blame] | 125 | $(BUILDDIR)/apps/plugins/%.lua: $(ROOTDIR)/apps/plugins/%.lua |
| 126 | $(call PRINTS,CP $(subst $(ROOTDIR)/,,$<))cp $< $(BUILDDIR)/apps/plugins/ |
| 127 | |
Thomas Martitz | d26bbb9 | 2012-03-26 23:41:38 +0200 | [diff] [blame] | 128 | $(BUILDDIR)/%.refmap: $(APPSDIR)/plugin.h $(OVERLAYREF_LDS) $(PLUGIN_LIBS) $(PLUGIN_CRT0) |
Jens Arnold | c21e2e6 | 2009-03-02 00:16:44 +0000 | [diff] [blame] | 129 | $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o /dev/null \ |
| 130 | $(filter %.o, $^) \ |
Jens Arnold | 6436b39 | 2009-03-02 08:16:36 +0000 | [diff] [blame] | 131 | $(filter %.a, $+) \ |
Jens Arnold | c21e2e6 | 2009-03-02 00:16:44 +0000 | [diff] [blame] | 132 | -lgcc $(OVERLAYLDFLAGS) |