diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2013-04-05 19:49:04 +0200 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2013-04-05 19:49:04 +0200 |
commit | ea0bfe7520742ac5dec97c6ac4cdc54d2410445c (patch) | |
tree | 12503bd7ff199df05dee75b952e1802c9ad64ded /rbutil | |
parent | 891351db6001f51d7615f7190a8751adea861376 (diff) | |
download | rockbox-ea0bfe7520742ac5dec97c6ac4cdc54d2410445c.tar.gz rockbox-ea0bfe7520742ac5dec97c6ac4cdc54d2410445c.zip |
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
Diffstat (limited to 'rbutil')
-rw-r--r-- | rbutil/ipodpatcher/Makefile | 4 | ||||
-rw-r--r-- | 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 \ | |||
27 | CFLAGS += -DWITH_BOOTOBJS | 27 | CFLAGS += -DWITH_BOOTOBJS |
28 | endif | 28 | endif |
29 | 29 | ||
30 | ifeq ($(findstring Darwin,$(shell uname)),Darwin) | ||
31 | # additional frameworks to link on on OS X | 30 | # additional frameworks to link on on OS X |
32 | LDOPTS += -framework CoreFoundation -framework IOKit | 31 | LDOPTS_OSX += -framework CoreFoundation -framework IOKit |
33 | endif | ||
34 | 32 | ||
35 | LIBSOURCES = ipodpatcher.c fat32format.c arc4.c \ | 33 | LIBSOURCES = ipodpatcher.c fat32format.c arc4.c \ |
36 | ipodio-posix.c ipodio-win32-scsi.c ipodio-win32.c | 34 | 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))) | |||
25 | # overwrite for releases | 25 | # overwrite for releases |
26 | APPVERSION ?= $(shell $(TOP)/../tools/version.sh $(TOP)/..) | 26 | APPVERSION ?= $(shell $(TOP)/../tools/version.sh $(TOP)/..) |
27 | CFLAGS += -DVERSION=\""$(APPVERSION)"\" | 27 | CFLAGS += -DVERSION=\""$(APPVERSION)"\" |
28 | TARGET_DIR ?= $(shell pwd)/ | 28 | TARGET_DIR ?= $(abspath .)/ |
29 | 29 | ||
30 | CPPDEFINES=$(shell echo foo | $(CROSS)$(CC) -dM -E -) | ||
30 | # use POSIX/C99 printf on windows | 31 | # use POSIX/C99 printf on windows |
31 | CFLAGS += -D__USE_MINGW_ANSI_STDIO=1 | 32 | CFLAGS += -D__USE_MINGW_ANSI_STDIO=1 |
32 | 33 | ||
33 | BINARY = $(OUTPUT) | 34 | BINARY = $(OUTPUT) |
34 | # when building a Windows binary add the correct file suffix | 35 | # when building a Windows binary add the correct file suffix |
35 | ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) | 36 | ifeq ($(findstring CYGWIN,$(CPPDEFINES)),CYGWIN) |
36 | BINARY = $(OUTPUT).exe | 37 | BINARY = $(OUTPUT).exe |
37 | CFLAGS+=-mno-cygwin | 38 | CFLAGS+=-mno-cygwin |
39 | COMPILETARGET = cygwin | ||
38 | else | 40 | else |
39 | ifeq ($(findstring MINGW,$(shell uname)),MINGW) | 41 | ifeq ($(findstring MINGW,$(CPPDEFINES)),MINGW) |
40 | BINARY = $(OUTPUT).exe | 42 | BINARY = $(OUTPUT).exe |
43 | COMPILETARGET = mingw | ||
41 | else | 44 | else |
42 | ifeq ($(findstring mingw,$(CROSS)$(CC)),mingw) | 45 | ifeq ($(findstring APPLE,$(CPPDEFINES)),APPLE) |
43 | BINARY = $(OUTPUT).exe | 46 | COMPILETARGET = darwin |
47 | LDOPTS += $(LDFLAGS_OSX) | ||
48 | else | ||
49 | COMPILETARGET = posix | ||
44 | endif | 50 | endif |
45 | endif | 51 | endif |
46 | endif | 52 | endif |
53 | $(info Compiler creates $(COMPILETARGET) binaries) | ||
47 | 54 | ||
48 | NATIVECC ?= gcc | 55 | NATIVECC ?= gcc |
49 | CC ?= gcc | 56 | CC ?= gcc |
50 | # OS X specifics. Needs to consider cross compiling for Windows. | 57 | # OS X specifics. Needs to consider cross compiling for Windows. |
51 | ifeq ($(findstring Darwin,$(shell uname)),Darwin) | 58 | ifeq ($(findstring APPLE,$(CPPDEFINES)),APPLE) |
52 | ifneq ($(findstring mingw,$(CROSS)$(CC)),mingw) | ||
53 | # when building libs for OS X build for both i386 and ppc at the same time. | 59 | # when building libs for OS X build for both i386 and ppc at the same time. |
54 | # This creates fat objects, and ar can only create the archive but not operate | 60 | # This creates fat objects, and ar can only create the archive but not operate |
55 | # on it. As a result the ar call must NOT use the u (update) flag. | 61 | # on it. As a result the ar call must NOT use the u (update) flag. |
@@ -60,10 +66,9 @@ CC ?= gcc-4.0 | |||
60 | CFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 | 66 | CFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 |
61 | NATIVECC ?= gcc-4.0 | 67 | NATIVECC ?= gcc-4.0 |
62 | endif | 68 | endif |
63 | endif | ||
64 | WINDRES = windres | 69 | WINDRES = windres |
65 | 70 | ||
66 | BUILD_DIR ?= $(TARGET_DIR)build | 71 | BUILD_DIR ?= $(TARGET_DIR)build$(COMPILETARGET) |
67 | OBJDIR = $(abspath $(BUILD_DIR)/$(RBARCH))/ | 72 | OBJDIR = $(abspath $(BUILD_DIR)/$(RBARCH))/ |
68 | 73 | ||
69 | ifdef RBARCH | 74 | ifdef RBARCH |