2007-11-16 15:35:37 +00:00
|
|
|
# __________ __ ___.
|
|
|
|
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
# \/ \/ \/ \/ \/
|
2007-11-16 15:58:38 +00:00
|
|
|
# $Id$
|
2007-11-16 15:35:37 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
ifndef V
|
|
|
|
SILENT = @
|
|
|
|
endif
|
|
|
|
|
2013-05-11 15:22:44 +00:00
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
mkdir = if not exist $(subst /,\,$(1)) mkdir $(subst /,\,$(1))
|
|
|
|
else
|
|
|
|
mkdir = mkdir -p $(1)
|
|
|
|
endif
|
|
|
|
|
2011-06-26 01:32:25 +00:00
|
|
|
SPEEXSRC = ../../lib/rbcodec/codecs/libspeex
|
2007-11-16 15:35:37 +00:00
|
|
|
|
2007-11-16 19:53:47 +00:00
|
|
|
INCLUDES = -I $(SPEEXSRC)
|
2007-11-16 15:35:37 +00:00
|
|
|
SPEEXOPTS = -DHAVE_CONFIG_H -DROCKBOX_VOICE_ENCODER
|
|
|
|
|
2012-01-02 16:59:26 +00:00
|
|
|
CFLAGS += $(SPEEXOPTS) $(INCLUDES) -O3 -fomit-frame-pointer -Wno-unused-parameter
|
2007-11-16 15:35:37 +00:00
|
|
|
|
2013-05-03 22:12:13 +00:00
|
|
|
CPPDEFINES := $(shell echo foo | $(CROSS)$(CC) -dM -E -)
|
2007-11-16 21:05:34 +00:00
|
|
|
#build standalone win32 executables on cygwin
|
2013-05-03 22:12:13 +00:00
|
|
|
ifeq ($(findstring CYGWIN,$(CPPDEFINES)),CYGWIN)
|
2007-11-16 21:05:34 +00:00
|
|
|
CFLAGS+=-mno-cygwin
|
2013-05-03 22:12:13 +00:00
|
|
|
COMPILETARGET = cygwin
|
|
|
|
else
|
|
|
|
ifeq ($(findstring MINGW,$(CPPDEFINES)),MINGW)
|
|
|
|
COMPILETARGET = mingw
|
|
|
|
else
|
2012-01-05 22:26:04 +00:00
|
|
|
# OS X specifics. Needs to consider cross compiling for Windows.
|
2013-05-03 22:12:13 +00:00
|
|
|
ifeq ($(findstring APPLE,$(CPPDEFINES)),APPLE)
|
2012-01-05 22:26:04 +00:00
|
|
|
# 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
|
2013-05-03 22:12:13 +00:00
|
|
|
COMPILETARGET = darwin
|
|
|
|
else
|
|
|
|
COMPILETARGET = posix
|
|
|
|
endif
|
2012-01-05 22:26:04 +00:00
|
|
|
endif
|
2008-07-09 21:39:45 +00:00
|
|
|
endif
|
2013-05-03 22:12:13 +00:00
|
|
|
$(info Compiler creates $(COMPILETARGET) binaries)
|
2008-07-09 21:39:45 +00:00
|
|
|
|
2009-10-08 21:26:39 +00:00
|
|
|
# don't try to use the systems libspeex when building a static binary.
|
|
|
|
ifndef STATIC
|
2010-09-05 10:27:39 +00:00
|
|
|
SYS_SPEEX ?= $(shell pkg-config --silence-errors --libs speex speexdsp)
|
2009-10-08 21:26:39 +00:00
|
|
|
endif
|
2008-07-09 21:39:45 +00:00
|
|
|
|
2009-10-08 21:26:39 +00:00
|
|
|
# fall back to our own librbspeex if no suitable found.
|
|
|
|
ifeq ($(SYS_SPEEX),)
|
2007-11-16 15:35:37 +00:00
|
|
|
# This sets up 'SRC' based on the files mentioned in SOURCES
|
2013-05-03 22:12:13 +00:00
|
|
|
SRC := $(shell $(CC) $(CFLAGS) -E -P -xc $(SPEEXSRC)/SOURCES)
|
2012-01-05 22:26:04 +00:00
|
|
|
LIBS = $(TARGET_DIR)librbspeex.a
|
2009-10-08 21:26:39 +00:00
|
|
|
else
|
|
|
|
LIBS = $(SYS_SPEEX)
|
|
|
|
endif
|
2007-11-16 15:35:37 +00:00
|
|
|
|
2012-01-05 22:26:04 +00:00
|
|
|
TARGET_DIR ?= $(shell pwd)/
|
2013-05-03 22:12:13 +00:00
|
|
|
BUILD_DIR ?= $(TARGET_DIR)build$(COMPILETARGET)
|
2007-12-14 16:04:38 +00:00
|
|
|
SOURCES = $(SRC:%.c=$(SPEEXSRC)/%.c) rbspeex.c rbspeexenc.c rbspeexdec.c
|
2012-01-05 22:26:04 +00:00
|
|
|
OBJS = $(addprefix $(BUILD_DIR)/,$(SRC:%.c=%.o))
|
2007-11-16 15:35:37 +00:00
|
|
|
DIRS =
|
|
|
|
|
|
|
|
.PHONY : all
|
|
|
|
|
2007-11-28 13:42:44 +00:00
|
|
|
all: ../rbspeexenc ../rbspeexdec
|
2007-11-16 15:35:37 +00:00
|
|
|
|
2013-05-11 18:25:15 +00:00
|
|
|
$(foreach src,$(SOURCES),$(eval $(BUILD_DIR)/$(subst .c,.o,$(notdir $(src))): $(src)))
|
|
|
|
$(foreach src,$(SOURCES),$(eval $(BUILD_DIR)/$(subst .c,.d,$(notdir $(src))): $(src)))
|
|
|
|
DEPS = $(addprefix $(BUILD_DIR)/,$(subst .c,.d,$(notdir $(SOURCES))))
|
|
|
|
-include $(DEPS)
|
|
|
|
|
|
|
|
%.d:
|
|
|
|
@echo DEP $(notdir $@)
|
|
|
|
$(SILENT)$(call mkdir,$(BUILD_DIR))
|
|
|
|
$(SILENT)$(CC) -MG -MM -MT $(subst .d,.o,$@) $(CFLAGS) -o $(BUILD_DIR)/$(notdir $@) $<
|
2008-07-20 15:47:47 +00:00
|
|
|
|
2011-12-17 09:57:28 +00:00
|
|
|
dll: $(TARGET_DIR)rbspeex.dll
|
|
|
|
|
2012-01-05 22:26:04 +00:00
|
|
|
$(TARGET_DIR)rbspeex.dll: $(OBJS) $(BUILD_DIR)/rbspeex.o
|
2011-12-16 21:10:25 +00:00
|
|
|
@echo DLL $(notdir $@)
|
2011-12-17 09:57:28 +00:00
|
|
|
$(SILENT)$(CROSS)$(CC) $(CFLAGS) -shared -o $@ $^ \
|
|
|
|
-Wl,--output-def,$(TARGET_DIR)rbspeex.def
|
2011-12-16 21:10:25 +00:00
|
|
|
|
2012-01-05 22:26:04 +00:00
|
|
|
$(TARGET_DIR)librbspeex.a: $(OBJS) $(BUILD_DIR)/rbspeex.o
|
2011-12-03 13:58:42 +00:00
|
|
|
@echo AR $(notdir $@)
|
2012-01-05 22:26:04 +00:00
|
|
|
$(SILENT)$(CROSS)$(AR) rcs $@ $^ > /dev/null 2>&1
|
2007-11-17 16:54:54 +00:00
|
|
|
|
2012-01-05 22:26:04 +00:00
|
|
|
librbspeex.a: $(TARGET_DIR)librbspeex.a
|
|
|
|
|
|
|
|
../rbspeexenc: $(OBJS) $(BUILD_DIR)/rbspeexenc.o librbspeex.a
|
2007-11-17 16:54:54 +00:00
|
|
|
@echo Linking ../rbspeexenc
|
2012-01-05 22:26:04 +00:00
|
|
|
$(SILENT)$(CROSS)$(CC) $(CFLAGS) $(ARCHFLAGS) -o ../rbspeexenc $(BUILD_DIR)/rbspeexenc.o \
|
|
|
|
$(LIBS) -lm $(TARGET_DIR)librbspeex.a
|
2007-11-16 15:35:37 +00:00
|
|
|
|
2012-01-05 22:26:04 +00:00
|
|
|
../rbspeexdec: $(OBJS) librbspeex.a $(BUILD_DIR)/rbspeexdec.o
|
2007-11-28 13:42:44 +00:00
|
|
|
@echo Linking ../rbspeexdec
|
2012-01-05 22:26:04 +00:00
|
|
|
$(SILENT)$(CROSS)$(CC) $(CFLAGS) $(ARCHFLAGS) -o ../rbspeexdec $(BUILD_DIR)/rbspeexdec.o \
|
|
|
|
$(LIBS) -lm $(TARGET_DIR)librbspeex.a
|
2007-11-28 13:42:44 +00:00
|
|
|
|
2007-11-16 15:35:37 +00:00
|
|
|
%.o:
|
2007-11-17 16:54:54 +00:00
|
|
|
@echo CC $<
|
2012-01-05 22:26:04 +00:00
|
|
|
$(SILENT)$(CROSS)$(CC) $(CFLAGS) $(ARCHFLAGS) -c $< -o $@
|
2007-12-14 16:04:38 +00:00
|
|
|
|
2007-11-16 15:35:37 +00:00
|
|
|
clean:
|
2013-05-11 18:25:15 +00:00
|
|
|
rm -f $(OBJS) $(TARGET_DIR)librbspeex* ../rbspeexenc ../rbspeexdec
|
|
|
|
rm -f $(DEPS)
|
2008-07-20 15:47:47 +00:00
|
|
|
rm -rf build*
|
|
|
|
|
2012-01-05 22:26:04 +00:00
|
|
|
$(BUILD_DIR):
|
|
|
|
@echo MKDIR $(BUILD_DIR)
|
2013-05-11 15:22:44 +00:00
|
|
|
$(SILENT)$(call mkdir, $(BUILD_DIR))
|
2007-11-16 15:35:37 +00:00
|
|
|
|