summaryrefslogtreecommitdiffstats
path: root/tools/rbspeex/Makefile
blob: 383acc986a51e76b302459d16ae2e5e8281882bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#             __________               __   ___.
#   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
#   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
#   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
#   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
#                     \/            \/     \/    \/            \/
# $Id$
#

ifndef V
SILENT = @
endif

SPEEXSRC = ../../apps/codecs/libspeex

INCLUDES = -I $(SPEEXSRC)
SPEEXOPTS = -DHAVE_CONFIG_H -DROCKBOX_VOICE_ENCODER

CFLAGS = $(SPEEXOPTS) $(INCLUDES) -O3 -fomit-frame-pointer -Wno-unused-parameter

#build standalone win32 executables on cygwin
ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
CFLAGS+=-mno-cygwin
endif
# on mingw32, make sure CC is set to gcc
ifeq ($(findstring MINGW,$(shell uname)),MINGW)
CC = gcc
endif

ifdef 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 "^\#" | grep -v "^$$")

OUT = build$(ARCH)
SOURCES = $(SRC:%.c=$(SPEEXSRC)/%.c) rbspeex.c rbspeexenc.c rbspeexdec.c
OBJS = $(addprefix $(OUT)/,$(SRC:%.c=%.o))
DEPFILE = $(OUT)/dep-speex
DIRS = 

.PHONY : all

all: ../rbspeexenc ../rbspeexdec

$(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 "$(OUT)/$$obj" $(CFLAGS) $$each 2>/dev/null; \
	    fi; \
	    if test -n "$$del"; then \
	        rm $$del; \
	        del=""; \
	    fi \
	done > $(DEPFILE); \
	echo "oo" > /dev/null )

-include $(DEPFILE)

$(OUT)/librbspeex.a: $(OBJS) $(DEPFILE) $(OUT)/rbspeex.o 
	@echo AR $(OUT)/librbspeex$(ARCH).a
	$(SILENT)$(AR) ruv $@ $+ > /dev/null 2>&1

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 $(OUT)/rbspeexenc.o librbspeex$(ARCH).a -lm

../rbspeexdec: $(OBJS) librbspeex$(ARCH).a $(OUT)/rbspeexdec.o 
	@echo Linking ../rbspeexdec
	$(SILENT)$(CC) $(CFLAGS) -o ../rbspeexdec $(OUT)/rbspeexdec.o librbspeex$(ARCH).a -lm 

%.o:
	@echo CC $<
	$(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

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) librbspeex* ../rbspeexenc ../rbspeexdec dep-speex
	rm -rf build*

build$(ARCH):
	@echo MKDIR build$(ARCH)
	$(SILENT)mkdir build$(ARCH)