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: # michael@0: # The default implementation strategy for Linux is now pthreads michael@0: # michael@0: ifneq ($(OS_TARGET),Android) michael@0: USE_PTHREADS = 1 michael@0: endif michael@0: michael@0: ifeq ($(USE_PTHREADS),1) michael@0: IMPL_STRATEGY = _PTH michael@0: endif michael@0: michael@0: CC = gcc michael@0: CCC = g++ michael@0: RANLIB = ranlib michael@0: michael@0: DEFAULT_COMPILER = gcc michael@0: michael@0: ifeq ($(OS_TARGET),Android) michael@0: ifndef ANDROID_NDK michael@0: $(error Must set ANDROID_NDK to the path to the android NDK first) michael@0: endif michael@0: ANDROID_PREFIX=$(OS_TEST)-linux-androideabi michael@0: ANDROID_TARGET=$(ANDROID_PREFIX)-4.4.3 michael@0: # should autodetect which linux we are on, currently android only michael@0: # supports linux-x86 prebuilts michael@0: ANDROID_TOOLCHAIN=$(ANDROID_NDK)/toolchains/$(ANDROID_TARGET)/prebuilt/linux-x86 michael@0: ANDROID_SYSROOT=$(ANDROID_NDK)/platforms/android-$(OS_TARGET_RELEASE)/arch-$(OS_TEST) michael@0: ANDROID_CC=$(ANDROID_TOOLCHAIN)/bin/$(ANDROID_PREFIX)-gcc michael@0: # internal tools need to be built with the native compiler michael@0: ifndef INTERNAL_TOOLS michael@0: CC = $(ANDROID_CC) --sysroot=$(ANDROID_SYSROOT) michael@0: DEFAULT_COMPILER=$(ANDROID_PREFIX)-gcc michael@0: ARCHFLAG = --sysroot=$(ANDROID_SYSROOT) michael@0: DEFINES += -DNO_SYSINFO -DNO_FORK_CHECK -DANDROID michael@0: CROSS_COMPILE = 1 michael@0: endif michael@0: endif michael@0: ifeq ($(OS_TEST),ppc64) michael@0: CPU_ARCH = ppc michael@0: ifeq ($(USE_64),1) michael@0: ARCHFLAG = -m64 michael@0: endif michael@0: else michael@0: ifeq ($(OS_TEST),alpha) michael@0: OS_REL_CFLAGS = -D_ALPHA_ michael@0: CPU_ARCH = alpha michael@0: else michael@0: ifeq ($(OS_TEST),x86_64) michael@0: ifeq ($(USE_64),1) michael@0: CPU_ARCH = x86_64 michael@0: ARCHFLAG = -m64 michael@0: else michael@0: ifeq ($(USE_X32),1) michael@0: CPU_ARCH = x86_64 michael@0: ARCHFLAG = -mx32 michael@0: 64BIT_TAG = _x32 michael@0: else michael@0: OS_REL_CFLAGS = -Di386 michael@0: CPU_ARCH = x86 michael@0: ARCHFLAG = -m32 michael@0: endif michael@0: endif michael@0: else michael@0: ifeq ($(OS_TEST),sparc64) michael@0: CPU_ARCH = sparc michael@0: else michael@0: ifeq (,$(filter-out arm% sa110,$(OS_TEST))) michael@0: CPU_ARCH = arm michael@0: else michael@0: ifeq (,$(filter-out parisc%,$(OS_TEST))) michael@0: CPU_ARCH = hppa michael@0: else michael@0: ifeq (,$(filter-out i%86,$(OS_TEST))) michael@0: OS_REL_CFLAGS = -Di386 michael@0: CPU_ARCH = x86 michael@0: else michael@0: ifeq ($(OS_TEST),sh4a) michael@0: CPU_ARCH = sh4 michael@0: else michael@0: # $(OS_TEST) == m68k, ppc, ia64, sparc, s390, s390x, mips, sh3, sh4 michael@0: CPU_ARCH = $(OS_TEST) michael@0: endif michael@0: endif michael@0: endif michael@0: endif michael@0: endif michael@0: endif michael@0: endif michael@0: endif michael@0: michael@0: michael@0: ifneq ($(OS_TARGET),Android) michael@0: LIBC_TAG = _glibc michael@0: endif michael@0: michael@0: ifeq ($(OS_RELEASE),2.0) michael@0: OS_REL_CFLAGS += -DLINUX2_0 michael@0: MKSHLIB = $(CC) -shared -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so) $(RPATH) michael@0: ifdef MAPFILE michael@0: MKSHLIB += -Wl,--version-script,$(MAPFILE) michael@0: endif michael@0: PROCESS_MAP_FILE = grep -v ';-' $< | \ michael@0: sed -e 's,;+,,' -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,;,' > $@ michael@0: endif michael@0: michael@0: ifdef BUILD_OPT michael@0: ifeq (11,$(ALLOW_OPT_CODE_SIZE)$(OPT_CODE_SIZE)) michael@0: OPTIMIZER = -Os 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 michael@0: endif michael@0: endif michael@0: endif michael@0: michael@0: michael@0: ifeq ($(USE_PTHREADS),1) michael@0: OS_PTHREAD = -lpthread michael@0: endif michael@0: michael@0: 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: OS_LIBS = $(OS_PTHREAD) -ldl -lc michael@0: michael@0: ifdef USE_PTHREADS michael@0: DEFINES += -D_REENTRANT michael@0: endif michael@0: michael@0: ARCH = linux michael@0: michael@0: DSO_CFLAGS = -fPIC michael@0: DSO_LDOPTS = -shared $(ARCHFLAG) -Wl,--gc-sections michael@0: # The linker on Red Hat Linux 7.2 and RHEL 2.1 (GNU ld version 2.11.90.0.8) michael@0: # incorrectly reports undefined references in the libraries we link with, so michael@0: # we don't use -z defs there. michael@0: ZDEFS_FLAG = -Wl,-z,defs michael@0: DSO_LDOPTS += $(if $(findstring 2.11.90.0.8,$(shell ld -v)),,$(ZDEFS_FLAG)) michael@0: LDFLAGS += $(ARCHFLAG) michael@0: michael@0: # On Maemo, we need to use the -rpath-link flag for even the standard system michael@0: # library directories. michael@0: ifdef _SBOX_DIR michael@0: LDFLAGS += -Wl,-rpath-link,/usr/lib:/lib michael@0: endif michael@0: michael@0: # INCLUDES += -I/usr/include -Y/usr/include/linux michael@0: G++INCLUDES = -I/usr/include/g++ michael@0: michael@0: # michael@0: # Always set CPU_TAG on Linux. michael@0: # michael@0: CPU_TAG = _$(CPU_ARCH) michael@0: michael@0: # michael@0: # On Linux 2.6 or later, build libfreebl3.so with no NSPR and libnssutil3.so michael@0: # dependencies by default. Set FREEBL_NO_DEPEND to 0 in the environment to michael@0: # override this. michael@0: # michael@0: ifneq ($(OS_TARGET),Android) michael@0: ifeq (2.6,$(firstword $(sort 2.6 $(OS_RELEASE)))) michael@0: ifndef FREEBL_NO_DEPEND michael@0: FREEBL_NO_DEPEND = 1 michael@0: FREEBL_LOWHASH = 1 michael@0: endif michael@0: endif michael@0: endif michael@0: michael@0: USE_SYSTEM_ZLIB = 1 michael@0: ZLIB_LIBS = -lz michael@0: michael@0: # The -rpath '$$ORIGIN' linker option instructs this library to search for its michael@0: # dependencies in the same directory where it resides. michael@0: ifeq ($(BUILD_SUN_PKG), 1) michael@0: ifeq ($(USE_64), 1) michael@0: RPATH = -Wl,-rpath,'$$ORIGIN:/opt/sun/private/lib64:/opt/sun/private/lib' michael@0: else michael@0: RPATH = -Wl,-rpath,'$$ORIGIN:/opt/sun/private/lib' michael@0: endif michael@0: endif michael@0: michael@0: OS_REL_CFLAGS += -DLINUX2_1 michael@0: MKSHLIB = $(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so) $(RPATH) michael@0: michael@0: ifdef MAPFILE michael@0: MKSHLIB += -Wl,--version-script,$(MAPFILE) michael@0: endif michael@0: PROCESS_MAP_FILE = grep -v ';-' $< | \ michael@0: sed -e 's,;+,,' -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,;,' > $@ michael@0: michael@0: ifeq ($(OS_RELEASE),2.4) michael@0: DEFINES += -DNO_FORK_CHECK michael@0: endif