1# This Source Code Form is subject to the terms of the Mozilla Public
2# License, v. 2.0. If a copy of the MPL was not distributed with this file,
3# You can obtain one at http://mozilla.org/MPL/2.0/.
4
5EXTRA_DEPS += $(topsrcdir)/toolkit/library/libxul.mk
6
7ifeq (Linux,$(OS_ARCH))
8ifneq (Android,$(OS_TARGET))
9OS_LDFLAGS += -Wl,-version-script,symverscript
10
11symverscript: $(topsrcdir)/toolkit/library/symverscript.in
12	$(call py_action,preprocessor, \
13		-DVERSION='xul$(MOZILLA_SYMBOLVERSION)' $< -o $@)
14
15EXTRA_DEPS += symverscript
16endif
17endif
18
19ifdef MOZ_WEBRTC
20ifeq (WINNT,$(OS_TARGET))
21ifndef MOZ_HAS_WINSDK_WITH_D3D
22OS_LDFLAGS += \
23  -LIBPATH:'$(MOZ_DIRECTX_SDK_PATH)/lib/$(MOZ_D3D_CPU_SUFFIX)' \
24  $(NULL)
25endif
26endif
27endif
28
29# Generate GDB pretty printer-autoload files only on Linux. OSX's GDB is
30# too old to support Python pretty-printers; if this changes, we could make
31# this 'ifdef GNU_CC'.
32ifeq (Linux,$(OS_ARCH))
33# Create a GDB Python auto-load file alongside the libxul shared library in
34# the build directory.
35PP_TARGETS += LIBXUL_AUTOLOAD
36LIBXUL_AUTOLOAD = $(topsrcdir)/toolkit/library/libxul.so-gdb.py.in
37LIBXUL_AUTOLOAD_FLAGS := -Dtopsrcdir=$(abspath $(topsrcdir))
38endif
39
40# BFD ld doesn't create multiple PT_LOADs as usual when an unknown section
41# exists. Using an implicit linker script to make it fold that section in
42# .data.rel.ro makes it create multiple PT_LOADs. That implicit linker
43# script however makes gold misbehave, first because it doesn't like that
44# the linker script is given after crtbegin.o, and even past that, replaces
45# the default section rules with those from the script instead of
46# supplementing them. Which leads to a lib with a huge load of sections.
47ifneq (OpenBSD,$(OS_TARGET))
48ifneq (WINNT,$(OS_TARGET))
49ifdef LD_IS_BFD
50OS_LDFLAGS += $(topsrcdir)/toolkit/library/StaticXULComponents.ld
51endif
52endif
53endif
54
55ifdef _MSC_VER
56get_first_and_last = dumpbin -exports $1 | grep _NSModule@@ | sort -k 3 | sed -n 's/^.*?\([^@]*\)@@.*$$/\1/;1p;$$p'
57else
58get_first_and_last = $(TOOLCHAIN_PREFIX)nm -g $1 | grep _NSModule$$ | grep -vw refptr | sort | sed -n 's/^.* _*\([^ ]*\)$$/\1/;1p;$$p'
59endif
60
61LOCAL_CHECKS = test "$$($(get_first_and_last) | xargs echo)" != "start_kPStaticModules_NSModule end_kPStaticModules_NSModule" && echo "NSModules are not ordered appropriately" && exit 1 || exit 0
62
63ifeq (Linux,$(OS_ARCH))
64LOCAL_CHECKS += ; test "$$($(TOOLCHAIN_PREFIX)readelf -l $1 | awk '$1 == "LOAD" { t += 1 } END { print t }')" -le 1 && echo "Only one PT_LOAD segment" && exit 1 || exit 0
65endif
66