From d964199cc74d8b0079ef4929a2b6a137e201f630 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Sat, 4 May 2013 00:12:13 +0200 Subject: [PATCH] Replace use of uname by checking the compiler output. Similar as done in ea0bfe7 ask the compiler for the binary it creates instead of using uname to figure the target. Simplify source file preprocessing to avoid using grep to improve compatibility with Windows. Change-Id: I39ecfe690c9bb70b07b0af5a7804d7e5ab512d71 --- tools/rbspeex/Makefile | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/rbspeex/Makefile b/tools/rbspeex/Makefile index 2435caeaf4..feaf82997c 100644 --- a/tools/rbspeex/Makefile +++ b/tools/rbspeex/Makefile @@ -18,13 +18,17 @@ SPEEXOPTS = -DHAVE_CONFIG_H -DROCKBOX_VOICE_ENCODER CFLAGS += $(SPEEXOPTS) $(INCLUDES) -O3 -fomit-frame-pointer -Wno-unused-parameter +CPPDEFINES := $(shell echo foo | $(CROSS)$(CC) -dM -E -) #build standalone win32 executables on cygwin -ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) +ifeq ($(findstring CYGWIN,$(CPPDEFINES)),CYGWIN) CFLAGS+=-mno-cygwin -endif +COMPILETARGET = cygwin +else +ifeq ($(findstring MINGW,$(CPPDEFINES)),MINGW) +COMPILETARGET = mingw +else # OS X specifics. Needs to consider cross compiling for Windows. -ifeq ($(findstring Darwin,$(shell uname)),Darwin) -ifneq ($(findstring mingw,$(CROSS)$(CC)),mingw) +ifeq ($(findstring APPLE,$(CPPDEFINES)),APPLE) # 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. @@ -34,8 +38,13 @@ ARCHFLAGS = -arch ppc -arch i386 CC ?= gcc-4.0 CFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 NATIVECC ?= gcc-4.0 +COMPILETARGET = darwin +else +COMPILETARGET = posix endif endif +endif +$(info Compiler creates $(COMPILETARGET) binaries) # don't try to use the systems libspeex when building a static binary. ifndef STATIC @@ -45,14 +54,15 @@ endif # fall back to our own librbspeex if no suitable found. 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 "^$$") +SRC := $(shell $(CC) $(CFLAGS) -E -P -xc $(SPEEXSRC)/SOURCES) +$(warning $(SRC)) LIBS = $(TARGET_DIR)librbspeex.a else LIBS = $(SYS_SPEEX) endif TARGET_DIR ?= $(shell pwd)/ -BUILD_DIR ?= $(TARGET_DIR)build +BUILD_DIR ?= $(TARGET_DIR)build$(COMPILETARGET) SOURCES = $(SRC:%.c=$(SPEEXSRC)/%.c) rbspeex.c rbspeexenc.c rbspeexdec.c OBJS = $(addprefix $(BUILD_DIR)/,$(SRC:%.c=%.o)) DEPFILE = $(BUILD_DIR)/dep-speex