Bug 1904979 - Update codespell to 2.3.0 r=linter-reviewers,Standard8
[gecko.git] / security / nss / coreconf / Darwin.mk
blob0569e1819dd94ad601ff74ef6e212d2471059451
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 CC ?= gcc
7 CCC ?= g++
8 RANLIB ?= ranlib
10 include $(CORE_DEPTH)/coreconf/UNIX.mk
11 include $(CORE_DEPTH)/coreconf/Werror.mk
13 DEFAULT_COMPILER = gcc
15 ifndef CPU_ARCH
16 # When cross-compiling, CPU_ARCH should already be defined as the target
17 # architecture, set to powerpc or i386.
18 CPU_ARCH := $(shell uname -p)
19 endif
21 ifeq (,$(filter-out i%86,$(CPU_ARCH)))
22 ifdef USE_64
23 CC += -arch x86_64
24 CCC += -arch x86_64
25 override CPU_ARCH = x86_64
26 else
27 OS_REL_CFLAGS = -Di386
28 CC += -arch i386
29 CCC += -arch i386
30 override CPU_ARCH = x86
31 endif
32 else
33 ifeq (arm,$(CPU_ARCH))
34 # Nothing set for arm currently.
35 else
36 OS_REL_CFLAGS = -Dppc
37 CC += -arch ppc
38 CCC += -arch ppc
39 endif
40 endif
42 ifneq (,$(MACOS_SDK_DIR))
43 GCC_VERSION_FULL := $(shell $(CC) -dumpversion)
44 GCC_VERSION_MAJOR := $(shell echo $(GCC_VERSION_FULL) | awk -F. '{ print $$1 }')
45 GCC_VERSION_MINOR := $(shell echo $(GCC_VERSION_FULL) | awk -F. '{ print $$2 }')
46 GCC_VERSION = $(GCC_VERSION_MAJOR).$(GCC_VERSION_MINOR)
48 ifeq (,$(filter-out 2 3,$(GCC_VERSION_MAJOR)))
49 # GCC <= 3
50 DARWIN_SDK_FRAMEWORKS = -F$(MACOS_SDK_DIR)/System/Library/Frameworks
51 ifneq (,$(shell find $(MACOS_SDK_DIR)/Library/Frameworks -maxdepth 0))
52 DARWIN_SDK_FRAMEWORKS += -F$(MACOS_SDK_DIR)/Library/Frameworks
53 endif
54 DARWIN_SDK_CFLAGS = -nostdinc -isystem $(MACOS_SDK_DIR)/usr/include/gcc/darwin/$(GCC_VERSION) -isystem $(MACOS_SDK_DIR)/usr/include $(DARWIN_SDK_FRAMEWORKS)
55 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
56 DARWIN_SDK_SHLIBFLAGS = $(DARWIN_SDK_LDFLAGS) $(DARWIN_SDK_FRAMEWORKS)
57 NEXT_ROOT = $(MACOS_SDK_DIR)
58 export NEXT_ROOT
59 else
60 # GCC >= 4
61 DARWIN_SDK_CFLAGS = -isysroot $(MACOS_SDK_DIR)
62 ifneq (4.0.0,$(GCC_VERSION_FULL))
63 # gcc > 4.0.0 passes -syslibroot to ld based on -isysroot.
64 # Don't add -isysroot to DARWIN_SDK_LDFLAGS, because the programs
65 # that are linked with those flags also get DARWIN_SDK_CFLAGS.
66 DARWIN_SDK_SHLIBFLAGS = -isysroot $(MACOS_SDK_DIR)
67 else
68 # gcc 4.0.0 doesn't pass -syslibroot to ld, it needs to be
69 # explicit.
70 DARWIN_SDK_LDFLAGS = -Wl,-syslibroot,$(MACOS_SDK_DIR)
71 DARWIN_SDK_SHLIBFLAGS = $(DARWIN_SDK_LDFLAGS)
72 endif
73 endif
75 LDFLAGS += $(DARWIN_SDK_LDFLAGS)
76 endif
78 # "Commons" are tentative definitions in a global scope, like this:
79 # int x;
80 # The meaning of a common is ambiguous. It may be a true definition:
81 # int x = 0;
82 # or it may be a declaration of a symbol defined in another file:
83 # extern int x;
84 # Use the -fno-common option to force all commons to become true
85 # definitions so that the linker can catch multiply-defined symbols.
86 # Also, common symbols are not allowed with Darwin dynamic libraries.
88 OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) -fno-common -pipe -DDARWIN -DHAVE_STRERROR -DHAVE_BSD_FLOCK $(DARWIN_SDK_CFLAGS)
90 ifdef BUILD_OPT
91 ifeq (11,$(ALLOW_OPT_CODE_SIZE)$(OPT_CODE_SIZE))
92 OPTIMIZER = -Oz
93 else
94 OPTIMIZER = -O2
95 endif
96 ifdef MOZ_DEBUG_SYMBOLS
97 ifdef MOZ_DEBUG_FLAGS
98 OPTIMIZER += $(MOZ_DEBUG_FLAGS)
99 else
100 OPTIMIZER += -gdwarf-2 -gfull
101 endif
102 endif
103 endif
105 ARCH = darwin
107 DSO_CFLAGS = -fPIC
108 # May override this with different compatibility and current version numbers.
109 DARWIN_DYLIB_VERSIONS = -compatibility_version 1 -current_version 1
110 # May override this with -bundle to create a loadable module.
111 DSO_LDOPTS = -dynamiclib $(DARWIN_DYLIB_VERSIONS) -install_name @executable_path/$(notdir $@) -headerpad_max_install_names
113 ifdef USE_GCOV
114 OS_CFLAGS += --coverage
115 LDFLAGS += --coverage
116 DSO_LDOPTS += --coverage
117 endif
119 MKSHLIB = $(CC) $(DSO_LDOPTS) $(DARWIN_SDK_SHLIBFLAGS)
120 DLL_SUFFIX = dylib
121 ifdef MAPFILE
122 MKSHLIB += -exported_symbols_list $(MAPFILE)
123 endif
124 PROCESS_MAP_FILE = grep -v ';+' $< | grep -v ';-' | \
125 sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' -e 's,^,_,' > $@
127 USE_SYSTEM_ZLIB = 1
128 ZLIB_LIBS = -lz
130 # The system sqlite library in the latest version of Mac OS X often becomes
131 # newer than the sqlite library in NSS. This may result in certain Mac OS X
132 # system libraries having unresolved sqlite symbols during the shlibsign step
133 # of the NSS build when we set DYLD_LIBRARY_PATH to the NSS lib directory and
134 # the NSS libsqlite3.dylib is used instead of the system one. So just use the
135 # system sqlite library on Mac, if it's sufficiently new.
137 SYS_SQLITE3_VERSION_FULL := $(shell /usr/bin/sqlite3 -version | awk '{print $$1}')
138 SYS_SQLITE3_VERSION_MAJOR := $(shell echo $(SYS_SQLITE3_VERSION_FULL) | awk -F. '{ print $$1 }')
139 SYS_SQLITE3_VERSION_MINOR := $(shell echo $(SYS_SQLITE3_VERSION_FULL) | awk -F. '{ print $$2 }')
141 ifeq (3,$(SYS_SQLITE3_VERSION_MAJOR))
142 ifeq (,$(filter-out 0 1 2 3 4,$(SYS_SQLITE3_VERSION_MINOR)))
143 # sqlite <= 3.4.x is too old, it doesn't provide sqlite3_file_control
144 else
145 NSS_USE_SYSTEM_SQLITE = 1
146 endif
147 endif