forked from len0rd/rockbox
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
This commit is contained in:
parent
7b37686533
commit
1ef25cd7e0
1 changed files with 38 additions and 42 deletions
|
@ -22,9 +22,19 @@ CFLAGS += $(SPEEXOPTS) $(INCLUDES) -O3 -fomit-frame-pointer -Wno-unused-paramete
|
|||
ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
|
||||
CFLAGS+=-mno-cygwin
|
||||
endif
|
||||
|
||||
ifdef RBARCH
|
||||
CFLAGS += -arch $(RBARCH)
|
||||
# OS X specifics. Needs to consider cross compiling for Windows.
|
||||
ifeq ($(findstring Darwin,$(shell uname)),Darwin)
|
||||
ifneq ($(findstring mingw,$(CROSS)$(CC)),mingw)
|
||||
# when building libs for OS X build for both i386 and ppc at the same time.
|
||||
# This creates fat objects, and ar can only create the archive but not operate
|
||||
# on it. As a result the ar call must NOT use the u (update) flag.
|
||||
ARCHFLAGS = -arch ppc -arch i386
|
||||
# building against SDK 10.4 is not compatible with gcc-4.2 (default on newer Xcode)
|
||||
# might need adjustment for older Xcode.
|
||||
CC ?= gcc-4.0
|
||||
CFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4
|
||||
NATIVECC ?= gcc-4.0
|
||||
endif
|
||||
endif
|
||||
|
||||
# don't try to use the systems libspeex when building a static binary.
|
||||
|
@ -36,15 +46,16 @@ endif
|
|||
ifeq ($(SYS_SPEEX),)
|
||||
# This sets up 'SRC' based on the files mentioned in SOURCES
|
||||
SRC := $(shell cat $(SPEEXSRC)/SOURCES | $(CC) $(CFLAGS) -E -P - | grep -v "^\#" | grep -v "^$$")
|
||||
LIBS = $(TARGET_DIR)librbspeex$(RBARCH).a
|
||||
LIBS = $(TARGET_DIR)librbspeex.a
|
||||
else
|
||||
LIBS = $(SYS_SPEEX)
|
||||
endif
|
||||
|
||||
OUT = $(TARGET_DIR)build$(RBARCH)
|
||||
TARGET_DIR ?= $(shell pwd)/
|
||||
BUILD_DIR ?= $(TARGET_DIR)build
|
||||
SOURCES = $(SRC:%.c=$(SPEEXSRC)/%.c) rbspeex.c rbspeexenc.c rbspeexdec.c
|
||||
OBJS = $(addprefix $(OUT)/,$(SRC:%.c=%.o))
|
||||
DEPFILE = $(OUT)/dep-speex
|
||||
OBJS = $(addprefix $(BUILD_DIR)/,$(SRC:%.c=%.o))
|
||||
DEPFILE = $(BUILD_DIR)/dep-speex
|
||||
DIRS =
|
||||
|
||||
.PHONY : all
|
||||
|
@ -52,14 +63,14 @@ DIRS =
|
|||
all: ../rbspeexenc ../rbspeexdec
|
||||
|
||||
$(DEPFILE): $(SOURCES)
|
||||
@echo MKDIR $(OUT)
|
||||
$(SILENT)mkdir -p $(OUT)
|
||||
@echo MKDIR $(BUILD_DIR)
|
||||
$(SILENT)mkdir -p $(BUILD_DIR)
|
||||
@echo Creating dependencies
|
||||
$(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; \
|
||||
$(CC) -MG -MM -MT "$(BUILD_DIR)/$$obj" $(CFLAGS) $$each 2>/dev/null; \
|
||||
fi; \
|
||||
if test -n "$$del"; then \
|
||||
rm $$del; \
|
||||
|
@ -68,56 +79,41 @@ $(DEPFILE): $(SOURCES)
|
|||
done > $(DEPFILE); \
|
||||
echo "oo" > /dev/null )
|
||||
|
||||
-include $(DEPFILE)
|
||||
include $(DEPFILE)
|
||||
|
||||
dll: $(TARGET_DIR)rbspeex.dll
|
||||
|
||||
$(TARGET_DIR)rbspeex.dll: $(OBJS) $(OUT)/rbspeex.o
|
||||
$(TARGET_DIR)rbspeex.dll: $(OBJS) $(BUILD_DIR)/rbspeex.o
|
||||
@echo DLL $(notdir $@)
|
||||
$(SILENT)$(CROSS)$(CC) $(CFLAGS) -shared -o $@ $^ \
|
||||
-Wl,--output-def,$(TARGET_DIR)rbspeex.def
|
||||
|
||||
$(OUT)/librbspeex.a: $(OBJS) $(DEPFILE) $(OUT)/rbspeex.o
|
||||
$(TARGET_DIR)librbspeex.a: $(OBJS) $(BUILD_DIR)/rbspeex.o
|
||||
@echo AR $(notdir $@)
|
||||
$(SILENT)$(CROSS)$(AR) rucs $@ $+ > /dev/null 2>&1
|
||||
$(SILENT)rm -f $@
|
||||
$(SILENT)$(CROSS)$(AR) rcs $@ $^ > /dev/null 2>&1
|
||||
|
||||
librbspeex$(RBARCH).a: $(OUT)/librbspeex.a
|
||||
$(SILENT)cp $(OUT)/librbspeex.a $(TARGET_DIR)librbspeex$(RBARCH).a
|
||||
librbspeex.a: $(TARGET_DIR)librbspeex.a
|
||||
|
||||
../rbspeexenc: $(OBJS) $(OUT)/rbspeexenc.o librbspeex$(RBARCH).a
|
||||
../rbspeexenc: $(OBJS) $(BUILD_DIR)/rbspeexenc.o librbspeex.a
|
||||
@echo Linking ../rbspeexenc
|
||||
$(SILENT)$(CROSS)$(CC) $(CFLAGS) -o ../rbspeexenc $(OUT)/rbspeexenc.o \
|
||||
$(LIBS) -lm $(TARGET_DIR)librbspeex$(RBARCH).a
|
||||
$(SILENT)$(CROSS)$(CC) $(CFLAGS) $(ARCHFLAGS) -o ../rbspeexenc $(BUILD_DIR)/rbspeexenc.o \
|
||||
$(LIBS) -lm $(TARGET_DIR)librbspeex.a
|
||||
|
||||
../rbspeexdec: $(OBJS) librbspeex$(RBARCH).a $(OUT)/rbspeexdec.o
|
||||
../rbspeexdec: $(OBJS) librbspeex.a $(BUILD_DIR)/rbspeexdec.o
|
||||
@echo Linking ../rbspeexdec
|
||||
$(SILENT)$(CROSS)$(CC) $(CFLAGS) -o ../rbspeexdec $(OUT)/rbspeexdec.o \
|
||||
$(LIBS) -lm $(TARGET_DIR)librbspeex$(RBARCH).a
|
||||
$(SILENT)$(CROSS)$(CC) $(CFLAGS) $(ARCHFLAGS) -o ../rbspeexdec $(BUILD_DIR)/rbspeexdec.o \
|
||||
$(LIBS) -lm $(TARGET_DIR)librbspeex.a
|
||||
|
||||
%.o:
|
||||
@echo CC $<
|
||||
$(SILENT)$(CROSS)$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
# some trickery to build ppc and i386 from a single call
|
||||
ifeq ($(RBARCH),)
|
||||
librbspeexi386.a:
|
||||
make RBARCH=i386 TARGET_DIR=$(TARGET_DIR) librbspeexi386.a
|
||||
|
||||
librbspeexppc.a:
|
||||
make RBARCH=ppc TARGET_DIR=$(TARGET_DIR) librbspeexppc.a
|
||||
endif
|
||||
|
||||
librbspeex-universal: librbspeexi386.a librbspeexppc.a
|
||||
@echo lipo librbspeex.a
|
||||
$(SILENT) rm -f $(TARGET_DIR)librbspeex.a
|
||||
$(SILENT)lipo -create $(TARGET_DIR)librbspeexppc.a \
|
||||
$(TARGET_DIR)librbspeexi386.a -output $(TARGET_DIR)librbspeex.a
|
||||
$(SILENT)$(CROSS)$(CC) $(CFLAGS) $(ARCHFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) $(TARGET_DIR)librbspeex* ../rbspeexenc ../rbspeexdec $(TARGET_DIR)dep-speex
|
||||
rm -rf build*
|
||||
|
||||
$(OUT):
|
||||
@echo MKDIR $(OUT)
|
||||
$(SILENT)mkdir $(OUT)
|
||||
$(BUILD_DIR):
|
||||
@echo MKDIR $(BUILD_DIR)
|
||||
$(SILENT)mkdir $(BUILD_DIR)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue