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)
|
ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
|
||||||
CFLAGS+=-mno-cygwin
|
CFLAGS+=-mno-cygwin
|
||||||
endif
|
endif
|
||||||
|
# OS X specifics. Needs to consider cross compiling for Windows.
|
||||||
ifdef RBARCH
|
ifeq ($(findstring Darwin,$(shell uname)),Darwin)
|
||||||
CFLAGS += -arch $(RBARCH)
|
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
|
endif
|
||||||
|
|
||||||
# don't try to use the systems libspeex when building a static binary.
|
# don't try to use the systems libspeex when building a static binary.
|
||||||
|
@ -36,15 +46,16 @@ endif
|
||||||
ifeq ($(SYS_SPEEX),)
|
ifeq ($(SYS_SPEEX),)
|
||||||
# This sets up 'SRC' based on the files mentioned in SOURCES
|
# This sets up 'SRC' based on the files mentioned in SOURCES
|
||||||
SRC := $(shell cat $(SPEEXSRC)/SOURCES | $(CC) $(CFLAGS) -E -P - | grep -v "^\#" | grep -v "^$$")
|
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
|
else
|
||||||
LIBS = $(SYS_SPEEX)
|
LIBS = $(SYS_SPEEX)
|
||||||
endif
|
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
|
SOURCES = $(SRC:%.c=$(SPEEXSRC)/%.c) rbspeex.c rbspeexenc.c rbspeexdec.c
|
||||||
OBJS = $(addprefix $(OUT)/,$(SRC:%.c=%.o))
|
OBJS = $(addprefix $(BUILD_DIR)/,$(SRC:%.c=%.o))
|
||||||
DEPFILE = $(OUT)/dep-speex
|
DEPFILE = $(BUILD_DIR)/dep-speex
|
||||||
DIRS =
|
DIRS =
|
||||||
|
|
||||||
.PHONY : all
|
.PHONY : all
|
||||||
|
@ -52,14 +63,14 @@ DIRS =
|
||||||
all: ../rbspeexenc ../rbspeexdec
|
all: ../rbspeexenc ../rbspeexdec
|
||||||
|
|
||||||
$(DEPFILE): $(SOURCES)
|
$(DEPFILE): $(SOURCES)
|
||||||
@echo MKDIR $(OUT)
|
@echo MKDIR $(BUILD_DIR)
|
||||||
$(SILENT)mkdir -p $(OUT)
|
$(SILENT)mkdir -p $(BUILD_DIR)
|
||||||
@echo Creating dependencies
|
@echo Creating dependencies
|
||||||
$(SILENT)rm -f $(DEPFILE)
|
$(SILENT)rm -f $(DEPFILE)
|
||||||
$(SILENT)(for each in $(SOURCES) x; do \
|
$(SILENT)(for each in $(SOURCES) x; do \
|
||||||
if test "x" != "$$each"; then \
|
if test "x" != "$$each"; then \
|
||||||
obj=`echo $$each | sed -e 's/\.[cS]/.o/' | sed -e 's/^.*\///' `; \
|
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; \
|
fi; \
|
||||||
if test -n "$$del"; then \
|
if test -n "$$del"; then \
|
||||||
rm $$del; \
|
rm $$del; \
|
||||||
|
@ -68,56 +79,41 @@ $(DEPFILE): $(SOURCES)
|
||||||
done > $(DEPFILE); \
|
done > $(DEPFILE); \
|
||||||
echo "oo" > /dev/null )
|
echo "oo" > /dev/null )
|
||||||
|
|
||||||
-include $(DEPFILE)
|
include $(DEPFILE)
|
||||||
|
|
||||||
dll: $(TARGET_DIR)rbspeex.dll
|
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 $@)
|
@echo DLL $(notdir $@)
|
||||||
$(SILENT)$(CROSS)$(CC) $(CFLAGS) -shared -o $@ $^ \
|
$(SILENT)$(CROSS)$(CC) $(CFLAGS) -shared -o $@ $^ \
|
||||||
-Wl,--output-def,$(TARGET_DIR)rbspeex.def
|
-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 $@)
|
@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
|
librbspeex.a: $(TARGET_DIR)librbspeex.a
|
||||||
$(SILENT)cp $(OUT)/librbspeex.a $(TARGET_DIR)librbspeex$(RBARCH).a
|
|
||||||
|
../rbspeexenc: $(OBJS) $(BUILD_DIR)/rbspeexenc.o librbspeex.a
|
||||||
../rbspeexenc: $(OBJS) $(OUT)/rbspeexenc.o librbspeex$(RBARCH).a
|
|
||||||
@echo Linking ../rbspeexenc
|
@echo Linking ../rbspeexenc
|
||||||
$(SILENT)$(CROSS)$(CC) $(CFLAGS) -o ../rbspeexenc $(OUT)/rbspeexenc.o \
|
$(SILENT)$(CROSS)$(CC) $(CFLAGS) $(ARCHFLAGS) -o ../rbspeexenc $(BUILD_DIR)/rbspeexenc.o \
|
||||||
$(LIBS) -lm $(TARGET_DIR)librbspeex$(RBARCH).a
|
$(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
|
@echo Linking ../rbspeexdec
|
||||||
$(SILENT)$(CROSS)$(CC) $(CFLAGS) -o ../rbspeexdec $(OUT)/rbspeexdec.o \
|
$(SILENT)$(CROSS)$(CC) $(CFLAGS) $(ARCHFLAGS) -o ../rbspeexdec $(BUILD_DIR)/rbspeexdec.o \
|
||||||
$(LIBS) -lm $(TARGET_DIR)librbspeex$(RBARCH).a
|
$(LIBS) -lm $(TARGET_DIR)librbspeex.a
|
||||||
|
|
||||||
%.o:
|
%.o:
|
||||||
@echo CC $<
|
@echo CC $<
|
||||||
$(SILENT)$(CROSS)$(CC) $(CFLAGS) -c $< -o $@
|
$(SILENT)$(CROSS)$(CC) $(CFLAGS) $(ARCHFLAGS) -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
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJS) $(TARGET_DIR)librbspeex* ../rbspeexenc ../rbspeexdec $(TARGET_DIR)dep-speex
|
rm -f $(OBJS) $(TARGET_DIR)librbspeex* ../rbspeexenc ../rbspeexdec $(TARGET_DIR)dep-speex
|
||||||
rm -rf build*
|
rm -rf build*
|
||||||
|
|
||||||
$(OUT):
|
$(BUILD_DIR):
|
||||||
@echo MKDIR $(OUT)
|
@echo MKDIR $(BUILD_DIR)
|
||||||
$(SILENT)mkdir $(OUT)
|
$(SILENT)mkdir $(BUILD_DIR)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue