summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rbutil/ipodpatcher/Makefile4
-rw-r--r--rbutil/libtools.make23
2 files changed, 15 insertions, 12 deletions
diff --git a/rbutil/ipodpatcher/Makefile b/rbutil/ipodpatcher/Makefile
index 79fe4c7..0b0b404 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 7714235..44ed5fe 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