Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 #
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 include $(CORE_DEPTH)/coreconf/UNIX.mk
8 DEFAULT_COMPILER = gcc
10 CC = gcc
11 CCC = g++
12 RANLIB = ranlib
14 ifndef CPU_ARCH
15 # When cross-compiling, CPU_ARCH should already be defined as the target
16 # architecture, set to powerpc or i386.
17 CPU_ARCH := $(shell uname -p)
18 endif
20 ifeq (,$(filter-out i%86,$(CPU_ARCH)))
21 ifdef USE_64
22 CC += -arch x86_64
23 override CPU_ARCH = x86_64
24 else
25 OS_REL_CFLAGS = -Di386
26 CC += -arch i386
27 override CPU_ARCH = x86
28 endif
29 else
30 ifeq (arm,$(CPU_ARCH))
31 # Nothing set for arm currently.
32 else
33 OS_REL_CFLAGS = -Dppc
34 CC += -arch ppc
35 endif
36 endif
38 ifneq (,$(MACOS_SDK_DIR))
39 GCC_VERSION_FULL := $(shell $(CC) -dumpversion)
40 GCC_VERSION_MAJOR := $(shell echo $(GCC_VERSION_FULL) | awk -F. '{ print $$1 }')
41 GCC_VERSION_MINOR := $(shell echo $(GCC_VERSION_FULL) | awk -F. '{ print $$2 }')
42 GCC_VERSION = $(GCC_VERSION_MAJOR).$(GCC_VERSION_MINOR)
44 ifeq (,$(filter-out 2 3,$(GCC_VERSION_MAJOR)))
45 # GCC <= 3
46 DARWIN_SDK_FRAMEWORKS = -F$(MACOS_SDK_DIR)/System/Library/Frameworks
47 ifneq (,$(shell find $(MACOS_SDK_DIR)/Library/Frameworks -maxdepth 0))
48 DARWIN_SDK_FRAMEWORKS += -F$(MACOS_SDK_DIR)/Library/Frameworks
49 endif
50 DARWIN_SDK_CFLAGS = -nostdinc -isystem $(MACOS_SDK_DIR)/usr/include/gcc/darwin/$(GCC_VERSION) -isystem $(MACOS_SDK_DIR)/usr/include $(DARWIN_SDK_FRAMEWORKS)
51 DARWIN_SDK_LDFLAGS = -L$(MACOS_SDK_DIR)/usr/lib/gcc/darwin -L$(MACOS_SDK_DIR)/usr/lib/gcc/darwin/$(GCC_VERSION_FULL) -L$(MACOS_SDK_DIR)/usr/lib
52 DARWIN_SDK_SHLIBFLAGS = $(DARWIN_SDK_LDFLAGS) $(DARWIN_SDK_FRAMEWORKS)
53 NEXT_ROOT = $(MACOS_SDK_DIR)
54 export NEXT_ROOT
55 else
56 # GCC >= 4
57 DARWIN_SDK_CFLAGS = -isysroot $(MACOS_SDK_DIR)
58 ifneq (4.0.0,$(GCC_VERSION_FULL))
59 # gcc > 4.0.0 passes -syslibroot to ld based on -isysroot.
60 # Don't add -isysroot to DARWIN_SDK_LDFLAGS, because the programs
61 # that are linked with those flags also get DARWIN_SDK_CFLAGS.
62 DARWIN_SDK_SHLIBFLAGS = -isysroot $(MACOS_SDK_DIR)
63 else
64 # gcc 4.0.0 doesn't pass -syslibroot to ld, it needs to be
65 # explicit.
66 DARWIN_SDK_LDFLAGS = -Wl,-syslibroot,$(MACOS_SDK_DIR)
67 DARWIN_SDK_SHLIBFLAGS = $(DARWIN_SDK_LDFLAGS)
68 endif
69 endif
71 LDFLAGS += $(DARWIN_SDK_LDFLAGS)
72 endif
74 # "Commons" are tentative definitions in a global scope, like this:
75 # int x;
76 # The meaning of a common is ambiguous. It may be a true definition:
77 # int x = 0;
78 # or it may be a declaration of a symbol defined in another file:
79 # extern int x;
80 # Use the -fno-common option to force all commons to become true
81 # definitions so that the linker can catch multiply-defined symbols.
82 # Also, common symbols are not allowed with Darwin dynamic libraries.
84 OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) -Wall -fno-common -pipe -DDARWIN -DHAVE_STRERROR -DHAVE_BSD_FLOCK $(DARWIN_SDK_CFLAGS)
86 ifdef BUILD_OPT
87 ifeq (11,$(ALLOW_OPT_CODE_SIZE)$(OPT_CODE_SIZE))
88 OPTIMIZER = -Oz
89 else
90 OPTIMIZER = -O2
91 endif
92 ifdef MOZ_DEBUG_SYMBOLS
93 ifdef MOZ_DEBUG_FLAGS
94 OPTIMIZER += $(MOZ_DEBUG_FLAGS)
95 else
96 OPTIMIZER += -gdwarf-2 -gfull
97 endif
98 endif
99 endif
101 ARCH = darwin
103 DSO_CFLAGS = -fPIC
104 # May override this with different compatibility and current version numbers.
105 DARWIN_DYLIB_VERSIONS = -compatibility_version 1 -current_version 1
106 # May override this with -bundle to create a loadable module.
107 DSO_LDOPTS = -dynamiclib $(DARWIN_DYLIB_VERSIONS) -install_name @executable_path/$(notdir $@) -headerpad_max_install_names
109 MKSHLIB = $(CC) $(DSO_LDOPTS) $(DARWIN_SDK_SHLIBFLAGS)
110 DLL_SUFFIX = dylib
111 ifdef MAPFILE
112 MKSHLIB += -exported_symbols_list $(MAPFILE)
113 endif
114 PROCESS_MAP_FILE = grep -v ';+' $< | grep -v ';-' | \
115 sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' -e 's,^,_,' > $@
117 USE_SYSTEM_ZLIB = 1
118 ZLIB_LIBS = -lz