PageRenderTime 61ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 0ms

/external/libvpx/build/make/Makefile

https://gitlab.com/brian0218/rk3188_r-box_android4.2.2_sdk
Makefile | 357 lines | 246 code | 50 blank | 61 comment | 3 complexity | bf54140bcedd7e68ffdd70256d2ee309 MD5 | raw file
  1. ##
  2. ## Copyright (c) 2010 The WebM project authors. All Rights Reserved.
  3. ##
  4. ## Use of this source code is governed by a BSD-style license
  5. ## that can be found in the LICENSE file in the root of the source
  6. ## tree. An additional intellectual property rights grant can be found
  7. ## in the file PATENTS. All contributing project authors may
  8. ## be found in the AUTHORS file in the root of the source tree.
  9. ##
  10. include config.mk
  11. quiet?=true
  12. ifeq ($(target),)
  13. # If a target wasn't specified, invoke for all enabled targets.
  14. .DEFAULT:
  15. @for t in $(ALL_TARGETS); do \
  16. $(MAKE) --no-print-directory target=$$t $(MAKECMDGOALS) || exit $$?;\
  17. done
  18. all: .DEFAULT
  19. clean:: .DEFAULT
  20. install:: .DEFAULT
  21. # Note: md5sum is not installed on OS X, but openssl is. Openssl may not be
  22. # installed on cygwin, so we need to autodetect here.
  23. md5sum := $(firstword $(wildcard \
  24. $(foreach e,md5sum openssl,\
  25. $(foreach p,$(subst :, ,$(PATH)),$(p)/$(e)*))\
  26. ))
  27. md5sum := $(if $(filter %openssl,$(md5sum)),$(md5sum) dgst -md5,$(md5sum))
  28. TGT_CC:=$(word 3, $(subst -, ,$(TOOLCHAIN)))
  29. dist:
  30. @for t in $(ALL_TARGETS); do \
  31. $(MAKE) --no-print-directory target=$$t $(MAKECMDGOALS) || exit $$?;\
  32. done
  33. # Run configure for the user with the current toolchain.
  34. @if [ -d "$(DIST_DIR)/src" ]; then \
  35. mkdir -p "$(DIST_DIR)/build"; \
  36. cd "$(DIST_DIR)/build"; \
  37. echo "Rerunning configure $(CONFIGURE_ARGS)"; \
  38. ../src/configure $(CONFIGURE_ARGS); \
  39. $(if $(filter vs%,$(TGT_CC)),make NO_LAUNCH_DEVENV=1;) \
  40. fi
  41. @if [ -d "$(DIST_DIR)" ]; then \
  42. echo " [MD5SUM] $(DIST_DIR)"; \
  43. cd $(DIST_DIR) && \
  44. $(md5sum) `find . -name md5sums.txt -prune -o -type f -print` \
  45. | sed -e 's/MD5(\(.*\))= \([0-9a-f]\{32\}\)/\2 \1/' \
  46. > md5sums.txt;\
  47. fi
  48. endif
  49. ifneq ($(target),)
  50. # Normally, we want to build the filename from the target and the toolchain.
  51. # This disambiguates from the $(target).mk file that exists in the source tree.
  52. # However, the toolchain is part of the target in universal builds, so we
  53. # don't want to include TOOLCHAIN in that case. FAT_ARCHS is used to test
  54. # if we're in the universal case.
  55. include $(target)$(if $(FAT_ARCHS),,-$(TOOLCHAIN)).mk
  56. endif
  57. BUILD_ROOT?=.
  58. VPATH=$(SRC_PATH_BARE)
  59. CFLAGS+=-I$(BUILD_PFX)$(BUILD_ROOT) -I$(SRC_PATH)
  60. ASFLAGS+=-I$(BUILD_PFX)$(BUILD_ROOT)/ -I$(SRC_PATH)/
  61. DIST_DIR?=dist
  62. HOSTCC?=gcc
  63. TGT_ISA:=$(word 1, $(subst -, ,$(TOOLCHAIN)))
  64. TGT_OS:=$(word 2, $(subst -, ,$(TOOLCHAIN)))
  65. TGT_CC:=$(word 3, $(subst -, ,$(TOOLCHAIN)))
  66. quiet:=$(if $(verbose),,yes)
  67. qexec=$(if $(quiet),@)
  68. # Cancel built-in implicit rules
  69. %: %.o
  70. %.asm:
  71. %.a:
  72. #
  73. # Common rules"
  74. #
  75. .PHONY: all-$(target)
  76. all-$(target):
  77. .PHONY: clean
  78. clean::
  79. rm -f $(OBJS-yes) $(OBJS-yes:.o=.d) $(OBJS-yes:.asm.s.o=.asm.s)
  80. rm -f $(CLEAN-OBJS)
  81. .PHONY: dist
  82. dist:
  83. .PHONY: install
  84. install::
  85. $(BUILD_PFX)%.c.d: %.c
  86. $(if $(quiet),@echo " [DEP] $@")
  87. $(qexec)mkdir -p $(dir $@)
  88. $(qexec)$(CC) $(CFLAGS) -M $< | $(fmt_deps) > $@
  89. $(BUILD_PFX)%.c.o: %.c
  90. $(if $(quiet),@echo " [CC] $@")
  91. $(qexec)$(CC) $(CFLAGS) -c -o $@ $<
  92. $(BUILD_PFX)%.asm.d: %.asm
  93. $(if $(quiet),@echo " [DEP] $@")
  94. $(qexec)mkdir -p $(dir $@)
  95. $(qexec)$(SRC_PATH_BARE)/build/make/gen_asm_deps.sh \
  96. --build-pfx=$(BUILD_PFX) --depfile=$@ $(ASFLAGS) $< > $@
  97. $(BUILD_PFX)%.asm.o: %.asm
  98. $(if $(quiet),@echo " [AS] $@")
  99. $(qexec)$(AS) $(ASFLAGS) -o $@ $<
  100. $(BUILD_PFX)%.s.d: %.s
  101. $(if $(quiet),@echo " [DEP] $@")
  102. $(qexec)mkdir -p $(dir $@)
  103. $(qexec)$(SRC_PATH_BARE)/build/make/gen_asm_deps.sh \
  104. --build-pfx=$(BUILD_PFX) --depfile=$@ $(ASFLAGS) $< > $@
  105. $(BUILD_PFX)%.s.o: %.s
  106. $(if $(quiet),@echo " [AS] $@")
  107. $(qexec)$(AS) $(ASFLAGS) -o $@ $<
  108. .PRECIOUS: %.asm.s
  109. $(BUILD_PFX)%.asm.s: %.asm
  110. $(if $(quiet),@echo " [ASM CONVERSION] $@")
  111. $(qexec)mkdir -p $(dir $@)
  112. $(qexec)$(ASM_CONVERSION) <$< >$@
  113. # If we're in debug mode, pretend we don't have GNU strip, to fall back to
  114. # the copy implementation
  115. HAVE_GNU_STRIP := $(if $(CONFIG_DEBUG),,$(HAVE_GNU_STRIP))
  116. ifeq ($(HAVE_GNU_STRIP),yes)
  117. # Older binutils strip global sybols not needed for relocation processing
  118. # when given --strip-unneeded. Use nm and awk to identify globals and
  119. # keep them.
  120. %.a: %_g.a
  121. $(if $(quiet),@echo " [STRIP] $@ < $<")
  122. $(qexec)$(STRIP) --strip-unneeded \
  123. `$(NM) $< | grep ' [A-TV-Z] ' | awk '{print "-K"$$3'}`\
  124. -o $@ $<
  125. else
  126. %.a: %_g.a
  127. $(if $(quiet),@echo " [CP] $@ < $<")
  128. $(qexec)cp $< $@
  129. endif
  130. #
  131. # Rule to extract assembly constants from C sources
  132. #
  133. obj_int_extract: build/make/obj_int_extract.c
  134. $(if $(quiet),@echo " [HOSTCC] $@")
  135. $(qexec)$(HOSTCC) -I. -I$(SRC_PATH_BARE) -o $@ $<
  136. CLEAN-OBJS += obj_int_extract
  137. #
  138. # Utility functions
  139. #
  140. pairmap=$(if $(strip $(2)),\
  141. $(call $(1),$(word 1,$(2)),$(word 2,$(2)))\
  142. $(call pairmap,$(1),$(wordlist 3,$(words $(2)),$(2)))\
  143. )
  144. enabled=$(filter-out $($(1)-no),$($(1)-yes))
  145. cond_enabled=$(if $(filter yes,$($(1))), $(call enabled,$(2)))
  146. find_file1=$(word 1,$(wildcard $(subst //,/,$(addsuffix /$(1),$(2)))))
  147. find_file=$(foreach f,$(1),$(call find_file1,$(strip $(f)),$(strip $(2))) )
  148. obj_pats=.c=.c.o $(AS_SFX)=$(AS_SFX).o
  149. objs=$(addprefix $(BUILD_PFX),$(foreach p,$(obj_pats),$(filter %.o,$(1:$(p))) ))
  150. install_map_templates=$(eval $(call install_map_template,$(1),$(2)))
  151. not=$(subst yes,no,$(1))
  152. ifeq ($(CONFIG_MSVS),yes)
  153. lib_file_name=$(1).lib
  154. else
  155. lib_file_name=lib$(1).a
  156. endif
  157. #
  158. # Rule Templates
  159. #
  160. define linker_template
  161. $(1): $(filter-out -%,$(2))
  162. $(1):
  163. $(if $(quiet),@echo " [LD] $$@")
  164. $(qexec)$$(LD) $$(strip $$(LDFLAGS) -o $$@ $(2) $(3) $$(extralibs))
  165. endef
  166. # make-3.80 has a bug with expanding large input strings to the eval function,
  167. # which was triggered in some cases by the following component of
  168. # linker_template:
  169. # $(1): $$(call find_file, $(patsubst -l%,lib%.a,$(filter -l%,$(2))),\
  170. # $$(patsubst -L%,%,$$(filter -L%,$$(LDFLAGS) $(2))))
  171. # This may be useful to revisit in the future (it tries to locate libraries
  172. # in a search path and add them as prerequisites
  173. define install_map_template
  174. $(DIST_DIR)/$(1): $(2)
  175. $(if $(quiet),@echo " [INSTALL] $$@")
  176. $(qexec)mkdir -p $$(dir $$@)
  177. $(qexec)cp -p $$< $$@
  178. endef
  179. define archive_template
  180. # Not using a pattern rule here because we don't want to generate empty
  181. # archives when they are listed as a dependency in files not responsible
  182. # for creating them.
  183. $(1):
  184. $(if $(quiet),@echo " [AR] $$@")
  185. $(qexec)$$(AR) $$(ARFLAGS) $$@ $$?
  186. endef
  187. define so_template
  188. # Not using a pattern rule here because we don't want to generate empty
  189. # archives when they are listed as a dependency in files not responsible
  190. # for creating them.
  191. #
  192. # This needs further abstraction for dealing with non-GNU linkers.
  193. $(1):
  194. $(if $(quiet),@echo " [LD] $$@")
  195. $(qexec)$$(LD) -shared $$(LDFLAGS) \
  196. -Wl,--no-undefined -Wl,-soname,$$(SONAME) \
  197. -Wl,--version-script,$$(SO_VERSION_SCRIPT) -o $$@ \
  198. $$(filter %.o,$$?) $$(extralibs)
  199. endef
  200. define lipo_lib_template
  201. $(1): $(addsuffix /$(1),$(FAT_ARCHS))
  202. $(if $(quiet),@echo " [LIPO] $$@")
  203. $(qexec)libtool -static -o $$@ $$?
  204. endef
  205. define lipo_bin_template
  206. $(1): $(addsuffix /$(1),$(FAT_ARCHS))
  207. $(if $(quiet),@echo " [LIPO] $$@")
  208. $(qexec)lipo -output $$@ -create $$?
  209. endef
  210. #
  211. # Get current configuration
  212. #
  213. ifneq ($(target),)
  214. include $(SRC_PATH_BARE)/$(target:-$(TOOLCHAIN)=).mk
  215. endif
  216. ifeq ($(filter clean,$(MAKECMDGOALS)),)
  217. # Older versions of make don't like -include directives with no arguments
  218. ifneq ($(filter %.d,$(OBJS-yes:.o=.d)),)
  219. -include $(filter %.d,$(OBJS-yes:.o=.d))
  220. endif
  221. endif
  222. #
  223. # Configuration dependent rules
  224. #
  225. $(call pairmap,install_map_templates,$(INSTALL_MAPS))
  226. DOCS=$(call cond_enabled,CONFIG_INSTALL_DOCS,DOCS)
  227. .docs: $(DOCS)
  228. @touch $@
  229. INSTALL-DOCS=$(call cond_enabled,CONFIG_INSTALL_DOCS,INSTALL-DOCS)
  230. ifeq ($(MAKECMDGOALS),dist)
  231. INSTALL-DOCS+=$(call cond_enabled,CONFIG_INSTALL_DOCS,DIST-DOCS)
  232. endif
  233. .install-docs: .docs $(addprefix $(DIST_DIR)/,$(INSTALL-DOCS))
  234. @touch $@
  235. clean::
  236. rm -f .docs .install-docs $(DOCS)
  237. BINS=$(call enabled,BINS)
  238. .bins: $(BINS)
  239. @touch $@
  240. INSTALL-BINS=$(call cond_enabled,CONFIG_INSTALL_BINS,INSTALL-BINS)
  241. ifeq ($(MAKECMDGOALS),dist)
  242. INSTALL-BINS+=$(call cond_enabled,CONFIG_INSTALL_BINS,DIST-BINS)
  243. endif
  244. .install-bins: .bins $(addprefix $(DIST_DIR)/,$(INSTALL-BINS))
  245. @touch $@
  246. clean::
  247. rm -f .bins .install-bins $(BINS)
  248. LIBS=$(call enabled,LIBS)
  249. .libs: $(LIBS)
  250. @touch $@
  251. $(foreach lib,$(filter %_g.a,$(LIBS)),$(eval $(call archive_template,$(lib))))
  252. $(foreach lib,$(filter %so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH),$(LIBS)),$(eval $(call so_template,$(lib))))
  253. INSTALL-LIBS=$(call cond_enabled,CONFIG_INSTALL_LIBS,INSTALL-LIBS)
  254. ifeq ($(MAKECMDGOALS),dist)
  255. INSTALL-LIBS+=$(call cond_enabled,CONFIG_INSTALL_LIBS,DIST-LIBS)
  256. endif
  257. .install-libs: .libs $(addprefix $(DIST_DIR)/,$(INSTALL-LIBS))
  258. @touch $@
  259. clean::
  260. rm -f .libs .install-libs $(LIBS)
  261. ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
  262. PROJECTS=$(call enabled,PROJECTS)
  263. .projects: $(PROJECTS)
  264. @touch $@
  265. INSTALL-PROJECTS=$(call cond_enabled,CONFIG_INSTALL_PROJECTS,INSTALL-PROJECTS)
  266. ifeq ($(MAKECMDGOALS),dist)
  267. INSTALL-PROJECTS+=$(call cond_enabled,CONFIG_INSTALL_PROJECTS,DIST-PROJECTS)
  268. endif
  269. .install-projects: .projects $(addprefix $(DIST_DIR)/,$(INSTALL-PROJECTS))
  270. @touch $@
  271. clean::
  272. rm -f .projects .install-projects $(PROJECTS)
  273. endif
  274. # If there are any source files to be distributed, then include the build
  275. # system too.
  276. ifneq ($(call enabled,DIST-SRCS),)
  277. DIST-SRCS-yes += configure
  278. DIST-SRCS-yes += build/make/configure.sh
  279. DIST-SRCS-yes += build/make/gen_asm_deps.sh
  280. DIST-SRCS-yes += build/make/Makefile
  281. DIST-SRCS-$(CONFIG_MSVS) += build/make/gen_msvs_def.sh
  282. DIST-SRCS-$(CONFIG_MSVS) += build/make/gen_msvs_proj.sh
  283. DIST-SRCS-$(CONFIG_MSVS) += build/make/gen_msvs_sln.sh
  284. DIST-SRCS-$(CONFIG_MSVS) += build/x86-msvs/yasm.rules
  285. DIST-SRCS-$(CONFIG_RVCT) += build/make/armlink_adapter.sh
  286. # Include obj_int_extract if we use offsets from asm_*_offsets
  287. DIST-SRCS-$(ARCH_ARM)$(ARCH_X86)$(ARCH_X86_64) += build/make/obj_int_extract.c
  288. DIST-SRCS-$(ARCH_ARM) += build/make/ads2gas.pl
  289. DIST-SRCS-yes += $(target:-$(TOOLCHAIN)=).mk
  290. endif
  291. INSTALL-SRCS := $(call cond_enabled,CONFIG_INSTALL_SRCS,INSTALL-SRCS)
  292. ifeq ($(MAKECMDGOALS),dist)
  293. INSTALL-SRCS += $(call cond_enabled,CONFIG_INSTALL_SRCS,DIST-SRCS)
  294. endif
  295. .install-srcs: $(addprefix $(DIST_DIR)/src/,$(INSTALL-SRCS))
  296. @touch $@
  297. clean::
  298. rm -f .install-srcs
  299. ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
  300. BUILD_TARGETS += .projects
  301. INSTALL_TARGETS += .install-projects
  302. endif
  303. BUILD_TARGETS += .docs .libs .bins
  304. INSTALL_TARGETS += .install-docs .install-srcs .install-libs .install-bins
  305. all-$(target): $(BUILD_TARGETS)
  306. install:: $(INSTALL_TARGETS)
  307. dist: $(INSTALL_TARGETS)