config/rules.mk
author Boris Zbarsky <bzbarsky@mit.edu>
Thu, 30 Jul 2009 11:01:01 -0400
changeset 30899 c1ab8650e0ce
parent 30606 48a8978d67f6
child 30927 977aed4e7e0e
permissions -rw-r--r--
Backed out changeset 03c40c5a2d4b (bug 505988) to fix password manager test orange.
hg@1
     1
# vim:set ts=8 sw=8 sts=8 noet:
hg@1
     2
#
hg@1
     3
# ***** BEGIN LICENSE BLOCK *****
hg@1
     4
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
hg@1
     5
#
hg@1
     6
# The contents of this file are subject to the Mozilla Public License Version
hg@1
     7
# 1.1 (the "License"); you may not use this file except in compliance with
hg@1
     8
# the License. You may obtain a copy of the License at
hg@1
     9
# http://www.mozilla.org/MPL/
hg@1
    10
#
hg@1
    11
# Software distributed under the License is distributed on an "AS IS" basis,
hg@1
    12
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
hg@1
    13
# for the specific language governing rights and limitations under the
hg@1
    14
# License.
hg@1
    15
#
hg@1
    16
# The Original Code is mozilla.org code.
hg@1
    17
#
hg@1
    18
# The Initial Developer of the Original Code is
hg@1
    19
# Netscape Communications Corporation.
hg@1
    20
# Portions created by the Initial Developer are Copyright (C) 1998
hg@1
    21
# the Initial Developer. All Rights Reserved.
hg@1
    22
#
hg@1
    23
# Contributor(s):
hg@1
    24
#  Chase Phillips <chase@mozilla.org>
hg@1
    25
#  Benjamin Smedberg <benjamin@smedbergs.us>
hg@1
    26
#  Jeff Walden <jwalden+code@mit.edu>
hg@1
    27
#
hg@1
    28
# Alternatively, the contents of this file may be used under the terms of
hg@1
    29
# either of the GNU General Public License Version 2 or later (the "GPL"),
hg@1
    30
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
hg@1
    31
# in which case the provisions of the GPL or the LGPL are applicable instead
hg@1
    32
# of those above. If you wish to allow use of your version of this file only
hg@1
    33
# under the terms of either the GPL or the LGPL, and not to allow others to
hg@1
    34
# use your version of this file under the terms of the MPL, indicate your
hg@1
    35
# decision by deleting the provisions above and replace them with the notice
hg@1
    36
# and other provisions required by the GPL or the LGPL. If you do not delete
hg@1
    37
# the provisions above, a recipient may use your version of this file under
hg@1
    38
# the terms of any one of the MPL, the GPL or the LGPL.
hg@1
    39
#
hg@1
    40
# ***** END LICENSE BLOCK *****
benjamin@28510
    41
hg@1
    42
ifndef topsrcdir
benjamin@28510
    43
$(error topsrcdir was not set))
hg@1
    44
endif
hg@1
    45
hg@1
    46
ifndef MOZILLA_DIR
hg@1
    47
MOZILLA_DIR = $(topsrcdir)
hg@1
    48
endif
hg@1
    49
hg@1
    50
ifndef INCLUDED_CONFIG_MK
hg@1
    51
include $(topsrcdir)/config/config.mk
hg@1
    52
endif
hg@1
    53
hg@1
    54
ifndef INCLUDED_VERSION_MK
hg@1
    55
include $(topsrcdir)/config/version.mk
hg@1
    56
endif
hg@1
    57
benjamin@28510
    58
ifdef SDK_XPIDLSRCS
benjamin@28510
    59
XPIDLSRCS += $(SDK_XPIDLSRCS)
benjamin@28510
    60
endif
benjamin@28510
    61
ifdef SDK_HEADERS
benjamin@28510
    62
EXPORTS += $(SDK_HEADERS)
benjamin@28510
    63
endif
benjamin@28510
    64
hg@1
    65
REPORT_BUILD = @echo $(notdir $<)
hg@1
    66
hg@1
    67
ifeq ($(OS_ARCH),OS2)
hg@1
    68
EXEC			=
hg@1
    69
else
hg@1
    70
EXEC			= exec
hg@1
    71
endif
hg@1
    72
fta@24320
    73
# Don't copy xulrunner files at install time, when using system xulrunner
fta@24320
    74
ifdef SYSTEM_LIBXUL
fta@24320
    75
  SKIP_COPY_XULRUNNER=1
fta@24320
    76
endif
fta@24320
    77
hg@1
    78
# ELOG prints out failed command when building silently (gmake -s).
hg@1
    79
ifneq (,$(findstring -s,$(MAKEFLAGS)))
hg@1
    80
  ELOG := $(EXEC) sh $(BUILD_TOOLS)/print-failed-commands.sh
hg@1
    81
else
hg@1
    82
  ELOG :=
hg@1
    83
endif
hg@1
    84
hg@1
    85
ifeq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
hg@1
    86
ifndef GNU_CC
hg@1
    87
_LIBNAME_RELATIVE_PATHS=1
hg@1
    88
endif
hg@1
    89
endif
hg@1
    90
hg@1
    91
ifeq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
benjamin@25869
    92
_VPATH_SRCS = $(if $(filter /%,$<),$<,$(CURDIR)/$<)
hg@1
    93
else
hg@1
    94
_VPATH_SRCS = $<
hg@1
    95
endif
hg@1
    96
hg@1
    97
# Add $(DIST)/lib to VPATH so that -lfoo dependencies are followed
hg@1
    98
VPATH += $(DIST)/lib
hg@1
    99
ifdef LIBXUL_SDK
hg@1
   100
VPATH += $(LIBXUL_SDK)/lib
hg@1
   101
endif
hg@1
   102
hg@1
   103
# EXPAND_LIBNAME - $(call EXPAND_LIBNAME,foo)
hg@1
   104
# expands to foo.lib on platforms with import libs and -lfoo otherwise
hg@1
   105
hg@1
   106
# EXPAND_LIBNAME_PATH - $(call EXPAND_LIBNAME_PATH,foo,dir)
hg@1
   107
# expands to dir/foo.lib on platforms with import libs and
hg@1
   108
# -Ldir -lfoo otherwise
hg@1
   109
hg@1
   110
# EXPAND_MOZLIBNAME - $(call EXPAND_MOZLIBNAME,foo)
hg@1
   111
# expands to $(DIST)/lib/foo.lib on platforms with import libs and
hg@1
   112
# -lfoo otherwise
hg@1
   113
hg@1
   114
ifdef _LIBNAME_RELATIVE_PATHS
hg@1
   115
EXPAND_LIBNAME = $(foreach lib,$(1),$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
hg@1
   116
EXPAND_LIBNAME_PATH = $(foreach lib,$(1),$(2)/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
hg@1
   117
EXPAND_MOZLIBNAME = $(foreach lib,$(1),$(DIST)/lib/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
hg@1
   118
else
hg@1
   119
EXPAND_LIBNAME = $(addprefix -l,$(1))
hg@1
   120
EXPAND_LIBNAME_PATH = -L$(2) $(addprefix -l,$(1))
hg@1
   121
EXPAND_MOZLIBNAME = $(addprefix -l,$(1))
hg@1
   122
endif
hg@1
   123
hg@1
   124
ifdef EXTRA_DSO_LIBS
hg@1
   125
EXTRA_DSO_LIBS	:= $(call EXPAND_MOZLIBNAME,$(EXTRA_DSO_LIBS))
hg@1
   126
endif
hg@1
   127
jwalden@22273
   128
################################################################################
jwalden@22273
   129
# Testing frameworks support
jwalden@22273
   130
################################################################################
jwalden@22273
   131
jwalden@22273
   132
ifdef ENABLE_TESTS
jwalden@22273
   133
jwalden@22273
   134
ifdef XPCSHELL_TESTS
jwalden@22273
   135
ifndef MODULE
jwalden@22273
   136
$(error Must define MODULE when defining XPCSHELL_TESTS.)
jwalden@22273
   137
endif
jwalden@22273
   138
sgautherie@25402
   139
testxpcobjdir = $(DEPTH)/_tests/xpcshell
sgautherie@25402
   140
jwalden@22273
   141
# Test file installation
mozilla@30590
   142
ifneq (,$(filter WINNT os2-emx,$(HOST_OS_ARCH)))
mozilla@30590
   143
# Windows and OS/2 nsinstall can't recursively copy directories, so use nsinstall.py
ted@26446
   144
TEST_INSTALLER = $(PYTHON) $(topsrcdir)/config/nsinstall.py
ted@26446
   145
else
ted@26446
   146
TEST_INSTALLER = $(INSTALL)
ted@26446
   147
endif
ted@26054
   148
ted@26054
   149
define _INSTALL_TESTS
ted@26446
   150
$(TEST_INSTALLER) $(wildcard $(srcdir)/$(dir)/*) $(testxpcobjdir)/$(MODULE)/$(dir)
ted@26054
   151
ted@26054
   152
endef # do not remove the blank line!
ted@26054
   153
ted@26054
   154
SOLO_FILE ?= $(error Specify a test filename in SOLO_FILE when using check-interactive or check-one)
ted@26054
   155
jwalden@22273
   156
libs::
ted@26054
   157
	$(foreach dir,$(XPCSHELL_TESTS),$(_INSTALL_TESTS))
ted@26447
   158
	$(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/build-list.pl \
ted@26447
   159
          $(testxpcobjdir)/all-test-dirs.list \
ted@26447
   160
          $(addprefix $(MODULE)/,$(XPCSHELL_TESTS))
jwalden@22273
   161
sgautherie@25402
   162
testxpcsrcdir = $(topsrcdir)/testing/xpcshell
sgautherie@24070
   163
ted@26054
   164
# Execute all tests in the $(XPCSHELL_TESTS) directories.
sgautherie@27861
   165
# See also testsuite-targets.mk 'xpcshell-tests' target for global execution.
sgautherie@27861
   166
xpcshell-tests:
ted@28231
   167
	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
ted@28231
   168
          -I$(topsrcdir)/build \
ted@26054
   169
          $(testxpcsrcdir)/runxpcshelltests.py \
ted@28231
   170
          --symbols-path=$(DIST)/crashreporter-symbols \
ted@26054
   171
          $(DIST)/bin/xpcshell \
ted@26054
   172
          $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
jwalden@22273
   173
ted@26054
   174
# Execute a single test, specified in $(SOLO_FILE), but don't automatically
ted@26054
   175
# start the test. Instead, present the xpcshell prompt so the user can
ted@26054
   176
# attach a debugger and then start the test.
sgautherie@27861
   177
check-interactive:
ted@28231
   178
	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
ted@28231
   179
          -I$(topsrcdir)/build \
ted@26054
   180
          $(testxpcsrcdir)/runxpcshelltests.py \
ted@28231
   181
          --symbols-path=$(DIST)/crashreporter-symbols \
ted@26054
   182
          --test=$(SOLO_FILE) \
ted@26054
   183
          --interactive \
ted@26054
   184
          $(DIST)/bin/xpcshell \
ted@26054
   185
          $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
jwalden@22273
   186
ted@26054
   187
# Execute a single test, specified in $(SOLO_FILE)
sgautherie@27861
   188
check-one:
ted@28231
   189
	$(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
ted@28231
   190
          -I$(topsrcdir)/build \
ted@26054
   191
          $(testxpcsrcdir)/runxpcshelltests.py \
ted@28231
   192
          --symbols-path=$(DIST)/crashreporter-symbols \
ted@26054
   193
          --test=$(SOLO_FILE) \
ted@26054
   194
          $(DIST)/bin/xpcshell \
ted@26054
   195
          $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
jwalden@22273
   196
jwalden@22273
   197
endif # XPCSHELL_TESTS
jwalden@22273
   198
jwalden@22273
   199
ifdef CPP_UNIT_TESTS
jwalden@22273
   200
jwalden@22273
   201
# Compile the tests to $(DIST)/bin.  Make lots of niceties available by default
jwalden@22273
   202
# through TestHarness.h, by modifying the list of includes and the libs against
jwalden@22273
   203
# which stuff links.
jwalden@22273
   204
CPPSRCS += $(CPP_UNIT_TESTS)
jwalden@22273
   205
SIMPLE_PROGRAMS += $(CPP_UNIT_TESTS:.cpp=$(BIN_SUFFIX))
benjamin@28510
   206
INCLUDES += -I$(DIST)/include/testing
jwalden@22275
   207
LIBS += $(XPCOM_GLUE_LDOPTS) $(NSPR_LIBS)
jwalden@22273
   208
jwalden@22273
   209
# ...and run them the usual way
jwalden@22273
   210
check::
jwalden@22273
   211
	@$(EXIT_ON_ERROR) \
jwalden@22273
   212
	  for f in $(subst .cpp,,$(CPP_UNIT_TESTS)); do \
jwalden@22273
   213
	    XPCOM_DEBUG_BREAK=stack-and-abort $(RUN_TEST_PROGRAM) $(DIST)/bin/$$f; \
jwalden@22273
   214
	  done
jwalden@22273
   215
jwalden@22273
   216
endif # CPP_UNIT_TESTS
jwalden@22273
   217
sgautherie@27879
   218
.PHONY: check xpcshell-tests check-interactive check-one
sgautherie@27879
   219
jwalden@22273
   220
endif # ENABLE_TESTS
jwalden@22273
   221
jwalden@22273
   222
hg@1
   223
#
hg@1
   224
# Library rules
hg@1
   225
#
hg@1
   226
# If BUILD_STATIC_LIBS or FORCE_STATIC_LIB is set, build a static library.
hg@1
   227
# Otherwise, build a shared library.
hg@1
   228
#
hg@1
   229
hg@1
   230
ifndef LIBRARY
ted@23647
   231
ifdef STATIC_LIBRARY_NAME
hg@1
   232
ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
hg@1
   233
ifdef SHORT_LIBNAME
ted@23647
   234
STATIC_LIBRARY_NAME	:= $(SHORT_LIBNAME)
ted@23805
   235
SHARED_LIBRARY_NAME	:= $(SHORT_LIBNAME)
hg@1
   236
endif
hg@1
   237
endif
ted@23647
   238
LIBRARY			:= $(LIB_PREFIX)$(STATIC_LIBRARY_NAME).$(LIB_SUFFIX)
ted@23647
   239
endif # STATIC_LIBRARY_NAME
ted@23647
   240
endif # LIBRARY
hg@1
   241
hg@1
   242
ifndef HOST_LIBRARY
hg@1
   243
ifdef HOST_LIBRARY_NAME
hg@1
   244
HOST_LIBRARY		:= $(LIB_PREFIX)$(HOST_LIBRARY_NAME).$(LIB_SUFFIX)
hg@1
   245
endif
hg@1
   246
endif
hg@1
   247
hg@1
   248
ifdef LIBRARY
hg@1
   249
ifneq (_1,$(FORCE_SHARED_LIB)_$(BUILD_STATIC_LIBS))
hg@1
   250
ifdef MKSHLIB
hg@1
   251
hg@1
   252
ifdef LIB_IS_C_ONLY
hg@1
   253
MKSHLIB			= $(MKCSHLIB)
hg@1
   254
endif
hg@1
   255
dbaron@4802
   256
ifdef MAKE_FRAMEWORK
ted@23647
   257
SHARED_LIBRARY		:= $(SHARED_LIBRARY_NAME)
dbaron@4802
   258
else
ted@23647
   259
SHARED_LIBRARY		:= $(DLL_PREFIX)$(SHARED_LIBRARY_NAME)$(DLL_SUFFIX)
dbaron@4802
   260
endif
hg@1
   261
hg@1
   262
ifeq ($(OS_ARCH),OS2)
hg@1
   263
DEF_FILE		:= $(SHARED_LIBRARY:.dll=.def)
hg@1
   264
endif
hg@1
   265
hg@1
   266
ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
ted@23647
   267
IMPORT_LIBRARY		:= $(LIB_PREFIX)$(SHARED_LIBRARY_NAME).$(IMPORT_LIB_SUFFIX)
hg@1
   268
endif
hg@1
   269
ted@6327
   270
ifdef MOZ_ENABLE_LIBXUL
ted@6326
   271
EMBED_MANIFEST_AT=2
ted@6326
   272
endif
ted@6326
   273
hg@1
   274
endif # MKSHLIB
hg@1
   275
endif # FORCE_SHARED_LIB && !BUILD_STATIC_LIBS
hg@1
   276
endif # LIBRARY
hg@1
   277
hg@1
   278
ifeq (,$(BUILD_STATIC_LIBS)$(FORCE_STATIC_LIB))
hg@1
   279
LIBRARY			:= $(NULL)
hg@1
   280
endif
hg@1
   281
hg@1
   282
ifeq (_1,$(FORCE_SHARED_LIB)_$(BUILD_STATIC_LIBS))
hg@1
   283
SHARED_LIBRARY		:= $(NULL)
hg@1
   284
DEF_FILE		:= $(NULL)
hg@1
   285
IMPORT_LIBRARY		:= $(NULL)
hg@1
   286
endif
hg@1
   287
hg@1
   288
ifdef FORCE_STATIC_LIB
hg@1
   289
ifndef FORCE_SHARED_LIB
hg@1
   290
SHARED_LIBRARY		:= $(NULL)
hg@1
   291
DEF_FILE		:= $(NULL)
hg@1
   292
IMPORT_LIBRARY		:= $(NULL)
hg@1
   293
endif
hg@1
   294
endif
hg@1
   295
hg@1
   296
ifdef FORCE_SHARED_LIB
hg@1
   297
ifndef FORCE_STATIC_LIB
hg@1
   298
LIBRARY			:= $(NULL)
hg@1
   299
endif
hg@1
   300
endif
hg@1
   301
hg@1
   302
ifdef JAVA_LIBRARY_NAME
hg@1
   303
JAVA_LIBRARY := $(JAVA_LIBRARY_NAME).jar
hg@1
   304
endif
hg@1
   305
hg@1
   306
ifeq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
hg@1
   307
ifndef GNU_CC
hg@1
   308
hg@1
   309
#
benjamin@22160
   310
# Unless we're building SIMPLE_PROGRAMS, all C++ files share a PDB file per
benjamin@22160
   311
# directory. For parallel builds, this PDB file is shared and locked by
benjamin@22160
   312
# MSPDBSRV.EXE, starting with MSVC8 SP1. If you're using MSVC 7.1 or MSVC8
benjamin@22160
   313
# without SP1, don't do parallel builds.
benjamin@21344
   314
#
benjamin@21344
   315
# The final PDB for libraries and programs is created by the linker and uses
benjamin@21344
   316
# a different name from the single PDB file created by the compiler. See
benjamin@21344
   317
# bug 462740.
benjamin@21344
   318
#
benjamin@22160
   319
benjamin@22160
   320
ifdef SIMPLE_PROGRAMS
benjamin@22160
   321
COMPILE_PDBFILE = $(basename $(@F)).pdb
benjamin@22160
   322
else
benjamin@21344
   323
COMPILE_PDBFILE = generated.pdb
benjamin@22160
   324
endif
benjamin@22160
   325
benjamin@21344
   326
LINK_PDBFILE = $(basename $(@F)).pdb
hg@1
   327
ifdef MOZ_DEBUG
hg@1
   328
CODFILE=$(basename $(@F)).cod
hg@1
   329
endif
hg@1
   330
hg@1
   331
ifdef MOZ_MAPINFO
ted@23647
   332
ifdef SHARED_LIBRARY_NAME
ted@23647
   333
MAPFILE=$(SHARED_LIBRARY_NAME).map
hg@1
   334
else
hg@1
   335
MAPFILE=$(basename $(@F)).map
ted@23647
   336
endif # SHARED_LIBRARY_NAME
hg@1
   337
endif # MOZ_MAPINFO
hg@1
   338
hg@1
   339
ifdef DEFFILE
sdwilsh@30606
   340
OS_LDFLAGS += -DEF:$(call normalizepath,$(DEFFILE))
sdwilsh@16008
   341
EXTRA_DEPS += $(DEFFILE)
hg@1
   342
endif
hg@1
   343
hg@1
   344
ifdef MAPFILE
reed@11488
   345
OS_LDFLAGS += -MAP:$(MAPFILE)
hg@1
   346
endif
hg@1
   347
hg@1
   348
endif # !GNU_CC
hg@1
   349
hg@1
   350
ifdef ENABLE_CXX_EXCEPTIONS
hg@1
   351
ifdef GNU_CC
hg@1
   352
CXXFLAGS		+= -fexceptions
hg@1
   353
else
hg@1
   354
ifeq (,$(filter-out 1200 1300 1310,$(_MSC_VER)))
hg@1
   355
CXXFLAGS		+= -GX
hg@1
   356
else
hg@1
   357
CXXFLAGS		+= -EHsc
hg@1
   358
endif # _MSC_VER
hg@1
   359
endif # GNU_CC
hg@1
   360
endif # ENABLE_CXX_EXCEPTIONS
hg@1
   361
endif # WINNT
hg@1
   362
hg@1
   363
ifeq (,$(filter-out WINNT WINCE,$(HOST_OS_ARCH)))
hg@1
   364
HOST_PDBFILE=$(basename $(@F)).pdb
hg@1
   365
endif
hg@1
   366
hg@1
   367
ifndef TARGETS
hg@1
   368
TARGETS			= $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
hg@1
   369
endif
hg@1
   370
hg@1
   371
ifndef OBJS
hg@1
   372
_OBJS			= \
hg@1
   373
	$(JRI_STUB_CFILES) \
hg@1
   374
	$(addsuffix .$(OBJ_SUFFIX), $(JMC_GEN)) \
hg@1
   375
	$(CSRCS:.c=.$(OBJ_SUFFIX)) \
hg@1
   376
	$(patsubst %.cc,%.$(OBJ_SUFFIX),$(CPPSRCS:.cpp=.$(OBJ_SUFFIX))) \
hg@1
   377
	$(CMSRCS:.m=.$(OBJ_SUFFIX)) \
hg@1
   378
	$(CMMSRCS:.mm=.$(OBJ_SUFFIX)) \
hg@1
   379
	$(ASFILES:.$(ASM_SUFFIX)=.$(OBJ_SUFFIX))
hg@1
   380
OBJS	= $(strip $(_OBJS))
hg@1
   381
endif
hg@1
   382
hg@1
   383
ifndef HOST_OBJS
ted@868
   384
_HOST_OBJS		= \
ted@868
   385
        $(addprefix host_,$(HOST_CSRCS:.c=.$(OBJ_SUFFIX))) \
ted@868
   386
	$(addprefix host_,$(patsubst %.cc,%.$(OBJ_SUFFIX),$(HOST_CPPSRCS:.cpp=.$(OBJ_SUFFIX)))) \
ted@868
   387
	$(addprefix host_,$(HOST_CMSRCS:.m=.$(OBJ_SUFFIX))) \
ted@868
   388
	$(addprefix host_,$(HOST_CMMSRCS:.mm=.$(OBJ_SUFFIX)))
ted@868
   389
HOST_OBJS = $(strip $(_HOST_OBJS))
hg@1
   390
endif
hg@1
   391
hg@1
   392
LIBOBJS			:= $(addprefix \", $(OBJS))
hg@1
   393
LIBOBJS			:= $(addsuffix \", $(LIBOBJS))
hg@1
   394
hg@1
   395
ifndef MOZ_AUTO_DEPS
benjamin@28510
   396
ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS))
hg@1
   397
MDDEPFILES		= $(addprefix $(MDDEPDIR)/,$(OBJS:.$(OBJ_SUFFIX)=.pp))
hg@1
   398
ifndef NO_GEN_XPT
benjamin@28510
   399
MDDEPFILES		+= $(addprefix $(MDDEPDIR)/,$(XPIDLSRCS:.idl=.xpt))
hg@1
   400
endif
hg@1
   401
endif
hg@1
   402
endif
hg@1
   403
hg@1
   404
ALL_TRASH = \
hg@1
   405
	$(GARBAGE) $(TARGETS) $(OBJS) $(PROGOBJS) LOGS TAGS a.out \
mh+mozilla@17042
   406
	$(filter-out $(ASFILES),$(OBJS:.$(OBJ_SUFFIX)=.s)) $(OBJS:.$(OBJ_SUFFIX)=.ii) \
benjamin@6924
   407
	$(OBJS:.$(OBJ_SUFFIX)=.i) \
hg@1
   408
	$(HOST_PROGOBJS) $(HOST_OBJS) $(IMPORT_LIBRARY) $(DEF_FILE)\
hg@1
   409
	$(EXE_DEF_FILE) so_locations _gen _stubs $(wildcard *.res) $(wildcard *.RES) \
hg@1
   410
	$(wildcard *.pdb) $(CODFILE) $(MAPFILE) $(IMPORT_LIBRARY) \
hg@1
   411
	$(SHARED_LIBRARY:$(DLL_SUFFIX)=.exp) $(wildcard *.ilk) \
hg@1
   412
	$(PROGRAM:$(BIN_SUFFIX)=.exp) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.exp) \
hg@1
   413
	$(PROGRAM:$(BIN_SUFFIX)=.lib) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.lib) \
hg@1
   414
	$(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.$(OBJ_SUFFIX)) \
hg@1
   415
	$(wildcard gts_tmp_*) $(LIBRARY:%.a=.%.timestamp)
hg@1
   416
ALL_TRASH_DIRS = \
hg@1
   417
	$(GARBAGE_DIRS) /no-such-file
hg@1
   418
romaxa@16757
   419
ifdef QTDIR
romaxa@16757
   420
GARBAGE                 += $(MOCSRCS)
romaxa@16757
   421
endif
romaxa@16757
   422
hg@1
   423
ifdef SIMPLE_PROGRAMS
hg@1
   424
GARBAGE			+= $(SIMPLE_PROGRAMS:%=%.$(OBJ_SUFFIX))
hg@1
   425
endif
hg@1
   426
hg@1
   427
ifdef HOST_SIMPLE_PROGRAMS
hg@1
   428
GARBAGE			+= $(HOST_SIMPLE_PROGRAMS:%=%.$(OBJ_SUFFIX))
hg@1
   429
endif
hg@1
   430
hg@1
   431
#
hg@1
   432
# the Solaris WorkShop template repository cache.  it occasionally can get
hg@1
   433
# out of sync, so targets like clobber should kill it.
hg@1
   434
#
ginn@24783
   435
ifeq ($(SOLARIS_SUNPRO_CXX),1)
hg@1
   436
GARBAGE_DIRS += SunWS_cache
hg@1
   437
endif
hg@1
   438
hg@1
   439
ifeq ($(OS_ARCH),OpenVMS)
hg@1
   440
GARBAGE			+= $(wildcard *.*_defines)
hg@1
   441
ifdef SHARED_LIBRARY
hg@1
   442
VMS_SYMVEC_FILE		= $(SHARED_LIBRARY:$(DLL_SUFFIX)=_symvec.opt)
hg@1
   443
ifdef MOZ_DEBUG
hg@1
   444
VMS_SYMVEC_FILE_MODULE	= $(topsrcdir)/build/unix/vms/$(notdir $(SHARED_LIBRARY:$(DLL_SUFFIX)=_dbg_symvec.opt))
hg@1
   445
else
hg@1
   446
VMS_SYMVEC_FILE_MODULE	= $(topsrcdir)/build/unix/vms/$(notdir $(SHARED_LIBRARY:$(DLL_SUFFIX)=_symvec.opt))
hg@1
   447
endif
hg@1
   448
VMS_SYMVEC_FILE_COMP	= $(topsrcdir)/build/unix/vms/component_symvec.opt
hg@1
   449
GARBAGE			+= $(VMS_SYMVEC_FILE)
hg@1
   450
ifdef IS_COMPONENT
hg@1
   451
DSO_LDOPTS := $(filter-out -auto_symvec,$(DSO_LDOPTS)) $(VMS_SYMVEC_FILE)
hg@1
   452
endif
hg@1
   453
endif
hg@1
   454
endif
hg@1
   455
hg@1
   456
XPIDL_GEN_DIR		= _xpidlgen
hg@1
   457
hg@1
   458
ifdef MOZ_UPDATE_XTERM
hg@1
   459
# Its good not to have a newline at the end of the titlebar string because it
hg@1
   460
# makes the make -s output easier to read.  Echo -n does not work on all
hg@1
   461
# platforms, but we can trick sed into doing it.
benjamin@25610
   462
UPDATE_TITLE = sed -e "s!Y!$(1) in $(shell $(BUILD_TOOLS)/print-depth-path.sh)/$(2)!" $(MOZILLA_DIR)/config/xterm.str;
hg@1
   463
endif
hg@1
   464
benjamin@25610
   465
define SUBMAKE # $(call SUBMAKE,target,directory)
benjamin@25610
   466
@$(UPDATE_TITLE)
benjamin@25610
   467
+@$(MAKE) $(if $(2),-C $(2)) $(1)
benjamin@25610
   468
benjamin@25610
   469
endef # The extra line is important here! don't delete it
benjamin@25610
   470
benjamin@22942
   471
ifneq (,$(strip $(DIRS)))
hg@1
   472
LOOP_OVER_DIRS = \
benjamin@25610
   473
  $(foreach dir,$(DIRS),$(call SUBMAKE,$@,$(dir)))
benjamin@22942
   474
endif
hg@1
   475
ted@21102
   476
# we only use this for the makefiles target and other stuff that doesn't matter
benjamin@22942
   477
ifneq (,$(strip $(PARALLEL_DIRS)))
ted@21102
   478
LOOP_OVER_PARALLEL_DIRS = \
benjamin@25610
   479
  $(foreach dir,$(PARALLEL_DIRS),$(call SUBMAKE,$@,$(dir)))
benjamin@22942
   480
endif
ted@21102
   481
benjamin@22942
   482
ifneq (,$(strip $(STATIC_DIRS)))
jag@11454
   483
LOOP_OVER_STATIC_DIRS = \
benjamin@25610
   484
  $(foreach dir,$(STATIC_DIRS),$(call SUBMAKE,$@,$(dir)))
benjamin@22942
   485
endif
jag@11454
   486
benjamin@22942
   487
ifneq (,$(strip $(TOOL_DIRS)))
hg@1
   488
LOOP_OVER_TOOL_DIRS = \
benjamin@25610
   489
  $(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,$@,$(dir)))
benjamin@22942
   490
endif
hg@1
   491
ted@21102
   492
ifdef PARALLEL_DIRS
ted@21102
   493
# create a bunch of fake targets for order-only processing
ted@21102
   494
PARALLEL_DIRS_export = $(addsuffix _export,$(PARALLEL_DIRS))
ted@21102
   495
PARALLEL_DIRS_libs = $(addsuffix _libs,$(PARALLEL_DIRS))
ted@21102
   496
PARALLEL_DIRS_tools = $(addsuffix _tools,$(PARALLEL_DIRS))
benjamin@21226
   497
benjamin@21226
   498
.PHONY: $(PARALLEL_DIRS_export) $(PARALLEL_DIRS_libs) $(PARALLEL_DIRS_tools)
ted@21102
   499
endif
ted@21102
   500
hg@1
   501
#
hg@1
   502
# Now we can differentiate between objects used to build a library, and
hg@1
   503
# objects used to build an executable in the same directory.
hg@1
   504
#
hg@1
   505
ifndef PROGOBJS
hg@1
   506
PROGOBJS		= $(OBJS)
hg@1
   507
endif
hg@1
   508
hg@1
   509
ifndef HOST_PROGOBJS
hg@1
   510
HOST_PROGOBJS		= $(HOST_OBJS)
hg@1
   511
endif
hg@1
   512
hg@1
   513
# MAKE_DIRS: List of directories to build while looping over directories.
jimb@21658
   514
# A Makefile that needs $(MDDEPDIR) created but doesn't set any of these
jimb@21658
   515
# variables we know to check can just set NEED_MDDEPDIR explicitly.
benjamin@28510
   516
ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS)$(NEED_MDDEPDIR))
jimb@21658
   517
MAKE_DIRS		+= $(CURDIR)/$(MDDEPDIR)
hg@1
   518
GARBAGE_DIRS		+= $(MDDEPDIR)
hg@1
   519
endif
hg@1
   520
hg@1
   521
#
hg@1
   522
# Tags: emacs (etags), vi (ctags)
hg@1
   523
# TAG_PROGRAM := ctags -L -
hg@1
   524
#
hg@1
   525
TAG_PROGRAM		= xargs etags -a
hg@1
   526
hg@1
   527
#
benjamin@787
   528
# Turn on C++ linking if we have any .cpp or .mm files
hg@1
   529
# (moved this from config.mk so that config.mk can be included 
hg@1
   530
#  before the CPPSRCS are defined)
hg@1
   531
#
benjamin@787
   532
ifneq ($(CPPSRCS)$(CMMSRCS),)
hg@1
   533
CPP_PROG_LINK		= 1
hg@1
   534
endif
hg@1
   535
hg@1
   536
#
hg@1
   537
# Make sure to wrap static libs inside linker specific flags to turn on & off
hg@1
   538
# inclusion of all symbols inside the static libs
hg@1
   539
#
hg@1
   540
ifndef NO_LD_ARCHIVE_FLAGS
hg@1
   541
ifdef SHARED_LIBRARY_LIBS
hg@1
   542
EXTRA_DSO_LDOPTS := $(MKSHLIB_FORCE_ALL) $(SHARED_LIBRARY_LIBS) $(MKSHLIB_UNFORCE_ALL) $(EXTRA_DSO_LDOPTS)
hg@1
   543
endif
hg@1
   544
endif
hg@1
   545
hg@1
   546
#
hg@1
   547
# This will strip out symbols that the component should not be 
hg@1
   548
# exporting from the .dynsym section.
hg@1
   549
#
hg@1
   550
ifdef IS_COMPONENT
hg@1
   551
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
hg@1
   552
endif # IS_COMPONENT
hg@1
   553
hg@1
   554
#
hg@1
   555
# Enforce the requirement that MODULE_NAME must be set 
hg@1
   556
# for components in static builds
hg@1
   557
#
hg@1
   558
ifdef IS_COMPONENT
hg@1
   559
ifdef EXPORT_LIBRARY
hg@1
   560
ifndef FORCE_SHARED_LIB
hg@1
   561
ifndef MODULE_NAME
hg@1
   562
$(error MODULE_NAME is required for components which may be used in static builds)
hg@1
   563
endif
hg@1
   564
endif
hg@1
   565
endif
hg@1
   566
endif
hg@1
   567
hg@1
   568
#
hg@1
   569
# MacOS X specific stuff
hg@1
   570
#
hg@1
   571
hg@1
   572
ifeq ($(OS_ARCH),Darwin)
hg@1
   573
ifdef SHARED_LIBRARY
hg@1
   574
ifdef IS_COMPONENT
hg@1
   575
EXTRA_DSO_LDOPTS	+= -bundle
hg@1
   576
else
benjamin@3341
   577
EXTRA_DSO_LDOPTS	+= -dynamiclib -install_name @executable_path/$(SHARED_LIBRARY) -compatibility_version 1 -current_version 1 -single_module
hg@1
   578
endif
hg@1
   579
endif
hg@1
   580
endif
hg@1
   581
hg@1
   582
#
hg@1
   583
# On NetBSD a.out systems, use -Bsymbolic.  This fixes what would otherwise be
hg@1
   584
# fatal symbol name clashes between components.
hg@1
   585
#
hg@1
   586
ifeq ($(OS_ARCH),NetBSD)
hg@1
   587
ifeq ($(DLL_SUFFIX),.so.1.0)
hg@1
   588
ifdef IS_COMPONENT
hg@1
   589
EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
hg@1
   590
endif
hg@1
   591
endif
hg@1
   592
endif
hg@1
   593
hg@1
   594
ifeq ($(OS_ARCH),FreeBSD)
hg@1
   595
ifdef IS_COMPONENT
hg@1
   596
EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
hg@1
   597
endif
hg@1
   598
endif
hg@1
   599
hg@1
   600
ifeq ($(OS_ARCH),NetBSD)
hg@1
   601
ifneq (,$(filter arc cobalt hpcmips mipsco newsmips pmax sgimips,$(OS_TEST)))
hg@1
   602
ifeq ($(MODULE),layout)
hg@1
   603
OS_CFLAGS += -Wa,-xgot
hg@1
   604
OS_CXXFLAGS += -Wa,-xgot
hg@1
   605
endif
hg@1
   606
endif
hg@1
   607
endif
hg@1
   608
hg@1
   609
ifeq ($(OS_ARCH),Linux)
hg@1
   610
ifneq (,$(filter mips mipsel,$(OS_TEST)))
hg@1
   611
ifeq ($(MODULE),layout)
hg@1
   612
OS_CFLAGS += -Wa,-xgot
hg@1
   613
OS_CXXFLAGS += -Wa,-xgot
hg@1
   614
endif
hg@1
   615
endif
hg@1
   616
endif
hg@1
   617
hg@1
   618
#
hg@1
   619
# HP-UXBeOS specific section: for COMPONENTS only, add -Bsymbolic flag
hg@1
   620
# which uses internal symbols first
hg@1
   621
#
hg@1
   622
ifeq ($(OS_ARCH),HP-UX)
hg@1
   623
ifdef IS_COMPONENT
hg@1
   624
ifeq ($(GNU_CC)$(GNU_CXX),)
hg@1
   625
EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
hg@1
   626
ifneq ($(HAS_EXTRAEXPORTS),1)
hg@1
   627
MKSHLIB  += -Wl,+eNSGetModule -Wl,+eerrno
hg@1
   628
MKCSHLIB += +eNSGetModule +eerrno
hg@1
   629
ifneq ($(OS_TEST),ia64)
hg@1
   630
MKSHLIB  += -Wl,+e_shlInit
hg@1
   631
MKCSHLIB += +e_shlInit
hg@1
   632
endif # !ia64
hg@1
   633
endif # !HAS_EXTRAEXPORTS
hg@1
   634
endif # non-gnu compilers
hg@1
   635
endif # IS_COMPONENT
hg@1
   636
endif # HP-UX
hg@1
   637
hg@1
   638
ifeq ($(OS_ARCH),AIX)
hg@1
   639
ifdef IS_COMPONENT
hg@1
   640
ifneq ($(HAS_EXTRAEXPORTS),1)
hg@1
   641
MKSHLIB += -bE:$(MOZILLA_DIR)/build/unix/aix.exp -bnoexpall
hg@1
   642
MKCSHLIB += -bE:$(MOZILLA_DIR)/build/unix/aix.exp -bnoexpall
hg@1
   643
endif # HAS_EXTRAEXPORTS
hg@1
   644
endif # IS_COMPONENT
hg@1
   645
endif # AIX
hg@1
   646
hg@1
   647
#
hg@1
   648
# OSF1: add -B symbolic flag for components
hg@1
   649
#
hg@1
   650
ifeq ($(OS_ARCH),OSF1)
hg@1
   651
ifdef IS_COMPONENT
hg@1
   652
ifeq ($(GNU_CC)$(GNU_CXX),)
hg@1
   653
EXTRA_DSO_LDOPTS += -B symbolic
hg@1
   654
endif  
hg@1
   655
endif  
hg@1
   656
endif
hg@1
   657
hg@1
   658
#
hg@1
   659
# Linux: add -Bsymbolic flag for components
hg@1
   660
# 
hg@1
   661
ifeq ($(OS_ARCH),Linux)
hg@1
   662
ifdef IS_COMPONENT
hg@1
   663
EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
hg@1
   664
endif
hg@1
   665
endif 
hg@1
   666
hg@1
   667
#
hg@1
   668
# MINGW32
hg@1
   669
#
hg@1
   670
ifeq ($(OS_ARCH),WINNT)
hg@1
   671
ifdef GNU_CC
hg@1
   672
ifndef IS_COMPONENT
hg@1
   673
DSO_LDOPTS += -Wl,--out-implib -Wl,$(IMPORT_LIBRARY)
hg@1
   674
endif
hg@1
   675
endif
hg@1
   676
endif
hg@1
   677
hg@1
   678
ifeq ($(USE_TVFS),1)
hg@1
   679
IFLAGS1 = -rb
hg@1
   680
IFLAGS2 = -rb
hg@1
   681
else
hg@1
   682
IFLAGS1 = -m 644
hg@1
   683
IFLAGS2 = -m 755
hg@1
   684
endif
hg@1
   685
hg@1
   686
ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
hg@1
   687
OUTOPTION = -Fo# eol
hg@1
   688
else
hg@1
   689
OUTOPTION = -o # eol
hg@1
   690
endif # WINNT && !GNU_CC
hg@1
   691
ifneq (,$(filter WINCE,$(OS_ARCH)))
hg@1
   692
OUTOPTION = -Fo# eol
hg@1
   693
endif
hg@1
   694
hg@1
   695
ifeq ($(OS_TARGET), WINCE)
hg@1
   696
OUTOPTION = -Fo# eol
dougt@12039
   697
HOST_OUTOPTION = -Fo# eol
dougt@12039
   698
else
hg@1
   699
neil@112
   700
ifeq (,$(CROSS_COMPILE))
neil@112
   701
HOST_OUTOPTION = $(OUTOPTION)
neil@112
   702
else
neil@112
   703
HOST_OUTOPTION = -o # eol
neil@112
   704
endif
neil@112
   705
dougt@12039
   706
endif
hg@1
   707
################################################################################
hg@1
   708
hg@1
   709
# SUBMAKEFILES: List of Makefiles for next level down.
hg@1
   710
#   This is used to update or create the Makefiles before invoking them.
benjamin@21226
   711
SUBMAKEFILES += $(addsuffix /Makefile, $(DIRS) $(TOOL_DIRS) $(PARALLEL_DIRS))
hg@1
   712
hg@1
   713
# The root makefile doesn't want to do a plain export/libs, because
hg@1
   714
# of the tiers and because of libxul. Suppress the default rules in favor
hg@1
   715
# of something else. Makefiles which use this var *must* provide a sensible
hg@1
   716
# default rule before including rules.mk
hg@1
   717
ifndef SUPPRESS_DEFAULT_RULES
hg@1
   718
ifdef TIERS
hg@1
   719
default all alldep::
benjamin@25610
   720
	$(foreach tier,$(TIERS),$(call SUBMAKE,tier_$(tier)))
hg@1
   721
else
hg@1
   722
hg@1
   723
default all::
benjamin@22942
   724
ifneq (,$(strip $(STATIC_DIRS)))
benjamin@25610
   725
	$(foreach dir,$(STATIC_DIRS),$(call SUBMAKE,,$(dir)))
benjamin@22942
   726
endif
hg@1
   727
	$(MAKE) export
hg@1
   728
	$(MAKE) libs
hg@1
   729
	$(MAKE) tools
hg@1
   730
hg@1
   731
# Do depend as well
hg@1
   732
alldep:: 
hg@1
   733
	$(MAKE) export
hg@1
   734
	$(MAKE) depend
hg@1
   735
	$(MAKE) libs
hg@1
   736
	$(MAKE) tools
hg@1
   737
hg@1
   738
endif # TIERS
hg@1
   739
endif # SUPPRESS_DEFAULT_RULES
hg@1
   740
ynvich@15948
   741
ifeq ($(filter s,$(MAKEFLAGS)),)
ynvich@15876
   742
ECHO := echo
ynvich@15876
   743
QUIET :=
ynvich@15876
   744
else
ynvich@15876
   745
ECHO := true
ynvich@15876
   746
QUIET := -q
ynvich@15876
   747
endif
ynvich@15876
   748
reed@11668
   749
MAKE_TIER_SUBMAKEFILES = +$(if $(tier_$*_dirs),$(MAKE) $(addsuffix /Makefile,$(tier_$*_dirs)))
hg@1
   750
benjamin@25610
   751
export_tier_%:
ynvich@15876
   752
	@$(ECHO) "$@"
hg@1
   753
	@$(MAKE_TIER_SUBMAKEFILES)
benjamin@25610
   754
	$(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,export,$(dir)))
hg@1
   755
hg@1
   756
libs_tier_%:
ynvich@15876
   757
	@$(ECHO) "$@"
hg@1
   758
	@$(MAKE_TIER_SUBMAKEFILES)
benjamin@25610
   759
	$(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,libs,$(dir)))
hg@1
   760
hg@1
   761
tools_tier_%:
ynvich@15876
   762
	@$(ECHO) "$@"
hg@1
   763
	@$(MAKE_TIER_SUBMAKEFILES)
benjamin@25610
   764
	$(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,tools,$(dir)))
hg@1
   765
hg@1
   766
$(foreach tier,$(TIERS),tier_$(tier))::
ynvich@15876
   767
	@$(ECHO) "$@: $($@_staticdirs) $($@_dirs)"
benjamin@25610
   768
	$(foreach dir,$($@_staticdirs),$(call SUBMAKE,,$(dir)))
hg@1
   769
	$(MAKE) export_$@
hg@1
   770
	$(MAKE) libs_$@
hg@1
   771
hg@1
   772
# Do everything from scratch
hg@1
   773
everything::
hg@1
   774
	$(MAKE) clean
hg@1
   775
	$(MAKE) alldep
hg@1
   776
hg@1
   777
# Add dummy depend target for tinderboxes
hg@1
   778
depend::
hg@1
   779
hg@1
   780
# Target to only regenerate makefiles
hg@1
   781
makefiles: $(SUBMAKEFILES)
ted@21102
   782
ifneq (,$(DIRS)$(TOOL_DIRS)$(PARALLEL_DIRS))
benjamin@25610
   783
	$(LOOP_OVER_PARALLEL_DIRS)
benjamin@25610
   784
	$(LOOP_OVER_DIRS)
benjamin@25610
   785
	$(LOOP_OVER_TOOL_DIRS)
hg@1
   786
endif
hg@1
   787
ted@21102
   788
ifdef PARALLEL_DIRS
benjamin@21226
   789
export:: $(PARALLEL_DIRS_export)
ted@21102
   790
benjamin@21226
   791
$(PARALLEL_DIRS_export): %_export: %/Makefile
benjamin@25610
   792
	+@$(call SUBMAKE,export,$*)
ted@21102
   793
endif
ted@21102
   794
benjamin@28510
   795
export:: $(SUBMAKEFILES) $(MAKE_DIRS) $(if $(XPIDLSRCS),$(IDL_DIR))
benjamin@25610
   796
	$(LOOP_OVER_DIRS)
benjamin@25610
   797
	$(LOOP_OVER_TOOL_DIRS)
hg@1
   798
ted@21102
   799
ifdef PARALLEL_DIRS
benjamin@21226
   800
tools:: $(PARALLEL_DIRS_tools)
ted@21102
   801
benjamin@21226
   802
$(PARALLEL_DIRS_tools): %_tools: %/Makefile
benjamin@25610
   803
	+@$(call SUBMAKE,tools,$*)
ted@21102
   804
endif
ted@21102
   805
hg@1
   806
tools:: $(SUBMAKEFILES) $(MAKE_DIRS)
benjamin@25610
   807
	$(LOOP_OVER_DIRS)
benjamin@22942
   808
ifneq (,$(strip $(TOOL_DIRS)))
benjamin@25610
   809
	$(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,libs,$(dir)))
benjamin@22185
   810
endif
hg@1
   811
hg@1
   812
#
hg@1
   813
# Rule to create list of libraries for final link
hg@1
   814
#
hg@1
   815
export::
hg@1
   816
ifdef LIBRARY_NAME
hg@1
   817
ifdef EXPORT_LIBRARY
hg@1
   818
ifdef IS_COMPONENT
hg@1
   819
ifdef BUILD_STATIC_LIBS
ted@23647
   820
	@$(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/build-list.pl $(FINAL_LINK_COMPS) $(STATIC_LIBRARY_NAME)
hg@1
   821
ifdef MODULE_NAME
hg@1
   822
	@$(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/build-list.pl $(FINAL_LINK_COMP_NAMES) $(MODULE_NAME)
hg@1
   823
endif
ted@23647
   824
endif # BUILD_STATIC_LIBS
ted@23647
   825
else  # !IS_COMPONENT
ted@23647
   826
	$(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/build-list.pl $(FINAL_LINK_LIBS) $(STATIC_LIBRARY_NAME)
hg@1
   827
endif # IS_COMPONENT
hg@1
   828
endif # EXPORT_LIBRARY
hg@1
   829
endif # LIBRARY_NAME
hg@1
   830
hg@1
   831
# Create dependencies on static (and shared EXTRA_DSO_LIBS) libraries
hg@1
   832
LIBS_DEPS = $(filter %.$(LIB_SUFFIX), $(LIBS))
hg@1
   833
HOST_LIBS_DEPS = $(filter %.$(LIB_SUFFIX), $(HOST_LIBS))
hg@1
   834
DSO_LDOPTS_DEPS = $(EXTRA_DSO_LIBS) $(filter %.$(LIB_SUFFIX), $(EXTRA_DSO_LDOPTS))
hg@1
   835
Callek@22053
   836
# Dependancies which, if modified, should cause everything to rebuild
dtownsend@29413
   837
GLOBAL_DEPS += Makefile Makefile.in $(DEPTH)/config/autoconf.mk $(topsrcdir)/config/config.mk
Callek@22053
   838
hg@1
   839
##############################################
ted@21102
   840
ifdef PARALLEL_DIRS
benjamin@21226
   841
libs:: $(PARALLEL_DIRS_libs)
ted@21102
   842
benjamin@21226
   843
$(PARALLEL_DIRS_libs): %_libs: %/Makefile
benjamin@25610
   844
	+@$(call SUBMAKE,libs,$*)
ted@21102
   845
endif
ted@21102
   846
hg@1
   847
libs:: $(SUBMAKEFILES) $(MAKE_DIRS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) $(HOST_PROGRAM) $(PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
hg@1
   848
ifndef NO_DIST_INSTALL
hg@1
   849
ifdef LIBRARY
hg@1
   850
ifdef EXPORT_LIBRARY # Stage libs that will be linked into a static build
hg@1
   851
ifdef IS_COMPONENT
hg@1
   852
	$(INSTALL) $(IFLAGS1) $(LIBRARY) $(DEPTH)/staticlib/components
hg@1
   853
else
hg@1
   854
	$(INSTALL) $(IFLAGS1) $(LIBRARY) $(DEPTH)/staticlib
hg@1
   855
endif
hg@1
   856
endif # EXPORT_LIBRARY
hg@1
   857
ifdef DIST_INSTALL
hg@1
   858
ifdef IS_COMPONENT
hg@1
   859
	$(error Shipping static component libs makes no sense.)
hg@1
   860
else
hg@1
   861
	$(INSTALL) $(IFLAGS1) $(LIBRARY) $(DIST)/lib
hg@1
   862
endif
hg@1
   863
endif # DIST_INSTALL
hg@1
   864
endif # LIBRARY
hg@1
   865
ifdef SHARED_LIBRARY
hg@1
   866
ifdef IS_COMPONENT
hg@1
   867
	$(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)/components
hg@1
   868
	$(ELF_DYNSTR_GC) $(FINAL_TARGET)/components/$(SHARED_LIBRARY)
hg@1
   869
ifdef BEOS_ADDON_WORKAROUND
hg@1
   870
	( cd $(FINAL_TARGET)/components && $(CC) -nostart -o $(SHARED_LIBRARY).stub $(SHARED_LIBRARY) )
hg@1
   871
endif
hg@1
   872
else # ! IS_COMPONENT
hg@1
   873
ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
hg@1
   874
	$(INSTALL) $(IFLAGS2) $(IMPORT_LIBRARY) $(DIST)/lib
hg@1
   875
else
hg@1
   876
	$(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(DIST)/lib
hg@1
   877
endif
hg@1
   878
	$(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)
hg@1
   879
ifdef BEOS_ADDON_WORKAROUND
hg@1
   880
	( cd $(FINAL_TARGET) && $(CC) -nostart -o $(SHARED_LIBRARY).stub $(SHARED_LIBRARY) )
hg@1
   881
endif
hg@1
   882
endif # IS_COMPONENT
hg@1
   883
endif # SHARED_LIBRARY
hg@1
   884
ifdef PROGRAM
hg@1
   885
	$(INSTALL) $(IFLAGS2) $(PROGRAM) $(FINAL_TARGET)
hg@1
   886
endif
hg@1
   887
ifdef SIMPLE_PROGRAMS
hg@1
   888
	$(INSTALL) $(IFLAGS2) $(SIMPLE_PROGRAMS) $(FINAL_TARGET)
hg@1
   889
endif
hg@1
   890
ifdef HOST_PROGRAM
hg@1
   891
	$(INSTALL) $(IFLAGS2) $(HOST_PROGRAM) $(DIST)/host/bin
hg@1
   892
endif
hg@1
   893
ifdef HOST_SIMPLE_PROGRAMS
hg@1
   894
	$(INSTALL) $(IFLAGS2) $(HOST_SIMPLE_PROGRAMS) $(DIST)/host/bin
hg@1
   895
endif
hg@1
   896
ifdef HOST_LIBRARY
hg@1
   897
	$(INSTALL) $(IFLAGS1) $(HOST_LIBRARY) $(DIST)/host/lib
hg@1
   898
endif
hg@1
   899
ifdef JAVA_LIBRARY
hg@1
   900
ifdef IS_COMPONENT
hg@1
   901
	$(INSTALL) $(IFLAGS1) $(JAVA_LIBRARY) $(FINAL_TARGET)/components
hg@1
   902
else
hg@1
   903
	$(INSTALL) $(IFLAGS1) $(JAVA_LIBRARY) $(FINAL_TARGET)
hg@1
   904
endif
hg@1
   905
endif # JAVA_LIBRARY
hg@1
   906
endif # !NO_DIST_INSTALL
benjamin@25610
   907
	$(LOOP_OVER_DIRS)
hg@1
   908
hg@1
   909
##############################################
hg@1
   910
ted@11977
   911
ifndef NO_PROFILE_GUIDED_OPTIMIZE
ted@11977
   912
ifneq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
ted@11977
   913
ifeq ($(OS_ARCH)_$(GNU_CC)$(INTERNAL_TOOLS), WINNT_)
ted@11977
   914
# Force re-linking when building with PGO, since
ted@11977
   915
# the MSVC linker does all the work.  We force re-link
ted@11977
   916
# in both stages so you can do depend builds with PGO.
ted@11977
   917
ifdef SHARED_LIBRARY
ted@11977
   918
$(SHARED_LIBRARY): FORCE
ted@11977
   919
endif
ted@11977
   920
ifdef PROGRAM
ted@11977
   921
$(PROGRAM): FORCE
ted@11977
   922
endif
ted@11977
   923
ted@11977
   924
ifdef MOZ_PROFILE_USE
ted@11977
   925
# In the second pass, we need to merge the pgc files into the pgd file.
ted@11977
   926
# The compiler would do this for us automatically if they were in the right
ted@11977
   927
# place, but they're in dist/bin.
ted@23477
   928
ifneq (,$(SHARED_LIBRARY)$(PROGRAM))
ted@11977
   929
export::
ted@23477
   930
ifdef PROGRAM
ted@11977
   931
	$(PYTHON) $(topsrcdir)/build/win32/pgomerge.py \
ted@23477
   932
	  $(PROGRAM:$(BIN_SUFFIX)=) $(DIST)/bin
ted@23477
   933
endif
ted@23477
   934
ifdef SHARED_LIBRARY
ted@23477
   935
	$(PYTHON) $(topsrcdir)/build/win32/pgomerge.py \
ted@23647
   936
	  $(SHARED_LIBRARY_NAME) $(DIST)/bin
ted@23477
   937
endif
ted@11977
   938
endif
ted@11977
   939
endif # MOZ_PROFILE_USE
ted@11977
   940
endif # WINNT_
ted@11977
   941
endif # MOZ_PROFILE_GENERATE || MOZ_PROFILE_USE
ted@11977
   942
endif # NO_PROFILE_GUIDED_OPTIMIZE
ted@11977
   943
ted@11977
   944
##############################################
ted@11977
   945
hg@1
   946
checkout:
hg@1
   947
	$(MAKE) -C $(topsrcdir) -f client.mk checkout
hg@1
   948
hg@1
   949
clean clobber realclean clobber_all:: $(SUBMAKEFILES)
hg@1
   950
	-rm -f $(ALL_TRASH)
hg@1
   951
	-rm -rf $(ALL_TRASH_DIRS)
benjamin@25610
   952
	$(foreach dir,$(PARALLEL_DIRS) $(DIRS) $(STATIC_DIRS) $(TOOL_DIRS),-$(call SUBMAKE,$@,$(dir)))
hg@1
   953
hg@1
   954
distclean:: $(SUBMAKEFILES)
benjamin@25610
   955
	$(foreach dir,$(PARALLEL_DIRS) $(DIRS) $(STATIC_DIRS) $(TOOL_DIRS),-$(call SUBMAKE,$@,$(dir)))
hg@1
   956
	-rm -rf $(ALL_TRASH_DIRS) 
hg@1
   957
	-rm -f $(ALL_TRASH)  \
hg@1
   958
	Makefile .HSancillary \
hg@1
   959
	$(wildcard *.$(OBJ_SUFFIX)) $(wildcard *.ho) $(wildcard host_*.o*) \
hg@1
   960
	$(wildcard *.$(LIB_SUFFIX)) $(wildcard *$(DLL_SUFFIX)) \
hg@1
   961
	$(wildcard *.$(IMPORT_LIB_SUFFIX))
wuno@20288
   962
ifeq ($(OS_ARCH),OS2)
hg@1
   963
	-rm -f $(PROGRAM:.exe=.map)
hg@1
   964
endif
hg@1
   965
hg@1
   966
alltags:
hg@1
   967
	rm -f TAGS
hg@1
   968
	find $(topsrcdir) -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' -o -name '*.idl' \) -print | $(TAG_PROGRAM)
hg@1
   969
hg@1
   970
#
hg@1
   971
# PROGRAM = Foo
hg@1
   972
# creates OBJS, links with LIBS to create Foo
hg@1
   973
#
Callek@22053
   974
$(PROGRAM): $(PROGOBJS) $(LIBS_DEPS) $(EXTRA_DEPS) $(EXE_DEF_FILE) $(RESFILE) $(GLOBAL_DEPS)
hg@1
   975
ifeq (WINCE,$(OS_ARCH))
hg@1
   976
	$(LD) -NOLOGO -OUT:$@ $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(PROGOBJS) $(RESFILE) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
hg@1
   977
else
hg@1
   978
ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
benjamin@21344
   979
	$(LD) -NOLOGO -OUT:$@ -PDB:$(LINK_PDBFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(PROGOBJS) $(RESFILE) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
hg@1
   980
ifdef MSMANIFEST_TOOL
hg@1
   981
	@if test -f $@.manifest; then \
hg@1
   982
		if test -f "$(srcdir)/$@.manifest"; then \
hg@1
   983
			mt.exe -NOLOGO -MANIFEST "$(win_srcdir)/$@.manifest" $@.manifest -OUTPUTRESOURCE:$@\;1; \
hg@1
   984
		else \
hg@1
   985
			mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
hg@1
   986
		fi; \
hg@1
   987
		rm -f $@.manifest; \
hg@1
   988
	fi
hg@1
   989
endif	# MSVC with manifest tool
hg@1
   990
else
hg@1
   991
ifeq ($(CPP_PROG_LINK),1)
ginn@14800
   992
	$(CCC) -o $@ $(CXXFLAGS) $(WRAP_MALLOC_CFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(SOLARIS_JEMALLOC_LDFLAGS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS) $(WRAP_MALLOC_LIB) $(PROFILER_LIBS) $(EXE_DEF_FILE)
hg@1
   993
else # ! CPP_PROG_LINK
ginn@14800
   994
	$(CC) -o $@ $(CFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(SOLARIS_JEMALLOC_LDFLAGS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS) $(EXE_DEF_FILE)
hg@1
   995
endif # CPP_PROG_LINK
hg@1
   996
endif # WINNT && !GNU_CC
hg@1
   997
endif # WINCE
hg@1
   998
hg@1
   999
ifdef ENABLE_STRIP
hg@1
  1000
	$(STRIP) $@
hg@1
  1001
endif
hg@1
  1002
ifdef MOZ_POST_PROGRAM_COMMAND
hg@1
  1003
	$(MOZ_POST_PROGRAM_COMMAND) $@
hg@1
  1004
endif
hg@1
  1005
ifeq ($(OS_ARCH),BeOS)
hg@1
  1006
ifdef BEOS_PROGRAM_RESOURCE
hg@1
  1007
	xres -o $@ $(BEOS_PROGRAM_RESOURCE)
hg@1
  1008
	mimeset $@
hg@1
  1009
endif
hg@1
  1010
endif # BeOS
hg@1
  1011
Callek@22053
  1012
$(HOST_PROGRAM): $(HOST_PROGOBJS) $(HOST_LIBS_DEPS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
hg@1
  1013
ifeq (WINCE,$(OS_ARCH))
hg@1
  1014
	$(HOST_LD) -NOLOGO -OUT:$@ $(HOST_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
hg@1
  1015
else
hg@1
  1016
ifeq (_WINNT,$(GNU_CC)_$(HOST_OS_ARCH))
benjamin@21344
  1017
	$(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $(HOST_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
hg@1
  1018
ifdef MSMANIFEST_TOOL
hg@1
  1019
	@if test -f $@.manifest; then \
hg@1
  1020
		mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
hg@1
  1021
		rm -f $@.manifest; \
hg@1
  1022
	fi
hg@1
  1023
endif	# MSVC with manifest tool
hg@1
  1024
else
ted@868
  1025
ifeq ($(CPP_PROG_LINK),1)
ted@1423
  1026
	$(HOST_CXX) -o $@ $(HOST_CXXFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
ted@868
  1027
else
ted@1423
  1028
	$(HOST_CC) -o $@ $(HOST_CFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
ted@868
  1029
endif # CPP_PROG_LINK
hg@1
  1030
endif
hg@1
  1031
endif
hg@1
  1032
hg@1
  1033
#
hg@1
  1034
# This is an attempt to support generation of multiple binaries
hg@1
  1035
# in one directory, it assumes everything to compile Foo is in
hg@1
  1036
# Foo.o (from either Foo.c or Foo.cpp).
hg@1
  1037
#
hg@1
  1038
# SIMPLE_PROGRAMS = Foo Bar
hg@1
  1039
# creates Foo.o Bar.o, links with LIBS to create Foo, Bar.
hg@1
  1040
#
Callek@22053
  1041
$(SIMPLE_PROGRAMS): %$(BIN_SUFFIX): %.$(OBJ_SUFFIX) $(LIBS_DEPS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
hg@1
  1042
ifeq (WINCE,$(OS_ARCH))
hg@1
  1043
	$(LD) -nologo  -entry:main -out:$@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
hg@1
  1044
else
hg@1
  1045
ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
benjamin@21344
  1046
	$(LD) -nologo -out:$@ -pdb:$(LINK_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
hg@1
  1047
ifdef MSMANIFEST_TOOL
hg@1
  1048
	@if test -f $@.manifest; then \
hg@1
  1049
		mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
hg@1
  1050
		rm -f $@.manifest; \
hg@1
  1051
	fi
hg@1
  1052
endif	# MSVC with manifest tool
hg@1
  1053
else
hg@1
  1054
ifeq ($(CPP_PROG_LINK),1)
ginn@14800
  1055
	$(CCC) $(WRAP_MALLOC_CFLAGS) $(CXXFLAGS) -o $@ $< $(WIN32_EXE_LDFLAGS) $(SOLARIS_JEMALLOC_LDFLAGS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS) $(WRAP_MALLOC_LIB) $(PROFILER_LIBS) $(BIN_FLAGS)
hg@1
  1056
else
ginn@14800
  1057
	$(CC) $(WRAP_MALLOC_CFLAGS) $(CFLAGS) $(OUTOPTION)$@ $< $(WIN32_EXE_LDFLAGS) $(SOLARIS_JEMALLOC_LDFLAGS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS) $(WRAP_MALLOC_LIB) $(PROFILER_LIBS) $(BIN_FLAGS)
hg@1
  1058
endif # CPP_PROG_LINK
hg@1
  1059
endif # WINNT && !GNU_CC
hg@1
  1060
endif # WINCE
hg@1
  1061
hg@1
  1062
ifdef ENABLE_STRIP
hg@1
  1063
	$(STRIP) $@
hg@1
  1064
endif
hg@1
  1065
ifdef MOZ_POST_PROGRAM_COMMAND
hg@1
  1066
	$(MOZ_POST_PROGRAM_COMMAND) $@
hg@1
  1067
endif
hg@1
  1068
Callek@22053
  1069
$(HOST_SIMPLE_PROGRAMS): host_%$(HOST_BIN_SUFFIX): host_%.$(OBJ_SUFFIX) $(HOST_LIBS_DEPS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
hg@1
  1070
ifeq (WINCE,$(OS_ARCH))
hg@1
  1071
	$(HOST_LD) -NOLOGO -OUT:$@ $(WIN32_EXE_LDFLAGS) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
hg@1
  1072
else
hg@1
  1073
ifeq (WINNT_,$(HOST_OS_ARCH)_$(GNU_CC))
benjamin@21344
  1074
	$(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
hg@1
  1075
else
benjamin@15146
  1076
ifneq (,$(HOST_CPPSRCS)$(USE_HOST_CXX))
neil@669
  1077
	$(HOST_CXX) $(HOST_OUTOPTION)$@ $(HOST_CXXFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
neil@113
  1078
else
neil@112
  1079
	$(HOST_CC) $(HOST_OUTOPTION)$@ $(HOST_CFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
hg@1
  1080
endif
hg@1
  1081
endif
hg@1
  1082
endif
hg@1
  1083
hg@1
  1084
#
hg@1
  1085
# Purify target.  Solaris/sparc only to start.
hg@1
  1086
# Purify does not recognize "egcs" or "c++" so we go with 
hg@1
  1087
# "gcc" and "g++" for now.
hg@1
  1088
#
hg@1
  1089
pure:	$(PROGRAM)
hg@1
  1090
ifeq ($(CPP_PROG_LINK),1)
hg@1
  1091
	$(PURIFY) $(CCC) -o $^.pure $(CXXFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
hg@1
  1092
else
hg@1
  1093
	$(PURIFY) $(CC) -o $^.pure $(CFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
hg@1
  1094
endif
hg@1
  1095
ifndef NO_DIST_INSTALL
hg@1
  1096
	$(INSTALL) $(IFLAGS2) $^.pure $(FINAL_TARGET)
hg@1
  1097
endif
hg@1
  1098
hg@1
  1099
quantify: $(PROGRAM)
hg@1
  1100
ifeq ($(CPP_PROG_LINK),1)
hg@1
  1101
	$(QUANTIFY) $(CCC) -o $^.quantify $(CXXFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
hg@1
  1102
else
hg@1
  1103
	$(QUANTIFY) $(CC) -o $^.quantify $(CFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
hg@1
  1104
endif
hg@1
  1105
ifndef NO_DIST_INSTALL
hg@1
  1106
	$(INSTALL) $(IFLAGS2) $^.quantify $(FINAL_TARGET)
hg@1
  1107
endif
hg@1
  1108
hg@1
  1109
#
hg@1
  1110
# This allows us to create static versions of the shared libraries
hg@1
  1111
# that are built using other static libraries.  Confused...?
hg@1
  1112
#
hg@1
  1113
ifdef SHARED_LIBRARY_LIBS
hg@1
  1114
ifeq (,$(GNU_LD)$(filter-out OS2 WINNT WINCE, $(OS_ARCH)))
hg@1
  1115
ifneq (,$(BUILD_STATIC_LIBS)$(FORCE_STATIC_LIB))
hg@1
  1116
LOBJS	+= $(SHARED_LIBRARY_LIBS)
hg@1
  1117
endif
hg@1
  1118
else
hg@1
  1119
ifneq (,$(filter OSF1 BSD_OS FreeBSD NetBSD OpenBSD SunOS Darwin,$(OS_ARCH)))
hg@1
  1120
CLEANUP1	:= | egrep -v '(________64ELEL_|__.SYMDEF)'
hg@1
  1121
CLEANUP2	:= rm -f ________64ELEL_ __.SYMDEF
hg@1
  1122
else
hg@1
  1123
CLEANUP2	:= true
hg@1
  1124
endif
hg@1
  1125
SUB_LOBJS	= $(shell for lib in $(SHARED_LIBRARY_LIBS); do $(AR_LIST) $${lib} $(CLEANUP1); done;)
hg@1
  1126
endif
hg@1
  1127
endif
jst@6804
  1128
ifdef MOZILLA_PROBE_LIBS
jst@6804
  1129
PROBE_LOBJS	= $(shell for lib in $(MOZILLA_PROBE_LIBS); do $(AR_LIST) $${lib} $(CLEANUP1); done;)
jst@6804
  1130
endif
jst@6804
  1131
ifdef DTRACE_PROBE_OBJ
jst@6804
  1132
EXTRA_DEPS += $(DTRACE_PROBE_OBJ)
jst@6804
  1133
endif
hg@1
  1134
Callek@22053
  1135
$(LIBRARY): $(OBJS) $(LOBJS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
hg@1
  1136
	rm -f $@
hg@1
  1137
ifneq (,$(GNU_LD)$(filter-out OS2 WINNT WINCE, $(OS_ARCH)))
hg@1
  1138
ifdef SHARED_LIBRARY_LIBS
hg@1
  1139
	@rm -f $(SUB_LOBJS)
hg@1
  1140
	@for lib in $(SHARED_LIBRARY_LIBS); do $(AR_EXTRACT) $${lib}; $(CLEANUP2); done
hg@1
  1141
endif
hg@1
  1142
endif
hg@1
  1143
	$(AR) $(AR_FLAGS) $(OBJS) $(LOBJS) $(SUB_LOBJS)
hg@1
  1144
	$(RANLIB) $@
hg@1
  1145
	@rm -f foodummyfilefoo $(SUB_LOBJS)
hg@1
  1146
hg@1
  1147
ifeq (,$(filter-out WINNT WINCE, $(OS_ARCH)))
hg@1
  1148
$(IMPORT_LIBRARY): $(SHARED_LIBRARY)
hg@1
  1149
endif
hg@1
  1150
hg@1
  1151
ifeq ($(OS_ARCH),OS2)
hg@1
  1152
$(DEF_FILE): $(OBJS) $(SHARED_LIBRARY_LIBS)
hg@1
  1153
	rm -f $@
ted@23647
  1154
	echo LIBRARY $(SHARED_LIBRARY_NAME) INITINSTANCE TERMINSTANCE > $@
hg@1
  1155
	echo PROTMODE >> $@
hg@1
  1156
	echo CODE    LOADONCALL MOVEABLE DISCARDABLE >> $@
hg@1
  1157
	echo DATA    PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@
hg@1
  1158
	echo EXPORTS >> $@
hg@1
  1159
ifeq ($(IS_COMPONENT),1)
hg@1
  1160
ifeq ($(HAS_EXTRAEXPORTS),1)
hg@1
  1161
ifndef MOZ_OS2_USE_DECLSPEC
hg@1
  1162
	$(FILTER) $(OBJS) $(SHARED_LIBRARY_LIBS) >> $@
hg@1
  1163
endif	
hg@1
  1164
else
hg@1
  1165
	echo    _NSGetModule >> $@
hg@1
  1166
endif
hg@1
  1167
else
hg@1
  1168
ifndef MOZ_OS2_USE_DECLSPEC
hg@1
  1169
	$(FILTER) $(OBJS) $(SHARED_LIBRARY_LIBS) >> $@
hg@1
  1170
endif	
hg@1
  1171
endif
hg@1
  1172
	$(ADD_TO_DEF_FILE)
hg@1
  1173
hg@1
  1174
ifdef MOZ_OS2_USE_DECLSPEC
hg@1
  1175
$(IMPORT_LIBRARY): $(SHARED_LIBRARY)
hg@1
  1176
else
hg@1
  1177
$(IMPORT_LIBRARY): $(DEF_FILE)
hg@1
  1178
endif
hg@1
  1179
	rm -f $@
hg@1
  1180
	$(IMPLIB) $@ $^
hg@1
  1181
	$(RANLIB) $@
hg@1
  1182
endif # OS/2
hg@1
  1183
hg@1
  1184
$(HOST_LIBRARY): $(HOST_OBJS) Makefile
hg@1
  1185
	rm -f $@
hg@1
  1186
	$(HOST_AR) $(HOST_AR_FLAGS) $(HOST_OBJS)
hg@1
  1187
	$(HOST_RANLIB) $@
hg@1
  1188
hg@1
  1189
ifdef NO_LD_ARCHIVE_FLAGS
hg@1
  1190
SUB_SHLOBJS = $(SUB_LOBJS)
hg@1
  1191
endif
hg@1
  1192
jst@7058
  1193
ifdef HAVE_DTRACE
reed@7297
  1194
ifndef XP_MACOSX
jst@7058
  1195
ifdef DTRACE_PROBE_OBJ
jst@7058
  1196
ifndef DTRACE_LIB_DEPENDENT
jst@7058
  1197
$(DTRACE_PROBE_OBJ): $(OBJS)
jst@7058
  1198
	dtrace -G -C -32 -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(OBJS)
jst@7058
  1199
endif
jst@7058
  1200
endif
jst@7058
  1201
endif
reed@7297
  1202
endif
jst@7058
  1203
joshmoz@2963
  1204
# On Darwin (Mac OS X), dwarf2 debugging uses debug info left in .o files,
joshmoz@2963
  1205
# so instead of deleting .o files after repacking them into a dylib, we make
joshmoz@2963
  1206
# symlinks back to the originals. The symlinks are a no-op for stabs debugging,
joshmoz@2963
  1207
# so no need to conditionalize on OS version or debugging format.
joshmoz@2963
  1208
Callek@22053
  1209
$(SHARED_LIBRARY): $(OBJS) $(LOBJS) $(DEF_FILE) $(RESFILE) $(SHARED_LIBRARY_LIBS) $(EXTRA_DEPS) $(DSO_LDOPTS_DEPS) $(GLOBAL_DEPS)
hg@1
  1210
ifndef INCREMENTAL_LINKER
hg@1
  1211
	rm -f $@
hg@1
  1212
endif
hg@1
  1213
ifeq ($(OS_ARCH),OpenVMS)
hg@1
  1214
	@if test ! -f $(VMS_SYMVEC_FILE); then \
hg@1
  1215
	  if test -f $(VMS_SYMVEC_FILE_MODULE); then \
hg@1
  1216
	    echo Creating specific component options file $(VMS_SYMVEC_FILE); \
hg@1
  1217
	    cp $(VMS_SYMVEC_FILE_MODULE) $(VMS_SYMVEC_FILE); \
hg@1
  1218
	  fi; \
hg@1
  1219
	fi
hg@1
  1220
ifdef IS_COMPONENT
hg@1
  1221
	@if test ! -f $(VMS_SYMVEC_FILE); then \
hg@1
  1222
	  echo Creating generic component options file $(VMS_SYMVEC_FILE); \
hg@1
  1223
	  cp $(VMS_SYMVEC_FILE_COMP) $(VMS_SYMVEC_FILE); \
hg@1
  1224
	fi
hg@1
  1225
endif
jimb@18463
  1226
endif # OpenVMS
hg@1
  1227
ifdef NO_LD_ARCHIVE_FLAGS
hg@1
  1228
ifdef SHARED_LIBRARY_LIBS
hg@1
  1229
	@rm -f $(SUB_SHLOBJS)
hg@1
  1230
	@for lib in $(SHARED_LIBRARY_LIBS); do $(AR_EXTRACT) $${lib}; $(CLEANUP2); done
joshmoz@9998
  1231
ifeq ($(OS_ARCH),Darwin)
joshmoz@9998
  1232
	@echo Making symlinks to the original object files in the archive libraries $(SHARED_LIBRARY_LIBS)
joshmoz@9998
  1233
	@for lib in $(SHARED_LIBRARY_LIBS); do \
joshmoz@9998
  1234
		libdir=`echo $$lib|sed -e 's,/[^/]*\.a,,'`; \
joshmoz@9998
  1235
		ofiles=`$(AR_LIST) $${lib}`; \
joshmoz@9998
  1236
		for ofile in $$ofiles; do \
joshmoz@9998
  1237
			if [ -f $$libdir/$$ofile ]; then \
joshmoz@9998
  1238
				rm -f $$ofile; \
joshmoz@9998
  1239
				ln -s $$libdir/$$ofile $$ofile; \
joshmoz@9998
  1240
			fi; \
joshmoz@9998
  1241
		done; \
joshmoz@9998
  1242
	done
joshmoz@9998
  1243
endif
hg@1
  1244
endif # SHARED_LIBRARY_LIBS
hg@1
  1245
endif # NO_LD_ARCHIVE_FLAGS
jst@7058
  1246
ifdef DTRACE_LIB_DEPENDENT
jst@6804
  1247
	@rm -f $(PROBE_LOBJS)
jst@6804
  1248
	@for lib in $(MOZILLA_PROBE_LIBS); do $(AR_EXTRACT) $${lib}; $(CLEANUP2); done
reed@7297
  1249
ifndef XP_MACOSX
jst@7058
  1250
	dtrace -G -C -32 -s $(MOZILLA_DTRACE_SRC) -o  $(DTRACE_PROBE_OBJ) $(PROBE_LOBJS)
reed@7297
  1251
endif
jst@6804
  1252
	@for lib in $(MOZILLA_PROBE_LIBS); do \
jst@6804
  1253
		ofiles=`$(AR_LIST) $${lib}`; \
jst@6804
  1254
		$(AR_DELETE) $${lib} $$ofiles; \
jst@6804
  1255
	done
jst@7058
  1256
	$(MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(LOBJS) $(SUB_SHLOBJS) $(DTRACE_PROBE_OBJ) $(PROBE_LOBJS) $(RESFILE) $(LDFLAGS) $(EXTRA_DSO_LDOPTS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE) $(SHLIB_LDENDFILE)
jst@6804
  1257
	@rm -f $(PROBE_LOBJS)
jst@7058
  1258
	@rm -f $(DTRACE_PROBE_OBJ)
jst@6804
  1259
	@for lib in $(MOZILLA_PROBE_LIBS); do \
jst@6804
  1260
		if [ -L $${lib} ]; then rm -f `readlink $${lib}`; fi; \
jst@6804
  1261
	done
jst@6804
  1262
	@rm -f $(MOZILLA_PROBE_LIBS)
jst@6804
  1263
jimb@18463
  1264
else # ! DTRACE_LIB_DEPENDENT
jst@6804
  1265
	$(MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(DTRACE_PROBE_OBJ) $(LOBJS) $(SUB_SHLOBJS) $(RESFILE) $(LDFLAGS) $(EXTRA_DSO_LDOPTS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE) $(SHLIB_LDENDFILE)
jst@7058
  1266
endif # DTRACE_LIB_DEPENDENT
jst@6804
  1267
hg@1
  1268
ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
hg@1
  1269
ifdef MSMANIFEST_TOOL
ted@6326
  1270
ifdef EMBED_MANIFEST_AT
hg@1
  1271
	@if test -f $@.manifest; then \
ted@6326
  1272
		mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
hg@1
  1273
		rm -f $@.manifest; \
hg@1
  1274
	fi
ted@6326
  1275
endif   # EMBED_MANIFEST_AT
hg@1
  1276
endif	# MSVC with manifest tool
hg@1
  1277
endif	# WINNT && !GCC
joshmoz@2963
  1278
ifeq ($(OS_ARCH),Darwin)
joshmoz@2963
  1279
else # non-Darwin
joshmoz@2963
  1280
	@rm -f $(SUB_SHLOBJS)
joshmoz@2963
  1281
endif # Darwin
joshmoz@2963
  1282
	@rm -f foodummyfilefoo $(DELETE_AFTER_LINK)
hg@1
  1283
	chmod +x $@
hg@1
  1284
ifdef ENABLE_STRIP
hg@1
  1285
	$(STRIP) $@
hg@1
  1286
endif
hg@1
  1287
ifdef MOZ_POST_DSO_LIB_COMMAND
hg@1
  1288
	$(MOZ_POST_DSO_LIB_COMMAND) $@
hg@1
  1289
endif
hg@1
  1290
hg@1
  1291
ifdef MOZ_AUTO_DEPS
jwalden@4766
  1292
ifdef COMPILER_DEPEND
ginn@24783
  1293
ifeq ($(SOLARIS_SUNPRO_CC),1)
jwalden@4766
  1294
_MDDEPFILE = $(MDDEPDIR)/$(@F).pp
jwalden@4766
  1295
jwalden@4766
  1296
define MAKE_DEPS_AUTO_CC
jwalden@4766
  1297
if test -d $(@D); then \
jwalden@4766
  1298
	echo "Building deps for $< using Sun Studio cc"; \
jwalden@4766
  1299
	$(CC) $(COMPILE_CFLAGS) -xM  $< >$(_MDDEPFILE) ; \
jwalden@4766
  1300
fi
jwalden@4766
  1301
endef
jwalden@4766
  1302
define MAKE_DEPS_AUTO_CXX
jwalden@4766
  1303
if test -d $(@D); then \
jwalden@4766
  1304
	echo "Building deps for $< using Sun Studio CC"; \
jwalden@4766
  1305
	$(CXX) $(COMPILE_CXXFLAGS) -xM $< >$(_MDDEPFILE) ; \
jwalden@4766
  1306
fi
jwalden@4766
  1307
endef
jwalden@4766
  1308
endif # Sun Studio on Solaris
jwalden@4766
  1309
else # COMPILER_DEPEND
hg@1
  1310
#
hg@1
  1311
# Generate dependencies on the fly
hg@1
  1312
#
hg@1
  1313
_MDDEPFILE = $(MDDEPDIR)/$(@F).pp
hg@1
  1314
hg@1
  1315
define MAKE_DEPS_AUTO
hg@1
  1316
if test -d $(@D); then \
hg@1
  1317
	echo "Building deps for $<"; \
neil@5484
  1318
	$(MKDEPEND) -o'.$(OBJ_SUFFIX)' -f- $(DEFINES) $(ACDEFINES) $(INCLUDES) $< 2>/dev/null | sed -e "s|^[^ ]*/||" > $(_MDDEPFILE) ; \
hg@1
  1319
fi
hg@1
  1320
endef
jwalden@4766
  1321
jwalden@4766
  1322
MAKE_DEPS_AUTO_CC = $(MAKE_DEPS_AUTO)
jwalden@4766
  1323
MAKE_DEPS_AUTO_CXX = $(MAKE_DEPS_AUTO)
jwalden@4766
  1324
jwalden@4766
  1325
endif # COMPILER_DEPEND
hg@1
  1326
hg@1
  1327
endif # MOZ_AUTO_DEPS
hg@1
  1328
gavin@15188
  1329
ifdef MOZ_MEMORY
gavin@15188
  1330
ifeq ($(OS_ARCH),SunOS)
gavin@15188
  1331
SOLARIS_JEMALLOC_LDFLAGS = $(call EXPAND_LIBNAME_PATH,jemalloc,$(DIST)/lib)
gavin@15188
  1332
endif
gavin@15188
  1333
endif
gavin@15188
  1334
hg@1
  1335
# Rules for building native targets must come first because of the host_ prefix
Callek@22053
  1336
host_%.$(OBJ_SUFFIX): %.c $(GLOBAL_DEPS)
hg@1
  1337
	$(REPORT_BUILD)
neil@112
  1338
	$(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
neil@112
  1339
Callek@22053
  1340
host_%.$(OBJ_SUFFIX): %.cpp $(GLOBAL_DEPS)
neil@112
  1341
	$(REPORT_BUILD)
neil@112
  1342
	$(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
hg@1
  1343
Callek@22053
  1344
host_%.$(OBJ_SUFFIX): %.cc $(GLOBAL_DEPS)
ted@868
  1345
	$(REPORT_BUILD)
ted@868
  1346
	$(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
ted@868
  1347
Callek@22053
  1348
host_%.$(OBJ_SUFFIX): %.m $(GLOBAL_DEPS)
ted@868
  1349
	$(REPORT_BUILD)
joshmoz@12117
  1350
	$(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(HOST_CMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
ted@868
  1351
Callek@22053
  1352
host_%.$(OBJ_SUFFIX): %.mm $(GLOBAL_DEPS)
ted@868
  1353
	$(REPORT_BUILD)
joshmoz@12117
  1354
	$(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(HOST_CMMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
ted@868
  1355
benjamin@25610
  1356
%:: %.c $(GLOBAL_DEPS)
hg@1
  1357
	$(REPORT_BUILD)
jwalden@4766
  1358
	@$(MAKE_DEPS_AUTO_CC)
hg@1
  1359
	$(ELOG) $(CC) $(CFLAGS) $(LDFLAGS) $(OUTOPTION)$@ $(_VPATH_SRCS)
hg@1
  1360
Callek@22053
  1361
%.$(OBJ_SUFFIX): %.c $(GLOBAL_DEPS)
hg@1
  1362
	$(REPORT_BUILD)
jwalden@4766
  1363
	@$(MAKE_DEPS_AUTO_CC)
hg@1
  1364
	$(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $(_VPATH_SRCS)
hg@1
  1365
Callek@22053
  1366
moc_%.cpp: %.h $(GLOBAL_DEPS)
hg@1
  1367
	$(MOC) $< $(OUTOPTION)$@ 
hg@1
  1368
benjamin@6924
  1369
ifdef ASFILES
hg@1
  1370
# The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept
hg@1
  1371
# a '-c' flag.
Callek@22053
  1372
%.$(OBJ_SUFFIX): %.$(ASM_SUFFIX) $(GLOBAL_DEPS)
hg@1
  1373
	$(AS) -o $@ $(ASFLAGS) $(AS_DASH_C_FLAG) $(_VPATH_SRCS)
hg@1
  1374
endif
hg@1
  1375
Callek@22053
  1376
%.$(OBJ_SUFFIX): %.S $(GLOBAL_DEPS)
hg@1
  1377
	$(AS) -o $@ $(ASFLAGS) -c $<
hg@1
  1378
benjamin@25610
  1379
%:: %.cpp $(GLOBAL_DEPS)
jwalden@4766
  1380
	@$(MAKE_DEPS_AUTO_CXX)
hg@1
  1381
	$(CCC) $(OUTOPTION)$@ $(CXXFLAGS) $(_VPATH_SRCS) $(LDFLAGS)
hg@1
  1382
hg@1
  1383
#
hg@1
  1384
# Please keep the next two rules in sync.
hg@1
  1385
#
Callek@22053
  1386
%.$(OBJ_SUFFIX): %.cc $(GLOBAL_DEPS)
hg@1
  1387
	$(REPORT_BUILD)
jwalden@4766
  1388
	@$(MAKE_DEPS_AUTO_CXX)
hg@1
  1389
	$(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
hg@1
  1390
Callek@22053
  1391
%.$(OBJ_SUFFIX): %.cpp $(GLOBAL_DEPS)
hg@1
  1392
	$(REPORT_BUILD)
jwalden@4766
  1393
	@$(MAKE_DEPS_AUTO_CXX)
hg@1
  1394
ifdef STRICT_CPLUSPLUS_SUFFIX
hg@1
  1395
	echo "#line 1 \"$*.cpp\"" | cat - $*.cpp > t_$*.cc
hg@1
  1396
	$(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) t_$*.cc
hg@1
  1397
	rm -f t_$*.cc
hg@1
  1398
else
hg@1
  1399
	$(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
hg@1
  1400
endif #STRICT_CPLUSPLUS_SUFFIX
hg@1
  1401
Callek@22053
  1402
$(OBJ_PREFIX)%.$(OBJ_SUFFIX): %.mm $(GLOBAL_DEPS)
hg@1
  1403
	$(REPORT_BUILD)
jwalden@4766
  1404
	@$(MAKE_DEPS_AUTO_CXX)
joshmoz@12117
  1405
	$(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(_VPATH_SRCS)
hg@1
  1406
Callek@22053
  1407
$(OBJ_PREFIX)%.$(OBJ_SUFFIX): %.m $(GLOBAL_DEPS)
hg@1
  1408
	$(REPORT_BUILD)
jwalden@4766
  1409
	@$(MAKE_DEPS_AUTO_CC)
joshmoz@12117
  1410
	$(ELOG) $(CC) -o $@ -c $(COMPILE_CFLAGS) $(COMPILE_CMFLAGS) $(_VPATH_SRCS)
hg@1
  1411
hg@1
  1412
%.s: %.cpp
hg@1
  1413
	$(CCC) -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
hg@1
  1414
benjamin@3341
  1415
%.s: %.cc
benjamin@3341
  1416
	$(CCC) -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
benjamin@3341
  1417
hg@1
  1418
%.s: %.c
hg@1
  1419
	$(CC) -S $(COMPILE_CFLAGS) $(_VPATH_SRCS)
hg@1
  1420
hg@1
  1421
%.i: %.cpp
hg@1
  1422
	$(CCC) -C -E $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) > $*.i
hg@1
  1423
benjamin@3341
  1424
%.i: %.cc
benjamin@3341
  1425
	$(CCC) -C -E $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) > $*.i
benjamin@3341
  1426
hg@1
  1427
%.i: %.c
hg@1
  1428
	$(CC) -C -E $(COMPILE_CFLAGS) $(_VPATH_SRCS) > $*.i
hg@1
  1429
jag@13004
  1430
%.i: %.mm
jag@13004
  1431
	$(CCC) -C -E $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(_VPATH_SRCS) > $*.i
jag@13004
  1432
hg@1
  1433
%.res: %.rc
hg@1
  1434
	@echo Creating Resource file: $@
hg@1
  1435
ifeq ($(OS_ARCH),OS2)
hg@1
  1436
	$(RC) $(RCFLAGS:-D%=-d %) -i $(subst /,\,$(srcdir)) -r $< $@
hg@1
  1437
else
hg@1
  1438
ifdef GNU_CC
hg@1
  1439
	$(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) $(OUTOPTION)$@ $(_VPATH_SRCS)
hg@1
  1440
else
hg@1
  1441
	$(RC) $(RCFLAGS) -r $(DEFINES) $(INCLUDES) $(OUTOPTION)$@ $(_VPATH_SRCS)
hg@1
  1442
endif
hg@1
  1443
endif
hg@1
  1444
hg@1
  1445
# need 3 separate lines for OS/2
benjamin@25610
  1446
%:: %.pl
hg@1
  1447
	rm -f $@
hg@1
  1448
	cp $< $@
hg@1
  1449
	chmod +x $@
hg@1
  1450
benjamin@25610
  1451
%:: %.sh
hg@1
  1452
	rm -f $@; cp $< $@; chmod +x $@
hg@1
  1453
hg@1
  1454
# Cancel these implicit rules
hg@1
  1455
#
hg@1
  1456
%: %,v
hg@1
  1457
hg@1
  1458
%: RCS/%,v
hg@1
  1459
hg@1
  1460
%: s.%
hg@1
  1461
hg@1
  1462
%: SCCS/s.%
hg@1
  1463
hg@1
  1464
###############################################################################
hg@1
  1465
# Java rules
hg@1
  1466
###############################################################################
hg@1
  1467
ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
hg@1
  1468
SEP := ;
hg@1
  1469
else
hg@1
  1470
SEP := :
hg@1
  1471
endif
hg@1
  1472
hg@1
  1473
EMPTY :=
hg@1
  1474
SPACE := $(EMPTY) $(EMPTY)
hg@1
  1475
hg@1
  1476
# Cygwin and MSYS have their own special path form, but javac expects the source
hg@1
  1477
# and class paths to be in the DOS form (i.e. e:/builds/...).  This function
hg@1
  1478
# does the appropriate conversion on Windows, but is a noop on other systems.
hg@1
  1479
ifeq (,$(filter-out WINNT WINCE, $(HOST_OS_ARCH)))
hg@1
  1480
ifdef CYGWIN_WRAPPER
hg@1
  1481
normalizepath = $(foreach p,$(1),$(shell cygpath -m $(p)))
hg@1
  1482
else
hg@1
  1483
# assume MSYS
pedemont@1006
  1484
#  We use 'pwd -W' to get DOS form of the path.  However, since the given path
pedemont@1006
  1485
#  could be a file or a non-existent path, we cannot call 'pwd -W' directly
pedemont@1006
  1486
#  on the path.  Instead, we extract the root path (i.e. "c:/"), call 'pwd -W'
pedemont@1006
  1487
#  on it, then merge with the rest of the path.
pedemont@1006
  1488
root-path = $(shell echo $(1) | sed -e "s|\(/[^/]*\)/\?\(.*\)|\1|")
pedemont@1006
  1489
non-root-path = $(shell echo $(1) | sed -e "s|\(/[^/]*\)/\?\(.*\)|\2|")
pedemont@1006
  1490
normalizepath = $(foreach p,$(1),$(if $(filter /%,$(1)),$(shell cd $(call root-path,$(1)) && pwd -W)$(call non-root-path,$(1)),$(1)))
hg@1
  1491
endif
hg@1
  1492
else
hg@1
  1493
normalizepath = $(1)
hg@1
  1494
endif
hg@1
  1495
hg@1
  1496
_srcdir = $(call normalizepath,$(srcdir))
hg@1
  1497
ifdef JAVA_SOURCEPATH
hg@1
  1498
SP = $(subst $(SPACE),$(SEP),$(call normalizepath,$(strip $(JAVA_SOURCEPATH))))
hg@1
  1499
_JAVA_SOURCEPATH = ".$(SEP)$(_srcdir)$(SEP)$(SP)"
hg@1
  1500
else
hg@1
  1501
_JAVA_SOURCEPATH = ".$(SEP)$(_srcdir)"
hg@1
  1502
endif
hg@1
  1503
hg@1
  1504
ifdef JAVA_CLASSPATH
pedemont@1006
  1505
CP = $(subst $(SPACE),$(SEP),$(call normalizepath,$(strip $(JAVA_CLASSPATH))))
hg@1
  1506
_JAVA_CLASSPATH = ".$(SEP)$(CP)"
hg@1
  1507
else
hg@1
  1508
_JAVA_CLASSPATH = .
hg@1
  1509
endif
hg@1
  1510
hg@1
  1511
_JAVA_DIR = _java
hg@1
  1512
$(_JAVA_DIR)::
hg@1
  1513
	$(NSINSTALL) -D $@
hg@1
  1514
Callek@22053
  1515
$(_JAVA_DIR)/%.class: %.java $(GLOBAL_DEPS) $(_JAVA_DIR)
hg@1
  1516
	$(CYGWIN_WRAPPER) $(JAVAC) $(JAVAC_FLAGS) -classpath $(_JAVA_CLASSPATH) \
hg@1
  1517
			-sourcepath $(_JAVA_SOURCEPATH) -d $(_JAVA_DIR) $(_VPATH_SRCS)
hg@1
  1518
Callek@22053
  1519
$(JAVA_LIBRARY): $(addprefix $(_JAVA_DIR)/,$(JAVA_SRCS:.java=.class)) $(GLOBAL_DEPS)
hg@1
  1520
	$(JAR) cf $@ -C $(_JAVA_DIR) .
hg@1
  1521
hg@1
  1522
GARBAGE_DIRS += $(_JAVA_DIR)
hg@1
  1523
hg@1
  1524
###############################################################################
hg@1
  1525
# Update Makefiles
hg@1
  1526
###############################################################################
hg@1
  1527
hg@1
  1528
# In GNU make 3.80, makefiles must use the /cygdrive syntax, even if we're
hg@1
  1529
# processing them with AS perl. See bug 232003
hg@1
  1530
ifdef AS_PERL
hg@1
  1531
CYGWIN_TOPSRCDIR = -nowrap -p $(topsrcdir) -wrap
hg@1
  1532
endif
hg@1
  1533
hg@1
  1534
# Note: Passing depth to make-makefile is optional.
hg@1
  1535
#       It saves the script some work, though.
hg@1
  1536
Makefile: Makefile.in
hg@1
  1537
	@$(PERL) $(AUTOCONF_TOOLS)/make-makefile -t $(topsrcdir) -d $(DEPTH) $(CYGWIN_TOPSRCDIR)
hg@1
  1538
hg@1
  1539
ifdef SUBMAKEFILES
hg@1
  1540
# VPATH does not work on some machines in this case, so add $(srcdir)
hg@1
  1541
$(SUBMAKEFILES): % : $(srcdir)/%.in
hg@1
  1542
	$(PERL) $(AUTOCONF_TOOLS)/make-makefile -t $(topsrcdir) -d $(DEPTH) $(CYGWIN_TOPSRCDIR) $@
hg@1
  1543
endif
hg@1
  1544
hg@1
  1545
ifdef AUTOUPDATE_CONFIGURE
hg@1
  1546
$(topsrcdir)/configure: $(topsrcdir)/configure.in
hg@1
  1547
	(cd $(topsrcdir) && $(AUTOCONF)) && (cd $(DEPTH) && ./config.status --recheck)
hg@1
  1548
endif
hg@1
  1549
hg@1
  1550
###############################################################################
hg@1
  1551
# Bunch of things that extend the 'export' rule (in order):
hg@1
  1552
###############################################################################
hg@1
  1553
hg@1
  1554
################################################################################
benjamin@28510
  1555
# Copy each element of EXPORTS to $(DIST)/include
hg@1
  1556
hg@1
  1557
ifdef MOZ_JAVAXPCOM
benjamin@28510
  1558
ifneq ($(XPIDLSRCS),)
hg@1
  1559
$(JAVA_DIST_DIR)::
hg@1
  1560
	$(NSINSTALL) -D $@
hg@1
  1561
endif
hg@1
  1562
endif
hg@1
  1563
hg@1
  1564
ifneq ($(XPI_NAME),)
benjamin@21130
  1565
$(FINAL_TARGET):
benjamin@21130
  1566
	$(NSINSTALL) -D $@
benjamin@21130
  1567
benjamin@21130
  1568
export:: $(FINAL_TARGET)
hg@1
  1569
endif
hg@1
  1570
hg@1
  1571
ifndef NO_DIST_INSTALL
benjamin@28510
  1572
ifneq (,$(EXPORTS))
benjamin@28510
  1573
export:: $(EXPORTS)
benjamin@28510
  1574
	$(INSTALL) $(IFLAGS1) $^ $(DIST)/include
benjamin@28510
  1575
endif
neil@28585
  1576
endif # NO_DIST_INSTALL
hg@1
  1577
benjamin@28510
  1578
define EXPORT_NAMESPACE_RULE
neil@28585
  1579
ifndef NO_DIST_INSTALL
benjamin@28510
  1580
export:: $(EXPORTS_$(namespace))
benjamin@28510
  1581
	$(INSTALL) $(IFLAGS1) $$^ $(DIST)/include/$(namespace)
neil@28585
  1582
endif # NO_DIST_INSTALL
benjamin@28510
  1583
endef
benjamin@28510
  1584
benjamin@28510
  1585
$(foreach namespace,$(EXPORTS_NAMESPACES),$(eval $(EXPORT_NAMESPACE_RULE)))
hg@1
  1586
hg@1
  1587
################################################################################
hg@1
  1588
# Copy each element of PREF_JS_EXPORTS
hg@1
  1589
hg@1
  1590
ifdef GRE_MODULE
hg@1
  1591
PREF_DIR = greprefs
hg@1
  1592
else
hg@1
  1593
ifneq (,$(XPI_NAME)$(LIBXUL_SDK))
hg@1
  1594
PREF_DIR = defaults/preferences
hg@1
  1595
else
hg@1
  1596
PREF_DIR = defaults/pref
hg@1
  1597
endif
hg@1
  1598
endif
hg@1
  1599
benjamin@4238
  1600
ifneq ($(PREF_JS_EXPORTS),)
hg@1
  1601
# on win32, pref files need CRLF line endings... see bug 206029
hg@1
  1602
ifeq (WINNT,$(OS_ARCH))
hg@1
  1603
PREF_PPFLAGS = --line-endings=crlf
hg@1
  1604
endif
hg@1
  1605
hg@1
  1606
ifndef NO_DIST_INSTALL
benjamin@21130
  1607
$(FINAL_TARGET)/$(PREF_DIR):
benjamin@21130
  1608
	$(NSINSTALL) -D $@
benjamin@21130
  1609
benjamin@21130
  1610
libs:: $(FINAL_TARGET)/$(PREF_DIR) $(PREF_JS_EXPORTS)
hg@1
  1611
	$(EXIT_ON_ERROR)  \
hg@1
  1612
	for i in $(PREF_JS_EXPORTS); do \
hg@1
  1613
	  dest=$(FINAL_TARGET)/$(PREF_DIR)/`basename $$i`; \
hg@1
  1614
	  $(RM) -f $$dest; \
axel@469
  1615
	  $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
hg@1
  1616
	done
hg@1
  1617
endif
hg@1
  1618
endif
hg@1
  1619
hg@1
  1620
################################################################################
hg@1
  1621
# Copy each element of AUTOCFG_JS_EXPORTS to $(FINAL_TARGET)/defaults/autoconfig
hg@1
  1622
hg@1
  1623
ifneq ($(AUTOCFG_JS_EXPORTS),)
hg@1
  1624
$(FINAL_TARGET)/defaults/autoconfig::
benjamin@21130
  1625
	$(NSINSTALL) -D $@
hg@1
  1626
hg@1
  1627
ifndef NO_DIST_INSTALL
hg@1
  1628
export:: $(AUTOCFG_JS_EXPORTS) $(FINAL_TARGET)/defaults/autoconfig
hg@1
  1629
	$(INSTALL) $(IFLAGS1) $^
hg@1
  1630
endif
hg@1
  1631
hg@1
  1632
endif 
hg@1
  1633
################################################################################
benjamin@28510
  1634
# Export the elements of $(XPIDLSRCS)
hg@1
  1635
# generating .h and .xpt files and moving them to the appropriate places.
hg@1
  1636
benjamin@28510
  1637
ifneq ($(XPIDLSRCS),)
hg@1
  1638
hg@1
  1639
export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS))
hg@1
  1640
hg@1
  1641
ifndef XPIDL_MODULE
hg@1
  1642
XPIDL_MODULE		= $(MODULE)
hg@1
  1643
endif
hg@1
  1644
hg@1
  1645
ifeq ($(XPIDL_MODULE),) # we need $(XPIDL_MODULE) to make $(XPIDL_MODULE).xpt
hg@1
  1646
export:: FORCE
hg@1
  1647
	@echo
hg@1
  1648
	@echo "*** Error processing XPIDLSRCS:"
hg@1
  1649
	@echo "Please define MODULE or XPIDL_MODULE when defining XPIDLSRCS,"
hg@1
  1650
	@echo "so we have a module name to use when creating MODULE.xpt."
hg@1
  1651
	@echo; sleep 2; false
hg@1
  1652
endif
hg@1
  1653
benjamin@28510
  1654
$(IDL_DIR)::
benjamin@21130
  1655
	$(NSINSTALL) -D $@
hg@1
  1656
benjamin@28510
  1657
# generate .h files from into $(XPIDL_GEN_DIR), then export to $(DIST)/include;
hg@1
  1658
# warn against overriding existing .h file. 
hg@1
  1659
$(XPIDL_GEN_DIR)/.done:
hg@1
  1660
	@if test ! -d $(XPIDL_GEN_DIR); then echo Creating $(XPIDL_GEN_DIR)/.done; rm -rf $(XPIDL_GEN_DIR); mkdir $(XPIDL_GEN_DIR); fi
hg@1
  1661
	@touch $@
hg@1
  1662
hg@1
  1663
# don't depend on $(XPIDL_GEN_DIR), because the modification date changes
hg@1
  1664
# with any addition to the directory, regenerating all .h files -> everything.
hg@1
  1665
hg@1
  1666
$(XPIDL_GEN_DIR)/%.h: %.idl $(XPIDL_COMPILE) $(XPIDL_GEN_DIR)/.done
hg@1
  1667
	$(REPORT_BUILD)
hg@1
  1668
	$(ELOG) $(XPIDL_COMPILE) -m header -w $(XPIDL_FLAGS) -o $(XPIDL_GEN_DIR)/$* $(_VPATH_SRCS)
benjamin@28510
  1669
	@if test -n "$(findstring $*.h, $(EXPORTS))"; \
hg@1
  1670
	  then echo "*** WARNING: file $*.h generated from $*.idl overrides $(srcdir)/$*.h"; else true; fi
hg@1
  1671
hg@1
  1672
ifndef NO_GEN_XPT
hg@1
  1673
# generate intermediate .xpt files into $(XPIDL_GEN_DIR), then link
hg@1
  1674
# into $(XPIDL_MODULE).xpt and export it to $(FINAL_TARGET)/components.
hg@1
  1675
$(XPIDL_GEN_DIR)/%.xpt: %.idl $(XPIDL_COMPILE) $(XPIDL_GEN_DIR)/.done
hg@1
  1676
	$(REPORT_BUILD)
hg@1
  1677
	$(ELOG) $(XPIDL_COMPILE) -m typelib -w $(XPIDL_FLAGS) -e $@ -d $(MDDEPDIR)/$*.pp $(_VPATH_SRCS)
hg@1
  1678
hg@1
  1679
# no need to link together if XPIDLSRCS contains only XPIDL_MODULE
hg@1
  1680
ifneq ($(XPIDL_MODULE).idl,$(strip $(XPIDLSRCS)))
benjamin@28510
  1681
$(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS)) $(GLOBAL_DEPS) $(XPIDL_LINK)
benjamin@28510
  1682
	$(XPIDL_LINK) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS))
hg@1
  1683
endif # XPIDL_MODULE.xpt != XPIDLSRCS
hg@1
  1684
hg@1
  1685
libs:: $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt
hg@1
  1686
ifndef NO_DIST_INSTALL
hg@1
  1687
	$(INSTALL) $(IFLAGS1) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(FINAL_TARGET)/components
hg@1
  1688
endif
hg@1
  1689
hg@1
  1690
endif # NO_GEN_XPT
hg@1
  1691
hg@1
  1692
GARBAGE_DIRS		+= $(XPIDL_GEN_DIR)
hg@1
  1693
benjamin@28510
  1694
endif # XPIDLSRCS
hg@1
  1695
hg@1
  1696
ifneq ($(XPIDLSRCS),)
hg@1
  1697
# export .idl files to $(IDL_DIR)
hg@1
  1698
ifndef NO_DIST_INSTALL
hg@1
  1699
export:: $(XPIDLSRCS) $(IDL_DIR)
hg@1
  1700
	$(INSTALL) $(IFLAGS1) $^
hg@1
  1701
benjamin@28510
  1702
export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS)) $(DIST)/include
hg@1
  1703
	$(INSTALL) $(IFLAGS1) $^ 
hg@1
  1704
endif # NO_DIST_INSTALL
hg@1
  1705
hg@1
  1706
endif # XPIDLSRCS
hg@1
  1707
hg@1
  1708
hg@1
  1709
hg@1
  1710
#
hg@1
  1711
# General rules for exporting idl files.
hg@1
  1712
#
hg@1
  1713
# WORK-AROUND ONLY, for mozilla/tools/module-deps/bootstrap.pl build.
hg@1
  1714
# Bug to fix idl dependency problems w/o this extra build pass is
hg@1
  1715
#   http://bugzilla.mozilla.org/show_bug.cgi?id=145777
hg@1
  1716
#
hg@1
  1717
$(IDL_DIR)::
benjamin@21130
  1718
	$(NSINSTALL) -D $@
hg@1
  1719
hg@1
  1720
export-idl:: $(SUBMAKEFILES) $(MAKE_DIRS)
hg@1
  1721
benjamin@28510
  1722
ifneq ($(XPIDLSRCS),)
hg@1
  1723
ifndef NO_DIST_INSTALL
benjamin@28510
  1724
export-idl:: $(XPIDLSRCS) $(IDL_DIR)
hg@1
  1725
	$(INSTALL) $(IFLAGS1) $^
hg@1
  1726
endif
hg@1
  1727
endif
benjamin@25610
  1728
	$(LOOP_OVER_PARALLEL_DIRS)
benjamin@25610
  1729
	$(LOOP_OVER_DIRS)
benjamin@25610
  1730
	$(LOOP_OVER_TOOL_DIRS)
hg@1
  1731
benjamin@28510
  1732
ifdef MOZ_JAVAXPCOM
benjamin@28510
  1733
ifneq ($(XPIDLSRCS),)
hg@1
  1734
benjamin@28510
  1735
JAVA_XPIDLSRCS = $(XPIDLSRCS)
hg@1
  1736
hg@1
  1737
# A single IDL file can contain multiple interfaces, which result in multiple
hg@1
  1738
# Java interface files.  So use hidden dependency files.
hg@1
  1739
JAVADEPFILES = $(addprefix $(JAVA_GEN_DIR)/.,$(JAVA_XPIDLSRCS:.idl=.java.pp))
hg@1
  1740
hg@1
  1741
$(JAVA_GEN_DIR):
hg@1
  1742
	$(NSINSTALL) -D $@
hg@1
  1743
GARBAGE_DIRS += $(JAVA_GEN_DIR)
hg@1
  1744
hg@1
  1745
# generate .java files into _javagen/[package name dirs]
hg@1
  1746
_JAVA_GEN_DIR = $(JAVA_GEN_DIR)/$(JAVA_IFACES_PKG_NAME)
hg@1
  1747
$(_JAVA_GEN_DIR):
hg@1
  1748
	$(NSINSTALL) -D $@
hg@1
  1749
hg@1
  1750
$(JAVA_GEN_DIR)/.%.java.pp: %.idl $(XPIDL_COMPILE) $(_JAVA_GEN_DIR)
hg@1
  1751
	$(REPORT_BUILD)
hg@1
  1752
	$(ELOG) $(XPIDL_COMPILE) -m java -w -I$(srcdir) -I$(IDL_DIR) -o $(_JAVA_GEN_DIR)/$* $(_VPATH_SRCS)
hg@1
  1753
	@touch $@
hg@1
  1754
hg@1
  1755
# "Install" generated Java interfaces.  We segregate them based on the XPI_NAME.
hg@1
  1756
# If XPI_NAME is not set, install into the "default" directory.
hg@1
  1757
ifneq ($(XPI_NAME),)
hg@1
  1758
JAVA_INSTALL_DIR = $(JAVA_DIST_DIR)/$(XPI_NAME)
hg@1
  1759
else
hg@1
  1760
JAVA_INSTALL_DIR = $(JAVA_DIST_DIR)/default
hg@1
  1761
endif
hg@1
  1762
hg@1
  1763
$(JAVA_INSTALL_DIR):
hg@1
  1764
	$(NSINSTALL) -D $@
hg@1
  1765
hg@1
  1766
export:: $(JAVA_DIST_DIR) $(JAVADEPFILES) $(JAVA_INSTALL_DIR)
benjamin@4238
  1767
	(cd $(JAVA_GEN_DIR) && tar $(TAR_CREATE_FLAGS) - .) | (cd $(JAVA_INSTALL_DIR) && tar -xf -)
hg@1
  1768
benjamin@28510
  1769
endif # XPIDLSRCS
hg@1
  1770
endif # MOZ_JAVAXPCOM
hg@1
  1771
hg@1
  1772
################################################################################
hg@1
  1773
# Copy each element of EXTRA_COMPONENTS to $(FINAL_TARGET)/components
hg@1
  1774
ifdef EXTRA_COMPONENTS
hg@1
  1775
libs:: $(EXTRA_COMPONENTS)
hg@1
  1776
ifndef NO_DIST_INSTALL
hg@1
  1777
	$(INSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/components
hg@1
  1778
endif
hg@1
  1779
hg@1
  1780
endif
hg@1
  1781
hg@1
  1782
ifdef EXTRA_PP_COMPONENTS
hg@1
  1783
libs:: $(EXTRA_PP_COMPONENTS)
hg@1
  1784
ifndef NO_DIST_INSTALL
hg@1
  1785
	$(EXIT_ON_ERROR) \
dtownsend@9805
  1786
	$(NSINSTALL) -D $(FINAL_TARGET)/components; \
hg@1
  1787
	for i in $^; do \
hg@1
  1788
	  dest=$(FINAL_TARGET)/components/`basename $$i`; \
hg@1
  1789
	  $(RM) -f $$dest; \
axel@469
  1790
	  $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
hg@1
  1791
	done
hg@1
  1792
endif
hg@1
  1793
hg@1
  1794
endif
hg@1
  1795
hg@1
  1796
################################################################################
bzbarsky@2230
  1797
# Copy each element of EXTRA_JS_MODULES to $(FINAL_TARGET)/modules
bzbarsky@2230
  1798
ifdef EXTRA_JS_MODULES
bzbarsky@2230
  1799
libs:: $(EXTRA_JS_MODULES)
bzbarsky@2230
  1800
ifndef NO_DIST_INSTALL
bzbarsky@2230
  1801
	$(INSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/modules
bzbarsky@2230
  1802
endif
bzbarsky@2230
  1803
bzbarsky@2230
  1804
endif
bzbarsky@2230
  1805
bzbarsky@2230
  1806
ifdef EXTRA_PP_JS_MODULES
bzbarsky@2230
  1807
libs:: $(EXTRA_PP_JS_MODULES)
bzbarsky@2230
  1808
ifndef NO_DIST_INSTALL
bzbarsky@2230
  1809
	$(EXIT_ON_ERROR) \
dtownsend@9805
  1810
	$(NSINSTALL) -D $(FINAL_TARGET)/modules; \
bzbarsky@2230
  1811
	for i in $^; do \
bzbarsky@2230
  1812
	  dest=$(FINAL_TARGET)/modules/`basename $$i`; \
bzbarsky@2230
  1813
	  $(RM) -f $$dest; \
bzbarsky@2230
  1814
	  $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
bzbarsky@2230
  1815
	done
bzbarsky@2230
  1816
endif
bzbarsky@2230
  1817
bzbarsky@2230
  1818
endif
bzbarsky@2230
  1819
bzbarsky@2230
  1820
################################################################################
benjamin@28709
  1821
# SDK
benjamin@28709
  1822
benjamin@28709
  1823
ifneq (,$(SDK_LIBRARY))
benjamin@28709
  1824
$(SDK_LIB_DIR)::
benjamin@28709
  1825
	$(NSINSTALL) -D $@
benjamin@28709
  1826
benjamin@28709
  1827
ifndef NO_DIST_INSTALL
benjamin@28709
  1828
libs:: $(SDK_LIBRARY) $(SDK_LIB_DIR)
benjamin@28709
  1829
	$(INSTALL) $(IFLAGS2) $^
benjamin@28709
  1830
endif
benjamin@28709
  1831
benjamin@28709
  1832
endif # SDK_LIBRARY
benjamin@28709
  1833
benjamin@28709
  1834
ifneq (,$(SDK_BINARY))
benjamin@28709
  1835
$(SDK_BIN_DIR)::
benjamin@28709
  1836
	$(NSINSTALL) -D $@
benjamin@28709
  1837
benjamin@28709
  1838
ifndef NO_DIST_INSTALL
benjamin@28709
  1839
libs:: $(SDK_BINARY) $(SDK_BIN_DIR)
benjamin@28709
  1840
	$(INSTALL) $(IFLAGS2) $^
benjamin@28709
  1841
endif
benjamin@28709
  1842
benjamin@28709
  1843
endif # SDK_BINARY
benjamin@28709
  1844
benjamin@28709
  1845
################################################################################
hg@1
  1846
# CHROME PACKAGING
hg@1
  1847
hg@1
  1848
JAR_MANIFEST := $(srcdir)/jar.mn
hg@1
  1849
hg@1
  1850
chrome::
hg@1
  1851
	$(MAKE) realchrome
benjamin@25610
  1852
	$(LOOP_OVER_PARALLEL_DIRS)
benjamin@25610
  1853
	$(LOOP_OVER_DIRS)
benjamin@25610
  1854
	$(LOOP_OVER_TOOL_DIRS)
hg@1
  1855
benjamin@21130
  1856
$(FINAL_TARGET)/chrome:
benjamin@21130
  1857
	$(NSINSTALL) -D $@
benjamin@21130
  1858
benjamin@22164
  1859
ifneq (,$(wildcard $(JAR_MANIFEST)))
benjamin@22164
  1860
ifndef NO_DIST_INSTALL
benjamin@21130
  1861
libs realchrome:: $(CHROME_DEPS) $(FINAL_TARGET)/chrome
benjamin@22164
  1862
	$(PYTHON) $(MOZILLA_DIR)/config/JarMaker.py \
benjamin@22164
  1863
	  $(QUIET) -j $(FINAL_TARGET)/chrome \
benjamin@22164
  1864
	  $(MAKE_JARS_FLAGS) $(XULPPFLAGS) $(DEFINES) $(ACDEFINES) \
benjamin@22164
  1865
	  $(JAR_MANIFEST)
benjamin@22164
  1866
endif
hg@1
  1867
endif
hg@1
  1868
hg@1
  1869
ifneq ($(DIST_FILES),)
blassey@24428
  1870
$(DIST)/bin:
blassey@24428
  1871
	$(NSINSTALL) -D $@
blassey@24428
  1872
blassey@24428
  1873
libs:: $(DIST_FILES) $(DIST)/bin
hg@1
  1874
	@$(EXIT_ON_ERROR) \
hg@1
  1875
	for f in $(DIST_FILES); do \
hg@1
  1876
	  dest=$(FINAL_TARGET)/`basename $$f`; \
hg@1
  1877
	  $(RM) -f $$dest; \
axel@469
  1878
	  $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py \
hg@1
  1879
	    $(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
hg@1
  1880
	    $(srcdir)/$$f > $$dest; \
hg@1
  1881
	done
hg@1
  1882
endif
hg@1
  1883
hg@1
  1884
ifneq ($(DIST_CHROME_FILES),)
hg@1
  1885
libs:: $(DIST_CHROME_FILES)
hg@1
  1886
	@$(EXIT_ON_ERROR) \
hg@1
  1887
	for f in $(DIST_CHROME_FILES); do \
hg@1
  1888
	  dest=$(FINAL_TARGET)/chrome/`basename $$f`; \
hg@1
  1889
	  $(RM) -f $$dest; \
axel@469
  1890
	  $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py \
hg@1
  1891
	    $(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
hg@1
  1892
	    $(srcdir)/$$f > $$dest; \
hg@1
  1893
	done
hg@1
  1894
endif
hg@1
  1895
hg@1
  1896
ifneq ($(XPI_PKGNAME),)
hg@1
  1897
libs realchrome::
hg@1
  1898
ifdef STRIP_XPI
hg@1
  1899
ifndef MOZ_DEBUG
hg@1
  1900
	@echo "Stripping $(XPI_PKGNAME) package directory..."
hg@1
  1901
	@echo $(FINAL_TARGET)
hg@1
  1902
	@cd $(FINAL_TARGET) && find . ! -type d \
hg@1
  1903
			! -name "*.js" \
hg@1
  1904
			! -name "*.xpt" \
hg@1
  1905
			! -name "*.gif" \
hg@1
  1906
			! -name "*.jpg" \
hg@1
  1907
			! -name "*.png" \
hg@1
  1908
			! -name "*.xpm" \
hg@1
  1909
			! -name "*.txt" \
hg@1
  1910
			! -name "*.rdf" \
hg@1
  1911
			! -name "*.sh" \
hg@1
  1912
			! -name "*.properties" \
hg@1
  1913
			! -name "*.dtd" \
hg@1
  1914
			! -name "*.html" \
hg@1
  1915
			! -name "*.xul" \
hg@1
  1916
			! -name "*.css" \
hg@1
  1917
			! -name "*.xml" \
hg@1
  1918
			! -name "*.jar" \
hg@1
  1919
			! -name "*.dat" \
hg@1
  1920
			! -name "*.tbl" \
hg@1
  1921
			! -name "*.src" \
hg@1
  1922
			! -name "*.reg" \
hg@1
  1923
			$(PLATFORM_EXCLUDE_LIST) \
hg@1
  1924
			-exec $(STRIP) $(STRIP_FLAGS) {} >/dev/null 2>&1 \;
hg@1
  1925
endif
hg@1
  1926
endif
hg@1
  1927
	@echo "Packaging $(XPI_PKGNAME).xpi..."
hg@1
  1928
	cd $(FINAL_TARGET) && $(ZIP) -qr ../$(XPI_PKGNAME).xpi *
hg@1
  1929
endif
hg@1
  1930
hg@1
  1931
ifdef INSTALL_EXTENSION_ID
hg@1
  1932
ifndef XPI_NAME
hg@1
  1933
$(error XPI_NAME must be set for INSTALL_EXTENSION_ID)
hg@1
  1934
endif
hg@1
  1935
hg@1
  1936
libs::
hg@1
  1937
	$(RM) -rf "$(DIST)/bin/extensions/$(INSTALL_EXTENSION_ID)"
hg@1
  1938
	$(NSINSTALL) -D "$(DIST)/bin/extensions/$(INSTALL_EXTENSION_ID)"
benjamin@4238
  1939
	cd $(FINAL_TARGET) && tar $(TAR_CREATE_FLAGS) - . | (cd "../../bin/extensions/$(INSTALL_EXTENSION_ID)" && tar -xf -)
hg@1
  1940
hg@1
  1941
endif
hg@1
  1942
hg@1
  1943
ifneq (,$(filter flat symlink,$(MOZ_CHROME_FILE_FORMAT)))
hg@1
  1944
_JAR_REGCHROME_DISABLE_JAR=1
hg@1
  1945
else
hg@1
  1946
_JAR_REGCHROME_DISABLE_JAR=0
hg@1
  1947
endif
hg@1
  1948
hg@1
  1949
REGCHROME = $(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/add-chrome.pl \
mats@944
  1950
	$(if $(filter gtk2,$(MOZ_WIDGET_TOOLKIT)),-x) \
hg@1
  1951
	$(if $(CROSS_COMPILE),-o $(OS_ARCH)) $(FINAL_TARGET)/chrome/installed-chrome.txt \
hg@1
  1952
	$(_JAR_REGCHROME_DISABLE_JAR)
hg@1
  1953
hg@1
  1954
REGCHROME_INSTALL = $(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/add-chrome.pl \
mats@944
  1955
	$(if $(filter gtk2,$(MOZ_WIDGET_TOOLKIT)),-x) \
hg@1
  1956
	$(if $(CROSS_COMPILE),-o $(OS_ARCH)) $(DESTDIR)$(mozappdir)/chrome/installed-chrome.txt \
hg@1
  1957
	$(_JAR_REGCHROME_DISABLE_JAR)
hg@1
  1958
hg@1
  1959
hg@1
  1960
#############################################################################
hg@1
  1961
# Dependency system
hg@1
  1962
#############################################################################
hg@1
  1963
ifdef COMPILER_DEPEND
hg@1
  1964
depend::
hg@1
  1965
	@echo "$(MAKE): No need to run depend target.\
hg@1
  1966
			Using compiler-based depend." 1>&2
hg@1
  1967
ifeq ($(GNU_CC)$(GNU_CXX),)
hg@1
  1968
# Non-GNU compilers
hg@1
  1969
	@echo "`echo '$(MAKE):'|sed 's/./ /g'`"\
hg@1
  1970
	'(Compiler-based depend was turned on by "--enable-md".)' 1>&2
hg@1
  1971
else
hg@1
  1972
# GNU compilers
hg@1
  1973
	@space="`echo '$(MAKE): '|sed 's/./ /g'`";\
hg@1
  1974
	echo "$$space"'Since you are using a GNU compiler,\
hg@1
  1975
		it is on by default.' 1>&2; \
hg@1
  1976
	echo "$$space"'To turn it off, pass --disable-md to configure.' 1>&2
hg@1
  1977
endif
hg@1
  1978
hg@1
  1979
else # ! COMPILER_DEPEND
hg@1
  1980
hg@1
  1981
ifndef MOZ_AUTO_DEPS
hg@1
  1982
hg@1
  1983
define MAKE_DEPS_NOAUTO
neil@5484
  1984
	$(MKDEPEND) -w1024 -o'.$(OBJ_SUFFIX)' -f- $(DEFINES) $(ACDEFINES) $(INCLUDES) $< 2>/dev/null | sed -e "s|^[^ ]*/||" > $@
hg@1
  1985
endef
hg@1
  1986
hg@1
  1987
$(MDDEPDIR)/%.pp: %.c
hg@1
  1988
	$(REPORT_BUILD)
hg@1
  1989
	@$(MAKE_DEPS_NOAUTO)
hg@1
  1990
hg@1
  1991
$(MDDEPDIR)/%.pp: %.cpp
hg@1
  1992
	$(REPORT_BUILD)
hg@1
  1993
	@$(MAKE_DEPS_NOAUTO)
hg@1
  1994
hg@1
  1995
$(MDDEPDIR)/%.pp: %.s
hg@1
  1996
	$(REPORT_BUILD)
hg@1
  1997
	@$(MAKE_DEPS_NOAUTO)
hg@1
  1998
benjamin@28510
  1999
ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS))
hg@1
  2000
depend:: $(SUBMAKEFILES) $(MAKE_DIRS) $(MDDEPFILES)
hg@1
  2001
else
hg@1
  2002
depend:: $(SUBMAKEFILES)
hg@1
  2003
endif
benjamin@25610
  2004
	$(LOOP_OVER_PARALLEL_DIRS)
benjamin@25610
  2005
	$(LOOP_OVER_DIRS)
benjamin@25610
  2006
	$(LOOP_OVER_TOOL_DIRS)
hg@1
  2007
hg@1
  2008
dependclean:: $(SUBMAKEFILES)
hg@1
  2009
	rm -f $(MDDEPFILES)
benjamin@25610
  2010
	$(LOOP_OVER_PARALLEL_DIRS)
benjamin@25610
  2011
	$(LOOP_OVER_DIRS)
benjamin@25610
  2012
	$(LOOP_OVER_TOOL_DIRS)
hg@1
  2013
hg@1
  2014
endif # MOZ_AUTO_DEPS
hg@1
  2015
hg@1
  2016
endif # COMPILER_DEPEND
hg@1
  2017
hg@1
  2018
hg@1
  2019
#############################################################################
hg@1
  2020
# MDDEPDIR is the subdirectory where all the dependency files are placed.
hg@1
  2021
#   This uses a make rule (instead of a macro) to support parallel
hg@1
  2022
#   builds (-jN). If this were done in the LOOP_OVER_DIRS macro, two
hg@1
  2023
#   processes could simultaneously try to create the same directory.
hg@1
  2024
#
jimb@21658
  2025
#   We use $(CURDIR) in the rule's target to ensure that we don't find
jimb@21658
  2026
#   a dependency directory in the source tree via VPATH (perhaps from
jimb@21658
  2027
#   a previous build in the source tree) and thus neglect to create a
jimb@21658
  2028
#   dependency directory in the object directory, where we really need
jimb@21658
  2029
#   it.
jimb@21658
  2030
jimb@21658
  2031
$(CURDIR)/$(MDDEPDIR):
hg@1
  2032
	@if test ! -d $@; then echo Creating $@; rm -rf $@; mkdir $@; else true; fi
hg@1
  2033