From ea0bfe7520742ac5dec97c6ac4cdc54d2410445c Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Fri, 5 Apr 2013 19:49:04 +0200 Subject: Replace the use of uname to get the build output. Using uname has a couple of problems, especially when cross compiling. Instead check the defines set by the preprocessor to figure the type of binaries it produces. This improves support for cross compiling as it allows to (1) select the correct default target and (2) makes it possible to use separate build folders for different targets. Change-Id: I69a32904dab97755034f2f0d63f8402309d479d2 --- rbutil/ipodpatcher/Makefile | 4 +--- rbutil/libtools.make | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/rbutil/ipodpatcher/Makefile b/rbutil/ipodpatcher/Makefile index 79fe4c7c03..0b0b404ca2 100644 --- a/rbutil/ipodpatcher/Makefile +++ b/rbutil/ipodpatcher/Makefile @@ -27,10 +27,8 @@ BOOTSRC = ipod1g2g.c ipod3g.c ipod4g.c ipodcolor.c ipodmini1g.c \ CFLAGS += -DWITH_BOOTOBJS endif -ifeq ($(findstring Darwin,$(shell uname)),Darwin) # additional frameworks to link on on OS X -LDOPTS += -framework CoreFoundation -framework IOKit -endif +LDOPTS_OSX += -framework CoreFoundation -framework IOKit LIBSOURCES = ipodpatcher.c fat32format.c arc4.c \ ipodio-posix.c ipodio-win32-scsi.c ipodio-win32.c diff --git a/rbutil/libtools.make b/rbutil/libtools.make index 77142355c6..44ed5fef3d 100644 --- a/rbutil/libtools.make +++ b/rbutil/libtools.make @@ -25,31 +25,37 @@ TOP := $(dir $(lastword $(MAKEFILE_LIST))) # overwrite for releases APPVERSION ?= $(shell $(TOP)/../tools/version.sh $(TOP)/..) CFLAGS += -DVERSION=\""$(APPVERSION)"\" -TARGET_DIR ?= $(shell pwd)/ +TARGET_DIR ?= $(abspath .)/ +CPPDEFINES=$(shell echo foo | $(CROSS)$(CC) -dM -E -) # use POSIX/C99 printf on windows CFLAGS += -D__USE_MINGW_ANSI_STDIO=1 BINARY = $(OUTPUT) # when building a Windows binary add the correct file suffix -ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) +ifeq ($(findstring CYGWIN,$(CPPDEFINES)),CYGWIN) BINARY = $(OUTPUT).exe CFLAGS+=-mno-cygwin +COMPILETARGET = cygwin else -ifeq ($(findstring MINGW,$(shell uname)),MINGW) +ifeq ($(findstring MINGW,$(CPPDEFINES)),MINGW) BINARY = $(OUTPUT).exe +COMPILETARGET = mingw else -ifeq ($(findstring mingw,$(CROSS)$(CC)),mingw) -BINARY = $(OUTPUT).exe +ifeq ($(findstring APPLE,$(CPPDEFINES)),APPLE) +COMPILETARGET = darwin +LDOPTS += $(LDFLAGS_OSX) +else +COMPILETARGET = posix endif endif endif +$(info Compiler creates $(COMPILETARGET) binaries) NATIVECC ?= gcc CC ?= gcc # 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. @@ -60,10 +66,9 @@ CC ?= gcc-4.0 CFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 NATIVECC ?= gcc-4.0 endif -endif WINDRES = windres -BUILD_DIR ?= $(TARGET_DIR)build +BUILD_DIR ?= $(TARGET_DIR)build$(COMPILETARGET) OBJDIR = $(abspath $(BUILD_DIR)/$(RBARCH))/ ifdef RBARCH -- cgit v1.2.3