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)
|
2020-10-21 17:12:08 +00:00
|
|
|
SHELL = cmd.exe
|
2013-05-11 15:22:44 +00:00
|
|
|
mkdir = if not exist $(subst /,\,$(1)) mkdir $(subst /,\,$(1))
|
2015-06-20 18:44:17 +00:00
|
|
|
rm = if exist $(subst /,\,$(1)) del /q /s $(subst /,\,$(1))
|
2013-05-11 15:22:44 +00:00
|
|
|
else
|
|
|
|
mkdir = mkdir -p $(1)
|
2015-06-20 18:44:17 +00:00
|
|
|
rm = rm -rf $(1)
|
2013-05-11 15:22:44 +00:00
|
|
|
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)
|
2014-03-20 21:22:17 +00:00
|
|
|
# When building for 10.4+ we need to use gcc. Otherwise clang is used, so use
|
|
|
|
# that to determine if we need to set arch and isysroot.
|
|
|
|
ifeq ($(findstring __clang__,$(CPPDEFINES)),__clang__)
|
|
|
|
CFLAGS += -mmacosx-version-min=10.5
|
2020-10-18 16:53:48 +00:00
|
|
|
ifneq ($(ISYSROOT),)
|
|
|
|
CFLAGS += -isysroot $(ISYSROOT)
|
|
|
|
endif
|
2014-03-20 21:22:17 +00:00
|
|
|
else
|
|
|
|
# when building libs for OS X 10.4+ build for both i386 and ppc at the same time.
|
2012-01-05 22:26:04 +00:00
|
|
|
# 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.
|
2014-03-20 21:22:17 +00:00
|
|
|
ARCHFLAGS += -arch ppc -arch i386
|
2012-01-05 22:26:04 +00:00
|
|
|
# building against SDK 10.4 is not compatible with gcc-4.2 (default on newer Xcode)
|
|
|
|
# might need adjustment for older Xcode.
|
2014-03-20 21:22:17 +00:00
|
|
|
CC = gcc-4.0
|
2012-01-05 22:26:04 +00:00
|
|
|
CFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4
|
|
|
|
NATIVECC ?= gcc-4.0
|
2014-03-20 21:22:17 +00:00
|
|
|
endif
|
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
|
2020-10-18 13:48:38 +00:00
|
|
|
SPEEXSRCS := $(shell $(CC) $(CFLAGS) -E -P -xc $(SPEEXSRC)/SOURCES)
|
2021-05-18 12:41:09 +00:00
|
|
|
LIBSOURCES := $(SPEEXSRCS:%.c=$(SPEEXSRC)/%.c)
|
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
|
|
|
|
2021-05-18 12:41:09 +00:00
|
|
|
LIBSOURCES += rbspeex.c
|
|
|
|
|
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)
|
2020-10-18 13:48:38 +00:00
|
|
|
OBJDIR = $(abspath $(BUILD_DIR))/
|
|
|
|
SOURCES = rbspeex.c rbspeexenc.c rbspeexdec.c
|
|
|
|
OBJS := $(addsuffix .o,$(addprefix $(OBJDIR),$(notdir $(SOURCES))))
|
|
|
|
LIBOBJS := $(addsuffix .o,$(addprefix $(OBJDIR),$(notdir $(LIBSOURCES))))
|
2007-11-16 15:35:37 +00:00
|
|
|
|
|
|
|
.PHONY : all
|
|
|
|
|
2007-11-28 13:42:44 +00:00
|
|
|
all: ../rbspeexenc ../rbspeexdec
|
2007-11-16 15:35:37 +00:00
|
|
|
|
2020-10-18 13:48:38 +00:00
|
|
|
# create dependency files. Make sure to use the same prefix as with OBJS!
|
|
|
|
$(foreach src,$(SOURCES) $(LIBSOURCES),$(eval $(addprefix $(OBJDIR),$(notdir $(src).o)): $(src)))
|
|
|
|
$(foreach src,$(SOURCES) $(LIBSOURCES),$(eval $(addprefix $(OBJDIR),$(notdir $(src).d)): $(src)))
|
|
|
|
DEPS = $(addprefix $(OBJDIR),$(addsuffix .d,$(notdir $(SOURCES) $(LIBSOURCES))))
|
2013-05-11 18:25:15 +00:00
|
|
|
-include $(DEPS)
|
|
|
|
|
2011-12-17 09:57:28 +00:00
|
|
|
dll: $(TARGET_DIR)rbspeex.dll
|
|
|
|
|
2020-10-18 13:48:38 +00:00
|
|
|
$(TARGET_DIR)rbspeex.dll: $(LIBOBJS)
|
|
|
|
$(info 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
|
|
|
|
2020-10-18 13:48:38 +00:00
|
|
|
$(TARGET_DIR)librbspeex.a: $(LIBOBJS)
|
|
|
|
$(info AR $(notdir $@))
|
2015-06-20 18:44:17 +00:00
|
|
|
$(SILENT)$(call rm,$@)
|
2013-05-12 10:18:16 +00:00
|
|
|
$(SILENT)$(CROSS)$(AR) rcs $@ $^
|
2007-11-17 16:54:54 +00:00
|
|
|
|
2012-01-05 22:26:04 +00:00
|
|
|
librbspeex.a: $(TARGET_DIR)librbspeex.a
|
|
|
|
|
2020-10-18 13:48:38 +00:00
|
|
|
../rbspeexenc: $(OBJS) $(TARGET_DIR)librbspeex.a
|
|
|
|
$(info Linking ../rbspeexenc)
|
|
|
|
$(SILENT)$(CROSS)$(CC) $(CFLAGS) $(LDFLAGS) $(ARCHFLAGS) -o ../rbspeexenc $(BUILD_DIR)/rbspeexenc.c.o \
|
2021-06-27 15:16:35 +00:00
|
|
|
$(TARGET_DIR)librbspeex.a $(LIBS) -lm
|
2007-11-16 15:35:37 +00:00
|
|
|
|
2020-10-18 13:48:38 +00:00
|
|
|
../rbspeexdec: $(OBJS) $(TARGET_DIR)librbspeex.a
|
|
|
|
$(info Linking ../rbspeexdec)
|
|
|
|
$(SILENT)$(CROSS)$(CC) $(CFLAGS) $(LDFLAGS) $(ARCHFLAGS) -o ../rbspeexdec $(BUILD_DIR)/rbspeexdec.c.o \
|
2021-06-27 15:16:35 +00:00
|
|
|
$(TARGET_DIR)librbspeex.a $(LIBS) -lm
|
2007-11-28 13:42:44 +00:00
|
|
|
|
2020-10-18 13:48:38 +00:00
|
|
|
# common rules
|
|
|
|
$(OBJDIR)%.c.o:
|
|
|
|
$(info CC $<)
|
|
|
|
$(SILENT)$(call mkdir,$(dir $@))
|
|
|
|
$(SILENT)$(CROSS)$(CC) $(ARCHFLAGS) $(GCCFLAGS) $(CFLAGS) -MMD -c -o $@ $<
|
2007-12-14 16:04:38 +00:00
|
|
|
|
2007-11-16 15:35:37 +00:00
|
|
|
clean:
|
2020-10-18 13:48:38 +00:00
|
|
|
$(call rm,$(OBJS) $(LIBOBJS) $(TARGET_DIR)librbspeex* ../rbspeexenc ../rbspeexdec)
|
2015-06-20 18:44:17 +00:00
|
|
|
$(call rm,$(DEPS))
|
2020-10-18 13:48:38 +00:00
|
|
|
$(call rm,$(BUILD_DIR))
|
2008-07-20 15:47:47 +00:00
|
|
|
|
2012-01-05 22:26:04 +00:00
|
|
|
$(BUILD_DIR):
|
2020-10-18 13:48:38 +00:00
|
|
|
$(info MKDIR $(BUILD_DIR))
|
2013-05-11 15:22:44 +00:00
|
|
|
$(SILENT)$(call mkdir, $(BUILD_DIR))
|
2007-11-16 15:35:37 +00:00
|
|
|
|