summaryrefslogtreecommitdiff
path: root/tools/rbspeex/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'tools/rbspeex/Makefile')
-rw-r--r--tools/rbspeex/Makefile80
1 files changed, 38 insertions, 42 deletions
diff --git a/tools/rbspeex/Makefile b/tools/rbspeex/Makefile
index 9f3f348a69..247d25e1db 100644
--- a/tools/rbspeex/Makefile
+++ b/tools/rbspeex/Makefile
@@ -22,9 +22,19 @@ CFLAGS += $(SPEEXOPTS) $(INCLUDES) -O3 -fomit-frame-pointer -Wno-unused-paramete
22ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) 22ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
23CFLAGS+=-mno-cygwin 23CFLAGS+=-mno-cygwin
24endif 24endif
25 25# OS X specifics. Needs to consider cross compiling for Windows.
26ifdef RBARCH 26ifeq ($(findstring Darwin,$(shell uname)),Darwin)
27CFLAGS += -arch $(RBARCH) 27ifneq ($(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.
31ARCHFLAGS = -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.
34CC ?= gcc-4.0
35CFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4
36NATIVECC ?= gcc-4.0
37endif
28endif 38endif
29 39
30# don't try to use the systems libspeex when building a static binary. 40# don't try to use the systems libspeex when building a static binary.
@@ -36,15 +46,16 @@ endif
36ifeq ($(SYS_SPEEX),) 46ifeq ($(SYS_SPEEX),)
37# This sets up 'SRC' based on the files mentioned in SOURCES 47# This sets up 'SRC' based on the files mentioned in SOURCES
38SRC := $(shell cat $(SPEEXSRC)/SOURCES | $(CC) $(CFLAGS) -E -P - | grep -v "^\#" | grep -v "^$$") 48SRC := $(shell cat $(SPEEXSRC)/SOURCES | $(CC) $(CFLAGS) -E -P - | grep -v "^\#" | grep -v "^$$")
39LIBS = $(TARGET_DIR)librbspeex$(RBARCH).a 49LIBS = $(TARGET_DIR)librbspeex.a
40else 50else
41LIBS = $(SYS_SPEEX) 51LIBS = $(SYS_SPEEX)
42endif 52endif
43 53
44OUT = $(TARGET_DIR)build$(RBARCH) 54TARGET_DIR ?= $(shell pwd)/
55BUILD_DIR ?= $(TARGET_DIR)build
45SOURCES = $(SRC:%.c=$(SPEEXSRC)/%.c) rbspeex.c rbspeexenc.c rbspeexdec.c 56SOURCES = $(SRC:%.c=$(SPEEXSRC)/%.c) rbspeex.c rbspeexenc.c rbspeexdec.c
46OBJS = $(addprefix $(OUT)/,$(SRC:%.c=%.o)) 57OBJS = $(addprefix $(BUILD_DIR)/,$(SRC:%.c=%.o))
47DEPFILE = $(OUT)/dep-speex 58DEPFILE = $(BUILD_DIR)/dep-speex
48DIRS = 59DIRS =
49 60
50.PHONY : all 61.PHONY : all
@@ -52,14 +63,14 @@ DIRS =
52all: ../rbspeexenc ../rbspeexdec 63all: ../rbspeexenc ../rbspeexdec
53 64
54$(DEPFILE): $(SOURCES) 65$(DEPFILE): $(SOURCES)
55 @echo MKDIR $(OUT) 66 @echo MKDIR $(BUILD_DIR)
56 $(SILENT)mkdir -p $(OUT) 67 $(SILENT)mkdir -p $(BUILD_DIR)
57 @echo Creating dependencies 68 @echo Creating dependencies
58 $(SILENT)rm -f $(DEPFILE) 69 $(SILENT)rm -f $(DEPFILE)
59 $(SILENT)(for each in $(SOURCES) x; do \ 70 $(SILENT)(for each in $(SOURCES) x; do \
60 if test "x" != "$$each"; then \ 71 if test "x" != "$$each"; then \
61 obj=`echo $$each | sed -e 's/\.[cS]/.o/' | sed -e 's/^.*\///' `; \ 72 obj=`echo $$each | sed -e 's/\.[cS]/.o/' | sed -e 's/^.*\///' `; \
62 $(CC) -MG -MM -MT "$(OUT)/$$obj" $(CFLAGS) $$each 2>/dev/null; \ 73 $(CC) -MG -MM -MT "$(BUILD_DIR)/$$obj" $(CFLAGS) $$each 2>/dev/null; \
63 fi; \ 74 fi; \
64 if test -n "$$del"; then \ 75 if test -n "$$del"; then \
65 rm $$del; \ 76 rm $$del; \
@@ -68,56 +79,41 @@ $(DEPFILE): $(SOURCES)
68 done > $(DEPFILE); \ 79 done > $(DEPFILE); \
69 echo "oo" > /dev/null ) 80 echo "oo" > /dev/null )
70 81
71-include $(DEPFILE) 82include $(DEPFILE)
72 83
73dll: $(TARGET_DIR)rbspeex.dll 84dll: $(TARGET_DIR)rbspeex.dll
74 85
75$(TARGET_DIR)rbspeex.dll: $(OBJS) $(OUT)/rbspeex.o 86$(TARGET_DIR)rbspeex.dll: $(OBJS) $(BUILD_DIR)/rbspeex.o
76 @echo DLL $(notdir $@) 87 @echo DLL $(notdir $@)
77 $(SILENT)$(CROSS)$(CC) $(CFLAGS) -shared -o $@ $^ \ 88 $(SILENT)$(CROSS)$(CC) $(CFLAGS) -shared -o $@ $^ \
78 -Wl,--output-def,$(TARGET_DIR)rbspeex.def 89 -Wl,--output-def,$(TARGET_DIR)rbspeex.def
79 90
80$(OUT)/librbspeex.a: $(OBJS) $(DEPFILE) $(OUT)/rbspeex.o 91$(TARGET_DIR)librbspeex.a: $(OBJS) $(BUILD_DIR)/rbspeex.o
81 @echo AR $(notdir $@) 92 @echo AR $(notdir $@)
82 $(SILENT)$(CROSS)$(AR) rucs $@ $+ > /dev/null 2>&1 93 $(SILENT)rm -f $@
94 $(SILENT)$(CROSS)$(AR) rcs $@ $^ > /dev/null 2>&1
83 95
84librbspeex$(RBARCH).a: $(OUT)/librbspeex.a 96librbspeex.a: $(TARGET_DIR)librbspeex.a
85 $(SILENT)cp $(OUT)/librbspeex.a $(TARGET_DIR)librbspeex$(RBARCH).a 97
86 98../rbspeexenc: $(OBJS) $(BUILD_DIR)/rbspeexenc.o librbspeex.a
87../rbspeexenc: $(OBJS) $(OUT)/rbspeexenc.o librbspeex$(RBARCH).a
88 @echo Linking ../rbspeexenc 99 @echo Linking ../rbspeexenc
89 $(SILENT)$(CROSS)$(CC) $(CFLAGS) -o ../rbspeexenc $(OUT)/rbspeexenc.o \ 100 $(SILENT)$(CROSS)$(CC) $(CFLAGS) $(ARCHFLAGS) -o ../rbspeexenc $(BUILD_DIR)/rbspeexenc.o \
90 $(LIBS) -lm $(TARGET_DIR)librbspeex$(RBARCH).a 101 $(LIBS) -lm $(TARGET_DIR)librbspeex.a
91 102
92../rbspeexdec: $(OBJS) librbspeex$(RBARCH).a $(OUT)/rbspeexdec.o 103../rbspeexdec: $(OBJS) librbspeex.a $(BUILD_DIR)/rbspeexdec.o
93 @echo Linking ../rbspeexdec 104 @echo Linking ../rbspeexdec
94 $(SILENT)$(CROSS)$(CC) $(CFLAGS) -o ../rbspeexdec $(OUT)/rbspeexdec.o \ 105 $(SILENT)$(CROSS)$(CC) $(CFLAGS) $(ARCHFLAGS) -o ../rbspeexdec $(BUILD_DIR)/rbspeexdec.o \
95 $(LIBS) -lm $(TARGET_DIR)librbspeex$(RBARCH).a 106 $(LIBS) -lm $(TARGET_DIR)librbspeex.a
96 107
97%.o: 108%.o:
98 @echo CC $< 109 @echo CC $<
99 $(SILENT)$(CROSS)$(CC) $(CFLAGS) -c $< -o $@ 110 $(SILENT)$(CROSS)$(CC) $(CFLAGS) $(ARCHFLAGS) -c $< -o $@
100
101# some trickery to build ppc and i386 from a single call
102ifeq ($(RBARCH),)
103librbspeexi386.a:
104 make RBARCH=i386 TARGET_DIR=$(TARGET_DIR) librbspeexi386.a
105
106librbspeexppc.a:
107 make RBARCH=ppc TARGET_DIR=$(TARGET_DIR) librbspeexppc.a
108endif
109
110librbspeex-universal: librbspeexi386.a librbspeexppc.a
111 @echo lipo librbspeex.a
112 $(SILENT) rm -f $(TARGET_DIR)librbspeex.a
113 $(SILENT)lipo -create $(TARGET_DIR)librbspeexppc.a \
114 $(TARGET_DIR)librbspeexi386.a -output $(TARGET_DIR)librbspeex.a
115 111
116clean: 112clean:
117 rm -f $(OBJS) $(TARGET_DIR)librbspeex* ../rbspeexenc ../rbspeexdec $(TARGET_DIR)dep-speex 113 rm -f $(OBJS) $(TARGET_DIR)librbspeex* ../rbspeexenc ../rbspeexdec $(TARGET_DIR)dep-speex
118 rm -rf build* 114 rm -rf build*
119 115
120$(OUT): 116$(BUILD_DIR):
121 @echo MKDIR $(OUT) 117 @echo MKDIR $(BUILD_DIR)
122 $(SILENT)mkdir $(OUT) 118 $(SILENT)mkdir $(BUILD_DIR)
123 119