Move build logic for static builds into separate .mk so that it doesn't have to be duplicated across Makefiles. Use slightly more generic name for _getModuleInfo function so that it can be used for multiple binaries.

Bug #88038 r=bryner
This commit is contained in:
seawood%netscape.com 2002-02-19 10:01:05 +00:00
Родитель 184387e4c3
Коммит f5b16586fb
7 изменённых файлов: 155 добавлений и 141 удалений

Просмотреть файл

@ -114,7 +114,7 @@ endif
endif
ifdef _EXTRA_DSO_RELATIVE_PATHS
EXTRA_DSO_LIBS := $(addsuffix .$(LIB_SUFFIX),$(addprefix $(DIST)/lib/,$(EXTRA_DSO_LIBS)))
EXTRA_DSO_LIBS := $(addsuffix .$(LIB_SUFFIX),$(addprefix $(DIST)/lib/$(LIB_PREFIX),$(EXTRA_DSO_LIBS)))
EXTRA_DSO_LIBS := $(filter-out %/bin %/lib,$(EXTRA_DSO_LIBS))
EXTRA_DSO_LDOPTS := $(patsubst -l%,$(DIST)/lib/%.$(LIB_SUFFIX),$(EXTRA_DSO_LDOPTS))
LIBS := $(patsubst -l%,$(DIST)/lib/$(LIB_PREFIX)%.$(LIB_SUFFIX),$(LIBS))
@ -754,7 +754,7 @@ ifeq ($(MOZ_OS2_TOOLS),VACPP)
$(LD) -OUT:$@ $(LDFLAGS) $(PROGOBJS) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS) $(EXE_DEF_FILE) /ST:0x100000
else
ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
$(LD) /NOLOGO /OUT:$@ /PDB:$(PDBFILE) $(PROGOBJS) $(RESFILE) $(LDFLAGS) $(LIBS) $(OS_LIBS)
$(LD) /NOLOGO /OUT:$@ /PDB:$(PDBFILE) $(PROGOBJS) $(RESFILE) $(LDFLAGS) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
else
ifeq ($(CPP_PROG_LINK),1)
$(CCC) -o $@ $(CXXFLAGS) $(WRAP_MALLOC_CFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS) $(WRAP_MALLOC_LIB) $(PROFILER_LIBS)
@ -798,7 +798,7 @@ ifeq ($(MOZ_OS2_TOOLS),VACPP)
$(LD) /Out:$@ $< $(LDFLAGS) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS) $(WRAP_MALLOC_LIB) $(PROFILER_LIBS)
else
ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
$(LD) /nologo /out:$@ /pdb:$(PDBFILE) $< $(LDFLAGS) $(LIBS) $(OS_LIBS)
$(LD) /nologo /out:$@ /pdb:$(PDBFILE) $< $(LDFLAGS) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
else
ifeq ($(CPP_PROG_LINK),1)
$(CCC) $(WRAP_MALLOC_CFLAGS) $(CXXFLAGS) -o $@ $< $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS) $(WRAP_MALLOC_LIB) $(PROFILER_LIBS)

107
config/static-config.mk Normal file
Просмотреть файл

@ -0,0 +1,107 @@
#
# 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):
#
# Static components makefile
# Include this makefile after config/config.mk & before config/rules.mk
# This makefile will provide the defines for statically linking
# all of the components into the binary.
STATIC_CPPSRCS += nsStaticComponents.cpp
STATIC_DEFINES += -D_BUILD_STATIC_BIN=1
STATIC_REQUIRES += \
xpcom \
string \
$(NULL)
ifeq ($(OS_ARCH),OS2)
STATIC_EXTRA_DSO_LIBS += $(addprefix lib,$(shell cat $(FINAL_LINK_COMPS) $(FINAL_LINK_LIBS)))
STATIC_EXTRA_DSO_LIBS += mpfilelocprovider_s
STATIC_EXTRA_LIBS += libuls.lib libconv.lib unikbd.lib
else
ifeq ($(OS_ARCH),WINNT)
STATIC_EXTRA_LIBS += \
$(addsuffix .$(LIB_SUFFIX),$(addprefix $(DIST)/lib/components/$(LIB_PREFIX),$(shell cat $(FINAL_LINK_COMPS)))) \
$(addsuffix .$(LIB_SUFFIX),$(addprefix $(DIST)/lib/$(LIB_PREFIX),$(shell cat $(FINAL_LINK_LIBS)))) \
$(NULL)
else
STATIC_EXTRA_LIBS += -L$(DIST)/lib/components
STATIC_EXTRA_DSO_LIBS += $(shell cat $(FINAL_LINK_COMPS) $(FINAL_LINK_LIBS))
endif # WINNT
endif # OS2
STATIC_COMPONENT_LIST := $(shell cat $(FINAL_LINK_COMP_NAMES))
STATIC_EXTRA_DEPS += $(FINAL_LINK_COMPS) $(FINAL_LINK_LIBS) $(addsuffix .$(LIB_SUFFIX),$(addprefix $(DIST)/lib/components/$(LIB_PREFIX),$(shell cat $(FINAL_LINK_COMPS)))) $(addsuffix .$(LIB_SUFFIX),$(addprefix $(DIST)/lib/$(LIB_PREFIX),$(shell cat $(FINAL_LINK_LIBS))))
STATIC_EXTRA_DEPS += \
$(topsrcdir)/config/static-config.mk \
$(topsrcdir)/config/static-rules.mk \
$(NULL)
ifdef MOZ_PSM
STATIC_EXTRA_DEPS += $(NSS_DEP_LIBS)
endif
STATIC_EXTRA_LIBS += \
$(PNG_LIBS) \
$(MNG_LIBS) \
$(JPEG_LIBS) \
$(ZLIB_LIBS) \
$(MOZ_GDK_PIXBUF_LIBS) \
$(MOZ_XIE_LIBS) \
$(MOZ_XPRINT_LDFLAGS) \
$(NULL)
ifdef MOZ_PSM
STATIC_EXTRA_LIBS += \
$(NSS_LIBS) \
$(NULL)
endif
ifdef MOZ_LDAP_XPCOM
STATIC_EXTRA_LIBS += \
$(LDAP_LIBS) \
$(NULL)
endif
ifdef MOZ_SVG
STATIC_EXTRA_LIBS += $(MOZ_LIBART_LIBS)
endif
ifdef MOZ_ENABLE_GTK
STATIC_EXTRA_LIBS += $(XLDFLAGS) -lXt
endif
ifdef MOZ_ENABLE_XINERAMA
STATIC_EXTRA_LIBS += $(MOZ_XINERAMA_LIBS)
endif
ifdef MOZ_CALENDAR
STATIC_EXTRA_LIBS += -lical -licalss
endif
STATIC_EXTRA_LIBS += $(TK_LIBS)
ifeq ($(OS_ARCH),WINNT)
STATIC_EXTRA_LIBS += comctl32.lib comdlg32.lib uuid.lib shell32.lib ole32.lib oleaut32.lib version.lib winspool.lib
endif

12
config/static-rules.mk Normal file
Просмотреть файл

@ -0,0 +1,12 @@
nsStaticComponents.cpp: $(MOZILLA_DIR)/xpfe/bootstrap/nsStaticComponents.cpp.in Makefile Makefile.in $(FINAL_LINK_COMP_NAMES)
rm -f $@
cat $< | \
sed -e "s|%DECL_NSGETMODULES%|$(foreach m,$(STATIC_COMPONENT_LIST),DECL_NSGETMODULE($(m)))|" | \
sed -e "s|%MODULE_LIST%|$(foreach m, $(STATIC_COMPONENT_LIST),MODULE($(m)),)|" \
> $@
ifeq ($(OS_ARCH),IRIX)
LDFLAGS += -Wl,-LD_LAYOUT:lgot_buffer=80
endif

Просмотреть файл

@ -68,47 +68,15 @@ include $(topsrcdir)/config/config.mk
ifdef BUILD_STATIC_LIBS
ifdef MOZ_FAT_EMBED
EMBED_LINK_COMPS=$(FINAL_LINK_COMPS)
else
EMBED_LINK_COMPS=../src/embed-link-comps
ifndef MOZ_FAT_EMBED
FINAL_LINK_COMPS=../src/embed-link-comps
endif
ifeq ($(OS_ARCH),OS2)
EXTRA_LIBS = $(addprefix lib,$(shell cat $(EMBED_LINK_COMPS) $(FINAL_LINK_LIBS)))
EXTRA_LIBS += mpfilelocprovider_s
EXTRA_LDOPTS += libuls.lib libconv.lib unikbd.lib
else
EXTRA_LIBS = -L$(DEPTH)/dist/lib/components $(addprefix -l,$(shell cat $(EMBED_LINK_COMPS) $(FINAL_LINK_LIBS)))
endif
include $(topsrcdir)/config/static-config.mk
EXTRA_LIBS += \
$(PNG_LIBS) \
$(MNG_LIBS) \
$(JPEG_LIBS) \
$(ZLIB_LIBS) \
$(MOZ_GDK_PIXBUF_LIBS) \
$(MOZ_XIE_LIBS) \
$(MOZ_XPRINT_LDFLAGS) \
$(NULL)
ifdef MOZ_PSM
EXTRA_LIBS += \
$(NSS_LIBS) \
$(NULL)
endif
ifdef MOZ_LDAP_XPCOM
EXTRA_LIBS += $(LDAP_LIBS)
endif
ifdef MOZ_SVG
EXTRA_LIBS += $(MOZ_LIBART_LIBS)
endif
ifdef MOZ_ENABLE_GTK
EXTRA_LIBS += $(XLDFLAGS) -lXt -lSM -lICE
endif
EXTRA_DEPS += $(STATIC_EXTRA_DEPS)
EXTRA_DSO_LIBS += $(STATIC_EXTRA_DSO_LIBS)
EXTRA_LIBS += $(EXTRA_DSO_LIBS) $(STATIC_EXTRA_LIBS)
endif

Просмотреть файл

@ -69,34 +69,6 @@ else
PROGRAM = mozilla-bin$(BIN_SUFFIX)
endif
ifdef BUILD_STATIC_LIBS
ifeq ($(OS_ARCH),OS2)
EXTRA_DSO_LIBS = $(addprefix lib,$(shell cat $(FINAL_LINK_COMPS) $(FINAL_LINK_LIBS)))
EXTRA_DSO_LIBS += mpfilelocprovider_s
EXTRA_DSO_LDOPTS += libuls.lib libconv.lib unikbd.lib
_COMPONENT_LIST := $(shell cat $(FINAL_LINK_COMP_NAMES))
else
ifeq ($(OS_ARCH),WINNT)
EXTRA_DSO_LDOPTS = $(addsuffix .$(LIB_SUFFIX),$(addprefix $(DIST)/lib/components/$(LIB_PREFIX),$(shell cat $(FINAL_LINK_COMPS)))) $(addsuffix .$(LIB_SUFFIX),$(addprefix $(DIST)/lib/$(LIB_PREFIX),$(shell cat $(FINAL_LINK_LIBS))))
_COMPONENT_LIST := $(shell cat $(FINAL_LINK_COMP_NAMES))
else
EXTRA_DSO_LDOPTS = -L$(DIST)/lib/components
EXTRA_DSO_LIBS = $(shell cat $(FINAL_LINK_COMPS) $(FINAL_LINK_LIBS))
_COMPONENT_LIST := $(shell cat $(FINAL_LINK_COMP_NAMES))
endif
endif # WINNT
else
EXTRA_DSO_LIBS = gkgfx mpfilelocprovider_s
ifdef MOZ_OJI
ifeq ($(OS_ARCH),WINNT)
EXTRA_DSO_LIBS += jsj$(MOZ_BITS)$(VERSION_NUMBER)
else
EXTRA_DSO_LIBS += jsj
endif
endif
endif
CPPSRCS = \
nsAppRunner.cpp \
nsWindowCreator.cpp \
@ -113,49 +85,31 @@ XP_LIBS = \
$(NULL)
ifndef BUILD_STATIC_LIBS
EXTRA_DSO_LIBS += gkgfx mpfilelocprovider_s
ifdef MOZ_OJI
ifeq ($(OS_ARCH),WINNT)
EXTRA_DSO_LIBS += jsj$(MOZ_BITS)$(VERSION_NUMBER)
else
EXTRA_DSO_LIBS += jsj
endif
endif
XP_LIBS += \
$(MOZ_JS_LIBS) \
$(NULL)
else
CPPSRCS += nsStaticComponents.cpp
include $(topsrcdir)/config/static-config.mk
XP_LIBS += \
$(PNG_LIBS) \
$(MNG_LIBS) \
$(JPEG_LIBS) \
$(ZLIB_LIBS) \
$(MOZ_GDK_PIXBUF_LIBS) \
$(MOZ_XIE_LIBS) \
$(MOZ_XPRINT_LDFLAGS) \
$(NULL)
ifdef MOZ_PSM
XP_LIBS += \
$(NSS_LIBS) \
$(NULL)
endif
ifdef MOZ_LDAP_XPCOM
XP_LIBS += \
$(LDAP_LIBS) \
$(NULL)
endif
ifdef MOZ_SVG
XP_LIBS += $(MOZ_LIBART_LIBS)
endif
ifdef MOZ_ENABLE_GTK
XP_LIBS += $(XLDFLAGS) -lXt
endif
ifdef MOZ_ENABLE_XINERAMA
XP_LIBS += $(MOZ_XINERAMA_LIBS)
endif
ifdef MOZ_CALENDAR
XP_LIBS += -lical -licalss
endif
EXTRA_DEPS += \
$(STATIC_EXTRA_DEPS) \
$(NULL)
DEFINES += $(STATIC_DEFINES)
CPPSRCS += $(STATIC_CPPSRCS)
EXTRA_DSO_LIBS += $(STATIC_EXTRA_DSO_LIBS)
REQUIRES += $(STATIC_REQUIRES)
XP_LIBS += $(STATIC_EXTRA_LIBS)
endif
@ -164,10 +118,6 @@ XP_LIBS += \
$(NSPR_LIBS) \
$(NULL)
ifdef MOZ_ENABLE_PHOTON
XP_LIBS += $(TK_LIBS)
endif
ifdef NS_TRACE_MALLOC
DEFINES += -DNS_TRACE_MALLOC
endif
@ -221,24 +171,18 @@ LDFLAGS += \
$(NULL)
endif
XP_DIST_DEP_LIBS := $(filter-out -L$(DIST)/bin -L$(DIST)/lib, $(XP_DIST_LIBS))
ifeq ($(OS_ARCH),OS2)
ifdef BUILD_STATIC_LIBS
EXE_DEF_FILE = mozilla.def
endif
else
EXTRA_DEPS = \
$(addprefix $(DIST)/,$(patsubst -l%,bin/$(LIB_PREFIX)%$(DLL_SUFFIX),$(XP_DIST_DEP_LIBS:-l%_s=lib/$(LIB_PREFIX)%_s.a))) \
$(NULL)
ifdef BUILD_STATIC_LIBS
EXTRA_DEPS += $(FINAL_LINK_COMPS) $(FINAL_LINK_LIBS) $(addsuffix .$(LIB_SUFFIX),$(addprefix $(DIST)/lib/components/$(LIB_PREFIX),$(shell cat $(FINAL_LINK_COMPS)))) $(addsuffix .$(LIB_SUFFIX),$(addprefix $(DIST)/lib/$(LIB_PREFIX),$(shell cat $(FINAL_LINK_LIBS))))
endif
endif
include $(topsrcdir)/config/rules.mk
ifdef BUILD_STATIC_LIBS
include $(topsrcdir)/config/static-rules.mk
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk)
$(PROGRAM): $(SPLASH_XPM)
endif
@ -248,12 +192,6 @@ ifeq ($(OS_ARCH),Darwin)
EXTRA_DSO_LDOPTS = -execute
endif
ifeq ($(OS_ARCH),IRIX)
ifdef BUILD_STATIC_LIBS
LDFLAGS += -Wl,-LD_LAYOUT:lgot_buffer=80
endif
endif
# This code removes the console from release builds
# (unless you've set MOZ_WINCONSOLE=1).
ifndef MOZ_WINCONSOLE
@ -284,10 +222,6 @@ LDFLAGS += /SUBSYSTEM:WINDOWS
endif
endif
ifdef BUILD_STATIC_LIBS
DEFINES += -D_BUILD_STATIC_BIN=1
endif
CXXFLAGS += $(MOZ_TOOLKIT_REGISTRY_CFLAGS)
LOCAL_INCLUDES = -I$(srcdir)
@ -340,13 +274,6 @@ $(LDSCRIPT): $(ORDERFILE)
endif
nsStaticComponents.cpp: nsStaticComponents.cpp.in Makefile Makefile.in $(FINAL_LINK_COMP_NAMES)
rm -f $@
cat $< | \
sed -e "s|%DECL_NSGETMODULES%|$(foreach m,$(_COMPONENT_LIST),DECL_NSGETMODULE($(m)))|" | \
sed -e "s|%MODULE_LIST%|$(foreach m, $(_COMPONENT_LIST),MODULE($(m)),)|" \
> $@
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
ifdef MOZ_DEBUG

Просмотреть файл

@ -129,7 +129,7 @@ extern "C" void ShowOSAlert(const char* aMessage);
#ifdef _BUILD_STATIC_BIN
#include "nsStaticComponent.h"
nsresult PR_CALLBACK
apprunner_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
#endif
#if defined(XP_UNIX) || defined(XP_BEOS)
@ -1547,7 +1547,7 @@ int main(int argc, char* argv[])
#ifdef _BUILD_STATIC_BIN
// Initialize XPCOM's module info table
NSGetStaticModuleInfo = apprunner_getModuleInfo;
NSGetStaticModuleInfo = app_getModuleInfo;
#endif
// Handle -help and -version command line arguments.

Просмотреть файл

@ -63,7 +63,7 @@ static nsStaticModuleInfo gStaticModuleInfo[] = {
* Our NSGetStaticModuleInfoFunc
*/
nsresult
apprunner_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count)
app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count)
{
*info = gStaticModuleInfo;
*count = sizeof(gStaticModuleInfo) / sizeof(gStaticModuleInfo[0]);