summaryrefslogtreecommitdiff
path: root/tools/rbspeex
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2008-07-20 15:47:47 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2008-07-20 15:47:47 +0000
commitfd61460c4504da289635c7ece2ce4973311921cf (patch)
tree605e2b1d878db3a0b0d664fd6b0e4124014c55a0 /tools/rbspeex
parent903a048ddcf5b95dc85d1c440daf0f397b6d60b0 (diff)
Extend rbspeex Makefile to allow easier building a universal binary needed for rbutil.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18103 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/rbspeex')
-rw-r--r--tools/rbspeex/Makefile54
1 files changed, 37 insertions, 17 deletions
diff --git a/tools/rbspeex/Makefile b/tools/rbspeex/Makefile
index 2511393833..383acc986a 100644
--- a/tools/rbspeex/Makefile
+++ b/tools/rbspeex/Makefile
@@ -28,28 +28,29 @@ CC = gcc
endif
ifdef ARCH
-ARCH_CMD = -arch $(ARCH)
+CFLAGS += -arch $(ARCH)
endif
# This sets up 'SRC' based on the files mentioned in SOURCES
-SRC := $(shell cat $(SPEEXSRC)/SOURCES | $(CC) $(CFLAGS) -E -P - | grep -v "^\#")
+SRC := $(shell cat $(SPEEXSRC)/SOURCES | $(CC) $(CFLAGS) -E -P - | grep -v "^\#" | grep -v "^$$")
+OUT = build$(ARCH)
SOURCES = $(SRC:%.c=$(SPEEXSRC)/%.c) rbspeex.c rbspeexenc.c rbspeexdec.c
-OBJS := $(SRC:%.c=%.o)
-DEPFILE = dep-speex
+OBJS = $(addprefix $(OUT)/,$(SRC:%.c=%.o))
+DEPFILE = $(OUT)/dep-speex
DIRS =
.PHONY : all
all: ../rbspeexenc ../rbspeexdec
-$(DEPFILE): $(SOURCES)
+$(DEPFILE): $(SOURCES) $(OUT)
$(SILENT)rm -f $(DEPFILE)
$(SILENT)(for each in $(SOURCES) x; do \
if test "x" != "$$each"; then \
obj=`echo $$each | sed -e 's/\.[cS]/.o/' | sed -e 's/^.*\///' `; \
- $(CC) -MG -MM -MT "$$obj" $(CFLAGS) $$each 2>/dev/null; \
+ $(CC) -MG -MM -MT "$(OUT)/$$obj" $(CFLAGS) $$each 2>/dev/null; \
fi; \
if test -n "$$del"; then \
rm $$del; \
@@ -58,27 +59,46 @@ $(DEPFILE): $(SOURCES)
done > $(DEPFILE); \
echo "oo" > /dev/null )
-librbspeex$(ARCH).a: $(OBJS) $(DEPFILE) rbspeex.o
- @echo AR librbspeex.a
+-include $(DEPFILE)
+
+$(OUT)/librbspeex.a: $(OBJS) $(DEPFILE) $(OUT)/rbspeex.o
+ @echo AR $(OUT)/librbspeex$(ARCH).a
$(SILENT)$(AR) ruv $@ $+ > /dev/null 2>&1
-../rbspeexenc: $(OBJS) rbspeexenc.o librbspeex.a
+librbspeex$(ARCH).a: $(OUT)/librbspeex.a
+ $(SILENT)cp $(OUT)/librbspeex.a librbspeex$(ARCH).a
+
+../rbspeexenc: $(OBJS) $(OUT)/rbspeexenc.o librbspeex$(ARCH).a
@echo Linking ../rbspeexenc
- $(SILENT)$(CC) $(CFLAGS) -o ../rbspeexenc rbspeexenc.o librbspeex.a -lm
+ $(SILENT)$(CC) $(CFLAGS) -o ../rbspeexenc $(OUT)/rbspeexenc.o librbspeex$(ARCH).a -lm
-../rbspeexdec: $(OBJS) librbspeex.a rbspeexdec.o
+../rbspeexdec: $(OBJS) librbspeex$(ARCH).a $(OUT)/rbspeexdec.o
@echo Linking ../rbspeexdec
- $(SILENT)$(CC) $(CFLAGS) -o ../rbspeexdec rbspeexdec.o librbspeex.a -lm
+ $(SILENT)$(CC) $(CFLAGS) -o ../rbspeexdec $(OUT)/rbspeexdec.o librbspeex$(ARCH).a -lm
%.o:
@echo CC $<
- $(SILENT)$(CC) $(CFLAGS) -c $< -o $@ $(ARCH_CMD)
+ $(SILENT)$(CC) $(CFLAGS) -c $< -o $@
+
+# some trickery to build ppc and i386 from a single call
+ifeq ($(ARCH),)
+librbspeexi386.a:
+ make ARCH=i386 librbspeexi386.a
-universal: librbspeexppc.a librbspeexi386.a
- @echo lipo libusb.a
+librbspeexppc.a:
+ make ARCH=ppc librbspeexppc.a
+endif
+
+librbspeex-universal: librbspeexi386.a librbspeexppc.a
+ @echo lipo librbspeex.a
+ $(SILENT) rm -f librbspeex.a
lipo -create librbspeexppc.a librbspeexi386.a -output librbspeex.a
clean:
- rm -f $(OBJS) rbspeex.o libspeex.a librbspeex.a rbspeexenc.o ../rbspeexenc dep-speex
+ rm -f $(OBJS) librbspeex* ../rbspeexenc ../rbspeexdec dep-speex
+ rm -rf build*
+
+build$(ARCH):
+ @echo MKDIR build$(ARCH)
+ $(SILENT)mkdir build$(ARCH)
--include $(DEPFILE)