summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2020-10-18 15:48:38 +0200
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2020-10-18 19:07:08 +0200
commit7603533f7fc9f7aec7c04a1258cf772247170e90 (patch)
tree38a3dab550eefeb9ba53606de4f22eec024a5bf0
parent6a94f1e995fee94c792a4bef2fd0bce1974ede7b (diff)
downloadrockbox-7603533f7fc9f7aec7c04a1258cf772247170e90.tar.gz
rockbox-7603533f7fc9f7aec7c04a1258cf772247170e90.zip
tools: Modernize rbspeex Makefile.
- Replace echo with make internal info function. - Make dependency generation implicit to avoid another compiler call. - Align object handling with libtools.make. Change-Id: Iaaddd17af04039dcd8948399bc99d21def05181d
-rw-r--r--tools/rbspeex/Makefile55
1 files changed, 28 insertions, 27 deletions
diff --git a/tools/rbspeex/Makefile b/tools/rbspeex/Makefile
index a4f337f455..231cdb5517 100644
--- a/tools/rbspeex/Makefile
+++ b/tools/rbspeex/Makefile
@@ -68,7 +68,8 @@ endif
68# fall back to our own librbspeex if no suitable found. 68# fall back to our own librbspeex if no suitable found.
69ifeq ($(SYS_SPEEX),) 69ifeq ($(SYS_SPEEX),)
70# This sets up 'SRC' based on the files mentioned in SOURCES 70# This sets up 'SRC' based on the files mentioned in SOURCES
71SRC := $(shell $(CC) $(CFLAGS) -E -P -xc $(SPEEXSRC)/SOURCES) 71SPEEXSRCS := $(shell $(CC) $(CFLAGS) -E -P -xc $(SPEEXSRC)/SOURCES)
72LIBSOURCES := $(SPEEXSRCS:%.c=$(SPEEXSRC)/%.c) rbspeex.c
72LIBS = $(TARGET_DIR)librbspeex.a 73LIBS = $(TARGET_DIR)librbspeex.a
73else 74else
74LIBS = $(SYS_SPEEX) 75LIBS = $(SYS_SPEEX)
@@ -76,57 +77,57 @@ endif
76 77
77TARGET_DIR ?= $(shell pwd)/ 78TARGET_DIR ?= $(shell pwd)/
78BUILD_DIR ?= $(TARGET_DIR)build$(COMPILETARGET) 79BUILD_DIR ?= $(TARGET_DIR)build$(COMPILETARGET)
79SOURCES = $(SRC:%.c=$(SPEEXSRC)/%.c) rbspeex.c rbspeexenc.c rbspeexdec.c 80OBJDIR = $(abspath $(BUILD_DIR))/
80OBJS = $(addprefix $(BUILD_DIR)/,$(SRC:%.c=%.o)) 81SOURCES = rbspeex.c rbspeexenc.c rbspeexdec.c
81DIRS = 82OBJS := $(addsuffix .o,$(addprefix $(OBJDIR),$(notdir $(SOURCES))))
83LIBOBJS := $(addsuffix .o,$(addprefix $(OBJDIR),$(notdir $(LIBSOURCES))))
82 84
83.PHONY : all 85.PHONY : all
84 86
85all: ../rbspeexenc ../rbspeexdec 87all: ../rbspeexenc ../rbspeexdec
86 88
87$(foreach src,$(SOURCES),$(eval $(BUILD_DIR)/$(subst .c,.o,$(notdir $(src))): $(src))) 89# create dependency files. Make sure to use the same prefix as with OBJS!
88$(foreach src,$(SOURCES),$(eval $(BUILD_DIR)/$(subst .c,.d,$(notdir $(src))): $(src))) 90$(foreach src,$(SOURCES) $(LIBSOURCES),$(eval $(addprefix $(OBJDIR),$(notdir $(src).o)): $(src)))
89DEPS = $(addprefix $(BUILD_DIR)/,$(subst .c,.d,$(notdir $(SOURCES)))) 91$(foreach src,$(SOURCES) $(LIBSOURCES),$(eval $(addprefix $(OBJDIR),$(notdir $(src).d)): $(src)))
92DEPS = $(addprefix $(OBJDIR),$(addsuffix .d,$(notdir $(SOURCES) $(LIBSOURCES))))
90-include $(DEPS) 93-include $(DEPS)
91 94
92%.d:
93 $(SILENT)$(call mkdir,$(BUILD_DIR))
94 $(SILENT)$(CC) -MG -MM -MT $(subst .d,.o,$@) $(CFLAGS) -o $(BUILD_DIR)/$(notdir $@) $<
95
96dll: $(TARGET_DIR)rbspeex.dll 95dll: $(TARGET_DIR)rbspeex.dll
97 96
98$(TARGET_DIR)rbspeex.dll: $(OBJS) $(BUILD_DIR)/rbspeex.o 97$(TARGET_DIR)rbspeex.dll: $(LIBOBJS)
99 @echo DLL $(notdir $@) 98 $(info DLL $(notdir $@))
100 $(SILENT)$(CROSS)$(CC) $(CFLAGS) -shared -o $@ $^ \ 99 $(SILENT)$(CROSS)$(CC) $(CFLAGS) -shared -o $@ $^ \
101 -Wl,--output-def,$(TARGET_DIR)rbspeex.def 100 -Wl,--output-def,$(TARGET_DIR)rbspeex.def
102 101
103$(TARGET_DIR)librbspeex.a: $(OBJS) $(BUILD_DIR)/rbspeex.o 102$(TARGET_DIR)librbspeex.a: $(LIBOBJS)
104 @echo AR $(notdir $@) 103 $(info AR $(notdir $@))
105 $(SILENT)$(call rm,$@) 104 $(SILENT)$(call rm,$@)
106 $(SILENT)$(CROSS)$(AR) rcs $@ $^ 105 $(SILENT)$(CROSS)$(AR) rcs $@ $^
107 106
108librbspeex.a: $(TARGET_DIR)librbspeex.a 107librbspeex.a: $(TARGET_DIR)librbspeex.a
109 108
110../rbspeexenc: $(OBJS) $(BUILD_DIR)/rbspeexenc.o librbspeex.a 109../rbspeexenc: $(OBJS) $(TARGET_DIR)librbspeex.a
111 @echo Linking ../rbspeexenc 110 $(info Linking ../rbspeexenc)
112 $(SILENT)$(CROSS)$(CC) $(CFLAGS) $(ARCHFLAGS) -o ../rbspeexenc $(BUILD_DIR)/rbspeexenc.o \ 111 $(SILENT)$(CROSS)$(CC) $(CFLAGS) $(LDFLAGS) $(ARCHFLAGS) -o ../rbspeexenc $(BUILD_DIR)/rbspeexenc.c.o \
113 $(LIBS) -lm $(TARGET_DIR)librbspeex.a 112 $(LIBS) -lm $(TARGET_DIR)librbspeex.a
114 113
115../rbspeexdec: $(OBJS) librbspeex.a $(BUILD_DIR)/rbspeexdec.o 114../rbspeexdec: $(OBJS) $(TARGET_DIR)librbspeex.a
116 @echo Linking ../rbspeexdec 115 $(info Linking ../rbspeexdec)
117 $(SILENT)$(CROSS)$(CC) $(CFLAGS) $(ARCHFLAGS) -o ../rbspeexdec $(BUILD_DIR)/rbspeexdec.o \ 116 $(SILENT)$(CROSS)$(CC) $(CFLAGS) $(LDFLAGS) $(ARCHFLAGS) -o ../rbspeexdec $(BUILD_DIR)/rbspeexdec.c.o \
118 $(LIBS) -lm $(TARGET_DIR)librbspeex.a 117 $(LIBS) -lm $(TARGET_DIR)librbspeex.a
119 118
120%.o: 119# common rules
121 @echo CC $< 120$(OBJDIR)%.c.o:
122 $(SILENT)$(CROSS)$(CC) $(CFLAGS) $(ARCHFLAGS) -c $< -o $@ 121 $(info CC $<)
122 $(SILENT)$(call mkdir,$(dir $@))
123 $(SILENT)$(CROSS)$(CC) $(ARCHFLAGS) $(GCCFLAGS) $(CFLAGS) -MMD -c -o $@ $<
123 124
124clean: 125clean:
125 $(call rm,$(OBJS) $(TARGET_DIR)librbspeex* ../rbspeexenc ../rbspeexdec) 126 $(call rm,$(OBJS) $(LIBOBJS) $(TARGET_DIR)librbspeex* ../rbspeexenc ../rbspeexdec)
126 $(call rm,$(DEPS)) 127 $(call rm,$(DEPS))
127 $(call rm,build*) 128 $(call rm,$(BUILD_DIR))
128 129
129$(BUILD_DIR): 130$(BUILD_DIR):
130 @echo MKDIR $(BUILD_DIR) 131 $(info MKDIR $(BUILD_DIR))
131 $(SILENT)$(call mkdir, $(BUILD_DIR)) 132 $(SILENT)$(call mkdir, $(BUILD_DIR))
132 133