Merge branch 'master' into sim-target-tree
[kugel-rb.git] / tools / rbspeex / Makefile
blob267ef8d6d76fd42ee9ad277c3b4acc705153256c
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 ifndef V
11 SILENT = @
12 endif
14 SPEEXSRC = ../../apps/codecs/libspeex
16 INCLUDES = -I $(SPEEXSRC)
17 SPEEXOPTS = -DHAVE_CONFIG_H -DROCKBOX_VOICE_ENCODER
19 CFLAGS = $(SPEEXOPTS) $(INCLUDES) -O3 -fomit-frame-pointer -Wno-unused-parameter
21 #build standalone win32 executables on cygwin
22 ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
23 CFLAGS+=-mno-cygwin
24 endif
26 ifdef RBARCH
27 CFLAGS += -arch $(RBARCH)
28 endif
30 # don't try to use the systems libspeex when building a static binary.
31 ifndef STATIC
32 SYS_SPEEX = $(shell pkg-config --silence-errors --libs speex speexdsp)
33 endif
35 # fall back to our own librbspeex if no suitable found.
36 ifeq ($(SYS_SPEEX),)
37 # This sets up 'SRC' based on the files mentioned in SOURCES
38 SRC := $(shell cat $(SPEEXSRC)/SOURCES | $(CC) $(CFLAGS) -E -P - | grep -v "^\#" | grep -v "^$$")
39 LIBS = $(TARGET_DIR)librbspeex$(RBARCH).a
40 else
41 LIBS = $(SYS_SPEEX)
42 endif
44 OUT = $(TARGET_DIR)build$(RBARCH)
45 SOURCES = $(SRC:%.c=$(SPEEXSRC)/%.c) rbspeex.c rbspeexenc.c rbspeexdec.c
46 OBJS = $(addprefix $(OUT)/,$(SRC:%.c=%.o))
47 DEPFILE = $(OUT)/dep-speex
48 DIRS =
50 .PHONY : all
52 all: ../rbspeexenc ../rbspeexdec
54 $(DEPFILE): $(SOURCES)
55 @echo MKDIR $(OUT)
56 $(SILENT)mkdir -p $(OUT)
57 @echo Creating dependencies
58 $(SILENT)rm -f $(DEPFILE)
59 $(SILENT)(for each in $(SOURCES) x; do \
60 if test "x" != "$$each"; then \
61 obj=`echo $$each | sed -e 's/\.[cS]/.o/' | sed -e 's/^.*\///' `; \
62 $(CC) -MG -MM -MT "$(OUT)/$$obj" $(CFLAGS) $$each 2>/dev/null; \
63 fi; \
64 if test -n "$$del"; then \
65 rm $$del; \
66 del=""; \
67 fi \
68 done > $(DEPFILE); \
69 echo "oo" > /dev/null )
71 -include $(DEPFILE)
73 $(OUT)/librbspeex.a: $(OBJS) $(DEPFILE) $(OUT)/rbspeex.o
74 @echo AR $(OUT)/librbspeex$(RBARCH).a
75 $(SILENT)$(AR) ruv $@ $+ > /dev/null 2>&1
77 librbspeex$(RBARCH).a: $(OUT)/librbspeex.a
78 $(SILENT)cp $(OUT)/librbspeex.a $(TARGET_DIR)librbspeex$(RBARCH).a
80 ../rbspeexenc: $(OBJS) $(OUT)/rbspeexenc.o librbspeex$(RBARCH).a
81 @echo Linking ../rbspeexenc
82 $(SILENT)$(CC) $(CFLAGS) -o ../rbspeexenc $(OUT)/rbspeexenc.o $(LIBS) -lm $(TARGET_DIR)librbspeex$(RBARCH).a
84 ../rbspeexdec: $(OBJS) librbspeex$(RBARCH).a $(OUT)/rbspeexdec.o
85 @echo Linking ../rbspeexdec
86 $(SILENT)$(CC) $(CFLAGS) -o ../rbspeexdec $(OUT)/rbspeexdec.o $(LIBS) -lm $(TARGET_DIR)librbspeex$(RBARCH).a
88 %.o:
89 @echo CC $<
90 $(SILENT)$(CC) $(CFLAGS) -c $< -o $@
92 # some trickery to build ppc and i386 from a single call
93 ifeq ($(RBARCH),)
94 librbspeexi386.a:
95 make RBARCH=i386 TARGET_DIR=$(TARGET_DIR) librbspeexi386.a
97 librbspeexppc.a:
98 make RBARCH=ppc TARGET_DIR=$(TARGET_DIR) librbspeexppc.a
99 endif
101 librbspeex-universal: librbspeexi386.a librbspeexppc.a
102 @echo lipo librbspeex.a
103 $(SILENT) rm -f $(TARGET_DIR)librbspeex.a
104 $(SILENT)lipo -create $(TARGET_DIR)librbspeexppc.a $(TARGET_DIR)librbspeexi386.a -output $(TARGET_DIR)librbspeex.a
106 clean:
107 rm -f $(OBJS) $(TARGET_DIR)librbspeex* ../rbspeexenc ../rbspeexdec $(TARGET_DIR)dep-speex
108 rm -rf build*
110 $(OUT):
111 @echo MKDIR $(OUT)
112 $(SILENT)mkdir $(OUT)