rules.mk 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476
  1. # -*- makefile -*-
  2. #
  3. # This Source Code Form is subject to the terms of the Mozilla Public
  4. # License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. # You can obtain one at http://mozilla.org/MPL/2.0/.
  6. #
  7. ifndef topsrcdir
  8. $(error topsrcdir was not set))
  9. endif
  10. # Define an include-at-most-once flag
  11. ifdef INCLUDED_RULES_MK
  12. $(error Do not include rules.mk twice!)
  13. endif
  14. INCLUDED_RULES_MK = 1
  15. ifndef INCLUDED_CONFIG_MK
  16. include $(topsrcdir)/config/config.mk
  17. endif
  18. ifndef INCLUDED_VERSION_MK
  19. include $(MOZILLA_DIR)/config/version.mk
  20. endif
  21. USE_AUTOTARGETS_MK = 1
  22. include $(MOZILLA_DIR)/config/makefiles/makeutils.mk
  23. ifdef REBUILD_CHECK
  24. REPORT_BUILD = $(info $(shell $(PYTHON) $(MOZILLA_DIR)/config/rebuild_check.py $@ $^))
  25. REPORT_BUILD_VERBOSE = $(REPORT_BUILD)
  26. else
  27. REPORT_BUILD = $(info $(notdir $@))
  28. ifdef BUILD_VERBOSE_LOG
  29. REPORT_BUILD_VERBOSE = $(REPORT_BUILD)
  30. else
  31. REPORT_BUILD_VERBOSE =
  32. endif
  33. endif
  34. EXEC = exec
  35. # ELOG prints out failed command when building silently (gmake -s). Pymake
  36. # prints out failed commands anyway, so ELOG just makes things worse by
  37. # forcing shell invocations.
  38. ifneq (,$(findstring s, $(filter-out --%, $(MAKEFLAGS))))
  39. ELOG := $(EXEC) sh $(BUILD_TOOLS)/print-failed-commands.sh
  40. else
  41. ELOG :=
  42. endif # -s
  43. _VPATH_SRCS = $(abspath $<)
  44. ################################################################################
  45. # Testing frameworks support
  46. ################################################################################
  47. testxpcobjdir = $(DEPTH)/_tests/xpcshell
  48. ifdef ENABLE_TESTS
  49. ifdef CPP_UNIT_TESTS
  50. ifdef COMPILE_ENVIRONMENT
  51. # Compile the tests to $(DIST)/bin. Make lots of niceties available by default
  52. # through TestHarness.h, by modifying the list of includes and the libs against
  53. # which stuff links.
  54. SIMPLE_PROGRAMS += $(CPP_UNIT_TESTS)
  55. INCLUDES += -I$(ABS_DIST)/include/testing
  56. ifndef MOZ_PROFILE_GENERATE
  57. CPP_UNIT_TESTS_FILES = $(CPP_UNIT_TESTS)
  58. CPP_UNIT_TESTS_DEST = $(DIST)/cppunittests
  59. CPP_UNIT_TESTS_TARGET = target
  60. INSTALL_TARGETS += CPP_UNIT_TESTS
  61. endif
  62. run-cppunittests::
  63. @$(PYTHON) $(MOZILLA_DIR)/testing/runcppunittests.py --xre-path=$(DIST)/bin --symbols-path=$(DIST)/crashreporter-symbols $(CPP_UNIT_TESTS)
  64. cppunittests-remote: DM_TRANS?=adb
  65. cppunittests-remote:
  66. @if [ '${TEST_DEVICE}' != '' -o '$(DM_TRANS)' = 'adb' ]; then \
  67. $(PYTHON) -u $(MOZILLA_DIR)/testing/remotecppunittests.py \
  68. --xre-path=$(DEPTH)/dist/bin \
  69. --localLib=$(DEPTH)/dist/$(MOZ_APP_NAME) \
  70. --dm_trans=$(DM_TRANS) \
  71. --deviceIP=${TEST_DEVICE} \
  72. $(CPP_UNIT_TESTS) $(EXTRA_TEST_ARGS); \
  73. else \
  74. echo 'please prepare your host with environment variables for TEST_DEVICE'; \
  75. fi
  76. endif # COMPILE_ENVIRONMENT
  77. endif # CPP_UNIT_TESTS
  78. endif # ENABLE_TESTS
  79. #
  80. # Library rules
  81. #
  82. # If FORCE_STATIC_LIB is set, build a static library.
  83. # Otherwise, build a shared library.
  84. #
  85. ifndef LIBRARY
  86. ifdef REAL_LIBRARY
  87. # Don't build actual static library if a shared library is also built
  88. ifdef FORCE_SHARED_LIB
  89. # ... except when we really want one
  90. ifdef NO_EXPAND_LIBS
  91. LIBRARY := $(REAL_LIBRARY)
  92. else
  93. LIBRARY := $(REAL_LIBRARY).$(LIBS_DESC_SUFFIX)
  94. endif
  95. else
  96. # Only build actual library if it is installed in DIST/lib or SDK
  97. ifeq (,$(SDK_LIBRARY)$(DIST_INSTALL)$(NO_EXPAND_LIBS))
  98. LIBRARY := $(REAL_LIBRARY).$(LIBS_DESC_SUFFIX)
  99. else
  100. ifdef NO_EXPAND_LIBS
  101. LIBRARY := $(REAL_LIBRARY)
  102. else
  103. LIBRARY := $(REAL_LIBRARY) $(REAL_LIBRARY).$(LIBS_DESC_SUFFIX)
  104. endif
  105. endif
  106. endif
  107. endif # REAL_LIBRARY
  108. endif # LIBRARY
  109. ifndef HOST_LIBRARY
  110. ifdef HOST_LIBRARY_NAME
  111. HOST_LIBRARY := $(LIB_PREFIX)$(HOST_LIBRARY_NAME).$(LIB_SUFFIX)
  112. endif
  113. endif
  114. ifdef LIBRARY
  115. ifdef FORCE_SHARED_LIB
  116. ifdef MKSHLIB
  117. ifdef LIB_IS_C_ONLY
  118. MKSHLIB = $(MKCSHLIB)
  119. endif
  120. EMBED_MANIFEST_AT=2
  121. endif # MKSHLIB
  122. endif # FORCE_SHARED_LIB
  123. endif # LIBRARY
  124. ifeq ($(OS_ARCH),WINNT)
  125. ifndef GNU_CC
  126. #
  127. # Unless we're building SIMPLE_PROGRAMS, all C++ files share a PDB file per
  128. # directory. For parallel builds, this PDB file is shared and locked by
  129. # MSPDBSRV.EXE, starting with MSVC8 SP1. If you're using MSVC 7.1 or MSVC8
  130. # without SP1, don't do parallel builds.
  131. #
  132. # The final PDB for libraries and programs is created by the linker and uses
  133. # a different name from the single PDB file created by the compiler. See
  134. # bug 462740.
  135. #
  136. ifdef SIMPLE_PROGRAMS
  137. COMPILE_PDB_FLAG ?= -Fd$(basename $(@F)).pdb
  138. else
  139. COMPILE_PDB_FLAG ?= -Fdgenerated.pdb
  140. endif
  141. COMPILE_CFLAGS += $(COMPILE_PDB_FLAG)
  142. COMPILE_CXXFLAGS += $(COMPILE_PDB_FLAG)
  143. LINK_PDBFILE ?= $(basename $(@F)).pdb
  144. ifdef MOZ_DEBUG
  145. CODFILE=$(basename $(@F)).cod
  146. endif
  147. ifdef DEFFILE
  148. OS_LDFLAGS += -DEF:$(call normalizepath,$(DEFFILE))
  149. EXTRA_DEPS += $(DEFFILE)
  150. endif
  151. else #!GNU_CC
  152. ifdef DEFFILE
  153. OS_LDFLAGS += $(call normalizepath,$(DEFFILE))
  154. EXTRA_DEPS += $(DEFFILE)
  155. endif
  156. endif # !GNU_CC
  157. endif # WINNT
  158. ifeq (arm-Darwin,$(CPU_ARCH)-$(OS_TARGET))
  159. ifdef PROGRAM
  160. MOZ_PROGRAM_LDFLAGS += -Wl,-rpath -Wl,@executable_path/Frameworks
  161. endif
  162. endif
  163. ifeq ($(HOST_OS_ARCH),WINNT)
  164. HOST_PDBFILE=$(basename $(@F)).pdb
  165. HOST_PDB_FLAG ?= -Fd$(HOST_PDBFILE)
  166. HOST_CFLAGS += $(HOST_PDB_FLAG)
  167. HOST_CXXFLAGS += $(HOST_PDB_FLAG)
  168. endif
  169. # Don't build SIMPLE_PROGRAMS during the MOZ_PROFILE_GENERATE pass
  170. ifdef MOZ_PROFILE_GENERATE
  171. SIMPLE_PROGRAMS :=
  172. endif
  173. ifdef COMPILE_ENVIRONMENT
  174. ifndef TARGETS
  175. TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS)
  176. endif
  177. COBJS = $(notdir $(CSRCS:.c=.$(OBJ_SUFFIX)))
  178. SOBJS = $(notdir $(SSRCS:.S=.$(OBJ_SUFFIX)))
  179. # CPPSRCS can have different extensions (eg: .cpp, .cc)
  180. CPPOBJS = $(notdir $(addsuffix .$(OBJ_SUFFIX),$(basename $(CPPSRCS))))
  181. CMOBJS = $(notdir $(CMSRCS:.m=.$(OBJ_SUFFIX)))
  182. CMMOBJS = $(notdir $(CMMSRCS:.mm=.$(OBJ_SUFFIX)))
  183. # ASFILES can have different extensions (.s, .asm)
  184. ASOBJS = $(notdir $(addsuffix .$(OBJ_SUFFIX),$(basename $(ASFILES))))
  185. RS_STATICLIB_CRATE_OBJ = $(addprefix lib,$(notdir $(RS_STATICLIB_CRATE_SRC:.rs=.$(LIB_SUFFIX))))
  186. ifndef OBJS
  187. _OBJS = $(COBJS) $(SOBJS) $(CPPOBJS) $(CMOBJS) $(CMMOBJS) $(ASOBJS)
  188. OBJS = $(strip $(_OBJS))
  189. endif
  190. HOST_COBJS = $(addprefix host_,$(notdir $(HOST_CSRCS:.c=.$(OBJ_SUFFIX))))
  191. # HOST_CPPOBJS can have different extensions (eg: .cpp, .cc)
  192. HOST_CPPOBJS = $(addprefix host_,$(notdir $(addsuffix .$(OBJ_SUFFIX),$(basename $(HOST_CPPSRCS)))))
  193. HOST_CMOBJS = $(addprefix host_,$(notdir $(HOST_CMSRCS:.m=.$(OBJ_SUFFIX))))
  194. HOST_CMMOBJS = $(addprefix host_,$(notdir $(HOST_CMMSRCS:.mm=.$(OBJ_SUFFIX))))
  195. ifndef HOST_OBJS
  196. _HOST_OBJS = $(HOST_COBJS) $(HOST_CPPOBJS) $(HOST_CMOBJS) $(HOST_CMMOBJS)
  197. HOST_OBJS = $(strip $(_HOST_OBJS))
  198. endif
  199. else
  200. LIBRARY :=
  201. SHARED_LIBRARY :=
  202. IMPORT_LIBRARY :=
  203. REAL_LIBRARY :=
  204. PROGRAM :=
  205. SIMPLE_PROGRAMS :=
  206. HOST_LIBRARY :=
  207. HOST_PROGRAM :=
  208. HOST_SIMPLE_PROGRAMS :=
  209. SDK_LIBRARY :=
  210. endif
  211. ALL_TRASH = \
  212. $(GARBAGE) $(TARGETS) $(OBJS) $(PROGOBJS) LOGS TAGS a.out \
  213. $(filter-out $(ASFILES),$(OBJS:.$(OBJ_SUFFIX)=.s)) $(OBJS:.$(OBJ_SUFFIX)=.ii) \
  214. $(OBJS:.$(OBJ_SUFFIX)=.i) $(OBJS:.$(OBJ_SUFFIX)=.i_o) \
  215. $(HOST_PROGOBJS) $(HOST_OBJS) $(IMPORT_LIBRARY) \
  216. $(EXE_DEF_FILE) so_locations _gen _stubs $(wildcard *.res) $(wildcard *.RES) \
  217. $(wildcard *.pdb) $(CODFILE) $(IMPORT_LIBRARY) \
  218. $(SHARED_LIBRARY:$(DLL_SUFFIX)=.exp) $(wildcard *.ilk) \
  219. $(PROGRAM:$(BIN_SUFFIX)=.exp) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.exp) \
  220. $(PROGRAM:$(BIN_SUFFIX)=.lib) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.lib) \
  221. $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.$(OBJ_SUFFIX)) \
  222. $(wildcard gts_tmp_*) $(LIBRARY:%.a=.%.timestamp)
  223. ALL_TRASH_DIRS = \
  224. $(GARBAGE_DIRS) /no-such-file
  225. ifdef QTDIR
  226. GARBAGE += $(MOCSRCS)
  227. endif
  228. ifdef SIMPLE_PROGRAMS
  229. GARBAGE += $(SIMPLE_PROGRAMS:%=%.$(OBJ_SUFFIX))
  230. endif
  231. ifdef HOST_SIMPLE_PROGRAMS
  232. GARBAGE += $(HOST_SIMPLE_PROGRAMS:%=%.$(OBJ_SUFFIX))
  233. endif
  234. ifdef MACH
  235. ifndef NO_BUILDSTATUS_MESSAGES
  236. define BUILDSTATUS
  237. @echo 'BUILDSTATUS $1'
  238. endef
  239. endif
  240. endif
  241. define SUBMAKE # $(call SUBMAKE,target,directory,static)
  242. +@$(MAKE) $(if $(2),-C $(2)) $(1)
  243. endef # The extra line is important here! don't delete it
  244. define TIER_DIR_SUBMAKE
  245. $(call SUBMAKE,$(4),$(3),$(5))
  246. endef # Ths empty line is important.
  247. ifneq (,$(strip $(DIRS)))
  248. LOOP_OVER_DIRS = \
  249. $(foreach dir,$(DIRS),$(call SUBMAKE,$@,$(dir)))
  250. endif
  251. #
  252. # Now we can differentiate between objects used to build a library, and
  253. # objects used to build an executable in the same directory.
  254. #
  255. ifndef PROGOBJS
  256. PROGOBJS = $(OBJS)
  257. endif
  258. ifndef HOST_PROGOBJS
  259. HOST_PROGOBJS = $(HOST_OBJS)
  260. endif
  261. GARBAGE_DIRS += $(wildcard $(CURDIR)/$(MDDEPDIR))
  262. #
  263. # Tags: emacs (etags), vi (ctags)
  264. # TAG_PROGRAM := ctags -L -
  265. #
  266. TAG_PROGRAM = xargs etags -a
  267. #
  268. # Turn on C++ linking if we have any .cpp or .mm files
  269. # (moved this from config.mk so that config.mk can be included
  270. # before the CPPSRCS are defined)
  271. #
  272. ifneq ($(HOST_CPPSRCS)$(HOST_CMMSRCS),)
  273. HOST_CPP_PROG_LINK = 1
  274. endif
  275. #
  276. # This will strip out symbols that the component should not be
  277. # exporting from the .dynsym section.
  278. #
  279. ifdef IS_COMPONENT
  280. EXTRA_DSO_LDOPTS += $(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
  281. endif # IS_COMPONENT
  282. #
  283. # MacOS X specific stuff
  284. #
  285. ifeq ($(OS_ARCH),Darwin)
  286. ifdef SHARED_LIBRARY
  287. ifdef IS_COMPONENT
  288. EXTRA_DSO_LDOPTS += -bundle
  289. else
  290. ifdef MOZ_IOS
  291. _LOADER_PATH := @rpath
  292. else
  293. _LOADER_PATH := @executable_path
  294. endif
  295. EXTRA_DSO_LDOPTS += -dynamiclib -install_name $(_LOADER_PATH)/$(SHARED_LIBRARY) -compatibility_version 1 -current_version 1 -single_module
  296. endif
  297. endif
  298. endif
  299. #
  300. # On NetBSD a.out systems, use -Bsymbolic. This fixes what would otherwise be
  301. # fatal symbol name clashes between components.
  302. #
  303. ifeq ($(OS_ARCH),NetBSD)
  304. ifeq ($(DLL_SUFFIX),.so.1.0)
  305. ifdef IS_COMPONENT
  306. EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
  307. endif
  308. endif
  309. endif
  310. ifeq ($(OS_ARCH),FreeBSD)
  311. ifdef IS_COMPONENT
  312. EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
  313. endif
  314. endif
  315. ifeq ($(OS_ARCH),NetBSD)
  316. ifneq (,$(filter arc cobalt hpcmips mipsco newsmips pmax sgimips,$(OS_TEST)))
  317. ifneq (,$(filter layout/%,$(relativesrcdir)))
  318. OS_CFLAGS += -Wa,-xgot
  319. OS_CXXFLAGS += -Wa,-xgot
  320. endif
  321. endif
  322. endif
  323. #
  324. # Linux: add -Bsymbolic flag for components
  325. #
  326. ifeq ($(OS_ARCH),Linux)
  327. ifdef IS_COMPONENT
  328. EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
  329. endif
  330. ifdef LD_VERSION_SCRIPT
  331. EXTRA_DSO_LDOPTS += -Wl,--version-script,$(LD_VERSION_SCRIPT)
  332. EXTRA_DEPS += $(LD_VERSION_SCRIPT)
  333. endif
  334. endif
  335. ifdef SYMBOLS_FILE
  336. ifeq ($(OS_TARGET),WINNT)
  337. ifndef GNU_CC
  338. EXTRA_DSO_LDOPTS += -DEF:$(call normalizepath,$(SYMBOLS_FILE))
  339. else
  340. EXTRA_DSO_LDOPTS += $(call normalizepath,$(SYMBOLS_FILE))
  341. endif
  342. else
  343. ifdef GCC_USE_GNU_LD
  344. EXTRA_DSO_LDOPTS += -Wl,--version-script,$(SYMBOLS_FILE)
  345. else
  346. ifeq ($(OS_TARGET),Darwin)
  347. EXTRA_DSO_LDOPTS += -Wl,-exported_symbols_list,$(SYMBOLS_FILE)
  348. endif
  349. endif
  350. endif
  351. EXTRA_DEPS += $(SYMBOLS_FILE)
  352. endif
  353. #
  354. # GNU doesn't have path length limitation
  355. #
  356. ifeq ($(OS_ARCH),GNU)
  357. OS_CPPFLAGS += -DPATH_MAX=1024 -DMAXPATHLEN=1024
  358. endif
  359. #
  360. # MINGW32
  361. #
  362. ifeq ($(OS_ARCH),WINNT)
  363. ifdef GNU_CC
  364. ifndef IS_COMPONENT
  365. DSO_LDOPTS += -Wl,--out-implib -Wl,$(IMPORT_LIBRARY)
  366. endif
  367. endif
  368. endif
  369. ifeq ($(USE_TVFS),1)
  370. IFLAGS1 = -rb
  371. IFLAGS2 = -rb
  372. else
  373. IFLAGS1 = -m 644
  374. IFLAGS2 = -m 755
  375. endif
  376. ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
  377. OUTOPTION = -Fo# eol
  378. else
  379. OUTOPTION = -o # eol
  380. endif # WINNT && !GNU_CC
  381. ifneq (,$(filter ml%,$(AS)))
  382. ASOUTOPTION = -Fo# eol
  383. else
  384. ASOUTOPTION = -o # eol
  385. endif
  386. ifeq (,$(CROSS_COMPILE))
  387. HOST_OUTOPTION = $(OUTOPTION)
  388. else
  389. HOST_OUTOPTION = -o # eol
  390. endif
  391. ################################################################################
  392. # Ensure the build config is up to date. This is done automatically when builds
  393. # are performed through |mach build|. The check here is to catch people not
  394. # using mach. If we ever enforce builds through mach, this code can be removed.
  395. ifndef MOZBUILD_BACKEND_CHECKED
  396. ifndef MACH
  397. ifndef TOPLEVEL_BUILD
  398. BUILD_BACKEND_FILES := $(addprefix $(DEPTH)/backend.,$(addsuffix Backend,$(BUILD_BACKENDS)))
  399. $(DEPTH)/backend.%Backend:
  400. $(error Build configuration changed. Build with |mach build| or run |mach build-backend| to regenerate build config)
  401. define build_backend_rule
  402. $(1): $$(shell cat $(1).in)
  403. endef
  404. $(foreach file,$(BUILD_BACKEND_FILES),$(eval $(call build_backend_rule,$(file))))
  405. default:: $(BUILD_BACKEND_FILES)
  406. export MOZBUILD_BACKEND_CHECKED=1
  407. endif
  408. endif
  409. endif
  410. # The root makefile doesn't want to do a plain export/libs, because
  411. # of the tiers and because of libxul. Suppress the default rules in favor
  412. # of something else. Makefiles which use this var *must* provide a sensible
  413. # default rule before including rules.mk
  414. default all::
  415. $(foreach tier,$(TIERS),$(call SUBMAKE,$(tier)))
  416. ifeq ($(findstring s,$(filter-out --%, $(MAKEFLAGS))),)
  417. ECHO := echo
  418. QUIET :=
  419. else
  420. ECHO := true
  421. QUIET := -q
  422. endif
  423. # Do everything from scratch
  424. everything::
  425. $(MAKE) clean
  426. $(MAKE) all
  427. STATIC_LIB_DEP = $(if $(wildcard $(1).$(LIBS_DESC_SUFFIX)),$(1).$(LIBS_DESC_SUFFIX),$(1))
  428. STATIC_LIBS_DEPS := $(foreach l,$(STATIC_LIBS),$(call STATIC_LIB_DEP,$(l)))
  429. # Dependencies which, if modified, should cause everything to rebuild
  430. GLOBAL_DEPS += Makefile $(addprefix $(DEPTH)/config/,$(INCLUDED_AUTOCONF_MK)) $(MOZILLA_DIR)/config/config.mk
  431. ##############################################
  432. ifdef COMPILE_ENVIRONMENT
  433. OBJ_TARGETS = $(OBJS) $(PROGOBJS) $(HOST_OBJS) $(HOST_PROGOBJS)
  434. compile:: host target
  435. host:: $(HOST_LIBRARY) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS)
  436. target:: $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(RUST_LIBRARY_FILE)
  437. include $(MOZILLA_DIR)/config/makefiles/target_binaries.mk
  438. endif
  439. ##############################################
  440. ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE))
  441. ifdef MOZ_PROFILE_USE
  442. ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_)
  443. # When building with PGO, we have to make sure to re-link
  444. # in the MOZ_PROFILE_USE phase if we linked in the
  445. # MOZ_PROFILE_GENERATE phase. We'll touch this pgo.relink
  446. # file in the link rule in the GENERATE phase to indicate
  447. # that we need a relink.
  448. ifdef SHARED_LIBRARY
  449. $(SHARED_LIBRARY): pgo.relink
  450. endif
  451. ifdef PROGRAM
  452. $(PROGRAM): pgo.relink
  453. endif
  454. # In the second pass, we need to merge the pgc files into the pgd file.
  455. # The compiler would do this for us automatically if they were in the right
  456. # place, but they're in dist/bin.
  457. ifneq (,$(SHARED_LIBRARY)$(PROGRAM))
  458. export::
  459. ifdef PROGRAM
  460. $(PYTHON) $(MOZILLA_DIR)/build/win32/pgomerge.py \
  461. $(PROGRAM:$(BIN_SUFFIX)=) $(DIST)/bin
  462. endif
  463. ifdef SHARED_LIBRARY
  464. $(PYTHON) $(MOZILLA_DIR)/build/win32/pgomerge.py \
  465. $(patsubst $(DLL_PREFIX)%$(DLL_SUFFIX),%,$(SHARED_LIBRARY)) $(DIST)/bin
  466. endif
  467. endif # SHARED_LIBRARY || PROGRAM
  468. endif # WINNT_
  469. endif # MOZ_PROFILE_USE
  470. ifdef MOZ_PROFILE_GENERATE
  471. # Clean up profiling data during PROFILE_GENERATE phase
  472. export::
  473. ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_)
  474. $(foreach pgd,$(wildcard *.pgd),pgomgr -clear $(pgd);)
  475. else
  476. ifdef GNU_CC
  477. -$(RM) *.gcda
  478. endif
  479. endif
  480. endif
  481. ifneq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
  482. ifdef GNU_CC
  483. # Force rebuilding libraries and programs in both passes because each
  484. # pass uses different object files.
  485. $(PROGRAM) $(SHARED_LIBRARY) $(LIBRARY): FORCE
  486. endif
  487. endif
  488. endif # NO_PROFILE_GUIDED_OPTIMIZE
  489. ##############################################
  490. checkout:
  491. $(MAKE) -C $(topsrcdir) -f client.mk checkout
  492. clean clobber realclean clobber_all::
  493. -$(RM) $(ALL_TRASH)
  494. -$(RM) -r $(ALL_TRASH_DIRS)
  495. clean clobber realclean clobber_all distclean::
  496. $(foreach dir,$(DIRS),-$(call SUBMAKE,$@,$(dir)))
  497. distclean::
  498. -$(RM) -r $(ALL_TRASH_DIRS)
  499. -$(RM) $(ALL_TRASH) \
  500. Makefile .HSancillary \
  501. $(wildcard *.$(OBJ_SUFFIX)) $(wildcard *.ho) $(wildcard host_*.o*) \
  502. $(wildcard *.$(LIB_SUFFIX)) $(wildcard *$(DLL_SUFFIX)) \
  503. $(wildcard *.$(IMPORT_LIB_SUFFIX))
  504. alltags:
  505. $(RM) TAGS
  506. find $(topsrcdir) -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' -o -name '*.idl' \) -print | $(TAG_PROGRAM)
  507. #
  508. # PROGRAM = Foo
  509. # creates OBJS, links with LIBS to create Foo
  510. #
  511. $(PROGRAM): $(PROGOBJS) $(STATIC_LIBS_DEPS) $(EXTRA_DEPS) $(EXE_DEF_FILE) $(RESFILE) $(GLOBAL_DEPS)
  512. $(REPORT_BUILD)
  513. @$(RM) $@.manifest
  514. ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
  515. $(EXPAND_LD) -NOLOGO -OUT:$@ -PDB:$(LINK_PDBFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_PROGRAM_LDFLAGS) $(PROGOBJS) $(RESFILE) $(STATIC_LIBS) $(SHARED_LIBS) $(EXTRA_LIBS) $(OS_LIBS)
  516. ifdef MSMANIFEST_TOOL
  517. @if test -f $@.manifest; then \
  518. if test -f '$(srcdir)/$@.manifest'; then \
  519. echo 'Embedding manifest from $(srcdir)/$@.manifest and $@.manifest'; \
  520. $(MT) -NOLOGO -MANIFEST '$(win_srcdir)/$@.manifest' $@.manifest -OUTPUTRESOURCE:$@\;1; \
  521. else \
  522. echo 'Embedding manifest from $@.manifest'; \
  523. $(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
  524. fi; \
  525. elif test -f '$(srcdir)/$@.manifest'; then \
  526. echo 'Embedding manifest from $(srcdir)/$@.manifest'; \
  527. $(MT) -NOLOGO -MANIFEST '$(win_srcdir)/$@.manifest' -OUTPUTRESOURCE:$@\;1; \
  528. fi
  529. endif # MSVC with manifest tool
  530. ifdef MOZ_PROFILE_GENERATE
  531. # touch it a few seconds into the future to work around FAT's
  532. # 2-second granularity
  533. touch -t `date +%Y%m%d%H%M.%S -d 'now+5seconds'` pgo.relink
  534. endif
  535. else # !WINNT || GNU_CC
  536. $(EXPAND_CCC) -o $@ $(CXXFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(EXTRA_LIBS) $(OS_LIBS) $(BIN_FLAGS) $(EXE_DEF_FILE)
  537. $(call CHECK_BINARY,$@)
  538. endif # WINNT && !GNU_CC
  539. ifdef ENABLE_STRIP
  540. $(STRIP) $(STRIP_FLAGS) $@
  541. endif
  542. ifdef MOZ_POST_PROGRAM_COMMAND
  543. $(MOZ_POST_PROGRAM_COMMAND) $@
  544. endif
  545. $(HOST_PROGRAM): $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
  546. $(REPORT_BUILD)
  547. ifeq (_WINNT,$(GNU_CC)_$(HOST_OS_ARCH))
  548. $(EXPAND_LIBS_EXEC) -- $(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $(HOST_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
  549. ifdef MSMANIFEST_TOOL
  550. @if test -f $@.manifest; then \
  551. if test -f '$(srcdir)/$@.manifest'; then \
  552. echo 'Embedding manifest from $(srcdir)/$@.manifest and $@.manifest'; \
  553. $(MT) -NOLOGO -MANIFEST '$(win_srcdir)/$@.manifest' $@.manifest -OUTPUTRESOURCE:$@\;1; \
  554. else \
  555. echo 'Embedding manifest from $@.manifest'; \
  556. $(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
  557. fi; \
  558. elif test -f '$(srcdir)/$@.manifest'; then \
  559. echo 'Embedding manifest from $(srcdir)/$@.manifest'; \
  560. $(MT) -NOLOGO -MANIFEST '$(win_srcdir)/$@.manifest' -OUTPUTRESOURCE:$@\;1; \
  561. fi
  562. endif # MSVC with manifest tool
  563. else
  564. ifeq ($(HOST_CPP_PROG_LINK),1)
  565. $(EXPAND_LIBS_EXEC) -- $(HOST_CXX) -o $@ $(HOST_CXXFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
  566. else
  567. $(EXPAND_LIBS_EXEC) -- $(HOST_CC) -o $@ $(HOST_CFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
  568. endif # HOST_CPP_PROG_LINK
  569. endif
  570. ifndef CROSS_COMPILE
  571. $(call CHECK_STDCXX,$@)
  572. endif
  573. #
  574. # This is an attempt to support generation of multiple binaries
  575. # in one directory, it assumes everything to compile Foo is in
  576. # Foo.o (from either Foo.c or Foo.cpp).
  577. #
  578. # SIMPLE_PROGRAMS = Foo Bar
  579. # creates Foo.o Bar.o, links with LIBS to create Foo, Bar.
  580. #
  581. $(SIMPLE_PROGRAMS): %$(BIN_SUFFIX): %.$(OBJ_SUFFIX) $(STATIC_LIBS_DEPS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
  582. $(REPORT_BUILD)
  583. ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
  584. $(EXPAND_LD) -nologo -out:$@ -pdb:$(LINK_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_PROGRAM_LDFLAGS) $(STATIC_LIBS) $(SHARED_LIBS) $(EXTRA_LIBS) $(OS_LIBS)
  585. ifdef MSMANIFEST_TOOL
  586. @if test -f $@.manifest; then \
  587. $(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
  588. rm -f $@.manifest; \
  589. fi
  590. endif # MSVC with manifest tool
  591. else
  592. $(EXPAND_CCC) $(CXXFLAGS) -o $@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(EXTRA_LIBS) $(OS_LIBS) $(BIN_FLAGS)
  593. $(call CHECK_BINARY,$@)
  594. endif # WINNT && !GNU_CC
  595. ifdef ENABLE_STRIP
  596. $(STRIP) $(STRIP_FLAGS) $@
  597. endif
  598. ifdef MOZ_POST_PROGRAM_COMMAND
  599. $(MOZ_POST_PROGRAM_COMMAND) $@
  600. endif
  601. $(HOST_SIMPLE_PROGRAMS): host_%$(HOST_BIN_SUFFIX): host_%.$(OBJ_SUFFIX) $(HOST_LIBS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
  602. $(REPORT_BUILD)
  603. ifeq (WINNT_,$(HOST_OS_ARCH)_$(GNU_CC))
  604. $(EXPAND_LIBS_EXEC) -- $(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
  605. else
  606. ifneq (,$(HOST_CPPSRCS)$(USE_HOST_CXX))
  607. $(EXPAND_LIBS_EXEC) -- $(HOST_CXX) $(HOST_OUTOPTION)$@ $(HOST_CXXFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
  608. else
  609. $(EXPAND_LIBS_EXEC) -- $(HOST_CC) $(HOST_OUTOPTION)$@ $(HOST_CFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
  610. endif
  611. endif
  612. ifndef CROSS_COMPILE
  613. $(call CHECK_STDCXX,$@)
  614. endif
  615. ifdef DTRACE_PROBE_OBJ
  616. EXTRA_DEPS += $(DTRACE_PROBE_OBJ)
  617. OBJS += $(DTRACE_PROBE_OBJ)
  618. endif
  619. $(filter %.$(LIB_SUFFIX),$(LIBRARY)): $(OBJS) $(STATIC_LIBS_DEPS) $(filter %.$(LIB_SUFFIX),$(EXTRA_LIBS)) $(EXTRA_DEPS) $(GLOBAL_DEPS)
  620. $(REPORT_BUILD)
  621. # Always remove both library and library descriptor
  622. $(RM) $(REAL_LIBRARY) $(REAL_LIBRARY).$(LIBS_DESC_SUFFIX)
  623. $(EXPAND_AR) $(AR_FLAGS) $(OBJS) $(STATIC_LIBS) $(filter %.$(LIB_SUFFIX),$(EXTRA_LIBS))
  624. $(filter-out %.$(LIB_SUFFIX),$(LIBRARY)): $(filter %.$(LIB_SUFFIX),$(LIBRARY)) $(OBJS) $(STATIC_LIBS_DEPS) $(filter %.$(LIB_SUFFIX),$(EXTRA_LIBS)) $(EXTRA_DEPS) $(GLOBAL_DEPS)
  625. # When we only build a library descriptor, blow out any existing library
  626. $(REPORT_BUILD)
  627. $(if $(filter %.$(LIB_SUFFIX),$(LIBRARY)),,$(RM) $(REAL_LIBRARY))
  628. $(EXPAND_LIBS_GEN) -o $@ $(OBJS) $(STATIC_LIBS) $(filter %.$(LIB_SUFFIX),$(EXTRA_LIBS))
  629. ifeq ($(OS_ARCH),WINNT)
  630. # Import libraries are created by the rules creating shared libraries.
  631. # The rules to copy them to $(DIST)/lib depend on $(IMPORT_LIBRARY),
  632. # but make will happily consider the import library before it is refreshed
  633. # when rebuilding the corresponding shared library. Defining an empty recipe
  634. # for import libraries forces make to wait for the shared library recipe to
  635. # have run before considering other targets that depend on the import library.
  636. # See bug 795204.
  637. $(IMPORT_LIBRARY): $(SHARED_LIBRARY) ;
  638. endif
  639. $(HOST_LIBRARY): $(HOST_OBJS) Makefile
  640. $(REPORT_BUILD)
  641. $(RM) $@
  642. $(EXPAND_LIBS_EXEC) --extract -- $(HOST_AR) $(HOST_AR_FLAGS) $(HOST_OBJS)
  643. ifdef HAVE_DTRACE
  644. ifdef DTRACE_PROBE_OBJ
  645. ifndef DTRACE_LIB_DEPENDENT
  646. NON_DTRACE_OBJS := $(filter-out $(DTRACE_PROBE_OBJ),$(OBJS))
  647. $(DTRACE_PROBE_OBJ): $(NON_DTRACE_OBJS)
  648. dtrace -x nolibs -G -C -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(NON_DTRACE_OBJS)
  649. endif
  650. endif
  651. endif
  652. # On Darwin (Mac OS X), dwarf2 debugging uses debug info left in .o files,
  653. # so instead of deleting .o files after repacking them into a dylib, we make
  654. # symlinks back to the originals. The symlinks are a no-op for stabs debugging,
  655. # so no need to conditionalize on OS version or debugging format.
  656. $(SHARED_LIBRARY): $(OBJS) $(RESFILE) $(RUST_STATIC_LIB_FOR_SHARED_LIB) $(STATIC_LIBS_DEPS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
  657. $(REPORT_BUILD)
  658. ifndef INCREMENTAL_LINKER
  659. $(RM) $@
  660. endif
  661. ifdef DTRACE_LIB_DEPENDENT
  662. dtrace -x nolibs -G -C -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(shell $(EXPAND_LIBS) $(MOZILLA_PROBE_LIBS))
  663. $(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(SUB_SHLOBJS) $(DTRACE_PROBE_OBJ) $(MOZILLA_PROBE_LIBS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(STATIC_LIBS) $(RUST_STATIC_LIB_FOR_SHARED_LIB) $(SHARED_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(EXTRA_LIBS) $(OS_LIBS) $(SHLIB_LDENDFILE)
  664. @$(RM) $(DTRACE_PROBE_OBJ)
  665. else # ! DTRACE_LIB_DEPENDENT
  666. $(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(SUB_SHLOBJS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(STATIC_LIBS) $(RUST_STATIC_LIB_FOR_SHARED_LIB) $(SHARED_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(EXTRA_LIBS) $(OS_LIBS) $(SHLIB_LDENDFILE)
  667. endif # DTRACE_LIB_DEPENDENT
  668. $(call CHECK_BINARY,$@)
  669. ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
  670. ifdef MSMANIFEST_TOOL
  671. ifdef EMBED_MANIFEST_AT
  672. @if test -f $@.manifest; then \
  673. if test -f '$(srcdir)/$@.manifest'; then \
  674. echo 'Embedding manifest from $(srcdir)/$@.manifest and $@.manifest'; \
  675. $(MT) -NOLOGO -MANIFEST '$(win_srcdir)/$@.manifest' $@.manifest -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
  676. else \
  677. echo 'Embedding manifest from $@.manifest'; \
  678. $(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
  679. fi; \
  680. elif test -f '$(srcdir)/$@.manifest'; then \
  681. echo 'Embedding manifest from $(srcdir)/$@.manifest'; \
  682. $(MT) -NOLOGO -MANIFEST '$(win_srcdir)/$@.manifest' -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
  683. fi
  684. endif # EMBED_MANIFEST_AT
  685. endif # MSVC with manifest tool
  686. ifdef MOZ_PROFILE_GENERATE
  687. touch -t `date +%Y%m%d%H%M.%S -d 'now+5seconds'` pgo.relink
  688. endif
  689. endif # WINNT && !GCC
  690. chmod +x $@
  691. ifdef ENABLE_STRIP
  692. $(STRIP) $(STRIP_FLAGS) $@
  693. endif
  694. # The object file is in the current directory, and the source file can be any
  695. # relative path. This macro adds the dependency obj: src for each source file.
  696. # This dependency must be first for the $< flag to work correctly, and the
  697. # rules that have commands for these targets must not list any other
  698. # prerequisites, or they will override the $< variable.
  699. define src_objdep
  700. $(basename $2$(notdir $1)).$(OBJ_SUFFIX): $1 $$(call mkdir_deps,$$(MDDEPDIR))
  701. endef
  702. $(foreach f,$(CSRCS) $(SSRCS) $(CPPSRCS) $(CMSRCS) $(CMMSRCS) $(ASFILES),$(eval $(call src_objdep,$(f))))
  703. $(foreach f,$(HOST_CSRCS) $(HOST_CPPSRCS) $(HOST_CMSRCS) $(HOST_CMMSRCS),$(eval $(call src_objdep,$(f),host_)))
  704. # The Rust compiler only outputs library objects, and so we need different
  705. # mangling to generate dependency rules for it.
  706. mk_libname = $(basename lib$(notdir $1)).rlib
  707. src_libdep = $(call mk_libname,$1): $1 $$(call mkdir_deps,$$(MDDEPDIR))
  708. mk_global_crate_libname = $(basename lib$(notdir $1)).$(LIB_SUFFIX)
  709. crate_src_libdep = $(call mk_global_crate_libname,$1): $1 $$(call mkdir_deps,$$(MDDEPDIR))
  710. $(foreach f,$(RSSRCS),$(eval $(call src_libdep,$(f))))
  711. $(foreach f,$(RS_STATICLIB_CRATE_SRC),$(eval $(call crate_src_libdep,$(f))))
  712. $(OBJS) $(HOST_OBJS) $(PROGOBJS) $(HOST_PROGOBJS): $(GLOBAL_DEPS)
  713. # Rules for building native targets must come first because of the host_ prefix
  714. $(HOST_COBJS):
  715. $(REPORT_BUILD_VERBOSE)
  716. $(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
  717. $(HOST_CPPOBJS):
  718. $(REPORT_BUILD_VERBOSE)
  719. $(call BUILDSTATUS,OBJECT_FILE $@)
  720. $(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
  721. $(HOST_CMOBJS):
  722. $(REPORT_BUILD_VERBOSE)
  723. $(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CFLAGS) $(HOST_CMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
  724. $(HOST_CMMOBJS):
  725. $(REPORT_BUILD_VERBOSE)
  726. $(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CXXFLAGS) $(HOST_CMMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
  727. $(COBJS):
  728. $(REPORT_BUILD_VERBOSE)
  729. $(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
  730. # DEFINES and ACDEFINES are needed here to enable conditional compilation of Q_OBJECTs:
  731. # 'moc' only knows about #defines it gets on the command line (-D...), not in
  732. # included headers like mozilla-config.h
  733. $(filter moc_%.cpp,$(CPPSRCS)): moc_%.cpp: %.h
  734. $(REPORT_BUILD_VERBOSE)
  735. $(ELOG) $(MOC) $(DEFINES) $(ACDEFINES) $< $(OUTOPTION)$@
  736. $(filter moc_%.cc,$(CPPSRCS)): moc_%.cc: %.cc
  737. $(REPORT_BUILD_VERBOSE)
  738. $(ELOG) $(MOC) $(DEFINES) $(ACDEFINES) $(_VPATH_SRCS:.cc=.h) $(OUTOPTION)$@
  739. $(filter qrc_%.cpp,$(CPPSRCS)): qrc_%.cpp: %.qrc
  740. $(REPORT_BUILD_VERBOSE)
  741. $(ELOG) $(RCC) -name $* $< $(OUTOPTION)$@
  742. ifdef ASFILES
  743. # The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept
  744. # a '-c' flag.
  745. $(ASOBJS):
  746. $(REPORT_BUILD_VERBOSE)
  747. $(AS) $(ASOUTOPTION)$@ $(ASFLAGS) $($(notdir $<)_FLAGS) $(AS_DASH_C_FLAG) $(_VPATH_SRCS)
  748. endif
  749. $(SOBJS):
  750. $(REPORT_BUILD)
  751. $(AS) -o $@ $(DEFINES) $(ASFLAGS) $($(notdir $<)_FLAGS) $(LOCAL_INCLUDES) -c $<
  752. $(CPPOBJS):
  753. $(REPORT_BUILD_VERBOSE)
  754. $(call BUILDSTATUS,OBJECT_FILE $@)
  755. $(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
  756. $(CMMOBJS):
  757. $(REPORT_BUILD_VERBOSE)
  758. $(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
  759. $(CMOBJS):
  760. $(REPORT_BUILD_VERBOSE)
  761. $(ELOG) $(CC) -o $@ -c $(COMPILE_CFLAGS) $(COMPILE_CMFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
  762. $(filter %.s,$(CPPSRCS:%.cpp=%.s)): %.s: %.cpp $(call mkdir_deps,$(MDDEPDIR))
  763. $(REPORT_BUILD_VERBOSE)
  764. $(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
  765. $(filter %.s,$(CPPSRCS:%.cc=%.s)): %.s: %.cc $(call mkdir_deps,$(MDDEPDIR))
  766. $(REPORT_BUILD_VERBOSE)
  767. $(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
  768. $(filter %.s,$(CPPSRCS:%.cxx=%.s)): %.s: %.cpp $(call mkdir_deps,$(MDDEPDIR))
  769. $(REPORT_BUILD_VERBOSE)
  770. $(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
  771. $(filter %.s,$(CSRCS:%.c=%.s)): %.s: %.c $(call mkdir_deps,$(MDDEPDIR))
  772. $(REPORT_BUILD_VERBOSE)
  773. $(CC) -S $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
  774. ifneq (,$(filter %.i,$(MAKECMDGOALS)))
  775. # Call as $(call _group_srcs,extension,$(SRCS)) - this will create a list
  776. # of the full sources, as well as the $(notdir) version. So:
  777. # foo.cpp sub/bar.cpp
  778. # becomes:
  779. # foo.cpp sub/bar.cpp bar.cpp
  780. #
  781. # This way we can match both 'make sub/bar.i' and 'make bar.i'
  782. _group_srcs = $(sort $(patsubst %.$1,%.i,$(filter %.$1,$2 $(notdir $2))))
  783. _PREPROCESSED_CPP_FILES := $(call _group_srcs,cpp,$(CPPSRCS))
  784. _PREPROCESSED_CC_FILES := $(call _group_srcs,cc,$(CPPSRCS))
  785. _PREPROCESSED_CXX_FILES := $(call _group_srcs,cxx,$(CPPSRCS))
  786. _PREPROCESSED_C_FILES := $(call _group_srcs,c,$(CSRCS))
  787. _PREPROCESSED_CMM_FILES := $(call _group_srcs,mm,$(CMMSRCS))
  788. # Hack up VPATH so we can reach the sources. Eg: 'make Parser.i' may need to
  789. # reach $(srcdir)/frontend/Parser.i
  790. VPATH += $(addprefix $(srcdir)/,$(sort $(dir $(CPPSRCS) $(CSRCS) $(CMMSRCS))))
  791. # Make preprocessed files PHONY so they are always executed, since they are
  792. # manual targets and we don't necessarily write to $@.
  793. .PHONY: $(_PREPROCESSED_CPP_FILES) $(_PREPROCESSED_CC_FILES) $(_PREPROCESSED_CXX_FILES) $(_PREPROCESSED_C_FILES) $(_PREPROCESSED_CMM_FILES)
  794. $(_PREPROCESSED_CPP_FILES): %.i: %.cpp $(call mkdir_deps,$(MDDEPDIR))
  795. $(REPORT_BUILD_VERBOSE)
  796. $(addprefix $(MKDIR) -p ,$(filter-out .,$(@D)))
  797. $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
  798. $(_PREPROCESSED_CC_FILES): %.i: %.cc $(call mkdir_deps,$(MDDEPDIR))
  799. $(REPORT_BUILD_VERBOSE)
  800. $(addprefix $(MKDIR) -p ,$(filter-out .,$(@D)))
  801. $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
  802. $(_PREPROCESSED_CXX_FILES): %.i: %.cxx $(call mkdir_deps,$(MDDEPDIR))
  803. $(REPORT_BUILD_VERBOSE)
  804. $(addprefix $(MKDIR) -p ,$(filter-out .,$(@D)))
  805. $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
  806. $(_PREPROCESSED_C_FILES): %.i: %.c $(call mkdir_deps,$(MDDEPDIR))
  807. $(REPORT_BUILD_VERBOSE)
  808. $(addprefix $(MKDIR) -p ,$(filter-out .,$(@D)))
  809. $(CC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
  810. $(_PREPROCESSED_CMM_FILES): %.i: %.mm $(call mkdir_deps,$(MDDEPDIR))
  811. $(REPORT_BUILD_VERBOSE)
  812. $(addprefix $(MKDIR) -p ,$(filter-out .,$(@D)))
  813. $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
  814. # Default to pre-processing the actual unified file. This can be overridden
  815. # at the command-line to pre-process only the individual source file.
  816. PP_UNIFIED ?= 1
  817. # PP_REINVOKE gets set on the sub-make to prevent us from going in an
  818. # infinite loop if the filename doesn't exist in the unified source files.
  819. ifndef PP_REINVOKE
  820. MATCH_cpp = \(cpp\|cc|cxx\)
  821. UPPER_c = C
  822. UPPER_cpp = CPP
  823. UPPER_mm = CMM
  824. # When building with PP_UNIFIED=0, we also have to look in the Unified files to
  825. # find a matching pathname.
  826. _get_all_sources = $1 $(if $(filter Unified%,$1),$(shell sed -n 's/\#include "\(.*\)"$$/\1/p' $(filter Unified%,$1)))
  827. all_cpp_sources := $(call _get_all_sources,$(CPPSRCS))
  828. all_mm_sources := $(call _get_all_sources,$(CMMSRCS))
  829. all_c_sources := $(call _get_all_sources,$(CSRCS))
  830. all_sources := $(all_cpp_sources) $(all_cmm_sources) $(all_c_sources)
  831. # The catch-all %.i rule runs when we pass in a .i filename that doesn't match
  832. # one of the *SRCS variables. The two code paths depend on whether or not
  833. # we are requesting a unified file (PP_UNIFIED=1, the default) or not:
  834. #
  835. # PP_UNIFIED=1:
  836. # - Look for it in any of the Unified files, and re-exec make with
  837. # Unified_foo0.i as the target. This gets us the full unified preprocessed
  838. # file.
  839. #
  840. # PP_UNIFIED=0:
  841. # - If the .i filename is in *SRCS, or in a Unified filename, then we re-exec
  842. # make with that filename as the target. The *SRCS variables are modified
  843. # to have the Unified sources appended to them so that the static pattern
  844. # rules will match.
  845. %.i: FORCE
  846. ifeq ($(PP_UNIFIED),1)
  847. @$(MAKE) PP_REINVOKE=1 \
  848. $(or $(addsuffix .i, \
  849. $(foreach type,c cpp mm, \
  850. $(if $(filter Unified%,$($(UPPER_$(type))SRCS)), \
  851. $(shell grep -l '#include "\(.*/\)\?$(basename $@).$(or $(MATCH_$(type)),$(type))"' Unified*.$(type) | sed 's/\.$(type)$$//') \
  852. ))),$(error "File not found for preprocessing: $@"))
  853. else
  854. @$(MAKE) PP_REINVOKE=1 $@ \
  855. $(foreach type,c cpp mm,$(UPPER_$(type))SRCS="$(all_$(type)_sources)")
  856. endif
  857. endif
  858. endif
  859. $(RESFILE): %.res: %.rc
  860. $(REPORT_BUILD)
  861. @echo Creating Resource file: $@
  862. ifdef GNU_CC
  863. $(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) $(OUTOPTION)$@ $(_VPATH_SRCS)
  864. else
  865. $(RC) $(RCFLAGS) -r $(DEFINES) $(INCLUDES) $(OUTOPTION)$@ $(_VPATH_SRCS)
  866. endif
  867. # Cancel GNU make built-in implicit rules
  868. MAKEFLAGS += -r
  869. ifneq (,$(filter WINNT,$(OS_ARCH)))
  870. SEP := ;
  871. else
  872. SEP := :
  873. endif
  874. EMPTY :=
  875. SPACE := $(EMPTY) $(EMPTY)
  876. # MSYS has its own special path form, but javac expects the source and class
  877. # paths to be in the DOS form (i.e. e:/builds/...). This function does the
  878. # appropriate conversion on Windows, but is a noop on other systems.
  879. ifeq ($(HOST_OS_ARCH),WINNT)
  880. # We use 'pwd -W' to get DOS form of the path. However, since the given path
  881. # could be a file or a non-existent path, we cannot call 'pwd -W' directly
  882. # on the path. Instead, we extract the root path (i.e. "c:/"), call 'pwd -W'
  883. # on it, then merge with the rest of the path.
  884. root-path = $(shell echo $(1) | sed -e 's|\(/[^/]*\)/\?\(.*\)|\1|')
  885. non-root-path = $(shell echo $(1) | sed -e 's|\(/[^/]*\)/\?\(.*\)|\2|')
  886. normalizepath = $(foreach p,$(1),$(if $(filter /%,$(1)),$(patsubst %/,%,$(shell cd $(call root-path,$(1)) && pwd -W))/$(call non-root-path,$(1)),$(1)))
  887. else
  888. normalizepath = $(1)
  889. endif
  890. ###############################################################################
  891. # Java rules
  892. ###############################################################################
  893. ifneq (,$(JAVAFILES)$(ANDROID_RESFILES)$(ANDROID_APKNAME)$(JAVA_JAR_TARGETS))
  894. include $(MOZILLA_DIR)/config/makefiles/java-build.mk
  895. endif
  896. ###############################################################################
  897. # Bunch of things that extend the 'export' rule (in order):
  898. ###############################################################################
  899. ifneq ($(XPI_NAME),)
  900. $(FINAL_TARGET):
  901. $(NSINSTALL) -D $@
  902. export:: $(FINAL_TARGET)
  903. endif
  904. ################################################################################
  905. # The default location for prefs is the gre prefs directory.
  906. # PREF_DIR is used for L10N_PREF_JS_EXPORTS in various locales/ directories.
  907. PREF_DIR = defaults/pref
  908. # If DIST_SUBDIR is defined it indicates that app and gre dirs are
  909. # different and that we are building app related resources. Hence,
  910. # PREF_DIR should point to the app prefs location.
  911. ifneq (,$(DIST_SUBDIR)$(XPI_NAME))
  912. PREF_DIR = defaults/preferences
  913. endif
  914. ################################################################################
  915. # SDK
  916. ifneq (,$(SDK_LIBRARY))
  917. ifndef NO_DIST_INSTALL
  918. SDK_LIBRARY_FILES := $(SDK_LIBRARY)
  919. SDK_LIBRARY_DEST := $(SDK_LIB_DIR)
  920. SDK_LIBRARY_TARGET := target
  921. INSTALL_TARGETS += SDK_LIBRARY
  922. endif
  923. endif # SDK_LIBRARY
  924. ################################################################################
  925. # CHROME PACKAGING
  926. chrome::
  927. $(MAKE) realchrome
  928. $(LOOP_OVER_DIRS)
  929. $(FINAL_TARGET)/chrome: $(call mkdir_deps,$(FINAL_TARGET)/chrome)
  930. ifneq (,$(JAR_MANIFEST))
  931. ifndef NO_DIST_INSTALL
  932. ifdef XPI_NAME
  933. # XXX: Figure out why Pale Moon's defs.mk is not being propigated
  934. ifndef XPI_ROOT_APPID
  935. ifdef MC_PALEMOON
  936. XPI_ROOT_APPID=$(MOZ_APP_ID)
  937. endif
  938. endif
  939. ifdef XPI_ROOT_APPID
  940. # For add-on packaging we may specify that an application
  941. # sub-dir should be added to the root chrome manifest with
  942. # a specific application id.
  943. MAKE_JARS_FLAGS += --root-manifest-entry-appid='$(XPI_ROOT_APPID)'
  944. endif
  945. # if DIST_SUBDIR is defined but XPI_ROOT_APPID is not there's
  946. # no way langpacks will get packaged right, so error out.
  947. ifneq (,$(DIST_SUBDIR))
  948. ifndef XPI_ROOT_APPID
  949. $(error XPI_ROOT_APPID is not defined - langpacks will break.)
  950. endif
  951. endif
  952. endif
  953. libs realchrome:: $(FINAL_TARGET)/chrome
  954. $(call py_action,jar_maker,\
  955. $(QUIET) -d $(FINAL_TARGET) \
  956. $(MAKE_JARS_FLAGS) $(DEFINES) $(ACDEFINES) \
  957. $(JAR_MANIFEST))
  958. endif
  959. endif
  960. # When you move this out of the tools tier, please remove the corresponding
  961. # hacks in recursivemake.py that check if Makefile.in sets the variable.
  962. ifneq ($(XPI_PKGNAME),)
  963. tools realchrome::
  964. ifdef STRIP_XPI
  965. ifndef MOZ_DEBUG
  966. @echo 'Stripping $(XPI_PKGNAME) package directory...'
  967. @echo $(FINAL_TARGET)
  968. @cd $(FINAL_TARGET) && find . ! -type d \
  969. ! -name '*.js' \
  970. ! -name '*.xpt' \
  971. ! -name '*.gif' \
  972. ! -name '*.jpg' \
  973. ! -name '*.png' \
  974. ! -name '*.xpm' \
  975. ! -name '*.txt' \
  976. ! -name '*.rdf' \
  977. ! -name '*.sh' \
  978. ! -name '*.properties' \
  979. ! -name '*.dtd' \
  980. ! -name '*.html' \
  981. ! -name '*.xul' \
  982. ! -name '*.css' \
  983. ! -name '*.xml' \
  984. ! -name '*.jar' \
  985. ! -name '*.dat' \
  986. ! -name '*.tbl' \
  987. ! -name '*.src' \
  988. ! -name '*.reg' \
  989. $(PLATFORM_EXCLUDE_LIST) \
  990. -exec $(STRIP) $(STRIP_FLAGS) {} >/dev/null 2>&1 \;
  991. endif
  992. endif
  993. @echo 'Packaging $(XPI_PKGNAME).xpi...'
  994. $(call py_action,zip,-C $(FINAL_TARGET) ../$(XPI_PKGNAME).xpi '*')
  995. endif
  996. # See comment above about moving this out of the tools tier.
  997. ifdef INSTALL_EXTENSION_ID
  998. ifndef XPI_NAME
  999. $(error XPI_NAME must be set for INSTALL_EXTENSION_ID)
  1000. endif
  1001. tools::
  1002. $(RM) -r '$(DIST)/bin/distribution$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)'
  1003. $(NSINSTALL) -D '$(DIST)/bin/distribution$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)'
  1004. $(call copy_dir,$(FINAL_TARGET),$(DIST)/bin/distribution$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID))
  1005. endif
  1006. #############################################################################
  1007. # MDDEPDIR is the subdirectory where all the dependency files are placed.
  1008. # This uses a make rule (instead of a macro) to support parallel
  1009. # builds (-jN). If this were done in the LOOP_OVER_DIRS macro, two
  1010. # processes could simultaneously try to create the same directory.
  1011. #
  1012. # We use $(CURDIR) in the rule's target to ensure that we don't find
  1013. # a dependency directory in the source tree via VPATH (perhaps from
  1014. # a previous build in the source tree) and thus neglect to create a
  1015. # dependency directory in the object directory, where we really need
  1016. # it.
  1017. ifneq (,$(filter-out all chrome default export realchrome clean clobber clobber_all distclean realclean,$(MAKECMDGOALS)))
  1018. MDDEPEND_FILES := $(strip $(wildcard $(addprefix $(MDDEPDIR)/,$(addsuffix .pp,$(notdir $(sort $(OBJS) $(PROGOBJS) $(HOST_OBJS) $(HOST_PROGOBJS)))))))
  1019. ifneq (,$(MDDEPEND_FILES))
  1020. -include $(MDDEPEND_FILES)
  1021. endif
  1022. endif
  1023. MDDEPEND_FILES := $(strip $(wildcard $(addprefix $(MDDEPDIR)/,$(EXTRA_MDDEPEND_FILES))))
  1024. ifneq (,$(MDDEPEND_FILES))
  1025. -include $(MDDEPEND_FILES)
  1026. endif
  1027. #############################################################################
  1028. -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-rules.mk
  1029. -include $(MY_RULES)
  1030. #
  1031. # Generate Emacs tags in a file named TAGS if ETAGS was set in $(MY_CONFIG)
  1032. # or in $(MY_RULES)
  1033. #
  1034. ifdef ETAGS
  1035. ifneq ($(CSRCS)$(CPPSRCS)$(HEADERS),)
  1036. all:: TAGS
  1037. TAGS:: $(CSRCS) $(CPPSRCS) $(HEADERS)
  1038. $(ETAGS) $(CSRCS) $(CPPSRCS) $(HEADERS)
  1039. endif
  1040. endif
  1041. ################################################################################
  1042. # Install/copy rules
  1043. #
  1044. # The INSTALL_TARGETS variable contains a list of all install target
  1045. # categories. Each category defines a list of files and executables, and an
  1046. # install destination,
  1047. #
  1048. # FOO_FILES := foo bar
  1049. # FOO_EXECUTABLES := baz
  1050. # FOO_DEST := target_path
  1051. # INSTALL_TARGETS += FOO
  1052. #
  1053. # Additionally, a FOO_TARGET variable may be added to indicate the target for
  1054. # which the files and executables are installed. Default is "libs".
  1055. #
  1056. # Finally, a FOO_KEEP_PATH variable may be set to 1 to indicate the paths given
  1057. # in FOO_FILES/FOO_EXECUTABLES are to be kept at the destination. That is,
  1058. # if FOO_FILES is bar/baz/qux.h, and FOO_DEST is $(DIST)/include, the installed
  1059. # file would be $(DIST)/include/bar/baz/qux.h instead of $(DIST)/include/qux.h
  1060. # If we're using binary nsinstall and it's not built yet, fallback to python nsinstall.
  1061. ifneq (,$(filter $(DEPTH)/config/nsinstall$(HOST_BIN_SUFFIX),$(install_cmd)))
  1062. ifeq (,$(wildcard $(DEPTH)/config/nsinstall$(HOST_BIN_SUFFIX)))
  1063. nsinstall_is_usable = $(if $(wildcard $(DEPTH)/config/nsinstall$(HOST_BIN_SUFFIX)),yes)
  1064. define install_cmd_override
  1065. $(1): install_cmd = $$(if $$(nsinstall_is_usable),$$(INSTALL),$$(NSINSTALL_PY) -t) $$(1)
  1066. endef
  1067. endif
  1068. endif
  1069. install_target_tier = $(or $($(1)_TARGET),libs)
  1070. INSTALL_TARGETS_TIERS := $(sort $(foreach category,$(INSTALL_TARGETS),$(call install_target_tier,$(category))))
  1071. install_target_result = $($(1)_DEST:%/=%)/$(if $($(1)_KEEP_PATH),$(2),$(notdir $(2)))
  1072. install_target_files = $(foreach file,$($(1)_FILES),$(call install_target_result,$(category),$(file)))
  1073. install_target_executables = $(foreach file,$($(1)_EXECUTABLES),$(call install_target_result,$(category),$(file)))
  1074. # Work around a GNU make 3.81 bug where it gives $< the wrong value.
  1075. # See details in bug 934864.
  1076. define create_dependency
  1077. $(1): $(2)
  1078. $(1): $(2)
  1079. endef
  1080. define install_target_template
  1081. $(call install_cmd_override,$(2))
  1082. $(call create_dependency,$(2),$(1))
  1083. endef
  1084. $(foreach category,$(INSTALL_TARGETS),\
  1085. $(if $($(category)_DEST),,$(error Missing $(category)_DEST)) \
  1086. $(foreach tier,$(call install_target_tier,$(category)),\
  1087. $(eval INSTALL_TARGETS_FILES_$(tier) += $(call install_target_files,$(category))) \
  1088. $(eval INSTALL_TARGETS_EXECUTABLES_$(tier) += $(call install_target_executables,$(category))) \
  1089. ) \
  1090. $(foreach file,$($(category)_FILES) $($(category)_EXECUTABLES), \
  1091. $(eval $(call install_target_template,$(file),$(call install_target_result,$(category),$(file)))) \
  1092. ) \
  1093. )
  1094. $(foreach tier,$(INSTALL_TARGETS_TIERS), \
  1095. $(eval $(tier):: $(INSTALL_TARGETS_FILES_$(tier)) $(INSTALL_TARGETS_EXECUTABLES_$(tier))) \
  1096. )
  1097. install_targets_sanity = $(if $(filter-out $(notdir $@),$(notdir $(<))),$(error Looks like $@ has an unexpected dependency on $< which breaks INSTALL_TARGETS))
  1098. $(sort $(foreach tier,$(INSTALL_TARGETS_TIERS),$(INSTALL_TARGETS_FILES_$(tier)))):
  1099. $(install_targets_sanity)
  1100. $(call install_cmd,$(IFLAGS1) '$<' '$(@D)')
  1101. $(sort $(foreach tier,$(INSTALL_TARGETS_TIERS),$(INSTALL_TARGETS_EXECUTABLES_$(tier)))):
  1102. $(install_targets_sanity)
  1103. $(call install_cmd,$(IFLAGS2) '$<' '$(@D)')
  1104. ################################################################################
  1105. # Preprocessing rules
  1106. #
  1107. # The PP_TARGETS variable contains a list of all preprocessing target
  1108. # categories. Each category has associated variables listing input files, the
  1109. # output directory, extra preprocessor flags, and so on. For example:
  1110. #
  1111. # FOO := input-file
  1112. # FOO_PATH := target-directory
  1113. # FOO_FLAGS := -Dsome_flag
  1114. # PP_TARGETS += FOO
  1115. #
  1116. # If PP_TARGETS lists a category name <C> (like FOO, above), then we consult the
  1117. # following make variables to see what to do:
  1118. #
  1119. # - <C> lists input files to be preprocessed with mozbuild.action.preprocessor.
  1120. # We search VPATH for the names given here. If an input file name ends in
  1121. # '.in', that suffix is omitted from the output file name.
  1122. #
  1123. # - <C>_PATH names the directory in which to place the preprocessed output
  1124. # files. We create this directory if it does not already exist. Setting
  1125. # this variable is optional; if unset, we install the files in $(CURDIR).
  1126. #
  1127. # - <C>_FLAGS lists flags to pass to mozbuild.action.preprocessor, in addition
  1128. # to the usual bunch. Setting this variable is optional.
  1129. #
  1130. # - <C>_TARGET names the 'make' target that should depend on creating the output
  1131. # files. Setting this variable is optional; if unset, we preprocess the
  1132. # files for the 'libs' target.
  1133. #
  1134. # - <C>_KEEP_PATH may be set to 1 to indicate the paths given in <C> are to be
  1135. # kept under <C>_PATH. That is, if <C> is bar/baz/qux.h.in and <C>_PATH is
  1136. # $(DIST)/include, the preprocessed file would be $(DIST)/include/bar/baz/qux.h
  1137. # instead of $(DIST)/include/qux.h.
  1138. pp_target_tier = $(or $($(1)_TARGET),libs)
  1139. PP_TARGETS_TIERS := $(sort $(foreach category,$(PP_TARGETS),$(call pp_target_tier,$(category))))
  1140. pp_target_result = $(or $($(1)_PATH:%/=%),$(CURDIR))/$(if $($(1)_KEEP_PATH),$(2:.in=),$(notdir $(2:.in=)))
  1141. pp_target_results = $(foreach file,$($(1)),$(call pp_target_result,$(category),$(file)))
  1142. $(foreach category,$(PP_TARGETS), \
  1143. $(foreach tier,$(call pp_target_tier,$(category)), \
  1144. $(eval PP_TARGETS_RESULTS_$(tier) += $(call pp_target_results,$(category))) \
  1145. ) \
  1146. $(foreach file,$($(category)), \
  1147. $(eval $(call create_dependency,$(call pp_target_result,$(category),$(file)), \
  1148. $(file) $(GLOBAL_DEPS))) \
  1149. ) \
  1150. $(eval $(call pp_target_results,$(category)): PP_TARGET_FLAGS=$($(category)_FLAGS)) \
  1151. )
  1152. $(foreach tier,$(PP_TARGETS_TIERS), \
  1153. $(eval $(tier):: $(PP_TARGETS_RESULTS_$(tier))) \
  1154. )
  1155. PP_TARGETS_ALL_RESULTS := $(sort $(foreach tier,$(PP_TARGETS_TIERS),$(PP_TARGETS_RESULTS_$(tier))))
  1156. $(PP_TARGETS_ALL_RESULTS):
  1157. $(if $(filter-out $(notdir $@),$(notdir $(<:.in=))),$(error Looks like $@ has an unexpected dependency on $< which breaks PP_TARGETS))
  1158. $(RM) '$@'
  1159. $(call py_action,preprocessor,--depend $(MDDEPDIR)/$(@F).pp $(PP_TARGET_FLAGS) $(DEFINES) $(ACDEFINES) '$<' -o '$@')
  1160. $(filter %.css,$(PP_TARGETS_ALL_RESULTS)): PP_TARGET_FLAGS+=--marker %
  1161. # The depfile is based on the filename, and we don't want conflicts. So check
  1162. # there's only one occurrence of any given filename in PP_TARGETS_ALL_RESULTS.
  1163. PP_TARGETS_ALL_RESULT_NAMES := $(notdir $(PP_TARGETS_ALL_RESULTS))
  1164. $(foreach file,$(sort $(PP_TARGETS_ALL_RESULT_NAMES)), \
  1165. $(if $(filter-out 1,$(words $(filter $(file),$(PP_TARGETS_ALL_RESULT_NAMES)))), \
  1166. $(error Multiple preprocessing rules are creating a $(file) file) \
  1167. ) \
  1168. )
  1169. ifneq (,$(filter $(PP_TARGETS_TIERS) $(PP_TARGETS_ALL_RESULTS),$(MAKECMDGOALS)))
  1170. # If the depfile for a preprocessed file doesn't exist, add a dep to force
  1171. # re-preprocessing.
  1172. $(foreach file,$(PP_TARGETS_ALL_RESULTS), \
  1173. $(if $(wildcard $(MDDEPDIR)/$(notdir $(file)).pp), \
  1174. , \
  1175. $(eval $(file): FORCE) \
  1176. ) \
  1177. )
  1178. MDDEPEND_FILES := $(strip $(wildcard $(addprefix $(MDDEPDIR)/,$(addsuffix .pp,$(notdir $(PP_TARGETS_ALL_RESULTS))))))
  1179. ifneq (,$(MDDEPEND_FILES))
  1180. -include $(MDDEPEND_FILES)
  1181. endif
  1182. endif
  1183. # Pull in non-recursive targets if this is a partial tree build.
  1184. ifndef TOPLEVEL_BUILD
  1185. include $(MOZILLA_DIR)/config/makefiles/nonrecursive.mk
  1186. endif
  1187. ################################################################################
  1188. # Special gmake rules.
  1189. ################################################################################
  1190. #
  1191. # Re-define the list of default suffixes, so gmake won't have to churn through
  1192. # hundreds of built-in suffix rules for stuff we don't need.
  1193. #
  1194. .SUFFIXES:
  1195. #
  1196. # Fake targets. Always run these rules, even if a file/directory with that
  1197. # name already exists.
  1198. #
  1199. .PHONY: all alltags boot checkout chrome realchrome clean clobber clobber_all export install libs makefiles realclean run_apprunner tools $(DIRS) FORCE
  1200. # Used as a dependency to force targets to rebuild
  1201. FORCE:
  1202. # Delete target if error occurs when building target
  1203. .DELETE_ON_ERROR:
  1204. tags: TAGS
  1205. TAGS: $(CSRCS) $(CPPSRCS) $(wildcard *.h)
  1206. -etags $(CSRCS) $(CPPSRCS) $(wildcard *.h)
  1207. $(LOOP_OVER_DIRS)
  1208. ifndef INCLUDED_DEBUGMAKE_MK #{
  1209. ## Only parse when an echo* or show* target is requested
  1210. ifneq (,$(call isTargetStem,echo,show))
  1211. include $(MOZILLA_DIR)/config/makefiles/debugmake.mk
  1212. endif #}
  1213. endif #}
  1214. documentation:
  1215. @cd $(DEPTH)
  1216. $(DOXYGEN) $(DEPTH)/config/doxygen.cfg
  1217. ifdef ENABLE_TESTS
  1218. check::
  1219. $(LOOP_OVER_DIRS)
  1220. endif
  1221. FREEZE_VARIABLES = \
  1222. CSRCS \
  1223. CPPSRCS \
  1224. EXPORTS \
  1225. DIRS \
  1226. LIBRARY \
  1227. MODULE \
  1228. $(NULL)
  1229. $(foreach var,$(FREEZE_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))
  1230. CHECK_FROZEN_VARIABLES = $(foreach var,$(FREEZE_VARIABLES), \
  1231. $(if $(subst $($(var)_FROZEN),,'$($(var))'),$(error Makefile variable '$(var)' changed value after including rules.mk. Was $($(var)_FROZEN), now $($(var)).)))
  1232. libs export::
  1233. $(CHECK_FROZEN_VARIABLES)
  1234. PURGECACHES_DIRS ?= $(DIST)/bin
  1235. PURGECACHES_FILES = $(addsuffix /.purgecaches,$(PURGECACHES_DIRS))
  1236. default all:: $(PURGECACHES_FILES)
  1237. $(PURGECACHES_FILES):
  1238. if test -d $(@D) ; then touch $@ ; fi
  1239. .DEFAULT_GOAL := $(or $(OVERRIDE_DEFAULT_GOAL),default)
  1240. #############################################################################
  1241. # Derived targets and dependencies
  1242. include $(MOZILLA_DIR)/config/makefiles/autotargets.mk
  1243. ifneq ($(NULL),$(AUTO_DEPS))
  1244. default all libs tools export:: $(AUTO_DEPS)
  1245. endif