Prepare new maemo release
[maemo-rb.git] / tools / rbspeex / Makefile
blob2435caeaf4abbfa26b5a70113bc1dde8dc520000
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 ifndef V
11 SILENT = @
12 endif
14 SPEEXSRC = ../../lib/rbcodec/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
25 # OS X specifics. Needs to consider cross compiling for Windows.
26 ifeq ($(findstring Darwin,$(shell uname)),Darwin)
27 ifneq ($(findstring mingw,$(CROSS)$(CC)),mingw)
28 # when building libs for OS X build for both i386 and ppc at the same time.
29 # This creates fat objects, and ar can only create the archive but not operate
30 # on it. As a result the ar call must NOT use the u (update) flag.
31 ARCHFLAGS = -arch ppc -arch i386
32 # building against SDK 10.4 is not compatible with gcc-4.2 (default on newer Xcode)
33 # might need adjustment for older Xcode.
34 CC ?= gcc-4.0
35 CFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4
36 NATIVECC ?= gcc-4.0
37 endif
38 endif
40 # don't try to use the systems libspeex when building a static binary.
41 ifndef STATIC
42 SYS_SPEEX ?= $(shell pkg-config --silence-errors --libs speex speexdsp)
43 endif
45 # fall back to our own librbspeex if no suitable found.
46 ifeq ($(SYS_SPEEX),)
47 # This sets up 'SRC' based on the files mentioned in SOURCES
48 SRC := $(shell cat $(SPEEXSRC)/SOURCES | $(CC) $(CFLAGS) -E -P - | grep -v "^\#" | grep -v "^$$")
49 LIBS = $(TARGET_DIR)librbspeex.a
50 else
51 LIBS = $(SYS_SPEEX)
52 endif
54 TARGET_DIR ?= $(shell pwd)/
55 BUILD_DIR ?= $(TARGET_DIR)build
56 SOURCES = $(SRC:%.c=$(SPEEXSRC)/%.c) rbspeex.c rbspeexenc.c rbspeexdec.c
57 OBJS = $(addprefix $(BUILD_DIR)/,$(SRC:%.c=%.o))
58 DEPFILE = $(BUILD_DIR)/dep-speex
59 DIRS =
61 .PHONY : all
63 all: ../rbspeexenc ../rbspeexdec
65 $(DEPFILE): $(SOURCES)
66 @echo MKDIR $(BUILD_DIR)
67 $(SILENT)mkdir -p $(BUILD_DIR)
68 @echo Creating dependencies
69 $(SILENT)rm -f $(DEPFILE)
70 $(SILENT)(for each in $(SOURCES) x; do \
71 if test "x" != "$$each"; then \
72 obj=`echo $$each | sed -e 's/\.[cS]/.o/' | sed -e 's/^.*\///' `; \
73 $(CC) -MG -MM -MT "$(BUILD_DIR)/$$obj" $(CFLAGS) $$each 2>/dev/null; \
74 fi; \
75 if test -n "$$del"; then \
76 rm $$del; \
77 del=""; \
78 fi \
79 done > $(DEPFILE); \
80 echo "oo" > /dev/null )
82 include $(DEPFILE)
84 dll: $(TARGET_DIR)rbspeex.dll
86 $(TARGET_DIR)rbspeex.dll: $(OBJS) $(BUILD_DIR)/rbspeex.o
87 @echo DLL $(notdir $@)
88 $(SILENT)$(CROSS)$(CC) $(CFLAGS) -shared -o $@ $^ \
89 -Wl,--output-def,$(TARGET_DIR)rbspeex.def
91 $(TARGET_DIR)librbspeex.a: $(OBJS) $(BUILD_DIR)/rbspeex.o
92 @echo AR $(notdir $@)
93 $(SILENT)rm -f $@
94 $(SILENT)$(CROSS)$(AR) rcs $@ $^ > /dev/null 2>&1
96 librbspeex.a: $(TARGET_DIR)librbspeex.a
98 ../rbspeexenc: $(OBJS) $(BUILD_DIR)/rbspeexenc.o librbspeex.a
99 @echo Linking ../rbspeexenc
100 $(SILENT)$(CROSS)$(CC) $(CFLAGS) $(ARCHFLAGS) -o ../rbspeexenc $(BUILD_DIR)/rbspeexenc.o \
101 $(LIBS) -lm $(TARGET_DIR)librbspeex.a
103 ../rbspeexdec: $(OBJS) librbspeex.a $(BUILD_DIR)/rbspeexdec.o
104 @echo Linking ../rbspeexdec
105 $(SILENT)$(CROSS)$(CC) $(CFLAGS) $(ARCHFLAGS) -o ../rbspeexdec $(BUILD_DIR)/rbspeexdec.o \
106 $(LIBS) -lm $(TARGET_DIR)librbspeex.a
108 %.o:
109 @echo CC $<
110 $(SILENT)$(CROSS)$(CC) $(CFLAGS) $(ARCHFLAGS) -c $< -o $@
112 clean:
113 rm -f $(OBJS) $(TARGET_DIR)librbspeex* ../rbspeexenc ../rbspeexdec $(TARGET_DIR)dep-speex
114 rm -rf build*
116 $(BUILD_DIR):
117 @echo MKDIR $(BUILD_DIR)
118 $(SILENT)mkdir $(BUILD_DIR)