config.mk 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  1. #
  2. # ***** BEGIN LICENSE BLOCK *****
  3. # Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. #
  5. # The contents of this file are subject to the Mozilla Public License Version
  6. # 1.1 (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. # http://www.mozilla.org/MPL/
  9. #
  10. # Software distributed under the License is distributed on an "AS IS" basis,
  11. # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. # for the specific language governing rights and limitations under the
  13. # License.
  14. #
  15. # The Original Code is mozilla.org code.
  16. #
  17. # The Initial Developer of the Original Code is
  18. # Netscape Communications Corporation.
  19. # Portions created by the Initial Developer are Copyright (C) 1998
  20. # the Initial Developer. All Rights Reserved.
  21. #
  22. # Contributor(s):
  23. # Benjamin Smedberg <benjamin@smedbergs.us>
  24. #
  25. # Alternatively, the contents of this file may be used under the terms of
  26. # either of the GNU General Public License Version 2 or later (the "GPL"),
  27. # or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28. # in which case the provisions of the GPL or the LGPL are applicable instead
  29. # of those above. If you wish to allow use of your version of this file only
  30. # under the terms of either the GPL or the LGPL, and not to allow others to
  31. # use your version of this file under the terms of the MPL, indicate your
  32. # decision by deleting the provisions above and replace them with the notice
  33. # and other provisions required by the GPL or the LGPL. If you do not delete
  34. # the provisions above, a recipient may use your version of this file under
  35. # the terms of any one of the MPL, the GPL or the LGPL.
  36. #
  37. # ***** END LICENSE BLOCK *****
  38. #
  39. # config.mk
  40. #
  41. # Determines the platform and builds the macros needed to load the
  42. # appropriate platform-specific .mk file, then defines all (most?)
  43. # of the generic macros.
  44. #
  45. # Define an include-at-most-once flag
  46. INCLUDED_CONFIG_MK = 1
  47. EXIT_ON_ERROR = set -e; # Shell loops continue past errors without this.
  48. ifndef topsrcdir
  49. topsrcdir = $(DEPTH)
  50. endif
  51. ifndef INCLUDED_AUTOCONF_MK
  52. include $(DEPTH)/config/autoconf.mk
  53. endif
  54. ifndef INCLUDED_INSURE_MK
  55. ifdef MOZ_INSURIFYING
  56. include $(topsrcdir)/config/insure.mk
  57. endif
  58. endif
  59. COMMA = ,
  60. # Sanity check some variables
  61. CHECK_VARS := \
  62. XPI_NAME \
  63. LIBRARY_NAME \
  64. MODULE \
  65. DEPTH \
  66. SHORT_LIBNAME \
  67. XPI_PKGNAME \
  68. INSTALL_EXTENSION_ID \
  69. SHARED_LIBRARY_NAME \
  70. STATIC_LIBRARY_NAME \
  71. $(NULL)
  72. # checks for internal spaces or trailing spaces in the variable
  73. # named by $x
  74. check-variable = $(if $(filter-out 0 1,$(words $($(x))z)),$(error Spaces are not allowed in $(x)))
  75. $(foreach x,$(CHECK_VARS),$(check-variable))
  76. core_abspath = $(if $(findstring :,$(1)),$(1),$(if $(filter /%,$(1)),$(1),$(CURDIR)/$(1)))
  77. # FINAL_TARGET specifies the location into which we copy end-user-shipped
  78. # build products (typelibs, components, chrome).
  79. #
  80. # It will usually be the well-loved $(DIST)/bin, today, but can also be an
  81. # XPI-contents staging directory for ambitious and right-thinking extensions.
  82. FINAL_TARGET = $(if $(XPI_NAME),$(DIST)/xpi-stage/$(XPI_NAME),$(DIST)/bin)
  83. # MAKE_JARS_TARGET is a staging area for make-jars.pl. When packaging in
  84. # the jar format, make-jars leaves behind a directory structure that's not
  85. # needed in $(FINAL_TARGET). For both, flat, and symlink, the directory
  86. # structure contains the chrome, so leave it in $(FINAL_TARGET).
  87. ifeq (jar,$(MOZ_CHROME_FILE_FORMAT))
  88. MAKE_JARS_TARGET = $(if $(XPI_NAME),$(FINAL_TARGET).stage,$(DIST)/chrome-stage)
  89. else
  90. MAKE_JARS_TARGET = $(FINAL_TARGET)
  91. endif
  92. # The VERSION_NUMBER is suffixed onto the end of the DLLs we ship.
  93. VERSION_NUMBER = 50
  94. ifeq ($(HOST_OS_ARCH),WINNT)
  95. win_srcdir := $(subst $(topsrcdir),$(WIN_TOP_SRC),$(srcdir))
  96. BUILD_TOOLS = $(WIN_TOP_SRC)/build/unix
  97. else
  98. win_srcdir := $(srcdir)
  99. BUILD_TOOLS = $(topsrcdir)/build/unix
  100. endif
  101. CONFIG_TOOLS = $(MOZ_BUILD_ROOT)/config
  102. AUTOCONF_TOOLS = $(topsrcdir)/build/autoconf
  103. ifeq ($(OS_ARCH),QNX)
  104. ifeq ($(OS_TARGET),NTO)
  105. LD := qcc -Vgcc_ntox86 -nostdlib
  106. else
  107. LD := $(CC)
  108. endif
  109. endif
  110. ifeq ($(OS_ARCH),BeOS)
  111. BEOS_ADDON_WORKAROUND = 1
  112. endif
  113. #
  114. # Strip off the excessively long version numbers on these platforms,
  115. # but save the version to allow multiple versions of the same base
  116. # platform to be built in the same tree.
  117. #
  118. ifneq (,$(filter FreeBSD HP-UX IRIX Linux NetBSD OpenBSD OSF1 SunOS,$(OS_ARCH)))
  119. OS_RELEASE := $(basename $(OS_RELEASE))
  120. # Allow the user to ignore the OS_VERSION, which is usually irrelevant.
  121. ifdef WANT_MOZILLA_CONFIG_OS_VERSION
  122. OS_VERS := $(suffix $(OS_RELEASE))
  123. OS_VERSION := $(shell echo $(OS_VERS) | sed 's/-.*//')
  124. endif
  125. endif
  126. OS_CONFIG := $(OS_ARCH)$(OS_RELEASE)
  127. FINAL_LINK_LIBS = $(DEPTH)/config/final-link-libs
  128. FINAL_LINK_COMPS = $(DEPTH)/config/final-link-comps
  129. FINAL_LINK_COMP_NAMES = $(DEPTH)/config/final-link-comp-names
  130. MOZ_UNICHARUTIL_LIBS = $(LIBXUL_DIST)/lib/$(LIB_PREFIX)unicharutil_s.$(LIB_SUFFIX)
  131. MOZ_WIDGET_SUPPORT_LIBS = $(DIST)/lib/$(LIB_PREFIX)widgetsupport_s.$(LIB_SUFFIX)
  132. MKDIR ?= mkdir
  133. SLEEP ?= sleep
  134. TOUCH ?= touch
  135. PYTHON_PATH = $(PYTHON) $(topsrcdir)/config/pythonpath.py
  136. ifdef MOZ_MEMORY
  137. ifneq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
  138. JEMALLOC_LIBS = $(MKSHLIB_FORCE_ALL) $(call EXPAND_LIBNAME_PATH,jemalloc,$(DIST)/lib) $(MKSHLIB_UNFORCE_ALL)
  139. endif
  140. endif
  141. # determine debug-related options
  142. _DEBUG_CFLAGS :=
  143. _DEBUG_LDFLAGS :=
  144. ifndef MOZ_DEBUG
  145. # global debugging is disabled
  146. # check if it was explicitly enabled for this module
  147. ifneq (, $(findstring $(MODULE), $(MOZ_DEBUG_MODULES)))
  148. MOZ_DEBUG:=1
  149. endif
  150. else
  151. # global debugging is enabled
  152. # check if it was explicitly disabled for this module
  153. ifneq (, $(findstring ^$(MODULE), $(MOZ_DEBUG_MODULES)))
  154. MOZ_DEBUG:=
  155. endif
  156. endif
  157. ifdef MOZ_DEBUG
  158. _DEBUG_CFLAGS += $(MOZ_DEBUG_ENABLE_DEFS)
  159. XULPPFLAGS += $(MOZ_DEBUG_ENABLE_DEFS)
  160. else
  161. _DEBUG_CFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
  162. XULPPFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
  163. endif
  164. # determine if -g should be passed to the compiler, based on
  165. # the current module, and the value of MOZ_DBGRINFO_MODULES
  166. ifdef MOZ_DEBUG
  167. MOZ_DBGRINFO_MODULES += ALL_MODULES
  168. pattern := ALL_MODULES ^ALL_MODULES
  169. else
  170. MOZ_DBGRINFO_MODULES += ^ALL_MODULES
  171. pattern := ALL_MODULES ^ALL_MODULES
  172. endif
  173. ifdef MODULE
  174. # our current Makefile specifies a module name - add it to our pattern
  175. pattern += $(MODULE) ^$(MODULE)
  176. endif
  177. # start by finding the first relevant module name
  178. # (remember that the order of the module names in MOZ_DBGRINFO_MODULES
  179. # is reversed from the order the user specified to configure -
  180. # this allows the user to put general names at the beginning
  181. # of the list, and to override them with explicit module names later
  182. # in the list)
  183. first_match:=$(firstword $(filter $(pattern), $(MOZ_DBGRINFO_MODULES)))
  184. ifeq ($(first_match), $(MODULE))
  185. # the user specified explicitly that
  186. # this module should be compiled with -g
  187. _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS)
  188. _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)
  189. else
  190. ifeq ($(first_match), ^$(MODULE))
  191. # the user specified explicitly that this module
  192. # should not be compiled with -g (nothing to do)
  193. else
  194. ifeq ($(first_match), ALL_MODULES)
  195. # the user didn't mention this module explicitly,
  196. # but wanted all modules to be compiled with -g
  197. _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS)
  198. _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)
  199. else
  200. ifeq ($(first_match), ^ALL_MODULES)
  201. # the user didn't mention this module explicitly,
  202. # but wanted all modules to be compiled without -g (nothing to do)
  203. endif
  204. endif
  205. endif
  206. endif
  207. # append debug flags
  208. # (these might have been above when processing MOZ_DBGRINFO_MODULES)
  209. OS_CFLAGS += $(_DEBUG_CFLAGS)
  210. OS_CXXFLAGS += $(_DEBUG_CFLAGS)
  211. OS_LDFLAGS += $(_DEBUG_LDFLAGS)
  212. # XXX: What does this? Bug 482434 filed for better explanation.
  213. ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
  214. ifdef MOZ_DEBUG
  215. ifneq (,$(MOZ_BROWSE_INFO)$(MOZ_BSCFILE))
  216. OS_CFLAGS += -FR
  217. OS_CXXFLAGS += -FR
  218. endif
  219. else # ! MOZ_DEBUG
  220. # We don't build a static CRT when building a custom CRT,
  221. # it appears to be broken. So don't link to jemalloc if
  222. # the Makefile wants static CRT linking.
  223. ifeq ($(MOZ_MEMORY)_$(USE_STATIC_LIBS),1_)
  224. # Disable default CRT libs and add the right lib path for the linker
  225. OS_LDFLAGS += $(MOZ_MEMORY_LDFLAGS)
  226. endif
  227. # MOZ_DEBUG_SYMBOLS generates debug symbols in separate PDB files.
  228. # Used for generating an optimized build with debugging symbols.
  229. # Used in the Windows nightlies to generate symbols for crash reporting.
  230. ifdef MOZ_DEBUG_SYMBOLS
  231. OS_CXXFLAGS += -Zi -UDEBUG -DNDEBUG
  232. OS_CFLAGS += -Zi -UDEBUG -DNDEBUG
  233. OS_LDFLAGS += -DEBUG
  234. endif
  235. ifdef MOZ_QUANTIFY
  236. # -FIXED:NO is needed for Quantify to work, but it increases the size
  237. # of executables, so only use it if building for Quantify.
  238. WIN32_EXE_LDFLAGS += -FIXED:NO
  239. # We need -OPT:NOICF to prevent identical methods from being merged together.
  240. # Otherwise, Quantify doesn't know which method was actually called when it's
  241. # showing you the profile.
  242. OS_LDFLAGS += -OPT:NOICF
  243. endif
  244. #
  245. # Handle trace-malloc in optimized builds.
  246. # No opt to give sane callstacks.
  247. #
  248. ifdef NS_TRACE_MALLOC
  249. MOZ_OPTIMIZE_FLAGS=-Zi -Od -UDEBUG -DNDEBUG
  250. OS_LDFLAGS = -DEBUG -PDB:NONE
  251. endif # NS_TRACE_MALLOC
  252. endif # MOZ_DEBUG
  253. endif # WINNT && !GNU_CC
  254. #
  255. # Build using PIC by default
  256. # Do not use PIC if not building a shared lib (see exceptions below)
  257. #
  258. ifndef BUILD_STATIC_LIBS
  259. _ENABLE_PIC=1
  260. endif
  261. ifneq (,$(FORCE_SHARED_LIB)$(FORCE_USE_PIC))
  262. _ENABLE_PIC=1
  263. endif
  264. # In Firefox, all components are linked into either libxul or the static
  265. # meta-component, and should be compiled with PIC.
  266. ifdef MOZ_META_COMPONENT
  267. _ENABLE_PIC=1
  268. endif
  269. # If module is going to be merged into the nsStaticModule,
  270. # make sure that the entry points are translated and
  271. # the module is built static.
  272. ifdef IS_COMPONENT
  273. ifdef EXPORT_LIBRARY
  274. ifneq (,$(BUILD_STATIC_LIBS))
  275. ifdef MODULE_NAME
  276. DEFINES += -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT=1
  277. FORCE_STATIC_LIB=1
  278. endif
  279. endif
  280. endif
  281. endif
  282. # Determine if module being compiled is destined
  283. # to be merged into libxul
  284. ifdef MOZ_ENABLE_LIBXUL
  285. ifdef LIBXUL_LIBRARY
  286. ifdef IS_COMPONENT
  287. ifdef MODULE_NAME
  288. DEFINES += -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT=1
  289. else
  290. $(error Component makefile does not specify MODULE_NAME.)
  291. endif
  292. endif
  293. FORCE_STATIC_LIB=1
  294. _ENABLE_PIC=1
  295. SHORT_LIBNAME=
  296. endif
  297. endif
  298. # If we are building this component into an extension/xulapp, it cannot be
  299. # statically linked. In the future we may want to add a xulapp meta-component
  300. # build option.
  301. ifdef XPI_NAME
  302. _ENABLE_PIC=1
  303. ifdef IS_COMPONENT
  304. EXPORT_LIBRARY=
  305. FORCE_STATIC_LIB=
  306. FORCE_SHARED_LIB=1
  307. endif
  308. endif
  309. #
  310. # Disable PIC if necessary
  311. #
  312. ifndef _ENABLE_PIC
  313. DSO_CFLAGS=
  314. ifeq ($(OS_ARCH)_$(HAVE_GCC3_ABI),Darwin_1)
  315. DSO_PIC_CFLAGS=-mdynamic-no-pic
  316. else
  317. DSO_PIC_CFLAGS=
  318. endif
  319. endif
  320. ifndef SHARED_LIBRARY_NAME
  321. ifdef LIBRARY_NAME
  322. SHARED_LIBRARY_NAME=$(LIBRARY_NAME)
  323. endif
  324. endif
  325. ifndef STATIC_LIBRARY_NAME
  326. ifdef LIBRARY_NAME
  327. STATIC_LIBRARY_NAME=$(LIBRARY_NAME)
  328. endif
  329. endif
  330. # This comes from configure
  331. ifdef MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE
  332. NO_PROFILE_GUIDED_OPTIMIZE = 1
  333. endif
  334. # Enable profile-based feedback
  335. ifndef NO_PROFILE_GUIDED_OPTIMIZE
  336. ifdef MOZ_PROFILE_GENERATE
  337. # No sense in profiling tools
  338. ifndef INTERNAL_TOOLS
  339. OS_CFLAGS += $(PROFILE_GEN_CFLAGS)
  340. OS_CXXFLAGS += $(PROFILE_GEN_CFLAGS)
  341. OS_LDFLAGS += $(PROFILE_GEN_LDFLAGS)
  342. ifeq (WINNT,$(OS_ARCH))
  343. AR_FLAGS += -LTCG
  344. endif
  345. endif # INTERNAL_TOOLS
  346. endif # MOZ_PROFILE_GENERATE
  347. ifdef MOZ_PROFILE_USE
  348. ifndef INTERNAL_TOOLS
  349. OS_CFLAGS += $(PROFILE_USE_CFLAGS)
  350. OS_CXXFLAGS += $(PROFILE_USE_CFLAGS)
  351. OS_LDFLAGS += $(PROFILE_USE_LDFLAGS)
  352. ifeq (WINNT,$(OS_ARCH))
  353. AR_FLAGS += -LTCG
  354. endif
  355. endif # INTERNAL_TOOLS
  356. endif # MOZ_PROFILE_USE
  357. endif # NO_PROFILE_GUIDED_OPTIMIZE
  358. # Does the makefile specifies the internal XPCOM API linkage?
  359. ifneq (,$(MOZILLA_INTERNAL_API)$(LIBXUL_LIBRARY))
  360. DEFINES += -DMOZILLA_INTERNAL_API
  361. endif
  362. # Force XPCOM/widget/gfx methods to be _declspec(dllexport) when we're
  363. # building libxul libraries
  364. ifdef MOZ_ENABLE_LIBXUL
  365. ifdef LIBXUL_LIBRARY
  366. DEFINES += \
  367. -D_IMPL_NS_COM \
  368. -DEXPORT_XPT_API \
  369. -DEXPORT_XPTC_API \
  370. -D_IMPL_NS_COM_OBSOLETE \
  371. -D_IMPL_NS_GFX \
  372. -D_IMPL_NS_WIDGET \
  373. -DIMPL_XREAPI \
  374. -DIMPL_NS_NET \
  375. -DIMPL_THEBES \
  376. $(NULL)
  377. ifndef MOZ_NATIVE_ZLIB
  378. DEFINES += -DZLIB_INTERNAL
  379. endif
  380. endif
  381. endif
  382. # Force _all_ exported methods to be |_declspec(dllexport)| when we're
  383. # building them into the executable.
  384. ifeq (,$(filter-out WINNT WINCE OS2, $(OS_ARCH)))
  385. ifdef BUILD_STATIC_LIBS
  386. DEFINES += \
  387. -D_IMPL_NS_GFX \
  388. -D_IMPL_NS_MSG_BASE \
  389. -D_IMPL_NS_WIDGET \
  390. $(NULL)
  391. endif
  392. endif
  393. # Flags passed to make-jars.pl
  394. MAKE_JARS_FLAGS = \
  395. -t $(topsrcdir) \
  396. -f $(MOZ_CHROME_FILE_FORMAT) \
  397. $(NULL)
  398. ifdef USE_EXTENSION_MANIFEST
  399. MAKE_JARS_FLAGS += -e
  400. endif
  401. ifdef BOTH_MANIFESTS
  402. MAKE_JARS_FLAGS += --both-manifests
  403. endif
  404. TAR_CREATE_FLAGS = -cvhf
  405. ifeq ($(OS_ARCH),BSD_OS)
  406. TAR_CREATE_FLAGS = -cvLf
  407. endif
  408. ifeq ($(OS_ARCH),OS2)
  409. TAR_CREATE_FLAGS = -cvf
  410. endif
  411. #
  412. # Personal makefile customizations go in these optional make include files.
  413. #
  414. MY_CONFIG := $(DEPTH)/config/myconfig.mk
  415. MY_RULES := $(DEPTH)/config/myrules.mk
  416. #
  417. # Default command macros; can be overridden in <arch>.mk.
  418. #
  419. CCC = $(CXX)
  420. NFSPWD = $(CONFIG_TOOLS)/nfspwd
  421. PURIFY = purify $(PURIFYOPTIONS)
  422. QUANTIFY = quantify $(QUANTIFYOPTIONS)
  423. ifdef CROSS_COMPILE
  424. XPIDL_COMPILE = $(CYGWIN_WRAPPER) $(LIBXUL_DIST)/host/bin/host_xpidl$(HOST_BIN_SUFFIX)
  425. else
  426. XPIDL_COMPILE = $(CYGWIN_WRAPPER) $(LIBXUL_DIST)/bin/xpidl$(BIN_SUFFIX)
  427. endif
  428. XPIDL_LINK = $(PYTHON) $(LIBXUL_DIST)/sdk/bin/xpt.py link
  429. INCLUDES = \
  430. $(LOCAL_INCLUDES) \
  431. -I$(srcdir) \
  432. -I. \
  433. -I$(DIST)/include -I$(DIST)/include/nsprpub \
  434. $(if $(LIBXUL_SDK),-I$(LIBXUL_SDK)/include -I$(LIBXUL_SDK)/include/nsprpub) \
  435. $(OS_INCLUDES) \
  436. $(NULL)
  437. ifdef MOZ_SHARK
  438. OS_CFLAGS += -F/System/Library/PrivateFrameworks
  439. OS_CXXFLAGS += -F/System/Library/PrivateFrameworks
  440. OS_LDFLAGS += -F/System/Library/PrivateFrameworks -framework CHUD
  441. endif # ifdef MOZ_SHARK
  442. CFLAGS = $(OS_CFLAGS)
  443. CXXFLAGS = $(OS_CXXFLAGS)
  444. LDFLAGS = $(OS_LDFLAGS) $(MOZ_FIX_LINK_PATHS)
  445. # Allow each module to override the *default* optimization settings
  446. # by setting MODULE_OPTIMIZE_FLAGS if the developer has not given
  447. # arguments to --enable-optimize
  448. ifdef MOZ_OPTIMIZE
  449. ifeq (1,$(MOZ_OPTIMIZE))
  450. ifdef MODULE_OPTIMIZE_FLAGS
  451. CFLAGS += $(MODULE_OPTIMIZE_FLAGS)
  452. CXXFLAGS += $(MODULE_OPTIMIZE_FLAGS)
  453. else
  454. CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
  455. CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS)
  456. endif # MODULE_OPTIMIZE_FLAGS
  457. else
  458. CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
  459. CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS)
  460. endif # MOZ_OPTIMIZE == 1
  461. LDFLAGS += $(MOZ_OPTIMIZE_LDFLAGS)
  462. endif # MOZ_OPTIMIZE
  463. ifdef CROSS_COMPILE
  464. HOST_CFLAGS += $(HOST_OPTIMIZE_FLAGS)
  465. else
  466. ifdef MOZ_OPTIMIZE
  467. ifeq (1,$(MOZ_OPTIMIZE))
  468. ifdef MODULE_OPTIMIZE_FLAGS
  469. HOST_CFLAGS += $(MODULE_OPTIMIZE_FLAGS)
  470. else
  471. HOST_CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
  472. endif # MODULE_OPTIMIZE_FLAGS
  473. else
  474. HOST_CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
  475. endif # MOZ_OPTIMIZE == 1
  476. endif # MOZ_OPTIMIZE
  477. endif # CROSS_COMPILE
  478. ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
  479. #// Currently, unless USE_STATIC_LIBS is defined, the multithreaded
  480. #// DLL version of the RTL is used...
  481. #//
  482. #//------------------------------------------------------------------------
  483. ifdef USE_STATIC_LIBS
  484. RTL_FLAGS=-MT # Statically linked multithreaded RTL
  485. ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC))
  486. ifndef MOZ_NO_DEBUG_RTL
  487. RTL_FLAGS=-MTd # Statically linked multithreaded MSVC4.0 debug RTL
  488. endif
  489. endif # MOZ_DEBUG || NS_TRACE_MALLOC
  490. else # !USE_STATIC_LIBS
  491. RTL_FLAGS=-MD # Dynamically linked, multithreaded RTL
  492. ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC))
  493. ifndef MOZ_NO_DEBUG_RTL
  494. RTL_FLAGS=-MDd # Dynamically linked, multithreaded MSVC4.0 debug RTL
  495. endif
  496. endif # MOZ_DEBUG || NS_TRACE_MALLOC
  497. endif # USE_STATIC_LIBS
  498. endif # WINNT && !GNU_CC
  499. ifeq ($(OS_ARCH),Darwin)
  500. # Darwin doesn't cross-compile, so just set both types of flags here.
  501. HOST_CMFLAGS += -fobjc-exceptions
  502. HOST_CMMFLAGS += -fobjc-exceptions
  503. OS_COMPILE_CMFLAGS += -fobjc-exceptions
  504. OS_COMPILE_CMMFLAGS += -fobjc-exceptions
  505. endif
  506. COMPILE_CFLAGS = $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(XCFLAGS) $(PROFILER_CFLAGS) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CFLAGS)
  507. COMPILE_CXXFLAGS = $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(XCFLAGS) $(PROFILER_CFLAGS) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CXXFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CXXFLAGS)
  508. COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS)
  509. COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS)
  510. ifndef CROSS_COMPILE
  511. HOST_CFLAGS += $(RTL_FLAGS)
  512. endif
  513. #
  514. # Name of the binary code directories
  515. #
  516. # Override defaults
  517. # We need to know where to find the libraries we
  518. # put on the link line for binaries, and should
  519. # we link statically or dynamic? Assuming dynamic for now.
  520. ifneq (WINNT_,$(OS_ARCH)_$(GNU_CC))
  521. ifneq (,$(filter-out WINCE,$(OS_ARCH)))
  522. LIBS_DIR = -L$(DIST)/bin -L$(DIST)/lib
  523. ifdef LIBXUL_SDK
  524. LIBS_DIR += -L$(LIBXUL_SDK)/bin -L$(LIBXUL_SDK)/lib
  525. endif
  526. endif
  527. endif
  528. # Default location of include files
  529. IDL_DIR = $(DIST)/idl
  530. XPIDL_FLAGS = -I$(srcdir) -I$(IDL_DIR)
  531. ifdef LIBXUL_SDK
  532. XPIDL_FLAGS += -I$(LIBXUL_SDK)/idl
  533. endif
  534. SDK_LIB_DIR = $(DIST)/sdk/lib
  535. SDK_BIN_DIR = $(DIST)/sdk/bin
  536. DEPENDENCIES = .md
  537. MOZ_COMPONENT_LIBS=$(XPCOM_LIBS) $(MOZ_COMPONENT_NSPR_LIBS)
  538. ifdef GC_LEAK_DETECTOR
  539. XPCOM_LIBS += -lboehm
  540. endif
  541. ifeq (xpconnect, $(findstring xpconnect, $(BUILD_MODULES)))
  542. DEFINES += -DXPCONNECT_STANDALONE
  543. endif
  544. ifeq ($(OS_ARCH),OS2)
  545. ELF_DYNSTR_GC = echo
  546. else
  547. ELF_DYNSTR_GC = :
  548. endif
  549. ifndef CROSS_COMPILE
  550. ifdef USE_ELF_DYNSTR_GC
  551. ifdef MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS
  552. ELF_DYNSTR_GC = $(DEPTH)/config/elf-dynstr-gc
  553. endif
  554. endif
  555. endif
  556. ifeq ($(OS_ARCH),Darwin)
  557. ifdef NEXT_ROOT
  558. export NEXT_ROOT
  559. PBBUILD = NEXT_ROOT= $(PBBUILD_BIN)
  560. else # NEXT_ROOT
  561. PBBUILD = $(PBBUILD_BIN)
  562. endif # NEXT_ROOT
  563. PBBUILD_SETTINGS = GCC_VERSION="$(GCC_VERSION)" SYMROOT=build ARCHS="$(OS_TEST)"
  564. ifdef MACOS_SDK_DIR
  565. PBBUILD_SETTINGS += SDKROOT="$(MACOS_SDK_DIR)"
  566. endif # MACOS_SDK_DIR
  567. ifdef MACOSX_DEPLOYMENT_TARGET
  568. export MACOSX_DEPLOYMENT_TARGET
  569. PBBUILD_SETTINGS += MACOSX_DEPLOYMENT_TARGET="$(MACOSX_DEPLOYMENT_TARGET)"
  570. endif # MACOSX_DEPLOYMENT_TARGET
  571. ifdef MOZ_OPTIMIZE
  572. ifeq (2,$(MOZ_OPTIMIZE))
  573. # Only override project defaults if the config specified explicit settings
  574. PBBUILD_SETTINGS += GCC_MODEL_TUNING= OPTIMIZATION_CFLAGS="$(MOZ_OPTIMIZE_FLAGS)"
  575. endif # MOZ_OPTIMIZE=2
  576. endif # MOZ_OPTIMIZE
  577. ifeq (1,$(HAS_XCODE_2_1))
  578. # Xcode 2.1 puts its build products in a directory corresponding to the
  579. # selected build style/configuration.
  580. XCODE_PRODUCT_DIR = build/$(BUILDSTYLE)
  581. else
  582. XCODE_PRODUCT_DIR = build
  583. endif # HAS_XCODE_2_1=1
  584. endif # OS_ARCH=Darwin
  585. ifdef MOZ_NATIVE_MAKEDEPEND
  586. MKDEPEND_DIR =
  587. MKDEPEND = $(CYGWIN_WRAPPER) $(MOZ_NATIVE_MAKEDEPEND)
  588. else
  589. MKDEPEND_DIR = $(CONFIG_TOOLS)/mkdepend
  590. MKDEPEND = $(CYGWIN_WRAPPER) $(MKDEPEND_DIR)/mkdepend$(BIN_SUFFIX)
  591. endif
  592. # Set link flags according to whether we want a console.
  593. ifdef MOZ_WINCONSOLE
  594. ifeq ($(MOZ_WINCONSOLE),1)
  595. ifeq ($(OS_ARCH),OS2)
  596. BIN_FLAGS += -Zlinker -PM:VIO
  597. endif
  598. ifeq ($(OS_ARCH),WINNT)
  599. ifdef GNU_CC
  600. WIN32_EXE_LDFLAGS += -mconsole
  601. else
  602. WIN32_EXE_LDFLAGS += -SUBSYSTEM:CONSOLE
  603. endif
  604. endif
  605. else # MOZ_WINCONSOLE
  606. ifeq ($(OS_ARCH),OS2)
  607. BIN_FLAGS += -Zlinker -PM:PM
  608. endif
  609. ifeq ($(OS_ARCH),WINNT)
  610. ifdef GNU_CC
  611. WIN32_EXE_LDFLAGS += -mwindows
  612. else
  613. WIN32_EXE_LDFLAGS += -SUBSYSTEM:WINDOWS
  614. endif
  615. endif
  616. endif
  617. endif
  618. # Flags needed to link against the component library
  619. ifdef MOZ_COMPONENTLIB
  620. MOZ_COMPONENTLIB_EXTRA_DSO_LIBS = mozcomps xpcom_compat
  621. # Tell the linker where NSS is, if we're building crypto
  622. ifeq ($(OS_ARCH),Darwin)
  623. ifeq (,$(findstring crypto,$(MOZ_META_COMPONENTS)))
  624. MOZ_COMPONENTLIB_EXTRA_LIBS = $(foreach library, $(patsubst -l%, $(LIB_PREFIX)%$(DLL_SUFFIX), $(filter -l%, $(NSS_LIBS))), -dylib_file @executable_path/$(library):$(DIST)/bin/$(library))
  625. endif
  626. endif
  627. endif
  628. # If we're building a component on MSVC, we don't want to generate an
  629. # import lib, because that import lib will collide with the name of a
  630. # static version of the same library.
  631. ifeq ($(GNU_LD)$(OS_ARCH),WINNT)
  632. ifdef IS_COMPONENT
  633. LDFLAGS += -IMPLIB:fake.lib
  634. DELETE_AFTER_LINK = fake.lib fake.exp
  635. endif
  636. endif
  637. #
  638. # Include any personal overrides the user might think are needed.
  639. #
  640. -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-config.mk
  641. -include $(MY_CONFIG)
  642. ######################################################################
  643. # Now test variables that might have been set or overridden by $(MY_CONFIG).
  644. DEFINES += -DOSTYPE=\"$(OS_CONFIG)\"
  645. DEFINES += -DOSARCH=$(OS_ARCH)
  646. # For profiling
  647. ifdef ENABLE_EAZEL_PROFILER
  648. ifndef INTERNAL_TOOLS
  649. ifneq ($(LIBRARY_NAME), xpt)
  650. ifneq (, $(findstring $(shell $(topsrcdir)/build/unix/print-depth-path.sh | awk -F/ '{ print $$2; }'), $(MOZ_PROFILE_MODULES)))
  651. PROFILER_CFLAGS = $(EAZEL_PROFILER_CFLAGS) -DENABLE_EAZEL_PROFILER
  652. PROFILER_LIBS = $(EAZEL_PROFILER_LIBS)
  653. endif
  654. endif
  655. endif
  656. endif
  657. ######################################################################
  658. GARBAGE += $(DEPENDENCIES) $(MKDEPENDENCIES) $(MKDEPENDENCIES).bak core $(wildcard core.[0-9]*) $(wildcard *.err) $(wildcard *.pure) $(wildcard *_pure_*.o) Templates.DB
  659. ifeq ($(OS_ARCH),Darwin)
  660. ifndef NSDISTMODE
  661. NSDISTMODE=absolute_symlink
  662. endif
  663. PWD := $(CURDIR)
  664. endif
  665. ifdef NSINSTALL_BIN
  666. NSINSTALL = $(CYGWIN_WRAPPER) $(NSINSTALL_BIN)
  667. else
  668. ifeq (OS2,$(CROSS_COMPILE)$(OS_ARCH))
  669. NSINSTALL = $(MOZ_TOOLS_DIR)/nsinstall
  670. else
  671. NSINSTALL = $(CONFIG_TOOLS)/nsinstall
  672. endif # OS2
  673. endif # NSINSTALL_BIN
  674. ifeq (,$(CROSS_COMPILE)$(filter-out WINNT OS2, $(OS_ARCH)))
  675. INSTALL = $(NSINSTALL)
  676. else
  677. ifeq ($(NSDISTMODE),copy)
  678. # copy files, but preserve source mtime
  679. INSTALL = $(NSINSTALL) -t
  680. else
  681. ifeq ($(NSDISTMODE),absolute_symlink)
  682. # install using absolute symbolic links
  683. ifeq ($(OS_ARCH),Darwin)
  684. INSTALL = $(NSINSTALL) -L $(PWD)
  685. else
  686. INSTALL = $(NSINSTALL) -L `$(NFSPWD)`
  687. endif # Darwin
  688. else
  689. # install using relative symbolic links
  690. INSTALL = $(NSINSTALL) -R
  691. endif # absolute_symlink
  692. endif # copy
  693. endif # WINNT/OS2
  694. ifeq (,$(filter-out WINCE,$(OS_ARCH)))
  695. NSINSTALL = $(CYGWIN_WRAPPER) nsinstall
  696. INSTALL = $(CYGWIN_WRAPPER) nsinstall
  697. endif
  698. # Use nsinstall in copy mode to install files on the system
  699. SYSINSTALL = $(NSINSTALL) -t
  700. ifeq ($(OS_ARCH),WINNT)
  701. ifneq (,$(CYGDRIVE_MOUNT))
  702. export CYGDRIVE_MOUNT
  703. endif
  704. endif
  705. #
  706. # Localization build automation
  707. #
  708. # Because you might wish to "make locales AB_CD=ab-CD", we don't hardcode
  709. # MOZ_UI_LOCALE directly, but use an intermediate variable that can be
  710. # overridden by the command line. (Besides, AB_CD is prettier).
  711. AB_CD = $(MOZ_UI_LOCALE)
  712. ifndef L10NBASEDIR
  713. L10NBASEDIR = $(error L10NBASEDIR not defined by configure)
  714. endif
  715. EXPAND_LOCALE_SRCDIR = $(if $(filter en-US,$(AB_CD)),$(topsrcdir)/$(1)/en-US,$(L10NBASEDIR)/$(AB_CD)/$(subst /locales,,$(1)))
  716. ifdef relativesrcdir
  717. LOCALE_SRCDIR = $(call EXPAND_LOCALE_SRCDIR,$(relativesrcdir))
  718. endif
  719. ifdef LOCALE_SRCDIR
  720. # if LOCALE_MERGEDIR is set, use mergedir first, then the localization,
  721. # and finally en-US
  722. ifdef LOCALE_MERGEDIR
  723. MAKE_JARS_FLAGS += -c $(LOCALE_MERGEDIR)/$(subst /locales,,$(relativesrcdir))
  724. endif
  725. MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR)
  726. ifdef LOCALE_MERGEDIR
  727. MAKE_JARS_FLAGS += -c $(topsrcdir)/$(relativesrcdir)/en-US
  728. endif
  729. endif
  730. ifeq (,$(filter WINCE WINNT OS2,$(OS_ARCH)))
  731. RUN_TEST_PROGRAM = $(DIST)/bin/run-mozilla.sh
  732. endif
  733. ifeq ($(OS_ARCH),OS2)
  734. RUN_TEST_PROGRAM = $(topsrcdir)/build/os2/test_os2.cmd "$(DIST)"
  735. endif
  736. #
  737. # Java macros
  738. #
  739. # Make sure any compiled classes work with at least JVM 1.4
  740. JAVAC_FLAGS += -source 1.4
  741. ifdef MOZ_DEBUG
  742. JAVAC_FLAGS += -g
  743. endif
  744. ifdef TIERS
  745. DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_dirs))
  746. STATIC_DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_staticdirs))
  747. endif