1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
REQUIRES = xpcom \
$(NULL)
LOCAL_INCLUDES = -I$(srcdir)
include $(topsrcdir)/config/config.mk
_FINAL_COMPONENT_NAMES := $(shell cat $(FINAL_LINK_COMP_NAMES))
_FINAL_COMPONENT_LIBS := $(shell cat $(FINAL_LINK_COMPS))
_FINAL_LINK_LIBS := $(shell cat $(FINAL_LINK_LIBS))
_META_COMPONENT_NAMES := _FINAL_COMPONENT_NAMES
_META_COMPONENT_LIBS := _FINAL_COMPONENT_LIBS
_META_DEP_LIBS := _FINAL_LINK_LIBS
LIBRARY_NAME = mozcomps
CPPSRCS = nsMetaModule_mozcomps.cpp
include $(topsrcdir)/config/static-config.mk
EXTRA_DSO_LIBS = $(STATIC_EXTRA_DSO_LIBS)
# See explanation below.
ifeq ($(OS_ARCH),Darwin)
EXTRA_DEPS = force_data_segment.o exported_symbols
endif
FORCE_SHARED_LIB = 1
include $(topsrcdir)/config/rules.mk
include $(topsrcdir)/config/static-rules.mk
# Force XPCOM_TRANSLATE_NSGM_ENTRY_POINT to be defined so the macros
# in nsIGenericFactory.h will come out in the wash.
DEFINES += -DMETA_MODULE=\"$(LIBRARY_NAME)\" -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT
# We don't want to link mozcomps against NSS if not necessary
ifneq (,$(findstring crypto,$(MOZ_META_COMPONENTS)))
STATIC_EXTRA_LIBS := $(filter-out $(NSS_LIBS),$(STATIC_EXTRA_LIBS))
endif
EXTRA_DSO_LDOPTS += \
$(LIBS_DIR) \
$(EXTRA_DSO_LIBS) \
$(STATIC_EXTRA_LIBS) \
$(MOZ_JS_LIBS) \
$(MOZ_UNICHARUTIL_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(TK_LIBS) \
$(NULL)
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
OS_LIBS += -framework QuickTime
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
OS_LIBS += -framework Cocoa
endif
ifeq ($(OS_ARCH),Darwin)
# A limitation exists in the Mach-O format which causes "scattered" relocation
# entries in shared libraries to be limited to a 24-bit address space (16 MB).
# The high 8 bits of the address are dropped. This can cause problems in
# a mozcomps build, particularly non-optimized builds. To avoid the problem,
# we move the data segment before the code segment in the libraray. The data
# segment is relatively small, and all of the relocations in question
# (which are pointers to construction vtables) reside in the
# (__DATA,__const) section.
#
# See also the 5th item in the TODO section of:
# http://www.opensource.apple.com/darwinsource/10.2.6/cctools/ld/notes
# (free APSL registration required)
# Generate a .o file with only a data segment, which we'll link as the first
# object file in the library. That will cause the data segment to be first.
force_data_segment.o:
ld -sectcreate __DATA __const /dev/null -noseglinkedit -arch ppc -o $@
exported_symbols:
echo _nsMetaModule_nsGetModule > $@
# We have to invoke ld directly so that force_data_segment.o can be linked
# before dylib1.o
MKSHLIB = $(LD) $(DSO_LDOPTS) -o $@
# force it to be first
SHLIB_LDSTARTFILE = force_data_segment.o -ldylib1.o
# translate gcc link options to corresponding ld options
EXTRA_DSO_LDOPTS := $(subst -dynamiclib,-dylib,$(EXTRA_DSO_LDOPTS))
EXTRA_DSO_LDOPTS := $(subst install_name,dylib_install_name,$(EXTRA_DSO_LDOPTS))
EXTRA_DSO_LDOPTS := $(subst compatibility_version,dylib_compatibility_version,$(EXTRA_DSO_LDOPTS))
EXTRA_DSO_LDOPTS := $(subst current_version,dylib_current_version,$(EXTRA_DSO_LDOPTS))
# It would be nice to limit the exported symbols here, but doing so exposes a
# bug in the linker that causes some C++ static initializers not to run after
# prebinding is updated at runtime (reported as Radar bug 3268595).
#EXTRA_DSO_LDOPTS += -exported_symbols_list exported_symbols
OS_LIBS := -lstdc++ $(OS_LIBS)
SHLIB_LDENDFILE = -lgcc
endif # darwin
ifeq ($(OS_ARCH),WINNT)
OS_LIBS += ole32.lib shell32.lib
endif
ifeq ($(OS_ARCH),BeOS)
OS_LIBS += -ltracker
endif
GARBAGE += $(CPPSRCS)
ifdef _NO_AUTO_VARS
_TARGET = $(srcdir)/$(@F)
GARBAGE += $(addprefix $(srcdir)/,$(CPPSRCS))
else
_TARGET = $@
endif
nsMetaModule_%.cpp: nsMetaModule.cpp.in Makefile Makefile.in $(topsrcdir)/config/config.mk
rm -f $@
cat $< | \
sed -e "s|%DECLARE_SUBMODULE_INFOS%|$(foreach m, $($(_META_COMPONENT_NAMES)), extern nsModuleInfo NSMODULEINFO($(m));)|" | \
sed -e "s|%SUBMODULE_INFOS%|$(foreach m, $($(_META_COMPONENT_NAMES)), \\& NSMODULEINFO($(m)),)|" \
> $(_TARGET)
|