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 | # |
michael@0 | 9 | # The default implementation strategy for Linux is now pthreads |
michael@0 | 10 | # |
michael@0 | 11 | ifneq ($(OS_TARGET),Android) |
michael@0 | 12 | USE_PTHREADS = 1 |
michael@0 | 13 | endif |
michael@0 | 14 | |
michael@0 | 15 | ifeq ($(USE_PTHREADS),1) |
michael@0 | 16 | IMPL_STRATEGY = _PTH |
michael@0 | 17 | endif |
michael@0 | 18 | |
michael@0 | 19 | CC = gcc |
michael@0 | 20 | CCC = g++ |
michael@0 | 21 | RANLIB = ranlib |
michael@0 | 22 | |
michael@0 | 23 | DEFAULT_COMPILER = gcc |
michael@0 | 24 | |
michael@0 | 25 | ifeq ($(OS_TARGET),Android) |
michael@0 | 26 | ifndef ANDROID_NDK |
michael@0 | 27 | $(error Must set ANDROID_NDK to the path to the android NDK first) |
michael@0 | 28 | endif |
michael@0 | 29 | ANDROID_PREFIX=$(OS_TEST)-linux-androideabi |
michael@0 | 30 | ANDROID_TARGET=$(ANDROID_PREFIX)-4.4.3 |
michael@0 | 31 | # should autodetect which linux we are on, currently android only |
michael@0 | 32 | # supports linux-x86 prebuilts |
michael@0 | 33 | ANDROID_TOOLCHAIN=$(ANDROID_NDK)/toolchains/$(ANDROID_TARGET)/prebuilt/linux-x86 |
michael@0 | 34 | ANDROID_SYSROOT=$(ANDROID_NDK)/platforms/android-$(OS_TARGET_RELEASE)/arch-$(OS_TEST) |
michael@0 | 35 | ANDROID_CC=$(ANDROID_TOOLCHAIN)/bin/$(ANDROID_PREFIX)-gcc |
michael@0 | 36 | # internal tools need to be built with the native compiler |
michael@0 | 37 | ifndef INTERNAL_TOOLS |
michael@0 | 38 | CC = $(ANDROID_CC) --sysroot=$(ANDROID_SYSROOT) |
michael@0 | 39 | DEFAULT_COMPILER=$(ANDROID_PREFIX)-gcc |
michael@0 | 40 | ARCHFLAG = --sysroot=$(ANDROID_SYSROOT) |
michael@0 | 41 | DEFINES += -DNO_SYSINFO -DNO_FORK_CHECK -DANDROID |
michael@0 | 42 | CROSS_COMPILE = 1 |
michael@0 | 43 | endif |
michael@0 | 44 | endif |
michael@0 | 45 | ifeq ($(OS_TEST),ppc64) |
michael@0 | 46 | CPU_ARCH = ppc |
michael@0 | 47 | ifeq ($(USE_64),1) |
michael@0 | 48 | ARCHFLAG = -m64 |
michael@0 | 49 | endif |
michael@0 | 50 | else |
michael@0 | 51 | ifeq ($(OS_TEST),alpha) |
michael@0 | 52 | OS_REL_CFLAGS = -D_ALPHA_ |
michael@0 | 53 | CPU_ARCH = alpha |
michael@0 | 54 | else |
michael@0 | 55 | ifeq ($(OS_TEST),x86_64) |
michael@0 | 56 | ifeq ($(USE_64),1) |
michael@0 | 57 | CPU_ARCH = x86_64 |
michael@0 | 58 | ARCHFLAG = -m64 |
michael@0 | 59 | else |
michael@0 | 60 | ifeq ($(USE_X32),1) |
michael@0 | 61 | CPU_ARCH = x86_64 |
michael@0 | 62 | ARCHFLAG = -mx32 |
michael@0 | 63 | 64BIT_TAG = _x32 |
michael@0 | 64 | else |
michael@0 | 65 | OS_REL_CFLAGS = -Di386 |
michael@0 | 66 | CPU_ARCH = x86 |
michael@0 | 67 | ARCHFLAG = -m32 |
michael@0 | 68 | endif |
michael@0 | 69 | endif |
michael@0 | 70 | else |
michael@0 | 71 | ifeq ($(OS_TEST),sparc64) |
michael@0 | 72 | CPU_ARCH = sparc |
michael@0 | 73 | else |
michael@0 | 74 | ifeq (,$(filter-out arm% sa110,$(OS_TEST))) |
michael@0 | 75 | CPU_ARCH = arm |
michael@0 | 76 | else |
michael@0 | 77 | ifeq (,$(filter-out parisc%,$(OS_TEST))) |
michael@0 | 78 | CPU_ARCH = hppa |
michael@0 | 79 | else |
michael@0 | 80 | ifeq (,$(filter-out i%86,$(OS_TEST))) |
michael@0 | 81 | OS_REL_CFLAGS = -Di386 |
michael@0 | 82 | CPU_ARCH = x86 |
michael@0 | 83 | else |
michael@0 | 84 | ifeq ($(OS_TEST),sh4a) |
michael@0 | 85 | CPU_ARCH = sh4 |
michael@0 | 86 | else |
michael@0 | 87 | # $(OS_TEST) == m68k, ppc, ia64, sparc, s390, s390x, mips, sh3, sh4 |
michael@0 | 88 | CPU_ARCH = $(OS_TEST) |
michael@0 | 89 | endif |
michael@0 | 90 | endif |
michael@0 | 91 | endif |
michael@0 | 92 | endif |
michael@0 | 93 | endif |
michael@0 | 94 | endif |
michael@0 | 95 | endif |
michael@0 | 96 | endif |
michael@0 | 97 | |
michael@0 | 98 | |
michael@0 | 99 | ifneq ($(OS_TARGET),Android) |
michael@0 | 100 | LIBC_TAG = _glibc |
michael@0 | 101 | endif |
michael@0 | 102 | |
michael@0 | 103 | ifeq ($(OS_RELEASE),2.0) |
michael@0 | 104 | OS_REL_CFLAGS += -DLINUX2_0 |
michael@0 | 105 | MKSHLIB = $(CC) -shared -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so) $(RPATH) |
michael@0 | 106 | ifdef MAPFILE |
michael@0 | 107 | MKSHLIB += -Wl,--version-script,$(MAPFILE) |
michael@0 | 108 | endif |
michael@0 | 109 | PROCESS_MAP_FILE = grep -v ';-' $< | \ |
michael@0 | 110 | sed -e 's,;+,,' -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,;,' > $@ |
michael@0 | 111 | endif |
michael@0 | 112 | |
michael@0 | 113 | ifdef BUILD_OPT |
michael@0 | 114 | ifeq (11,$(ALLOW_OPT_CODE_SIZE)$(OPT_CODE_SIZE)) |
michael@0 | 115 | OPTIMIZER = -Os |
michael@0 | 116 | else |
michael@0 | 117 | OPTIMIZER = -O2 |
michael@0 | 118 | endif |
michael@0 | 119 | ifdef MOZ_DEBUG_SYMBOLS |
michael@0 | 120 | ifdef MOZ_DEBUG_FLAGS |
michael@0 | 121 | OPTIMIZER += $(MOZ_DEBUG_FLAGS) |
michael@0 | 122 | else |
michael@0 | 123 | OPTIMIZER += -gdwarf-2 |
michael@0 | 124 | endif |
michael@0 | 125 | endif |
michael@0 | 126 | endif |
michael@0 | 127 | |
michael@0 | 128 | |
michael@0 | 129 | ifeq ($(USE_PTHREADS),1) |
michael@0 | 130 | OS_PTHREAD = -lpthread |
michael@0 | 131 | endif |
michael@0 | 132 | |
michael@0 | 133 | OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) $(ARCHFLAG) -Wall -Werror-implicit-function-declaration -Wno-switch -pipe -ffunction-sections -fdata-sections -DLINUX -Dlinux -DHAVE_STRERROR |
michael@0 | 134 | OS_LIBS = $(OS_PTHREAD) -ldl -lc |
michael@0 | 135 | |
michael@0 | 136 | ifdef USE_PTHREADS |
michael@0 | 137 | DEFINES += -D_REENTRANT |
michael@0 | 138 | endif |
michael@0 | 139 | |
michael@0 | 140 | ARCH = linux |
michael@0 | 141 | |
michael@0 | 142 | DSO_CFLAGS = -fPIC |
michael@0 | 143 | DSO_LDOPTS = -shared $(ARCHFLAG) -Wl,--gc-sections |
michael@0 | 144 | # The linker on Red Hat Linux 7.2 and RHEL 2.1 (GNU ld version 2.11.90.0.8) |
michael@0 | 145 | # incorrectly reports undefined references in the libraries we link with, so |
michael@0 | 146 | # we don't use -z defs there. |
michael@0 | 147 | ZDEFS_FLAG = -Wl,-z,defs |
michael@0 | 148 | DSO_LDOPTS += $(if $(findstring 2.11.90.0.8,$(shell ld -v)),,$(ZDEFS_FLAG)) |
michael@0 | 149 | LDFLAGS += $(ARCHFLAG) |
michael@0 | 150 | |
michael@0 | 151 | # On Maemo, we need to use the -rpath-link flag for even the standard system |
michael@0 | 152 | # library directories. |
michael@0 | 153 | ifdef _SBOX_DIR |
michael@0 | 154 | LDFLAGS += -Wl,-rpath-link,/usr/lib:/lib |
michael@0 | 155 | endif |
michael@0 | 156 | |
michael@0 | 157 | # INCLUDES += -I/usr/include -Y/usr/include/linux |
michael@0 | 158 | G++INCLUDES = -I/usr/include/g++ |
michael@0 | 159 | |
michael@0 | 160 | # |
michael@0 | 161 | # Always set CPU_TAG on Linux. |
michael@0 | 162 | # |
michael@0 | 163 | CPU_TAG = _$(CPU_ARCH) |
michael@0 | 164 | |
michael@0 | 165 | # |
michael@0 | 166 | # On Linux 2.6 or later, build libfreebl3.so with no NSPR and libnssutil3.so |
michael@0 | 167 | # dependencies by default. Set FREEBL_NO_DEPEND to 0 in the environment to |
michael@0 | 168 | # override this. |
michael@0 | 169 | # |
michael@0 | 170 | ifneq ($(OS_TARGET),Android) |
michael@0 | 171 | ifeq (2.6,$(firstword $(sort 2.6 $(OS_RELEASE)))) |
michael@0 | 172 | ifndef FREEBL_NO_DEPEND |
michael@0 | 173 | FREEBL_NO_DEPEND = 1 |
michael@0 | 174 | FREEBL_LOWHASH = 1 |
michael@0 | 175 | endif |
michael@0 | 176 | endif |
michael@0 | 177 | endif |
michael@0 | 178 | |
michael@0 | 179 | USE_SYSTEM_ZLIB = 1 |
michael@0 | 180 | ZLIB_LIBS = -lz |
michael@0 | 181 | |
michael@0 | 182 | # The -rpath '$$ORIGIN' linker option instructs this library to search for its |
michael@0 | 183 | # dependencies in the same directory where it resides. |
michael@0 | 184 | ifeq ($(BUILD_SUN_PKG), 1) |
michael@0 | 185 | ifeq ($(USE_64), 1) |
michael@0 | 186 | RPATH = -Wl,-rpath,'$$ORIGIN:/opt/sun/private/lib64:/opt/sun/private/lib' |
michael@0 | 187 | else |
michael@0 | 188 | RPATH = -Wl,-rpath,'$$ORIGIN:/opt/sun/private/lib' |
michael@0 | 189 | endif |
michael@0 | 190 | endif |
michael@0 | 191 | |
michael@0 | 192 | OS_REL_CFLAGS += -DLINUX2_1 |
michael@0 | 193 | MKSHLIB = $(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so) $(RPATH) |
michael@0 | 194 | |
michael@0 | 195 | ifdef MAPFILE |
michael@0 | 196 | MKSHLIB += -Wl,--version-script,$(MAPFILE) |
michael@0 | 197 | endif |
michael@0 | 198 | PROCESS_MAP_FILE = grep -v ';-' $< | \ |
michael@0 | 199 | sed -e 's,;+,,' -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,;,' > $@ |
michael@0 | 200 | |
michael@0 | 201 | ifeq ($(OS_RELEASE),2.4) |
michael@0 | 202 | DEFINES += -DNO_FORK_CHECK |
michael@0 | 203 | endif |