Makefile 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #-------------------------------------------------------------------------------
  2. # Copyright (C) 2012 Freescale Semiconductor, Inc. All Rights Reserved.
  3. #
  4. # THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESS OR IMPLIED
  5. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  6. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
  7. # SHALL FREESCALE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  8. # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
  9. # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  10. # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  11. # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  12. # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  13. # OF SUCH DAMAGE.
  14. #-------------------------------------------------------------------------------
  15. #
  16. # Top-level Makefile.
  17. #
  18. # This file is responsible for building all libraries and applications.
  19. #
  20. # Targets:
  21. # - all
  22. # - sdk
  23. # - board
  24. # - sdk_unit_test
  25. # - power_modes_test
  26. # - obds
  27. # - gpu_demo
  28. # - smp_primes
  29. # - stream
  30. # - usb_hid_mouse
  31. # - httpd
  32. # - ping
  33. # - clean
  34. # - clean_sdk
  35. # - clean_board
  36. # - clean_sdk_unit_test
  37. # - clean_power_modes_test
  38. # - clean_obds
  39. # - clean_gpu_demo
  40. # - clean_smp_primes
  41. # - clean_stream
  42. # - clean_usb_hid_mouse
  43. # - clean_httpd
  44. # - clean_ping
  45. #
  46. # The clean targets work with any combination of configuration variables. For
  47. # example, clean_sdk with TARGET set will clean libsdk for only that TARGET, while
  48. # clean_sdk without TARGET set will clean libsdk in all targets.
  49. #
  50. include mk/common.mk
  51. # Turn off parallel jobs for this makefile only. Child makefiles will still use the
  52. # specified number of jobs. This isn't strictly necessary, and actually slows the build
  53. # a little bit, but greatly improves the readability of the log output.
  54. .NOTPARALLEL:
  55. # Determine if the target is either the MX6DQ or MX6SDL.
  56. ifeq "$(TARGET)" "mx6dq"
  57. is_dq_or_sdl = 1
  58. else ifeq "$(TARGET)" "mx6sdl"
  59. is_dq_or_sdl = 1
  60. endif
  61. # Library subdirectories that the apps depend upon. Handled automatically by targets.mk.
  62. SUBDIRS = \
  63. sdk \
  64. lwip \
  65. $(BOARD_ROOT)
  66. # List of all applications to build. Applications must reside in the apps directory.
  67. ALL_APPS = \
  68. filesystem \
  69. httpd \
  70. obds \
  71. ping \
  72. power_modes_test \
  73. sdk_unit_test \
  74. stream \
  75. usb_hid_mouse
  76. # Apps that are only built for MX6DQ and MX6SDL.
  77. ifdef is_dq_or_sdl
  78. ALL_APPS += \
  79. caam_blob_gen \
  80. gpu_demo \
  81. smp_primes
  82. endif
  83. # Default target.
  84. .PHONY: all
  85. all: $(sort $(ALL_APPS)) ;
  86. # App targets. All apps depend on the listed subdirectories.
  87. .PHONY: ALL_APPS
  88. $(ALL_APPS): $(SUBDIRS)
  89. @$(call printmessage,build,Building, $@ ,gray,[$(TARGET) $(BOARD) $(BOARD_REVISION)],,\n)
  90. @$(MAKE) $(silent_make) -r -C apps/$@
  91. # Print message before recursive into subdirs.
  92. $(SUBDIRS)::
  93. @$(call printmessage,build,Building, $(@F) ,gray,[$(TARGET) $(BOARD) $(BOARD_REVISION)],,\n)
  94. # Target with a simple name for building the board package.
  95. .PHONY: board
  96. board: $(BOARD_ROOT)
  97. # Target to clean everything.
  98. .PHONY: clean
  99. clean:
  100. @echo "Deleting output directory..."
  101. @rm -rf output
  102. @echo "done."
  103. # Target to clean just the sdk library and objects.
  104. .PHONY: clean_sdk
  105. clean_sdk:
  106. ifdef TARGET
  107. rm -rf $(LIBSDK) $(OUTPUT_ROOT)/lib/obj/sdk
  108. else
  109. rm -rf $(SDK_ROOT)/output/*/lib/libsdk.a $(SDK_ROOT)/output/*/lib/obj/sdk
  110. endif
  111. # Target to clean the board library and objects.
  112. .PHONY: clean_board
  113. clean_board:
  114. ifdef TARGET
  115. ifdef BOARD
  116. rm -rf $(LIBBOARD) $(OUTPUT_ROOT)/lib/obj/board_$(BOARD_WITH_REV)
  117. else
  118. rm -rf $(OUTPUT_ROOT)/lib/libboard* $(OUTPUT_ROOT)/lib/obj/board_*
  119. endif
  120. else
  121. rm -rf $(SDK_ROOT)/output/*/lib/libboard* $(SDK_ROOT)/output/*/lib/obj/board_*
  122. endif
  123. # Set up targets to clean each of the applications. For an app "foo", the target to clean
  124. # just that app is "clean_foo". If no TARGET is passed to make, the app is cleaned
  125. # for all targets.
  126. ALL_APP_CLEAN_TARGETS := $(addprefix clean_,$(ALL_APPS))
  127. .PHONY: $(ALL_APP_CLEAN_TARGETS)
  128. $(ALL_APP_CLEAN_TARGETS):
  129. ifdef TARGET
  130. ifdef BOARD
  131. ifdef BOARD_REVISION
  132. ifdef BOARD_REVISION_IS_DEFAULT
  133. # Clean all revs of the board.
  134. rm -rf $(OUTPUT_ROOT)/$(patsubst clean_%,%,$@)/$(BOARD)_rev_*
  135. else
  136. # Specific rev specified so clean just that one rev.
  137. rm -rf $(OUTPUT_ROOT)/$(patsubst clean_%,%,$@)/$(BOARD_WITH_REV)
  138. endif
  139. else
  140. # Clean all revs of the board.
  141. rm -rf $(OUTPUT_ROOT)/$(patsubst clean_%,%,$@)/$(BOARD)_rev_*
  142. endif
  143. else
  144. # Clean all boards of the app.
  145. rm -rf $(OUTPUT_ROOT)/$(patsubst clean_%,%,$@)
  146. endif
  147. else
  148. # Clean all boards and targets of the app.
  149. rm -rf $(SDK_ROOT)/output/*/$(patsubst clean_%,%,$@)
  150. endif
  151. include mk/targets.mk