A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 100 lines 4.1 kB view raw
1# __________ __ ___. 2# Open \______ \ ____ ____ | | _\_ |__ _______ ___ 3# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 4# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6# \/ \/ \/ \/ \/ 7# $Id$ 8# 9 10# preprocess - run preprocessor on a file and return the result as a string 11# 12# The weird grep -v thing in here is due to Apple's stupidities and is needed 13# to make this do right when used on Mac OS X. 14# 15# The sed line is to prepend the directory to all source files 16 17# This is needed because GNU Make older than 4.3 treats this as the start 18# of a comment even within a $(shell) call and requires a backslash escape. 19# Newer Makes pass the whole "\#" through, making the backslash visible in 20# the shell. To safely pass a literal "#", it has to go in a variable. 21_hash_ = \# 22 23preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c -include config.h $(1) | \ 24 grep -v "^$(_hash_)" | grep -v "^ *$$" | \ 25 sed -e 's:^..*:$(dir $(1))&:') 26 27preprocess2file = $(shell $(CC) $(PPCFLAGS) $(3) -E -P -x c -include config.h $(1) | \ 28 grep -v '^$(_hash_)' | grep -v "^$$" > $(2)) 29 30asmdefs2file = $(SILENT)$(CC) $(PPCFLAGS) $(3) -S -x c -o - -include config.h $(1) | \ 31 perl -ne 'if(/^_?AD_(\w+):$$/){$$var=$$1}else{/^\W\.(?:word|long)\W(.*)$$/ && $$var && print "\#define $$var $$1\n";$$var=0}' > $(2) 32 33c2obj = $(addsuffix .o,$(basename $(call full_path_subst,$(ROOTDIR)/%,$(BUILDDIR)/%,$(1)))) 34 35a2lnk = $(patsubst lib%.a,-l%,$(notdir $(1))) 36 37# objcopy wrapper that keeps debug symbols in DEBUG builds 38# handles the $(1) == $(2) case too 39ifndef APP_TYPE 40objcopy = $(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $(1) $(2) # objcopy native 41else ifneq (,$(findstring sdl-sim,$(APP_TYPE))) 42objcopy = cp $(1) $(1).tmp;mv -f $(1).tmp $(2) # objcopy simulator 43else ifneq (,$(findstring ctru,$(MODELNAME))) # 3dsxtool requires symbols 44objcopy = cp $(1) $(1).tmp;mv -f $(1).tmp $(2) 45else 46 ifdef DEBUG 47 objcopy = cp $(1) $(1).tmp;mv -f $(1).tmp $(2) # objcopy hosted (DEBUG) 48 else 49 objcopy = $(OC) -S -x $(1) $(2) # objcopy hosted (!DEBUG) 50 endif 51endif 52 53# calculate dependencies for a list of source files $(2) and output them to $(1) 54mkdepfile = $(SILENT)perl $(TOOLSDIR)/multigcc.pl $(CC) $(PPCFLAGS) $(OTHER_INC) -MG -MM -include config.h -- $(2) | \ 55 sed -e "s: lang.h: lang/lang.h:" \ 56 -e 's:_asmdefs.o:_asmdefs.h:' \ 57 -e "s: max_language_size.h: lang/max_language_size.h:" | \ 58 $(TOOLSDIR)/addtargetdir.pl $(ROOTDIR) $(BUILDDIR) \ 59 >> $(1) 60 61# function to create .bmp dependencies 62bmpdepfile = $(SILENT) \ 63 for each in $(2); do \ 64 obj=`echo $$each | sed -e 's/\.bmp/.o/' -e 's:$(ROOTDIR):$(BUILDDIR):'`; \ 65 src=`echo $$each | sed -e 's/\.bmp/.c/' -e 's:$(ROOTDIR):$(BUILDDIR):'`; \ 66 hdr=`echo $$each | sed -e 's/.*\/\(.*\)\..*\.bmp/bitmaps\/\1\.h/'`; \ 67 echo $$obj: $$src; \ 68 echo $$src: $$each; \ 69 echo $(BUILDDIR)/$$hdr: $$src; \ 70 done \ 71 >> $(1) 72 73ifndef V 74SILENT:=@ 75else 76VERBOSEOPT:=-v 77endif 78PRINTS=$(SILENT)$(call info,$(1)) 79 80# old 'make' versions don't have the built-in 'info' function 81info=old$(shell echo >&2 "Consider upgrading to GNU make 3.81+ for optimum build performance.") 82ifeq ($(call info),old) 83export info=echo "$$(1)"; 84endif 85 86# path substituion can be surprisingly tricky, indeed the following almost 87# always work but not quite: 88# BMPOBJ = $(BMP:$(ROOTDIR)/%.bmp=$(BUILDDIR)/%.o) 89# indeed if 90# ROOTDIR=/rockbox 91# BUILDDIR=/rockbox/build-bla 92# then: 93# /rockbox/apps/bitmaps/rockboxlogo-bla.bmp -> /rockbox/apps/bitmaps/rockbox/build-blalogo.o 94# this function ensure that this type of problems does not occur 95# 96# usage: $(call full_path_subst,patterm,replacement,text) 97# 98# example: $(call full_path_subst,$(ROOTDIR)/%.bmp,$(BUILDDIR)/%.o,$(BMP)) 99NO_MATCH=this_string_will_never_match_anything 100full_path_subst=$(patsubst $(NO_MATCH)/%,%, $(patsubst $(NO_MATCH)/$(1), $(2), $(addprefix $(NO_MATCH)/, $(3))))