michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: include $(CORE_DEPTH)/coreconf/UNIX.mk michael@0: michael@0: DEFAULT_COMPILER = gcc michael@0: michael@0: CC = gcc michael@0: CCC = g++ michael@0: RANLIB = ranlib michael@0: michael@0: ifndef CPU_ARCH michael@0: # When cross-compiling, CPU_ARCH should already be defined as the target michael@0: # architecture, set to powerpc or i386. michael@0: CPU_ARCH := $(shell uname -p) michael@0: endif michael@0: michael@0: ifeq (,$(filter-out i%86,$(CPU_ARCH))) michael@0: ifdef USE_64 michael@0: CC += -arch x86_64 michael@0: override CPU_ARCH = x86_64 michael@0: else michael@0: OS_REL_CFLAGS = -Di386 michael@0: CC += -arch i386 michael@0: override CPU_ARCH = x86 michael@0: endif michael@0: else michael@0: ifeq (arm,$(CPU_ARCH)) michael@0: # Nothing set for arm currently. michael@0: else michael@0: OS_REL_CFLAGS = -Dppc michael@0: CC += -arch ppc michael@0: endif michael@0: endif michael@0: michael@0: ifneq (,$(MACOS_SDK_DIR)) michael@0: GCC_VERSION_FULL := $(shell $(CC) -dumpversion) michael@0: GCC_VERSION_MAJOR := $(shell echo $(GCC_VERSION_FULL) | awk -F. '{ print $$1 }') michael@0: GCC_VERSION_MINOR := $(shell echo $(GCC_VERSION_FULL) | awk -F. '{ print $$2 }') michael@0: GCC_VERSION = $(GCC_VERSION_MAJOR).$(GCC_VERSION_MINOR) michael@0: michael@0: ifeq (,$(filter-out 2 3,$(GCC_VERSION_MAJOR))) michael@0: # GCC <= 3 michael@0: DARWIN_SDK_FRAMEWORKS = -F$(MACOS_SDK_DIR)/System/Library/Frameworks michael@0: ifneq (,$(shell find $(MACOS_SDK_DIR)/Library/Frameworks -maxdepth 0)) michael@0: DARWIN_SDK_FRAMEWORKS += -F$(MACOS_SDK_DIR)/Library/Frameworks michael@0: endif michael@0: 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: 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: DARWIN_SDK_SHLIBFLAGS = $(DARWIN_SDK_LDFLAGS) $(DARWIN_SDK_FRAMEWORKS) michael@0: NEXT_ROOT = $(MACOS_SDK_DIR) michael@0: export NEXT_ROOT michael@0: else michael@0: # GCC >= 4 michael@0: DARWIN_SDK_CFLAGS = -isysroot $(MACOS_SDK_DIR) michael@0: ifneq (4.0.0,$(GCC_VERSION_FULL)) michael@0: # gcc > 4.0.0 passes -syslibroot to ld based on -isysroot. michael@0: # Don't add -isysroot to DARWIN_SDK_LDFLAGS, because the programs michael@0: # that are linked with those flags also get DARWIN_SDK_CFLAGS. michael@0: DARWIN_SDK_SHLIBFLAGS = -isysroot $(MACOS_SDK_DIR) michael@0: else michael@0: # gcc 4.0.0 doesn't pass -syslibroot to ld, it needs to be michael@0: # explicit. michael@0: DARWIN_SDK_LDFLAGS = -Wl,-syslibroot,$(MACOS_SDK_DIR) michael@0: DARWIN_SDK_SHLIBFLAGS = $(DARWIN_SDK_LDFLAGS) michael@0: endif michael@0: endif michael@0: michael@0: LDFLAGS += $(DARWIN_SDK_LDFLAGS) michael@0: endif michael@0: michael@0: # "Commons" are tentative definitions in a global scope, like this: michael@0: # int x; michael@0: # The meaning of a common is ambiguous. It may be a true definition: michael@0: # int x = 0; michael@0: # or it may be a declaration of a symbol defined in another file: michael@0: # extern int x; michael@0: # Use the -fno-common option to force all commons to become true michael@0: # definitions so that the linker can catch multiply-defined symbols. michael@0: # Also, common symbols are not allowed with Darwin dynamic libraries. michael@0: michael@0: OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) -Wall -fno-common -pipe -DDARWIN -DHAVE_STRERROR -DHAVE_BSD_FLOCK $(DARWIN_SDK_CFLAGS) michael@0: michael@0: ifdef BUILD_OPT michael@0: ifeq (11,$(ALLOW_OPT_CODE_SIZE)$(OPT_CODE_SIZE)) michael@0: OPTIMIZER = -Oz michael@0: else michael@0: OPTIMIZER = -O2 michael@0: endif michael@0: ifdef MOZ_DEBUG_SYMBOLS michael@0: ifdef MOZ_DEBUG_FLAGS michael@0: OPTIMIZER += $(MOZ_DEBUG_FLAGS) michael@0: else michael@0: OPTIMIZER += -gdwarf-2 -gfull michael@0: endif michael@0: endif michael@0: endif michael@0: michael@0: ARCH = darwin michael@0: michael@0: DSO_CFLAGS = -fPIC michael@0: # May override this with different compatibility and current version numbers. michael@0: DARWIN_DYLIB_VERSIONS = -compatibility_version 1 -current_version 1 michael@0: # May override this with -bundle to create a loadable module. michael@0: DSO_LDOPTS = -dynamiclib $(DARWIN_DYLIB_VERSIONS) -install_name @executable_path/$(notdir $@) -headerpad_max_install_names michael@0: michael@0: MKSHLIB = $(CC) $(DSO_LDOPTS) $(DARWIN_SDK_SHLIBFLAGS) michael@0: DLL_SUFFIX = dylib michael@0: ifdef MAPFILE michael@0: MKSHLIB += -exported_symbols_list $(MAPFILE) michael@0: endif michael@0: PROCESS_MAP_FILE = grep -v ';+' $< | grep -v ';-' | \ michael@0: sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' -e 's,^,_,' > $@ michael@0: michael@0: USE_SYSTEM_ZLIB = 1 michael@0: ZLIB_LIBS = -lz