Advertisement
Guest User

main.mk

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