A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 176 lines 6.5 kB view raw
1# __________ __ ___. 2# Open \______ \ ____ ____ | | _\_ |__ _______ ___ 3# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 4# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6# \/ \/ \/ \/ \/ 7# $Id$ 8# 9 10# single-file plugins: 11is_app_build = 12ifdef APP_TYPE 13ifneq ($(APP_TYPE),sdl-sim) 14 is_app_build = yes 15endif 16endif 17 18ifdef is_app_build 19PLUGINS_SRC = $(call preprocess, $(APPSDIR)/plugins/SOURCES.app_build) 20else 21PLUGINS_SRC = $(call preprocess, $(APPSDIR)/plugins/SOURCES) 22endif 23OTHER_SRC += $(PLUGINS_SRC) 24ROCKS1 := $(PLUGINS_SRC:.c=.rock) 25ROCKS1 := $(call full_path_subst,$(ROOTDIR)/%,$(BUILDDIR)/%,$(ROCKS1)) 26 27ROCKS := $(ROCKS1) 28 29ROCKS1 := $(ROCKS1:%.lua=) 30 31# 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) 38PLUGINLIB_OBJ := $(call full_path_subst,$(ROOTDIR)/%,$(BUILDDIR)/%,$(PLUGINLIB_OBJ)) 39 40ifdef USE_LTO 41# We do NOT want LTO on the GCC support file. 42$(BUILDDIR)/apps/plugins/lib/gcc-support.o: PLUGINFLAGS += -fno-lto 43$(BUILDDIR)/apps/plugins/plugin_crt0.o: PLUGINFLAGS += -fno-lto 44endif 45 46### build data / rules 47ifndef APP_TYPE 48CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h 49PLUGIN_LDS := $(APPSDIR)/plugins/plugin.lds 50PLUGINLINK_LDS := $(BUILDDIR)/apps/plugins/plugin.link 51OVERLAYREF_LDS := $(BUILDDIR)/apps/plugins/overlay_ref.link 52endif 53OTHER_SRC += $(ROOTDIR)/apps/plugins/plugin_crt0.c 54PLUGIN_CRT0 := $(BUILDDIR)/apps/plugins/plugin_crt0.o 55# multifile plugins (subdirs): 56ifdef is_app_build 57PLUGINSUBDIRS := $(call preprocess, $(APPSDIR)/plugins/SUBDIRS.app_build) 58else 59PLUGINSUBDIRS := $(call preprocess, $(APPSDIR)/plugins/SUBDIRS) 60endif 61 62PLUGIN_LIBS := $(PLUGINLIB) $(PLUGINBITMAPLIB) $(SETJMPLIB) $(FIXEDPOINTLIB) 63 64# include <dir>.make from each subdir (yay!) 65$(foreach dir,$(PLUGINSUBDIRS),$(eval include $(dir)/$(notdir $(dir)).make)) 66 67OTHER_INC += -I$(APPSDIR)/plugins -I$(APPSDIR)/plugins/lib 68 69# special compile flags for plugins: 70PLUGINFLAGS = -I$(APPSDIR)/plugins -DPLUGIN $(CFLAGS) 71 72# single-file plugins depend on their respective .o 73$(ROCKS1): $(BUILDDIR)/%.rock: $(BUILDDIR)/%.o 74 75# dependency for all plugins 76$(ROCKS): $(APPSDIR)/plugin.h $(PLUGINLINK_LDS) $(PLUGIN_LIBS) $(PLUGIN_CRT0) 77 78$(PLUGINLIB): $(PLUGINLIB_OBJ) 79 $(SILENT)$(shell rm -f $@) 80 $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null 81 82$(PLUGINLINK_LDS): $(PLUGIN_LDS) $(CONFIGFILE) 83 $(call PRINTS,PP $(@F)) 84 $(shell mkdir -p $(dir $@)) 85 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS)) 86 87$(OVERLAYREF_LDS): $(PLUGIN_LDS) 88 $(call PRINTS,PP $(@F)) 89 $(shell mkdir -p $(dir $@)) 90 $(call preprocess2file,$<,$@,-DOVERLAY_OFFSET=0) 91 92$(BUILDDIR)/credits.raw credits.raw: $(DOCSDIR)/CREDITS 93 $(call PRINTS,Create credits.raw)perl $(APPSDIR)/plugins/credits.pl < $< > $(BUILDDIR)/$(@F) 94 95$(BUILDDIR)/apps/plugins/open_plugins.opx: 96 $(call PRINTS,MK open_plugins.opx) touch $< $(BUILDDIR)/apps/plugins/open_plugins.opx 97 98$(BUILDDIR)/apps/plugins/open_plugins.rock: $(BUILDDIR)/apps/plugins/open_plugins.opx 99 100# special dependencies 101$(BUILDDIR)/apps/plugins/wav2wv.rock: $(RBCODEC_BLD)/codecs/libwavpack.a $(PLUGIN_LIBS) 102 103# Do not use '-ffunction-sections' and '-fdata-sections' when compiling sdl-sim 104ifeq ($(findstring sdl-sim, $(APP_TYPE)), sdl-sim) 105 PLUGINLIBFLAGS = $(PLUGINFLAGS) 106else 107 PLUGINLIBFLAGS = $(PLUGINFLAGS) -ffunction-sections -fdata-sections 108endif 109 110ROOT_PLUGINSLIB_DIR := $(ROOTDIR)/apps/plugins/lib 111BUILD_PLUGINSLIB_DIR := $(BUILDDIR)/apps/plugins/lib 112 113# action_helper # 114ACTION_REQ := $(addprefix $(ROOT_PLUGINSLIB_DIR)/,action_helper.pl action_helper.h) \ 115 $(BUILD_PLUGINSLIB_DIR)/pluginlib_actions.o 116 117# special rule for generating and compiling action_helper 118$(BUILD_PLUGINSLIB_DIR)/action_helper.o: $(ACTION_REQ) 119 $(SILENT)mkdir -p $(dir $@) 120 $(call PRINTS,GEN $(@F))$(CC) $(PLUGINFLAGS) $(INCLUDES) -E -P \ 121 $(ROOT_PLUGINSLIB_DIR)/pluginlib_actions.h - < /dev/null | $< > $(basename $@).c 122 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(ROOT_PLUGINSLIB_DIR) \ 123 $(PLUGINLIBFLAGS) -c $(basename $@).c -o $@ 124 125# button_helper # 126BUTTON_REQ := $(addprefix $(ROOT_PLUGINSLIB_DIR)/,button_helper.pl button_helper.h) \ 127 $(BUILD_PLUGINSLIB_DIR)/action_helper.o 128 129# special rule for generating and compiling button_helper 130$(BUILD_PLUGINSLIB_DIR)/button_helper.o: $(BUTTON_REQ) $(ROOTDIR)/firmware/export/button.h 131 $(SILENT)mkdir -p $(dir $@) 132 $(call PRINTS,GEN $(@F))$(CC) $(PLUGINFLAGS) $(INCLUDES) -dM -E -P \ 133 $(addprefix -include ,button-target.h button.h) - < /dev/null | $< > $(basename $@).c 134 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(ROOT_PLUGINSLIB_DIR) \ 135 $(PLUGINLIBFLAGS) -c $(basename $@).c -o $@ 136 137# special pattern rule for compiling plugin lib (with function and data sections) 138$(BUILD_PLUGINSLIB_DIR)/%.o: $(ROOT_PLUGINSLIB_DIR)/%.c 139 $(SILENT)mkdir -p $(dir $@) 140 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINLIBFLAGS) -c $< -o $@ 141 142# special pattern rule for compiling plugins with extra flags 143$(BUILDDIR)/apps/plugins/%.o: $(ROOTDIR)/apps/plugins/%.c 144 $(SILENT)mkdir -p $(dir $@) 145 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -c $< -o $@ 146 147ifdef APP_TYPE 148 PLUGINLDFLAGS = $(SHARED_LDFLAGS) -Wl,$(LDMAP_OPT),$*.map 149 PLUGINFLAGS += $(SHARED_CFLAGS) # <-- from Makefile 150else 151 PLUGINLDFLAGS = -T$(PLUGINLINK_LDS) -Wl,--gc-sections -Wl,-Map,$*.map 152 OVERLAYLDFLAGS = -T$(OVERLAYREF_LDS) -Wl,--gc-sections -Wl,-Map,$*.refmap $(GLOBAL_LDOPTS) 153endif 154PLUGINLDFLAGS += $(GLOBAL_LDOPTS) 155 156ifdef USE_LTO 157 PLUGINFLAGS += -fno-builtin -ffreestanding 158 PLUGINLDFLAGS += -fno-builtin -ffreestanding 159 PLUGINLDFLAGS += -e plugin_start 160endif 161 162$(BUILDDIR)/%.rock: 163 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(BUILDDIR)/$*.elf \ 164 $(filter %.o, $^) \ 165 $(filter %.a, $+) \ 166 -lgcc $(PLUGINLDFLAGS) 167 $(SILENT)$(call objcopy,$(BUILDDIR)/$*.elf,$@) 168 169$(BUILDDIR)/apps/plugins/%.lua: $(ROOTDIR)/apps/plugins/%.lua 170 $(call PRINTS,CP $(subst $(ROOTDIR)/,,$<))cp $< $(BUILDDIR)/apps/plugins/ 171 172$(BUILDDIR)/%.refmap: $(APPSDIR)/plugin.h $(OVERLAYREF_LDS) $(PLUGIN_LIBS) $(PLUGIN_CRT0) 173 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o /dev/null \ 174 $(filter %.o, $^) \ 175 $(filter %.a, $+) \ 176 -lgcc $(OVERLAYLDFLAGS)