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) |
| 14 | is_app_build = yes |
| 15 | endif |
| 16 | endif |
| 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) |
| 25 | ROCKS1 := $(subst $(ROOTDIR),$(BUILDDIR),$(ROCKS1)) |
| 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) |
| 38 | PLUGINLIB_OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(PLUGINLIB_OBJ)) |
| 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 | |
| 56 | # include <dir>.make from each subdir (yay!) |
| 57 | $(foreach dir,$(PLUGINSUBDIRS),$(eval include $(dir)/$(notdir $(dir)).make)) |
| 58 | |
Björn Stenberg | 52320b8 | 2009-01-12 21:56:46 +0000 | [diff] [blame] | 59 | OTHER_INC += -I$(APPSDIR)/plugins -I$(APPSDIR)/plugins/lib |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 60 | |
| 61 | # special compile flags for plugins: |
Jens Arnold | c21e2e6 | 2009-03-02 00:16:44 +0000 | [diff] [blame] | 62 | PLUGINFLAGS = -I$(APPSDIR)/plugins -DPLUGIN $(CFLAGS) |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 63 | |
Jens Arnold | f82c944 | 2009-03-04 23:41:58 +0000 | [diff] [blame] | 64 | # single-file plugins depend on their respective .o |
| 65 | $(ROCKS1): $(BUILDDIR)/%.rock: $(BUILDDIR)/%.o |
| 66 | |
| 67 | # dependency for all plugins |
Thomas Martitz | cae4ae2 | 2010-08-24 14:30:46 +0000 | [diff] [blame] | 68 | $(ROCKS): $(APPSDIR)/plugin.h $(PLUGINLINK_LDS) $(PLUGINLIB) $(PLUGINBITMAPLIB) $(PLUGIN_CRT0) $(LIBSETJMP) |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 69 | |
| 70 | $(PLUGINLIB): $(PLUGINLIB_OBJ) |
Björn Stenberg | 303b455 | 2008-11-20 16:49:55 +0000 | [diff] [blame] | 71 | $(SILENT)$(shell rm -f $@) |
Jens Arnold | 6421f94 | 2009-03-01 09:04:15 +0000 | [diff] [blame] | 72 | $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 73 | |
Rafaël Carré | a9e2a71 | 2010-01-24 15:32:23 +0000 | [diff] [blame] | 74 | $(PLUGINLINK_LDS): $(PLUGIN_LDS) $(CONFIGFILE) |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 75 | $(call PRINTS,PP $(@F)) |
Björn Stenberg | 7167a7a | 2008-11-20 16:07:01 +0000 | [diff] [blame] | 76 | $(shell mkdir -p $(dir $@)) |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 77 | $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS)) |
| 78 | |
Jens Arnold | c21e2e6 | 2009-03-02 00:16:44 +0000 | [diff] [blame] | 79 | $(OVERLAYREF_LDS): $(PLUGIN_LDS) |
| 80 | $(call PRINTS,PP $(@F)) |
| 81 | $(shell mkdir -p $(dir $@)) |
| 82 | $(call preprocess2file,$<,$@,-DOVERLAY_OFFSET=0) |
| 83 | |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 84 | $(BUILDDIR)/credits.raw credits.raw: $(DOCSDIR)/CREDITS |
| 85 | $(call PRINTS,Create credits.raw)perl $(APPSDIR)/plugins/credits.pl < $< > $(BUILDDIR)/$(@F) |
| 86 | |
| 87 | # special dependencies |
Jens Arnold | c21e2e6 | 2009-03-02 00:16:44 +0000 | [diff] [blame] | 88 | $(BUILDDIR)/apps/plugins/wav2wv.rock: $(BUILDDIR)/apps/codecs/libwavpack.a $(PLUGINLIB) |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 89 | |
Andree Buschmann | 6a989b8 | 2011-09-07 19:21:57 +0000 | [diff] [blame] | 90 | # Do not use '-ffunction-sections' and '-fdata-sections' when compiling sdl-sim |
| 91 | ifeq ($(findstring sdl-sim, $(APP_TYPE)), sdl-sim) |
| 92 | PLUGINLIBFLAGS = $(PLUGINFLAGS) |
| 93 | else |
| 94 | PLUGINLIBFLAGS = $(PLUGINFLAGS) -ffunction-sections -fdata-sections |
| 95 | endif |
| 96 | |
Jens Arnold | f42b934 | 2009-03-03 08:28:50 +0000 | [diff] [blame] | 97 | # 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] | 98 | $(BUILDDIR)/apps/plugins/lib/%.o: $(ROOTDIR)/apps/plugins/lib/%.c |
| 99 | $(SILENT)mkdir -p $(dir $@) |
Andree Buschmann | 6a989b8 | 2011-09-07 19:21:57 +0000 | [diff] [blame] | 100 | $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINLIBFLAGS) -c $< -o $@ |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 101 | |
| 102 | # special pattern rule for compiling plugins with extra flags |
Teruaki Kawashima | e3fc65c | 2010-01-17 13:03:10 +0000 | [diff] [blame] | 103 | $(BUILDDIR)/apps/plugins/%.o: $(ROOTDIR)/apps/plugins/%.c |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 104 | $(SILENT)mkdir -p $(dir $@) |
| 105 | $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -c $< -o $@ |
| 106 | |
Thomas Martitz | 57613ea | 2010-07-10 13:49:49 +0000 | [diff] [blame] | 107 | ifdef APP_TYPE |
Nils Wallménius | 331b23d | 2011-06-07 11:56:23 +0000 | [diff] [blame] | 108 | PLUGINLDFLAGS = $(SHARED_LDFLAG) # <-- from Makefile |
| 109 | PLUGINFLAGS += $(SHARED_CFLAGS) # <-- from Makefile |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 110 | else |
| 111 | PLUGINLDFLAGS = -T$(PLUGINLINK_LDS) -Wl,--gc-sections -Wl,-Map,$*.map |
Jens Arnold | c21e2e6 | 2009-03-02 00:16:44 +0000 | [diff] [blame] | 112 | OVERLAYLDFLAGS = -T$(OVERLAYREF_LDS) -Wl,--gc-sections -Wl,-Map,$*.refmap |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 113 | endif |
Frank Gevaerts | b8286d4 | 2010-07-03 20:58:22 +0000 | [diff] [blame] | 114 | PLUGINLDFLAGS += $(GLOBAL_LDOPTS) |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 115 | |
Thomas Martitz | cae4ae2 | 2010-08-24 14:30:46 +0000 | [diff] [blame] | 116 | $(BUILDDIR)/%.rock: |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 117 | $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(BUILDDIR)/$*.elf \ |
| 118 | $(filter %.o, $^) \ |
Jens Arnold | c21e2e6 | 2009-03-02 00:16:44 +0000 | [diff] [blame] | 119 | $(filter %.a, $+) \ |
Björn Stenberg | c6b3d38 | 2008-11-20 11:27:31 +0000 | [diff] [blame] | 120 | -lgcc $(PLUGINLDFLAGS) |
Thomas Martitz | 0bc64a6 | 2012-01-03 21:15:11 +0000 | [diff] [blame^] | 121 | ifndef APP_TYPE |
| 122 | $(SILENT)$(OC) -O binary $(BUILDDIR)/$*.elf $@ # objcopy native |
| 123 | else ifeq (,$(findstring sdl-sim,$(APP_TYPE))) |
| 124 | $(SILENT)$(OC) -S -x $(BUILDDIR)/$*.elf $@ # objcopy hosted |
Björn Stenberg | 838c74f | 2008-11-20 12:09:36 +0000 | [diff] [blame] | 125 | else |
Thomas Martitz | 0bc64a6 | 2012-01-03 21:15:11 +0000 | [diff] [blame^] | 126 | $(SILENT)cp $(BUILDDIR)/$*.elf $@ # no objcopy, keep debug symbols |
Jens Arnold | c21e2e6 | 2009-03-02 00:16:44 +0000 | [diff] [blame] | 127 | endif |
| 128 | |
Maurus Cuelenaere | 21bca65 | 2009-10-28 22:48:22 +0000 | [diff] [blame] | 129 | $(BUILDDIR)/apps/plugins/%.lua: $(ROOTDIR)/apps/plugins/%.lua |
| 130 | $(call PRINTS,CP $(subst $(ROOTDIR)/,,$<))cp $< $(BUILDDIR)/apps/plugins/ |
| 131 | |
Thomas Martitz | cae4ae2 | 2010-08-24 14:30:46 +0000 | [diff] [blame] | 132 | $(BUILDDIR)/%.refmap: $(APPSDIR)/plugin.h $(OVERLAYREF_LDS) $(PLUGINLIB) $(PLUGINBITMAPLIB) $(LIBSETJMP) $(PLUGIN_CRT0) |
Jens Arnold | c21e2e6 | 2009-03-02 00:16:44 +0000 | [diff] [blame] | 133 | $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o /dev/null \ |
| 134 | $(filter %.o, $^) \ |
Jens Arnold | 6436b39 | 2009-03-02 08:16:36 +0000 | [diff] [blame] | 135 | $(filter %.a, $+) \ |
Jens Arnold | c21e2e6 | 2009-03-02 00:16:44 +0000 | [diff] [blame] | 136 | -lgcc $(OVERLAYLDFLAGS) |