Index: tools/rbspeex/Makefile =================================================================== --- tools/rbspeex/Makefile (revision 18183) +++ tools/rbspeex/Makefile (working copy) @@ -11,12 +11,9 @@ SILENT = @ endif -SPEEXSRC = ../../apps/codecs/libspeex - -INCLUDES = -I $(SPEEXSRC) SPEEXOPTS = -DHAVE_CONFIG_H -DROCKBOX_VOICE_ENCODER -CFLAGS = $(SPEEXOPTS) $(INCLUDES) -O3 -fomit-frame-pointer -Wno-unused-parameter +CFLAGS = $(SPEEXOPTS) -O3 -fomit-frame-pointer -Wno-unused-parameter #build standalone win32 executables on cygwin ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) @@ -31,9 +28,25 @@ CFLAGS += -arch $(ARCH) endif +# Attempt to compile our test-program and grab the return value +OUTPUT = $(shell $(CC) testprogram.c -lspeex -lspeexdsp -o /dev/null 2>&1; echo $$?) +# Always link against Rockbox' libspeex if building a static rbutil +ifdef STATIC + OUTPUT = 1 +endif -# This sets up 'SRC' based on the files mentioned in SOURCES -SRC := $(shell cat $(SPEEXSRC)/SOURCES | $(CC) $(CFLAGS) -E -P - | grep -v "^\#" | grep -v "^$$") +ifeq ($(OUTPUT),0) + # Program compiled correctly - use system libspeex + SPEEXSRC = /usr/include + CFLAGS+=-lspeex -lspeexdsp +else + # Program failed to compile - use ../../apps/codecs/libspeex + # This sets up 'SRC' based on the files mentioned in SOURCES + SPEEXSRC = ../../apps/codecs/libspeex + SRC := $(shell cat $(SPEEXSRC)/SOURCES | $(CC) $(CFLAGS) -E -P - | grep -v "^\#" | grep -v "^$$") +endif +INCLUDES = -I $(SPEEXSRC) +CFLAGS+=$(INCLUDES) OUT = build$(ARCH) SOURCES = $(SRC:%.c=$(SPEEXSRC)/%.c) rbspeex.c rbspeexenc.c rbspeexdec.c Index: rbutil/rbutilqt/rbutilqt.pro =================================================================== --- rbutil/rbutilqt/rbutilqt.pro (revision 18183) +++ rbutil/rbutilqt/rbutilqt.pro (working copy) @@ -13,12 +13,34 @@ RCC_DIR = build/rcc # add a custom rule for pre-building librbspeex -!mac { -rbspeex.commands = @$(MAKE) -C ../../tools/rbspeex librbspeex.a +static { + message("building staticly") + !mac { + rbspeex.commands = @STATIC=1 $(MAKE) -C ../../tools/rbspeex librbspeex.a + } + mac { + rbspeex.commands = @STATIC=1 $(MAKE) -C ../../tools/rbspeex librbspeex-universal + } } -mac { -rbspeex.commands = @$(MAKE) -C ../../tools/rbspeex librbspeex-universal +!static { + message("building dynamicly") + !mac { + rbspeex.commands = @$(MAKE) -C ../../tools/rbspeex librbspeex.a + } + mac { + rbspeex.commands = @$(MAKE) -C ../../tools/rbspeex librbspeex-universal + } + + # If not building staticly, use system libspeex if available + system($$QMAKE_CC -lspeex -lspeexdsp ../../tools/rbspeex/testprogram.c -o /dev/null) { + message("Using system libspeex") + LIBS += -lspeex -lspeexdsp + } + else { + message("Using Rockbox libspeex") + } } + QMAKE_EXTRA_TARGETS += rbspeex PRE_TARGETDEPS += rbspeex