Advertisement
Guest User

cat build/core/main.mk

a guest
Nov 23rd, 2015
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.38 KB | None | 0 0
  1. HABuildSDK [i9100g] droid $ cat build/core/main.mk
  2. # Only use ANDROID_BUILD_SHELL to wrap around bash.
  3. # DO NOT use other shells such as zsh.
  4. ifdef ANDROID_BUILD_SHELL
  5. SHELL := $(ANDROID_BUILD_SHELL)
  6. else
  7. # Use bash, not whatever shell somebody has installed as /bin/sh
  8. # This is repeated in config.mk, since envsetup.sh runs that file
  9. # directly.
  10. SHELL := /bin/bash
  11. endif
  12.  
  13. # this turns off the suffix rules built into make
  14. .SUFFIXES:
  15.  
  16. # this turns off the RCS / SCCS implicit rules of GNU Make
  17. % : RCS/%,v
  18. % : RCS/%
  19. % : %,v
  20. % : s.%
  21. % : SCCS/s.%
  22.  
  23. # If a rule fails, delete $@.
  24. .DELETE_ON_ERROR:
  25.  
  26. # Figure out where we are.
  27. #TOP := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
  28. #TOP := $(patsubst %/,%,$(TOP))
  29.  
  30. # TOPDIR is the normal variable you should use, because
  31. # if we are executing relative to the current directory
  32. # it can be "", whereas TOP must be "." which causes
  33. # pattern matching probles when make strips off the
  34. # trailing "./" from paths in various places.
  35. #ifeq ($(TOP),.)
  36. #TOPDIR :=
  37. #else
  38. #TOPDIR := $(TOP)/
  39. #endif
  40.  
  41. # Check for broken versions of make.
  42. # (Allow any version under Cygwin since we don't actually build the platform there.)
  43. ifeq (,$(findstring CYGWIN,$(shell uname -sm)))
  44. ifeq (0,$(shell expr $$(echo $(MAKE_VERSION) | sed "s/[^0-9\.].*//") = 3.81))
  45. ifeq (0,$(shell expr $$(echo $(MAKE_VERSION) | sed "s/[^0-9\.].*//") = 3.82))
  46. ifeq (0,$(shell expr $$(echo $(MAKE_VERSION) | sed "s/[^0-9\.].*//") = 4.0))
  47. $(warning ********************************************************************************)
  48. $(warning * You are using version $(MAKE_VERSION) of make.)
  49. $(warning * Android is tested to build with versions 3.81, 3.82 and 4.0)
  50. $(warning * see https://source.android.com/source/download.html)
  51. $(warning ********************************************************************************)
  52. endif
  53. endif
  54. endif
  55. endif
  56.  
  57. # Absolute path of the present working direcotry.
  58. # This overrides the shell variable $PWD, which does not necessarily points to
  59. # the top of the source tree, for example when "make -C" is used in m/mm/mmm.
  60. PWD := $(shell pwd)
  61.  
  62. TOP := .
  63. TOPDIR :=
  64.  
  65. BUILD_SYSTEM := $(TOPDIR)build/core
  66.  
  67. # This is the default target. It must be the first declared target.
  68. .PHONY: droid
  69. DEFAULT_GOAL := droid
  70. $(DEFAULT_GOAL):
  71.  
  72. # Used to force goals to build. Only use for conditionally defined goals.
  73. .PHONY: FORCE
  74. FORCE:
  75.  
  76. # These goals don't need to collect and include Android.mks/CleanSpec.mks
  77. # in the source tree.
  78. dont_bother_goals := clean clobber dataclean installclean \
  79. help out \
  80. snod systemimage-nodeps \
  81. stnod systemtarball-nodeps \
  82. userdataimage-nodeps userdatatarball-nodeps \
  83. cacheimage-nodeps \
  84. vendorimage-nodeps \
  85. ramdisk-nodeps \
  86. bootimage-nodeps
  87.  
  88. ifneq ($(filter $(dont_bother_goals), $(MAKECMDGOALS)),)
  89. dont_bother := true
  90. endif
  91.  
  92. # Targets that provide quick help on the build system.
  93. include $(BUILD_SYSTEM)/help.mk
  94.  
  95. # Set up various standard variables based on configuration
  96. # and host information.
  97. include $(BUILD_SYSTEM)/config.mk
  98.  
  99. # This allows us to force a clean build - included after the config.mk
  100. # environment setup is done, but before we generate any dependencies. This
  101. # file does the rm -rf inline so the deps which are all done below will
  102. # be generated correctly
  103. include $(BUILD_SYSTEM)/cleanbuild.mk
  104.  
  105. # Bring in Qualcomm helper macros
  106. include $(BUILD_SYSTEM)/qcom_utils.mk
  107.  
  108. # Include the google-specific config
  109. -include vendor/google/build/config.mk
  110.  
  111. # Include the extra device config
  112. -include vendor/extra/device.mk
  113.  
  114. VERSION_CHECK_SEQUENCE_NUMBER := 3
  115. -include $(OUT_DIR)/versions_checked.mk
  116. ifneq ($(VERSION_CHECK_SEQUENCE_NUMBER),$(VERSIONS_CHECKED))
  117.  
  118. $(info Checking build tools versions...)
  119.  
  120. ifneq ($(HOST_OS),windows)
  121. ifneq ($(HOST_OS)-$(HOST_ARCH),darwin-ppc)
  122. # check for a case sensitive file system
  123. ifneq (a,$(shell mkdir -p $(OUT_DIR) ; \
  124. echo a > $(OUT_DIR)/casecheck.txt; \
  125. echo B > $(OUT_DIR)/CaseCheck.txt; \
  126. cat $(OUT_DIR)/casecheck.txt))
  127. $(warning ************************************************************)
  128. $(warning You are building on a case-insensitive filesystem.)
  129. $(warning Please move your source tree to a case-sensitive filesystem.)
  130. $(warning ************************************************************)
  131. $(error Case-insensitive filesystems not supported)
  132. endif
  133. endif
  134. endif
  135.  
  136. # Make sure that there are no spaces in the absolute path; the
  137. # build system can't deal with them.
  138. ifneq ($(words $(shell pwd)),1)
  139. $(warning ************************************************************)
  140. $(warning You are building in a directory whose absolute path contains)
  141. $(warning a space character:)
  142. $(warning $(space))
  143. $(warning "$(shell pwd)")
  144. $(warning $(space))
  145. $(warning Please move your source tree to a path that does not contain)
  146. $(warning any spaces.)
  147. $(warning ************************************************************)
  148. $(error Directory names containing spaces not supported)
  149. endif
  150.  
  151. # Check for the corrent jdk
  152. ifneq ($(shell java -version 2>&1 | grep -i openjdk),)
  153. $(info ************************************************************)
  154. $(info You are attempting to build with an unsupported JDK.)
  155. $(info $(space))
  156. $(info You use OpenJDK but only Sun/Oracle JDK is supported.)
  157. $(info Please follow the machine setup instructions at)
  158. $(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
  159. $(info $(space))
  160. $(info Continue at your own peril!)
  161. $(info ************************************************************)
  162. endif
  163.  
  164. # Check for the correct version of java
  165. java_version := $(shell java -version 2>&1 | head -n 1 | grep '^java .*[ "]1\.[67][\. "$$]')
  166. ifneq ($(shell java -version 2>&1 | grep -i openjdk),)
  167. java_version :=
  168. endif
  169. ifeq ($(strip $(java_version)),)
  170. $(info ************************************************************)
  171. $(info You are attempting to build with an unsupported version)
  172. $(info of java.)
  173. $(info $(space))
  174. $(info Your version is: $(shell java -version 2>&1 | head -n 1).)
  175. $(info The correct version is: Java SE 1.6 or 1.7.)
  176. $(info $(space))
  177. $(info Please follow the machine setup instructions at)
  178. $(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
  179. $(info ************************************************************)
  180. endif
  181.  
  182. # Check for the correct version of javac
  183. javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.[67][\. "$$]')
  184. ifeq ($(strip $(javac_version)),)
  185. $(info ************************************************************)
  186. $(info You are attempting to build with the incorrect version)
  187. $(info of javac.)
  188. $(info $(space))
  189. $(info Your version is: $(shell javac -version 2>&1 | head -n 1).)
  190. $(info The correct version is: 1.6 or 1.7.)
  191. $(info $(space))
  192. $(info Please follow the machine setup instructions at)
  193. $(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
  194. $(info ************************************************************)
  195. $(error stop)
  196. endif
  197.  
  198. ifndef BUILD_EMULATOR
  199. ifeq (darwin,$(HOST_OS))
  200. GCC_REALPATH = $(realpath $(shell which $(HOST_CC)))
  201. ifneq ($(findstring llvm-gcc,$(GCC_REALPATH)),)
  202. # Using LLVM GCC results in a non functional emulator due to it
  203. # not honouring global register variables
  204. $(warning ****************************************)
  205. $(warning * gcc is linked to llvm-gcc which will *)
  206. $(warning * not create a useable emulator. *)
  207. $(warning ****************************************)
  208. BUILD_EMULATOR := false
  209. else
  210. BUILD_EMULATOR := true
  211. endif
  212. else # HOST_OS is not darwin
  213. BUILD_EMULATOR := true
  214. endif # HOST_OS is darwin
  215. endif
  216.  
  217. $(shell echo 'VERSIONS_CHECKED := $(VERSION_CHECK_SEQUENCE_NUMBER)' \
  218. > $(OUT_DIR)/versions_checked.mk)
  219. $(shell echo 'BUILD_EMULATOR ?= $(BUILD_EMULATOR)' \
  220. >> $(OUT_DIR)/versions_checked.mk)
  221. endif
  222.  
  223. # These are the modifier targets that don't do anything themselves, but
  224. # change the behavior of the build.
  225. # (must be defined before including definitions.make)
  226. INTERNAL_MODIFIER_TARGETS := showcommands all incrementaljavac
  227.  
  228. .PHONY: incrementaljavac
  229. incrementaljavac: ;
  230.  
  231. # WARNING:
  232. # ENABLE_INCREMENTALJAVAC should NOT be enabled by default, because change of
  233. # a Java source file won't trigger rebuild of its dependent Java files.
  234. # You can only enable it by adding "incrementaljavac" to your make command line.
  235. # You are responsible for the correctness of the incremental build.
  236. # This may decrease incremental build time dramatically for large Java libraries,
  237. # such as core.jar, framework.jar, etc.
  238. ENABLE_INCREMENTALJAVAC :=
  239. ifneq (,$(filter incrementaljavac, $(MAKECMDGOALS)))
  240. ENABLE_INCREMENTALJAVAC := true
  241. MAKECMDGOALS := $(filter-out incrementaljavac, $(MAKECMDGOALS))
  242. endif
  243.  
  244. # EMMA_INSTRUMENT_STATIC merges the static emma library to each emma-enabled module.
  245. ifeq (true,$(EMMA_INSTRUMENT_STATIC))
  246. EMMA_INSTRUMENT := true
  247. endif
  248.  
  249. # Bring in standard build system definitions.
  250. include $(BUILD_SYSTEM)/definitions.mk
  251.  
  252. # Bring in dex_preopt.mk
  253. include $(BUILD_SYSTEM)/dex_preopt.mk
  254.  
  255. ifneq ($(filter user userdebug eng,$(MAKECMDGOALS)),)
  256. $(info ***************************************************************)
  257. $(info ***************************************************************)
  258. $(info Do not pass '$(filter user userdebug eng,$(MAKECMDGOALS))' on \
  259. the make command line.)
  260. $(info Set TARGET_BUILD_VARIANT in buildspec.mk, or use lunch or)
  261. $(info choosecombo.)
  262. $(info ***************************************************************)
  263. $(info ***************************************************************)
  264. $(error stopping)
  265. endif
  266.  
  267. ifneq ($(filter-out $(INTERNAL_VALID_VARIANTS),$(TARGET_BUILD_VARIANT)),)
  268. $(info ***************************************************************)
  269. $(info ***************************************************************)
  270. $(info Invalid variant: $(TARGET_BUILD_VARIANT)
  271. $(info Valid values are: $(INTERNAL_VALID_VARIANTS)
  272. $(info ***************************************************************)
  273. $(info ***************************************************************)
  274. $(error stopping)
  275. endif
  276.  
  277. # -----------------------------------------------------------------
  278. # Variable to check java support level inside PDK build.
  279. # Not necessary if the components is not in PDK.
  280. # not defined : not supported
  281. # "sdk" : sdk API only
  282. # "platform" : platform API supproted
  283. TARGET_BUILD_JAVA_SUPPORT_LEVEL := platform
  284.  
  285. # -----------------------------------------------------------------
  286. # The pdk (Platform Development Kit) build
  287. # include build/core/pdk_config.mk
  288.  
  289. # -----------------------------------------------------------------
  290. ###
  291. ### In this section we set up the things that are different
  292. ### between the build variants
  293. ###
  294.  
  295. is_sdk_build :=
  296.  
  297. ifneq ($(filter sdk win_sdk sdk_addon,$(MAKECMDGOALS)),)
  298. is_sdk_build := true
  299. endif
  300.  
  301. ## user/userdebug ##
  302.  
  303. user_variant := $(filter user userdebug,$(TARGET_BUILD_VARIANT))
  304. enable_target_debugging := true
  305. tags_to_install :=
  306. ifneq (,$(user_variant))
  307. # Target is secure in user builds.
  308. ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1
  309.  
  310. ifeq ($(user_variant),userdebug)
  311. # Pick up some extra useful tools
  312. tags_to_install += debug
  313.  
  314. # Enable Dalvik lock contention logging for userdebug builds.
  315. ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.lockprof.threshold=500
  316. else
  317. # Disable debugging in plain user builds.
  318. enable_target_debugging :=
  319. endif
  320.  
  321. # Turn on Dalvik preoptimization for user builds, but only if not
  322. # explicitly disabled and the build is running on Linux (since host
  323. # Dalvik isn't built for non-Linux hosts).
  324. ifneq (true,$(DISABLE_DEXPREOPT))
  325. ifeq ($(user_variant),user)
  326. ifeq ($(HOST_OS),linux)
  327. WITH_DEXPREOPT := true
  328. endif
  329. endif
  330. endif
  331.  
  332. # Disallow mock locations by default for user builds
  333. ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=0
  334.  
  335. else # !user_variant
  336. # Turn on checkjni for non-user builds.
  337. ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=1
  338. # Set device insecure for non-user builds.
  339. ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0
  340. # Allow mock locations by default for non user builds
  341. ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=1
  342. endif # !user_variant
  343.  
  344. ifeq (true,$(strip $(enable_target_debugging)))
  345. # Target is more debuggable and adbd is on by default
  346. ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1
  347. # Include the debugging/testing OTA keys in this build.
  348. INCLUDE_TEST_OTA_KEYS := true
  349. else # !enable_target_debugging
  350. # Target is less debuggable and adbd is off by default
  351. ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0
  352. endif # !enable_target_debugging
  353.  
  354. ## eng ##
  355.  
  356. ifeq ($(TARGET_BUILD_VARIANT),eng)
  357. tags_to_install := debug eng
  358. ifneq ($(filter ro.setupwizard.mode=ENABLED, $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))),)
  359. # Don't require the setup wizard on eng builds
  360. ADDITIONAL_BUILD_PROPERTIES := $(filter-out ro.setupwizard.mode=%,\
  361. $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))) \
  362. ro.setupwizard.mode=OPTIONAL
  363. endif
  364. endif
  365.  
  366. ## sdk ##
  367.  
  368. ifdef is_sdk_build
  369.  
  370. # Detect if we want to build a repository for the SDK
  371. sdk_repo_goal := $(strip $(filter sdk_repo,$(MAKECMDGOALS)))
  372. MAKECMDGOALS := $(strip $(filter-out sdk_repo,$(MAKECMDGOALS)))
  373.  
  374. ifneq ($(words $(filter-out $(INTERNAL_MODIFIER_TARGETS) checkbuild,$(MAKECMDGOALS))),1)
  375. $(error The 'sdk' target may not be specified with any other targets)
  376. endif
  377.  
  378. # TODO: this should be eng I think. Since the sdk is built from the eng
  379. # variant.
  380. tags_to_install := debug eng
  381. ADDITIONAL_BUILD_PROPERTIES += xmpp.auto-presence=true
  382. ADDITIONAL_BUILD_PROPERTIES += ro.config.nocheckin=yes
  383. else # !sdk
  384. endif
  385.  
  386. BUILD_WITHOUT_PV := true
  387.  
  388. ## precise GC ##
  389.  
  390. ifneq ($(filter dalvik.gc.type-precise,$(PRODUCT_TAGS)),)
  391. # Enabling type-precise GC results in larger optimized DEX files. The
  392. # additional storage requirements for ".odex" files can cause /system
  393. # to overflow on some devices, so this is configured separately for
  394. # each product.
  395. ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.dexopt-flags=m=y
  396. endif
  397.  
  398. ADDITIONAL_BUILD_PROPERTIES += net.bt.name=Android
  399.  
  400. # enable vm tracing in files for now to help track
  401. # the cause of ANRs in the content process
  402. ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.stack-trace-file=/data/anr/traces.txt
  403.  
  404. # ------------------------------------------------------------
  405. # Define a function that, given a list of module tags, returns
  406. # non-empty if that module should be installed in /system.
  407.  
  408. # For most goals, anything not tagged with the "tests" tag should
  409. # be installed in /system.
  410. define should-install-to-system
  411. $(if $(filter tests,$(1)),,true)
  412. endef
  413.  
  414. ifdef is_sdk_build
  415. # For the sdk goal, anything with the "samples" tag should be
  416. # installed in /data even if that module also has "eng"/"debug"/"user".
  417. define should-install-to-system
  418. $(if $(filter samples tests,$(1)),,true)
  419. endef
  420. endif
  421.  
  422.  
  423. # If they only used the modifier goals (showcommands, etc), we'll actually
  424. # build the default target.
  425. ifeq ($(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS)),)
  426. .PHONY: $(INTERNAL_MODIFIER_TARGETS)
  427. $(INTERNAL_MODIFIER_TARGETS): $(DEFAULT_GOAL)
  428. endif
  429.  
  430. # Bring in all modules that need to be built.
  431. ifeq ($(HOST_OS)-$(HOST_ARCH),darwin-ppc)
  432. SDK_ONLY := true
  433. $(info Building the SDK under darwin-ppc is actually obsolete and unsupported.)
  434. $(error stop)
  435. endif
  436.  
  437. ifeq ($(HOST_OS),windows)
  438. SDK_ONLY := true
  439. endif
  440.  
  441. ifeq ($(SDK_ONLY),true)
  442. include $(TOPDIR)sdk/build/windows_sdk_whitelist.mk
  443. include $(TOPDIR)development/build/windows_sdk_whitelist.mk
  444.  
  445. # Exclude tools/acp when cross-compiling windows under linux
  446. ifeq ($(findstring Linux,$(UNAME)),)
  447. subdirs += build/tools/acp
  448. endif
  449.  
  450. else # !SDK_ONLY
  451. #
  452. # Typical build; include any Android.mk files we can find.
  453. #
  454. subdirs := $(TOP)
  455.  
  456. FULL_BUILD := true
  457.  
  458. endif # !SDK_ONLY
  459.  
  460. # Before we go and include all of the module makefiles, stash away
  461. # the PRODUCT_* values so that later we can verify they are not modified.
  462. stash_product_vars:=true
  463. ifeq ($(stash_product_vars),true)
  464. $(call stash-product-vars, __STASHED)
  465. endif
  466.  
  467. ifneq ($(ONE_SHOT_MAKEFILE),)
  468. # We've probably been invoked by the "mm" shell function
  469. # with a subdirectory's makefile.
  470. include $(ONE_SHOT_MAKEFILE)
  471. # Change CUSTOM_MODULES to include only modules that were
  472. # defined by this makefile; this will install all of those
  473. # modules as a side-effect. Do this after including ONE_SHOT_MAKEFILE
  474. # so that the modules will be installed in the same place they
  475. # would have been with a normal make.
  476. CUSTOM_MODULES := $(sort $(call get-tagged-modules,$(ALL_MODULE_TAGS)))
  477. FULL_BUILD :=
  478. # Stub out the notice targets, which probably aren't defined
  479. # when using ONE_SHOT_MAKEFILE.
  480. NOTICE-HOST-%: ;
  481. NOTICE-TARGET-%: ;
  482.  
  483. # A helper goal printing out install paths
  484. .PHONY: GET-INSTALL-PATH
  485. GET-INSTALL-PATH:
  486. @$(foreach m, $(ALL_MODULES), $(if $(ALL_MODULES.$(m).INSTALLED), \
  487. echo 'INSTALL-PATH: $(m) $(ALL_MODULES.$(m).INSTALLED)';))
  488.  
  489. else # ONE_SHOT_MAKEFILE
  490.  
  491. ifneq ($(dont_bother),true)
  492. #
  493. # Include all of the makefiles in the system
  494. #
  495.  
  496. subdir_makefile_dirs := abi bionic bootable build device external hardware hybris libcore system
  497.  
  498. # Can't use first-makefiles-under here because
  499. # --mindepth=2 makes the prunes not work.
  500.  
  501. subdir_makefiles := \
  502. ./frameworks/base/Android.mk \
  503. ./frameworks/native/cmds/dumpstate/Android.mk \
  504. ./frameworks/native/cmds/dumpsys/Android.mk \
  505. ./frameworks/native/libs/binder/Android.mk \
  506. ./frameworks/native/libs/gui/Android.mk \
  507. ./frameworks/native/libs/ui/Android.mk \
  508. ./frameworks/native/opengl/libagl/Android.mk \
  509. ./frameworks/native/opengl/libs/Android.mk \
  510. ./frameworks/native/services/powermanager/Android.mk \
  511. ./frameworks/native/services/sensorservice/Android.mk \
  512. ./frameworks/native/services/surfaceflinger/Android.mk \
  513. ./frameworks/native/services/batteryservice/Android.mk \
  514. ./frameworks/native/cmds/servicemanager/Android.mk \
  515. ./frameworks/opt/emoji/Android.mk \
  516. ./frameworks/av/camera/Android.mk \
  517. ./frameworks/av/media/libmedia/Android.mk \
  518. ./frameworks/av/media/libstagefright/Android.mk \
  519. ./frameworks/native/services/connectivitymanager/Android.mk \
  520. ./frameworks/av/drm/libdrmframework/Android.mk \
  521. ./frameworks/av/drm/common/Android.mk \
  522. ./frameworks/av/services/camera/libcameraservice/Android.mk \
  523. ./frameworks/av/media/libmediaplayerservice/Android.mk \
  524. ./prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/Android.mk \
  525. ./prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/Android.mk \
  526. ./prebuilts/ndk/Android.mk \
  527. ./prebuilts/tools/Android.mk \
  528. $(shell build/tools/findleaves.py --prune=out --prune=.repo --prune=.git $(subdir_makefile_dirs) Android.mk)
  529.  
  530. # End of hybris mods
  531.  
  532. $(foreach mk, $(subdir_makefiles), $(eval include $(mk)))
  533.  
  534. endif # dont_bother
  535.  
  536. endif # ONE_SHOT_MAKEFILE
  537.  
  538. # Now with all Android.mks loaded we can do post cleaning steps.
  539. include $(BUILD_SYSTEM)/post_clean.mk
  540.  
  541. ifeq ($(stash_product_vars),true)
  542. $(call assert-product-vars, __STASHED)
  543. endif
  544.  
  545. include $(BUILD_SYSTEM)/legacy_prebuilts.mk
  546. ifneq ($(filter-out $(GRANDFATHERED_ALL_PREBUILT),$(strip $(notdir $(ALL_PREBUILT)))),)
  547. $(warning *** Some files have been added to ALL_PREBUILT.)
  548. $(warning *)
  549. $(warning * ALL_PREBUILT is a deprecated mechanism that)
  550. $(warning * should not be used for new files.)
  551. $(warning * As an alternative, use PRODUCT_COPY_FILES in)
  552. $(warning * the appropriate product definition.)
  553. $(warning * build/target/product/core.mk is the product)
  554. $(warning * definition used in all products.)
  555. $(warning *)
  556. $(foreach bad_prebuilt,$(filter-out $(GRANDFATHERED_ALL_PREBUILT),$(strip $(notdir $(ALL_PREBUILT)))),$(warning * unexpected $(bad_prebuilt) in ALL_PREBUILT))
  557. $(warning *)
  558. $(error ALL_PREBUILT contains unexpected files)
  559. endif
  560.  
  561. # -------------------------------------------------------------------
  562. # All module makefiles have been included at this point.
  563. # -------------------------------------------------------------------
  564.  
  565.  
  566. # -------------------------------------------------------------------
  567. # Fix up CUSTOM_MODULES to refer to installed files rather than
  568. # just bare module names. Leave unknown modules alone in case
  569. # they're actually full paths to a particular file.
  570. known_custom_modules := $(filter $(ALL_MODULES),$(CUSTOM_MODULES))
  571. unknown_custom_modules := $(filter-out $(ALL_MODULES),$(CUSTOM_MODULES))
  572. CUSTOM_MODULES := \
  573. $(call module-installed-files,$(known_custom_modules)) \
  574. $(unknown_custom_modules)
  575.  
  576. # -------------------------------------------------------------------
  577. # Define dependencies for modules that require other modules.
  578. # This can only happen now, after we've read in all module makefiles.
  579. #
  580. # TODO: deal with the fact that a bare module name isn't
  581. # unambiguous enough. Maybe declare short targets like
  582. # APPS:Quake or HOST:SHARED_LIBRARIES:libutils.
  583. # BUG: the system image won't know to depend on modules that are
  584. # brought in as requirements of other modules.
  585. define add-required-deps
  586. $(1): | $(2)
  587. endef
  588. $(foreach m,$(ALL_MODULES), \
  589. $(eval r := $(ALL_MODULES.$(m).REQUIRED)) \
  590. $(if $(r), \
  591. $(eval r := $(call module-installed-files,$(r))) \
  592. $(eval t_m := $(filter $(TARGET_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
  593. $(eval h_m := $(filter $(HOST_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
  594. $(eval t_r := $(filter $(TARGET_OUT_ROOT)/%, $(r))) \
  595. $(eval h_r := $(filter $(HOST_OUT_ROOT)/%, $(r))) \
  596. $(if $(t_m), $(eval $(call add-required-deps, $(t_m),$(t_r)))) \
  597. $(if $(h_m), $(eval $(call add-required-deps, $(h_m),$(h_r)))) \
  598. ) \
  599. )
  600.  
  601. t_m :=
  602. h_m :=
  603. t_r :=
  604. h_r :=
  605.  
  606. # Resolve the dependencies on shared libraries.
  607. $(foreach m,$(TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES), \
  608. $(eval p := $(subst :,$(space),$(m))) \
  609. $(eval r := $(filter $(TARGET_OUT_ROOT)/%,$(call module-installed-files,\
  610. $(subst $(comma),$(space),$(lastword $(p)))))) \
  611. $(eval $(call add-required-deps,$(word 2,$(p)),$(r))))
  612. $(foreach m,$(HOST_DEPENDENCIES_ON_SHARED_LIBRARIES), \
  613. $(eval p := $(subst :,$(space),$(m))) \
  614. $(eval r := $(filter $(HOST_OUT_ROOT)/%,$(call module-installed-files,\
  615. $(subst $(comma),$(space),$(lastword $(p)))))) \
  616. $(eval $(call add-required-deps,$(word 2,$(p)),$(r))))
  617.  
  618. m :=
  619. r :=
  620. p :=
  621. add-required-deps :=
  622.  
  623. # -------------------------------------------------------------------
  624. # Figure out our module sets.
  625. #
  626. # Of the modules defined by the component makefiles,
  627. # determine what we actually want to build.
  628.  
  629. ifdef FULL_BUILD
  630. # The base list of modules to build for this product is specified
  631. # by the appropriate product definition file, which was included
  632. # by product_config.make.
  633. product_MODULES := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES)
  634. # Filter out the overridden packages before doing expansion
  635. product_MODULES := $(filter-out $(foreach p, $(product_MODULES), \
  636. $(PACKAGES.$(p).OVERRIDES)), $(product_MODULES))
  637. $(call expand-required-modules,product_MODULES,$(product_MODULES))
  638. product_FILES := $(call module-installed-files, $(product_MODULES))
  639. ifeq (0,1)
  640. $(info product_FILES for $(TARGET_DEVICE) ($(INTERNAL_PRODUCT)):)
  641. $(foreach p,$(product_FILES),$(info : $(p)))
  642. $(error done)
  643. endif
  644. else
  645. # We're not doing a full build, and are probably only including
  646. # a subset of the module makefiles. Don't try to build any modules
  647. # requested by the product, because we probably won't have rules
  648. # to build them.
  649. product_FILES :=
  650. endif
  651.  
  652. eng_MODULES := $(sort \
  653. $(call get-tagged-modules,eng) \
  654. $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_ENG)) \
  655. )
  656. debug_MODULES := $(sort \
  657. $(call get-tagged-modules,debug) \
  658. $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_DEBUG)) \
  659. )
  660. tests_MODULES := $(sort \
  661. $(call get-tagged-modules,tests) \
  662. $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_TESTS)) \
  663. )
  664.  
  665. # TODO: Remove the 3 places in the tree that use ALL_DEFAULT_INSTALLED_MODULES
  666. # and get rid of it from this list.
  667. # TODO: The shell is chosen by magic. Do we still need this?
  668. modules_to_install := $(sort \
  669. $(ALL_DEFAULT_INSTALLED_MODULES) \
  670. $(product_FILES) \
  671. $(foreach tag,$(tags_to_install),$($(tag)_MODULES)) \
  672. $(call get-tagged-modules, shell_$(TARGET_SHELL)) \
  673. $(CUSTOM_MODULES) \
  674. )
  675.  
  676. # Some packages may override others using LOCAL_OVERRIDES_PACKAGES.
  677. # Filter out (do not install) any overridden packages.
  678. overridden_packages := $(call get-package-overrides,$(modules_to_install))
  679. ifdef overridden_packages
  680. # old_modules_to_install := $(modules_to_install)
  681. modules_to_install := \
  682. $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
  683. $(modules_to_install))
  684. endif
  685. #$(error filtered out
  686. # $(filter-out $(modules_to_install),$(old_modules_to_install)))
  687.  
  688. # Don't include any GNU targets in the SDK. It's ok (and necessary)
  689. # to build the host tools, but nothing that's going to be installed
  690. # on the target (including static libraries).
  691. ifdef is_sdk_build
  692. target_gnu_MODULES := \
  693. $(filter \
  694. $(TARGET_OUT_INTERMEDIATES)/% \
  695. $(TARGET_OUT)/% \
  696. $(TARGET_OUT_DATA)/%, \
  697. $(sort $(call get-tagged-modules,gnu)))
  698. $(info Removing from sdk:)$(foreach d,$(target_gnu_MODULES),$(info : $(d)))
  699. modules_to_install := \
  700. $(filter-out $(target_gnu_MODULES),$(modules_to_install))
  701.  
  702. # Ensure every module listed in PRODUCT_PACKAGES* gets something installed
  703. # TODO: Should we do this for all builds and not just the sdk?
  704. $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES), \
  705. $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
  706. $(error $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES has nothing to install!)))
  707. $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_DEBUG), \
  708. $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
  709. $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_DEBUG has nothing to install!)))
  710. $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_ENG), \
  711. $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
  712. $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_ENG has nothing to install!)))
  713. $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_TESTS), \
  714. $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
  715. $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_TESTS has nothing to install!)))
  716. endif
  717.  
  718. # build/core/Makefile contains extra stuff that we don't want to pollute this
  719. # top-level makefile with. It expects that ALL_DEFAULT_INSTALLED_MODULES
  720. # contains everything that's built during the current make, but it also further
  721. # extends ALL_DEFAULT_INSTALLED_MODULES.
  722. ALL_DEFAULT_INSTALLED_MODULES := $(modules_to_install)
  723. include $(BUILD_SYSTEM)/Makefile
  724. modules_to_install := $(sort $(ALL_DEFAULT_INSTALLED_MODULES))
  725. ALL_DEFAULT_INSTALLED_MODULES :=
  726.  
  727.  
  728. # These are additional goals that we build, in order to make sure that there
  729. # is as little code as possible in the tree that doesn't build.
  730. modules_to_check := $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).CHECKED))
  731.  
  732. # If you would like to build all goals, and not skip any intermediate
  733. # steps, you can pass the "all" modifier goal on the commandline.
  734. ifneq ($(filter all,$(MAKECMDGOALS)),)
  735. modules_to_check += $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).BUILT))
  736. endif
  737.  
  738. # for easier debugging
  739. modules_to_check := $(sort $(modules_to_check))
  740. #$(error modules_to_check $(modules_to_check))
  741.  
  742. # -------------------------------------------------------------------
  743. # This is used to to get the ordering right, you can also use these,
  744. # but they're considered undocumented, so don't complain if their
  745. # behavior changes.
  746. .PHONY: prebuilt
  747. prebuilt: $(ALL_PREBUILT)
  748.  
  749. # An internal target that depends on all copied headers
  750. # (see copy_headers.make). Other targets that need the
  751. # headers to be copied first can depend on this target.
  752. .PHONY: all_copied_headers
  753. all_copied_headers: ;
  754.  
  755. $(ALL_C_CPP_ETC_OBJECTS): | all_copied_headers
  756.  
  757. # All the droid stuff, in directories
  758. .PHONY: files
  759. files: prebuilt \
  760. $(modules_to_install) \
  761. $(INSTALLED_ANDROID_INFO_TXT_TARGET)
  762.  
  763. # -------------------------------------------------------------------
  764.  
  765. .PHONY: checkbuild
  766. checkbuild: $(modules_to_check)
  767. ifeq (true,$(ANDROID_BUILD_EVERYTHING_BY_DEFAULT)$(filter $(MAKECMDGOALS),checkbuild))
  768. droid: checkbuild
  769. else
  770. # ANDROID_BUILD_EVERYTHING_BY_DEFAULT not set, or checkbuild is one of the cmd goals.
  771. checkbuild: droid
  772. endif
  773.  
  774. .PHONY: ramdisk
  775. ramdisk: $(INSTALLED_RAMDISK_TARGET)
  776.  
  777. .PHONY: factory_ramdisk
  778. factory_ramdisk: $(INSTALLED_FACTORY_RAMDISK_TARGET)
  779.  
  780. .PHONY: factory_bundle
  781. factory_bundle: $(INSTALLED_FACTORY_BUNDLE_TARGET)
  782.  
  783. .PHONY: systemtarball
  784. systemtarball: $(INSTALLED_SYSTEMTARBALL_TARGET)
  785.  
  786. .PHONY: boottarball
  787. boottarball: $(INSTALLED_BOOTTARBALL_TARGET)
  788.  
  789. .PHONY: userdataimage
  790. userdataimage: $(INSTALLED_USERDATAIMAGE_TARGET)
  791.  
  792. ifneq (,$(filter userdataimage, $(MAKECMDGOALS)))
  793. $(call dist-for-goals, userdataimage, $(BUILT_USERDATAIMAGE_TARGET))
  794. endif
  795.  
  796. .PHONY: userdatatarball
  797. userdatatarball: $(INSTALLED_USERDATATARBALL_TARGET)
  798.  
  799. .PHONY: cacheimage
  800. cacheimage: $(INSTALLED_CACHEIMAGE_TARGET)
  801.  
  802. .PHONY: vendorimage
  803. vendorimage: $(INSTALLED_VENDORIMAGE_TARGET)
  804.  
  805. .PHONY: bootimage
  806. bootimage: $(INSTALLED_BOOTIMAGE_TARGET)
  807.  
  808. # phony target that include any targets in $(ALL_MODULES)
  809. .PHONY: all_modules
  810. ifndef BUILD_MODULES_IN_PATHS
  811. all_modules: $(ALL_MODULES)
  812. else
  813. # BUILD_MODULES_IN_PATHS is a list of paths relative to the top of the tree
  814. module_path_patterns := $(foreach p, $(BUILD_MODULES_IN_PATHS),\
  815. $(if $(filter %/,$(p)),$(p)%,$(p)/%))
  816. my_all_modules := $(sort $(foreach m, $(ALL_MODULES),$(if $(filter\
  817. $(module_path_patterns), $(addsuffix /,$(ALL_MODULES.$(m).PATH))),$(m))))
  818. all_modules: $(my_all_modules)
  819. endif
  820.  
  821.  
  822. # Build files and then package it into the rom formats
  823. .PHONY: droidcore
  824. droidcore: files \
  825. systemimage \
  826. $(INSTALLED_BOOTIMAGE_TARGET) \
  827. $(INSTALLED_RECOVERYIMAGE_TARGET) \
  828. $(INSTALLED_USERDATAIMAGE_TARGET) \
  829. $(INSTALLED_CACHEIMAGE_TARGET) \
  830. $(INSTALLED_VENDORIMAGE_TARGET) \
  831. $(INSTALLED_FILES_FILE)
  832.  
  833. # dist_files only for putting your library into the dist directory with a full build.
  834. .PHONY: dist_files
  835.  
  836. ifneq ($(TARGET_BUILD_APPS),)
  837. # If this build is just for apps, only build apps and not the full system by default.
  838.  
  839. unbundled_build_modules :=
  840. ifneq ($(filter all,$(TARGET_BUILD_APPS)),)
  841. # If they used the magic goal "all" then build all apps in the source tree.
  842. unbundled_build_modules := $(foreach m,$(sort $(ALL_MODULES)),$(if $(filter APPS,$(ALL_MODULES.$(m).CLASS)),$(m)))
  843. else
  844. unbundled_build_modules := $(TARGET_BUILD_APPS)
  845. endif
  846.  
  847. # Dist the installed files if they exist.
  848. apps_only_installed_files := $(foreach m,$(unbundled_build_modules),$(ALL_MODULES.$(m).INSTALLED))
  849. $(call dist-for-goals,apps_only, $(apps_only_installed_files))
  850. # For uninstallable modules such as static Java library, we have to dist the built file,
  851. # as <module_name>.<suffix>
  852. apps_only_dist_built_files := $(foreach m,$(unbundled_build_modules),$(if $(ALL_MODULES.$(m).INSTALLED),,\
  853. $(if $(ALL_MODULES.$(m).BUILT),$(ALL_MODULES.$(m).BUILT):$(m)$(suffix $(ALL_MODULES.$(m).BUILT)))))
  854. $(call dist-for-goals,apps_only, $(apps_only_dist_built_files))
  855.  
  856. ifeq ($(EMMA_INSTRUMENT),true)
  857. $(EMMA_META_ZIP) : $(apps_only_installed_files)
  858.  
  859. $(call dist-for-goals,apps_only, $(EMMA_META_ZIP))
  860. endif
  861.  
  862. $(PROGUARD_DICT_ZIP) : $(apps_only_installed_files)
  863. $(call dist-for-goals,apps_only, $(PROGUARD_DICT_ZIP))
  864.  
  865. .PHONY: apps_only
  866. apps_only: $(unbundled_build_modules)
  867.  
  868. droid: apps_only
  869.  
  870. # Combine the NOTICE files for a apps_only build
  871. $(eval $(call combine-notice-files, \
  872. $(target_notice_file_txt), \
  873. $(target_notice_file_html), \
  874. "Notices for files for apps:", \
  875. $(TARGET_OUT_NOTICE_FILES), \
  876. $(apps_only_installed_files)))
  877.  
  878.  
  879. else # TARGET_BUILD_APPS
  880. $(call dist-for-goals, droidcore, \
  881. $(INTERNAL_UPDATE_PACKAGE_TARGET) \
  882. $(INTERNAL_OTA_PACKAGE_TARGET) \
  883. $(SYMBOLS_ZIP) \
  884. $(INSTALLED_FILES_FILE) \
  885. $(INSTALLED_BUILD_PROP_TARGET) \
  886. $(BUILT_TARGET_FILES_PACKAGE) \
  887. $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
  888. $(INSTALLED_RAMDISK_TARGET) \
  889. $(INSTALLED_FACTORY_RAMDISK_TARGET) \
  890. $(INSTALLED_FACTORY_BUNDLE_TARGET) \
  891. )
  892.  
  893. # Put a copy of the radio/bootloader files in the dist dir.
  894. $(foreach f,$(INSTALLED_RADIOIMAGE_TARGET), \
  895. $(call dist-for-goals, droidcore, $(f)))
  896.  
  897. ifneq ($(TARGET_BUILD_PDK),true)
  898. $(call dist-for-goals, droidcore, \
  899. $(APPS_ZIP) \
  900. $(INTERNAL_EMULATOR_PACKAGE_TARGET) \
  901. $(PACKAGE_STATS_FILE) \
  902. )
  903. endif
  904.  
  905. ifeq ($(EMMA_INSTRUMENT),true)
  906. $(EMMA_META_ZIP) : $(INSTALLED_SYSTEMIMAGE)
  907.  
  908. $(call dist-for-goals, dist_files, $(EMMA_META_ZIP))
  909. endif
  910.  
  911. # Building a full system-- the default is to build droidcore
  912. droid: droidcore dist_files
  913.  
  914. endif # TARGET_BUILD_APPS
  915.  
  916. .PHONY: docs
  917. docs: $(ALL_DOCS)
  918.  
  919. .PHONY: sdk
  920. ALL_SDK_TARGETS := $(INTERNAL_SDK_TARGET)
  921. sdk: $(ALL_SDK_TARGETS)
  922. $(call dist-for-goals,sdk win_sdk, \
  923. $(ALL_SDK_TARGETS) \
  924. $(SYMBOLS_ZIP) \
  925. $(INSTALLED_BUILD_PROP_TARGET) \
  926. )
  927.  
  928. # umbrella targets to assit engineers in verifying builds
  929. .PHONY: java native target host java-host java-target native-host native-target \
  930. java-host-tests java-target-tests native-host-tests native-target-tests \
  931. java-tests native-tests host-tests target-tests
  932. # some synonyms
  933. .PHONY: host-java target-java host-native target-native \
  934. target-java-tests target-native-tests
  935. host-java : java-host
  936. target-java : java-target
  937. host-native : native-host
  938. target-native : native-target
  939. target-java-tests : java-target-tests
  940. target-native-tests : native-target-tests
  941.  
  942.  
  943. .PHONY: lintall
  944.  
  945. .PHONY: samplecode
  946. sample_MODULES := $(sort $(call get-tagged-modules,samples))
  947. sample_APKS_DEST_PATH := $(TARGET_COMMON_OUT_ROOT)/samples
  948. sample_APKS_COLLECTION := \
  949. $(foreach module,$(sample_MODULES),$(sample_APKS_DEST_PATH)/$(notdir $(module)))
  950. $(foreach module,$(sample_MODULES),$(eval $(call \
  951. copy-one-file,$(module),$(sample_APKS_DEST_PATH)/$(notdir $(module)))))
  952. sample_ADDITIONAL_INSTALLED := \
  953. $(filter-out $(modules_to_install) $(modules_to_check) $(ALL_PREBUILT),$(sample_MODULES))
  954. samplecode: $(sample_APKS_COLLECTION)
  955. @echo -e ${CL_GRN}"Collect sample code apks:"${CL_RST}" $^"
  956. # remove apks that are not intended to be installed.
  957. rm -f $(sample_ADDITIONAL_INSTALLED)
  958.  
  959. .PHONY: findbugs
  960. findbugs: $(INTERNAL_FINDBUGS_HTML_TARGET) $(INTERNAL_FINDBUGS_XML_TARGET)
  961.  
  962. .PHONY: clean
  963. clean:
  964. @rm -rf $(OUT_DIR)/*
  965. @echo -e ${CL_GRN}"Entire build directory removed."${CL_RST}
  966.  
  967. .PHONY: clobber
  968. clobber: clean
  969.  
  970. # The rules for dataclean and installclean are defined in cleanbuild.mk.
  971.  
  972. #xxx scrape this from ALL_MODULE_NAME_TAGS
  973. .PHONY: modules
  974. modules:
  975. @echo -e ${CL_GRN}"Available sub-modules:"${CL_RST}
  976. @echo "$(call module-names-for-tag-list,$(ALL_MODULE_TAGS))" | \
  977. tr -s ' ' '\n' | sort -u | $(COLUMN)
  978.  
  979. .PHONY: showcommands
  980. showcommands:
  981. @echo >/dev/null
  982.  
  983. .PHONY: nothing
  984. nothing:
  985. @echo Successfully read the makefiles.
  986. HABuildSDK [i9100g] droid $
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement