diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2012-01-05 22:26:04 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2012-01-05 22:26:04 +0000 |
commit | 1ef25cd7e0ca653f87b3d9143248c0246a01271f (patch) | |
tree | 609fefc4a038ed944eb67ed5cd0883f88cc1f102 | |
parent | 7b376865337913cf618fb112af52ac1c5a44074f (diff) | |
download | rockbox-1ef25cd7e0ca653f87b3d9143248c0246a01271f.tar.gz rockbox-1ef25cd7e0ca653f87b3d9143248c0246a01271f.zip |
librbspeex.a: simplify Makefile for OS X.
- As done with the libucl Makefile replace the universal library handling and
use ar to create a library from fat objects instead.
- Replace OUT with BUILD_DIR to be in line with the other Makefiles. As a
result librbspeex will now be build in a subfolder better named than "build"
when building with Rockbox Utility.
- Make the Makefile depend on the depencency file. This should fix problems
with a broken dependency file not being regenerated properly, causing the
build to fail.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31587 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | tools/rbspeex/Makefile | 80 |
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 | |||
22 | ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) | 22 | ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) |
23 | CFLAGS+=-mno-cygwin | 23 | CFLAGS+=-mno-cygwin |
24 | endif | 24 | endif |
25 | 25 | # OS X specifics. Needs to consider cross compiling for Windows. | |
26 | ifdef RBARCH | 26 | ifeq ($(findstring Darwin,$(shell uname)),Darwin) |
27 | CFLAGS += -arch $(RBARCH) | 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 | ||
28 | endif | 38 | endif |
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 | |||
36 | ifeq ($(SYS_SPEEX),) | 46 | ifeq ($(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 |
38 | SRC := $(shell cat $(SPEEXSRC)/SOURCES | $(CC) $(CFLAGS) -E -P - | grep -v "^\#" | grep -v "^$$") | 48 | SRC := $(shell cat $(SPEEXSRC)/SOURCES | $(CC) $(CFLAGS) -E -P - | grep -v "^\#" | grep -v "^$$") |
39 | LIBS = $(TARGET_DIR)librbspeex$(RBARCH).a | 49 | LIBS = $(TARGET_DIR)librbspeex.a |
40 | else | 50 | else |
41 | LIBS = $(SYS_SPEEX) | 51 | LIBS = $(SYS_SPEEX) |
42 | endif | 52 | endif |
43 | 53 | ||
44 | OUT = $(TARGET_DIR)build$(RBARCH) | 54 | TARGET_DIR ?= $(shell pwd)/ |
55 | BUILD_DIR ?= $(TARGET_DIR)build | ||
45 | SOURCES = $(SRC:%.c=$(SPEEXSRC)/%.c) rbspeex.c rbspeexenc.c rbspeexdec.c | 56 | SOURCES = $(SRC:%.c=$(SPEEXSRC)/%.c) rbspeex.c rbspeexenc.c rbspeexdec.c |
46 | OBJS = $(addprefix $(OUT)/,$(SRC:%.c=%.o)) | 57 | OBJS = $(addprefix $(BUILD_DIR)/,$(SRC:%.c=%.o)) |
47 | DEPFILE = $(OUT)/dep-speex | 58 | DEPFILE = $(BUILD_DIR)/dep-speex |
48 | DIRS = | 59 | DIRS = |
49 | 60 | ||
50 | .PHONY : all | 61 | .PHONY : all |
@@ -52,14 +63,14 @@ DIRS = | |||
52 | all: ../rbspeexenc ../rbspeexdec | 63 | all: ../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) | 82 | include $(DEPFILE) |
72 | 83 | ||
73 | dll: $(TARGET_DIR)rbspeex.dll | 84 | dll: $(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 | ||
84 | librbspeex$(RBARCH).a: $(OUT)/librbspeex.a | 96 | librbspeex.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 | ||
102 | ifeq ($(RBARCH),) | ||
103 | librbspeexi386.a: | ||
104 | make RBARCH=i386 TARGET_DIR=$(TARGET_DIR) librbspeexi386.a | ||
105 | |||
106 | librbspeexppc.a: | ||
107 | make RBARCH=ppc TARGET_DIR=$(TARGET_DIR) librbspeexppc.a | ||
108 | endif | ||
109 | |||
110 | librbspeex-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 | ||
116 | clean: | 112 | clean: |
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 | ||