tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Linux.mk (5357B)


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