From 85b83e62a8c0bf18db10c1189d05ea8b7abc3811 Mon Sep 17 00:00:00 2001 From: Sean Bartell Date: Sat, 13 Aug 2011 15:21:21 -0400 Subject: [PATCH 5/7] rbcodec refactoring: codec makefile --- lib/rbcodec/codecs/codecs.make | 31 +++---------------------------- lib/rbcodec/test/Makefile | 6 +++--- tools/root.make | 22 ++++++++++++++++++++++ 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/lib/rbcodec/codecs/codecs.make b/lib/rbcodec/codecs/codecs.make index fd195e8..c551a54 100644 --- a/lib/rbcodec/codecs/codecs.make +++ b/lib/rbcodec/codecs/codecs.make @@ -53,8 +53,8 @@ include $(RBCODEC_DIR)/codecs/libgme/libkss.make include $(RBCODEC_DIR)/codecs/libgme/libemu2413.make # compile flags for codecs -CODECFLAGS = $(CFLAGS) $(RBCODEC_CFLAGS) -fstrict-aliasing \ - -I$(RBCODEC_DIR)/codecs -I$(RBCODEC_DIR)/codecs/lib -DCODEC +CODECFLAGS += $(CFLAGS) $(RBCODEC_CFLAGS) -fstrict-aliasing \ + -I$(RBCODEC_DIR)/codecs -I$(RBCODEC_DIR)/codecs/lib -DCODEC # set CODECFLAGS per codec lib, since gcc takes the last -Ox and the last # in a -ffoo -fno-foo pair, there is no need to filter them out @@ -116,21 +116,8 @@ ifeq ($(MEMORYSIZE),2) $(WMALIB) : CODECFLAGS += -Os endif -ifndef APP_TYPE - CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h - CODEC_LDS := $(APPSDIR)/plugins/plugin.lds # codecs and plugins use same file - CODECLINK_LDS := $(CODECDIR)/codec.link -endif - CODEC_CRT0 := $(CODECDIR)/codec_crt0.o -$(CODECS): $(CODEC_CRT0) $(CODECLINK_LDS) - -$(CODECLINK_LDS): $(CODEC_LDS) $(CONFIGFILE) - $(call PRINTS,PP $(@F)) - $(shell mkdir -p $(dir $@)) - $(call preprocess2file, $<, $@, -DCODEC) - # codec/library dependencies $(CODECDIR)/spc.codec : $(CODECDIR)/libspc.a $(CODECDIR)/mpa.codec : $(CODECDIR)/libmad.a @@ -171,9 +158,6 @@ $(CODECDIR)/kss.codec : $(CODECDIR)/libkss.a $(CODECDIR)/libemu2413.a $(CODECS): $(CODECLIB) # this must be last in codec dependency list -# libfaad and libmusepack both contain a huffman.h file, with different -# content. So we compile them with special command lines: - # pattern rule for compiling codecs $(CODECDIR)/%.o: $(RBCODEC_DIR)/codecs/%.c $(SILENT)mkdir -p $(dir $@) @@ -186,15 +170,6 @@ $(CODECDIR)/%.o: $(RBCODEC_DIR)/codecs/%.S $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) \ -I$(dir $<) $(CODECFLAGS) $(ASMFLAGS) -c $< -o $@ -ifdef APP_TYPE - CODECLDFLAGS = $(SHARED_LDFLAG) # <-- from Makefile - CODECFLAGS += $(SHARED_CFLAGS) # <-- from Makefile -else - CODECLDFLAGS = -T$(CODECLINK_LDS) -Wl,--gc-sections -Wl,-Map,$(CODECDIR)/$*.map - CODECFLAGS += -UDEBUG -DNDEBUG -endif -CODECLDFLAGS += $(GLOBAL_LDOPTS) - $(CODECDIR)/%-pre.map: $(CODEC_CRT0) $(CODECLINK_LDS) $(CODECDIR)/%.o $(CODECLIB) $(call PRINTS,LD $(@F))$(CC) $(CODECFLAGS) -o $(CODECDIR)/$*-pre.elf \ $(filter %.o, $^) \ @@ -202,7 +177,7 @@ $(CODECDIR)/%-pre.map: $(CODEC_CRT0) $(CODECLINK_LDS) $(CODECDIR)/%.o $(CODECLIB $(CODECLIB) \ -lgcc $(subst .map,-pre.map,$(CODECLDFLAGS)) -$(CODECDIR)/%.codec: $(CODECDIR)/%.o $(LIBSETJMP) +$(CODECDIR)/%.codec: $(CODECDIR)/%.o $(call PRINTS,LD $(@F))$(CC) $(CODECFLAGS) -o $(CODECDIR)/$*.elf \ $(filter %.o, $^) \ $(filter %.a, $+) \ diff --git a/lib/rbcodec/test/Makefile b/lib/rbcodec/test/Makefile index f587ea2..0c58902 100644 --- a/lib/rbcodec/test/Makefile +++ b/lib/rbcodec/test/Makefile @@ -2,7 +2,7 @@ default: all .PHONY: default all clean dep -ROOTDIR = $(shell readlink -e ../../..) +ROOTDIR = $(shell readlink -e ..) BUILDDIR = $(shell pwd)/build APPSDIR = $(ROOTDIR)/apps TOOLSDIR = $(ROOTDIR)/tools @@ -22,8 +22,8 @@ CFLAGS += -O0 -ggdb -DDEBUG -DLOGF_ENABLE -Wall -Wno-pointer-sign CFLAGS += -Wstrict-prototypes -pipe -std=gnu99 PPCFLAGS = $(CFLAGS) -SHARED_CFLAGS = -fPIC -fvisibility=hidden -SHARED_LDFLAG = -shared +CODECFLAGS = -fPIC -fvisibility=hidden +CODECLDFLAGS = -shared WARBLE_OBJS = $(BUILDDIR)/warble.o WARBLE_CFLAGS = '-DCODECDIR="$(CODECDIR)"' $(shell sdl-config --cflags) diff --git a/tools/root.make b/tools/root.make index 6b0b1a1..34c27d6 100644 --- a/tools/root.make +++ b/tools/root.make @@ -75,6 +75,28 @@ ifndef APP_TYPE include $(ROOTDIR)/lib/libsetjmp/libsetjmp.make endif +ifndef APP_TYPE + CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h + CODEC_LDS := $(APPSDIR)/plugins/plugin.lds # codecs and plugins use same file + CODECLINK_LDS := $(CODECDIR)/codec.link +endif + +$(CODECS): $(CODECLINK_LDS) $(LIBSETJMP) + +$(CODECLINK_LDS): $(CODEC_LDS) $(CONFIGFILE) + $(call PRINTS,PP $(@F)) + $(shell mkdir -p $(dir $@)) + $(call preprocess2file, $<, $@, -DCODEC) + +ifdef APP_TYPE + CODECLDFLAGS = $(SHARED_LDFLAG) # <-- from Makefile + CODECFLAGS += $(SHARED_CFLAGS) # <-- from Makefile +else + CODECLDFLAGS = -T$(CODECLINK_LDS) -Wl,--gc-sections -Wl,-Map,$(CODECDIR)/$*.map + CODECFLAGS += -UDEBUG -DNDEBUG +endif +CODECLDFLAGS += $(GLOBAL_LDOPTS) + ifneq (,$(findstring bootloader,$(APPSDIR))) include $(APPSDIR)/bootloader.make else ifneq (,$(findstring bootbox,$(APPSDIR))) -- 1.7.6