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