libs.mk 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  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. # ARM assembly files are written in RVCT-style. We use some make magic to
  11. # filter those files to allow GCC compilation
  12. ifeq ($(ARCH_ARM),yes)
  13. ASM:=$(if $(filter yes,$(CONFIG_GCC)$(CONFIG_MSVS)),.asm.S,.asm)
  14. else
  15. ASM:=.asm
  16. endif
  17. #
  18. # Rule to generate runtime cpu detection files
  19. #
  20. define rtcd_h_template
  21. $$(BUILD_PFX)$(1).h: $$(SRC_PATH_BARE)/$(2)
  22. @echo " [CREATE] $$@"
  23. $$(qexec)$$(SRC_PATH_BARE)/build/make/rtcd.pl --arch=$$(TGT_ISA) \
  24. --sym=$(1) \
  25. --config=$$(CONFIG_DIR)$$(target)-$$(TOOLCHAIN).mk \
  26. $$(RTCD_OPTIONS) $$^ > $$@
  27. CLEAN-OBJS += $$(BUILD_PFX)$(1).h
  28. RTCD += $$(BUILD_PFX)$(1).h
  29. endef
  30. CODEC_SRCS-yes += CHANGELOG
  31. CODEC_SRCS-yes += libs.mk
  32. include $(SRC_PATH_BARE)/vpx/vpx_codec.mk
  33. CODEC_SRCS-yes += $(addprefix vpx/,$(call enabled,API_SRCS))
  34. CODEC_DOC_SRCS += $(addprefix vpx/,$(call enabled,API_DOC_SRCS))
  35. include $(SRC_PATH_BARE)/vpx_mem/vpx_mem.mk
  36. CODEC_SRCS-yes += $(addprefix vpx_mem/,$(call enabled,MEM_SRCS))
  37. include $(SRC_PATH_BARE)/vpx_scale/vpx_scale.mk
  38. CODEC_SRCS-yes += $(addprefix vpx_scale/,$(call enabled,SCALE_SRCS))
  39. include $(SRC_PATH_BARE)/vpx_ports/vpx_ports.mk
  40. CODEC_SRCS-yes += $(addprefix vpx_ports/,$(call enabled,PORTS_SRCS))
  41. include $(SRC_PATH_BARE)/vpx_dsp/vpx_dsp.mk
  42. CODEC_SRCS-yes += $(addprefix vpx_dsp/,$(call enabled,DSP_SRCS))
  43. include $(SRC_PATH_BARE)/vpx_util/vpx_util.mk
  44. CODEC_SRCS-yes += $(addprefix vpx_util/,$(call enabled,UTIL_SRCS))
  45. ifeq ($(CONFIG_VP8),yes)
  46. VP8_PREFIX=vp8/
  47. include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8_common.mk
  48. endif
  49. ifeq ($(CONFIG_VP8_ENCODER),yes)
  50. include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8cx.mk
  51. CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_CX_SRCS))
  52. CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_CX_EXPORTS))
  53. INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h
  54. INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/%
  55. CODEC_DOC_SECTIONS += vp8 vp8_encoder
  56. endif
  57. ifeq ($(CONFIG_VP8_DECODER),yes)
  58. include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8dx.mk
  59. CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_DX_SRCS))
  60. CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_DX_EXPORTS))
  61. INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h
  62. INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/%
  63. CODEC_DOC_SECTIONS += vp8 vp8_decoder
  64. endif
  65. ifeq ($(CONFIG_VP9),yes)
  66. VP9_PREFIX=vp9/
  67. include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9_common.mk
  68. endif
  69. ifeq ($(CONFIG_VP9_ENCODER),yes)
  70. VP9_PREFIX=vp9/
  71. include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9cx.mk
  72. CODEC_SRCS-yes += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_CX_SRCS))
  73. CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_CX_EXPORTS))
  74. CODEC_SRCS-yes += $(VP9_PREFIX)vp9cx.mk vpx/vp8.h vpx/vp8cx.h
  75. INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h
  76. INSTALL-LIBS-$(CONFIG_SPATIAL_SVC) += include/vpx/svc_context.h
  77. INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/%
  78. CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8cx.h
  79. CODEC_DOC_SECTIONS += vp9 vp9_encoder
  80. endif
  81. ifeq ($(CONFIG_VP9_DECODER),yes)
  82. VP9_PREFIX=vp9/
  83. include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9dx.mk
  84. CODEC_SRCS-yes += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_DX_SRCS))
  85. CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_DX_EXPORTS))
  86. CODEC_SRCS-yes += $(VP9_PREFIX)vp9dx.mk vpx/vp8.h vpx/vp8dx.h
  87. INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h
  88. INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/%
  89. CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8dx.h
  90. CODEC_DOC_SECTIONS += vp9 vp9_decoder
  91. endif
  92. ifeq ($(CONFIG_ENCODERS),yes)
  93. CODEC_DOC_SECTIONS += encoder
  94. endif
  95. ifeq ($(CONFIG_DECODERS),yes)
  96. CODEC_DOC_SECTIONS += decoder
  97. endif
  98. # Suppress -Wextra warnings in third party code.
  99. $(BUILD_PFX)third_party/googletest/%.cc.o: CXXFLAGS += -Wno-missing-field-initializers
  100. # Suppress -Wextra warnings in first party code pending investigation.
  101. # https://bugs.chromium.org/p/webm/issues/detail?id=1069
  102. $(BUILD_PFX)vp8/encoder/onyx_if.c.o: CFLAGS += -Wno-unknown-warning-option -Wno-clobbered
  103. $(BUILD_PFX)vp8/decoder/onyxd_if.c.o: CFLAGS += -Wno-unknown-warning-option -Wno-clobbered
  104. ifeq ($(CONFIG_MSVS),yes)
  105. CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd)
  106. GTEST_LIB=$(if $(CONFIG_STATIC_MSVCRT),gtestmt,gtestmd)
  107. # This variable uses deferred expansion intentionally, since the results of
  108. # $(wildcard) may change during the course of the Make.
  109. VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))
  110. endif
  111. # The following pairs define a mapping of locations in the distribution
  112. # tree to locations in the source/build trees.
  113. INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx/%
  114. INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx_ports/%
  115. INSTALL_MAPS += $(LIBSUBDIR)/% %
  116. INSTALL_MAPS += src/% $(SRC_PATH_BARE)/%
  117. ifeq ($(CONFIG_MSVS),yes)
  118. INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Release/%)
  119. INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Debug/%)
  120. endif
  121. CODEC_SRCS-yes += build/make/version.sh
  122. CODEC_SRCS-yes += build/make/rtcd.pl
  123. CODEC_SRCS-yes += vpx_ports/emmintrin_compat.h
  124. CODEC_SRCS-yes += vpx_ports/mem_ops.h
  125. CODEC_SRCS-yes += vpx_ports/mem_ops_aligned.h
  126. CODEC_SRCS-yes += vpx_ports/vpx_once.h
  127. CODEC_SRCS-yes += $(BUILD_PFX)vpx_config.c
  128. INSTALL-SRCS-no += $(BUILD_PFX)vpx_config.c
  129. ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
  130. INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += third_party/x86inc/x86inc.asm
  131. INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += vpx_dsp/x86/bitdepth_conversion_sse2.asm
  132. endif
  133. CODEC_EXPORTS-yes += vpx/exports_com
  134. CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc
  135. ifeq ($(CONFIG_SPATIAL_SVC),yes)
  136. CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_spatial_svc
  137. endif
  138. CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec
  139. INSTALL-LIBS-yes += include/vpx/vpx_codec.h
  140. INSTALL-LIBS-yes += include/vpx/vpx_frame_buffer.h
  141. INSTALL-LIBS-yes += include/vpx/vpx_image.h
  142. INSTALL-LIBS-yes += include/vpx/vpx_integer.h
  143. INSTALL-LIBS-$(CONFIG_DECODERS) += include/vpx/vpx_decoder.h
  144. INSTALL-LIBS-$(CONFIG_ENCODERS) += include/vpx/vpx_encoder.h
  145. ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
  146. ifeq ($(CONFIG_MSVS),yes)
  147. INSTALL-LIBS-yes += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB).lib)
  148. INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB)d.lib)
  149. INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.dll)
  150. INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.exp)
  151. endif
  152. else
  153. INSTALL-LIBS-$(CONFIG_STATIC) += $(LIBSUBDIR)/libvpx.a
  154. INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(LIBSUBDIR)/libvpx_g.a
  155. endif
  156. CODEC_SRCS=$(call enabled,CODEC_SRCS)
  157. INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(CODEC_SRCS)
  158. INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS)
  159. # Generate a list of all enabled sources, in particular for exporting to gyp
  160. # based build systems.
  161. libvpx_srcs.txt:
  162. @echo " [CREATE] $@"
  163. @echo $(CODEC_SRCS) | xargs -n1 echo | LC_ALL=C sort -u > $@
  164. CLEAN-OBJS += libvpx_srcs.txt
  165. ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
  166. ifeq ($(CONFIG_MSVS),yes)
  167. vpx.def: $(call enabled,CODEC_EXPORTS)
  168. @echo " [CREATE] $@"
  169. $(qexec)$(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\
  170. --name=vpx\
  171. --out=$@ $^
  172. CLEAN-OBJS += vpx.def
  173. # Assembly files that are included, but don't define symbols themselves.
  174. # Filtered out to avoid Visual Studio build warnings.
  175. ASM_INCLUDES := \
  176. third_party/x86inc/x86inc.asm \
  177. vpx_config.asm \
  178. vpx_ports/x86_abi_support.asm \
  179. vpx_dsp/x86/bitdepth_conversion_sse2.asm \
  180. vpx.$(VCPROJ_SFX): $(CODEC_SRCS) vpx.def
  181. @echo " [CREATE] $@"
  182. $(qexec)$(GEN_VCPROJ) \
  183. $(if $(CONFIG_SHARED),--dll,--lib) \
  184. --target=$(TOOLCHAIN) \
  185. $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
  186. --name=vpx \
  187. --proj-guid=DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74 \
  188. --module-def=vpx.def \
  189. --ver=$(CONFIG_VS_VERSION) \
  190. --src-path-bare="$(SRC_PATH_BARE)" \
  191. --out=$@ $(CFLAGS) \
  192. $(filter-out $(addprefix %, $(ASM_INCLUDES)), $^) \
  193. --src-path-bare="$(SRC_PATH_BARE)" \
  194. PROJECTS-yes += vpx.$(VCPROJ_SFX)
  195. vpx.$(VCPROJ_SFX): vpx_config.asm
  196. vpx.$(VCPROJ_SFX): $(RTCD)
  197. endif
  198. else
  199. LIBVPX_OBJS=$(call objs,$(CODEC_SRCS))
  200. OBJS-yes += $(LIBVPX_OBJS)
  201. LIBS-$(if yes,$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a
  202. $(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS)
  203. SO_VERSION_MAJOR := 4
  204. SO_VERSION_MINOR := 1
  205. SO_VERSION_PATCH := 0
  206. ifeq ($(filter darwin%,$(TGT_OS)),$(TGT_OS))
  207. LIBVPX_SO := libvpx.$(SO_VERSION_MAJOR).dylib
  208. SHARED_LIB_SUF := .dylib
  209. EXPORT_FILE := libvpx.syms
  210. LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
  211. libvpx.dylib )
  212. else
  213. ifeq ($(filter iphonesimulator%,$(TGT_OS)),$(TGT_OS))
  214. LIBVPX_SO := libvpx.$(SO_VERSION_MAJOR).dylib
  215. SHARED_LIB_SUF := .dylib
  216. EXPORT_FILE := libvpx.syms
  217. LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, libvpx.dylib)
  218. else
  219. ifeq ($(filter os2%,$(TGT_OS)),$(TGT_OS))
  220. LIBVPX_SO := libvpx$(SO_VERSION_MAJOR).dll
  221. SHARED_LIB_SUF := _dll.a
  222. EXPORT_FILE := libvpx.def
  223. LIBVPX_SO_SYMLINKS :=
  224. LIBVPX_SO_IMPLIB := libvpx_dll.a
  225. else
  226. LIBVPX_SO := libvpx.so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR).$(SO_VERSION_PATCH)
  227. SHARED_LIB_SUF := .so
  228. EXPORT_FILE := libvpx.ver
  229. LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
  230. libvpx.so libvpx.so.$(SO_VERSION_MAJOR) \
  231. libvpx.so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR))
  232. endif
  233. endif
  234. endif
  235. LIBS-$(CONFIG_SHARED) += $(BUILD_PFX)$(LIBVPX_SO)\
  236. $(notdir $(LIBVPX_SO_SYMLINKS)) \
  237. $(if $(LIBVPX_SO_IMPLIB), $(BUILD_PFX)$(LIBVPX_SO_IMPLIB))
  238. $(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) $(EXPORT_FILE)
  239. $(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm
  240. $(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(SO_VERSION_MAJOR)
  241. $(BUILD_PFX)$(LIBVPX_SO): EXPORTS_FILE = $(EXPORT_FILE)
  242. libvpx.ver: $(call enabled,CODEC_EXPORTS)
  243. @echo " [CREATE] $@"
  244. $(qexec)echo "{ global:" > $@
  245. $(qexec)for f in $?; do awk '{print $$2";"}' < $$f >>$@; done
  246. $(qexec)echo "local: *; };" >> $@
  247. CLEAN-OBJS += libvpx.ver
  248. libvpx.syms: $(call enabled,CODEC_EXPORTS)
  249. @echo " [CREATE] $@"
  250. $(qexec)awk '{print "_"$$2}' $^ >$@
  251. CLEAN-OBJS += libvpx.syms
  252. libvpx.def: $(call enabled,CODEC_EXPORTS)
  253. @echo " [CREATE] $@"
  254. $(qexec)echo LIBRARY $(LIBVPX_SO:.dll=) INITINSTANCE TERMINSTANCE > $@
  255. $(qexec)echo "DATA MULTIPLE NONSHARED" >> $@
  256. $(qexec)echo "EXPORTS" >> $@
  257. $(qexec)awk '!/vpx_svc_*/ {print "_"$$2}' $^ >>$@
  258. CLEAN-OBJS += libvpx.def
  259. libvpx_dll.a: $(LIBVPX_SO)
  260. @echo " [IMPLIB] $@"
  261. $(qexec)emximp -o $@ $<
  262. CLEAN-OBJS += libvpx_dll.a
  263. define libvpx_symlink_template
  264. $(1): $(2)
  265. @echo " [LN] $(2) $$@"
  266. $(qexec)mkdir -p $$(dir $$@)
  267. $(qexec)ln -sf $(2) $$@
  268. endef
  269. $(eval $(call libvpx_symlink_template,\
  270. $(addprefix $(BUILD_PFX),$(notdir $(LIBVPX_SO_SYMLINKS))),\
  271. $(BUILD_PFX)$(LIBVPX_SO)))
  272. $(eval $(call libvpx_symlink_template,\
  273. $(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)),\
  274. $(LIBVPX_SO)))
  275. INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBVPX_SO_SYMLINKS)
  276. INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBSUBDIR)/$(LIBVPX_SO)
  277. INSTALL-LIBS-$(CONFIG_SHARED) += $(if $(LIBVPX_SO_IMPLIB),$(LIBSUBDIR)/$(LIBVPX_SO_IMPLIB))
  278. LIBS-yes += vpx.pc
  279. vpx.pc: config.mk libs.mk
  280. @echo " [CREATE] $@"
  281. $(qexec)echo '# pkg-config file from libvpx $(VERSION_STRING)' > $@
  282. $(qexec)echo 'prefix=$(PREFIX)' >> $@
  283. $(qexec)echo 'exec_prefix=$${prefix}' >> $@
  284. $(qexec)echo 'libdir=$${prefix}/$(LIBSUBDIR)' >> $@
  285. $(qexec)echo 'includedir=$${prefix}/include' >> $@
  286. $(qexec)echo '' >> $@
  287. $(qexec)echo 'Name: vpx' >> $@
  288. $(qexec)echo 'Description: WebM Project VPx codec implementation' >> $@
  289. $(qexec)echo 'Version: $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)' >> $@
  290. $(qexec)echo 'Requires:' >> $@
  291. $(qexec)echo 'Conflicts:' >> $@
  292. $(qexec)echo 'Libs: -L$${libdir} -lvpx -lm' >> $@
  293. ifeq ($(HAVE_PTHREAD_H),yes)
  294. $(qexec)echo 'Libs.private: -lm -lpthread' >> $@
  295. else
  296. $(qexec)echo 'Libs.private: -lm' >> $@
  297. endif
  298. $(qexec)echo 'Cflags: -I$${includedir}' >> $@
  299. INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc
  300. INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc
  301. CLEAN-OBJS += vpx.pc
  302. endif
  303. #
  304. # Rule to make assembler configuration file from C configuration file
  305. #
  306. ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
  307. # YASM
  308. $(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
  309. @echo " [CREATE] $@"
  310. @egrep "#define [A-Z0-9_]+ [01]" $< \
  311. | awk '{print $$2 " equ " $$3}' > $@
  312. else
  313. ADS2GAS=$(if $(filter yes,$(CONFIG_GCC)),| $(ASM_CONVERSION))
  314. $(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
  315. @echo " [CREATE] $@"
  316. @egrep "#define [A-Z0-9_]+ [01]" $< \
  317. | awk '{print $$2 " EQU " $$3}' $(ADS2GAS) > $@
  318. @echo " END" $(ADS2GAS) >> $@
  319. CLEAN-OBJS += $(BUILD_PFX)vpx_config.asm
  320. endif
  321. #
  322. # Add assembler dependencies for configuration.
  323. #
  324. $(filter %.S.o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
  325. $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
  326. $(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h)
  327. CLEAN-OBJS += $(BUILD_PFX)vpx_version.h
  328. #
  329. # Add include path for libwebm sources.
  330. #
  331. ifeq ($(CONFIG_WEBM_IO),yes)
  332. CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/libwebm
  333. endif
  334. ##
  335. ## libvpx test directives
  336. ##
  337. ifeq ($(CONFIG_UNIT_TESTS),yes)
  338. LIBVPX_TEST_DATA_PATH ?= .
  339. include $(SRC_PATH_BARE)/test/test.mk
  340. LIBVPX_TEST_SRCS=$(addprefix test/,$(call enabled,LIBVPX_TEST_SRCS))
  341. LIBVPX_TEST_BIN=./test_libvpx$(EXE_SFX)
  342. LIBVPX_TEST_DATA=$(addprefix $(LIBVPX_TEST_DATA_PATH)/,\
  343. $(call enabled,LIBVPX_TEST_DATA))
  344. libvpx_test_data_url=https://storage.googleapis.com/downloads.webmproject.org/test_data/libvpx/$(1)
  345. TEST_INTRA_PRED_SPEED_BIN=./test_intra_pred_speed$(EXE_SFX)
  346. TEST_INTRA_PRED_SPEED_SRCS=$(addprefix test/,$(call enabled,TEST_INTRA_PRED_SPEED_SRCS))
  347. TEST_INTRA_PRED_SPEED_OBJS := $(sort $(call objs,$(TEST_INTRA_PRED_SPEED_SRCS)))
  348. libvpx_test_srcs.txt:
  349. @echo " [CREATE] $@"
  350. @echo $(LIBVPX_TEST_SRCS) | xargs -n1 echo | LC_ALL=C sort -u > $@
  351. CLEAN-OBJS += libvpx_test_srcs.txt
  352. $(LIBVPX_TEST_DATA): $(SRC_PATH_BARE)/test/test-data.sha1
  353. @echo " [DOWNLOAD] $@"
  354. # Attempt to download the file using curl, retrying once if it fails for a
  355. # partial file (18).
  356. $(qexec)( \
  357. trap 'rm -f $@' INT TERM; \
  358. curl="curl --retry 1 -L -o $@ $(call libvpx_test_data_url,$(@F))"; \
  359. $$curl; \
  360. case "$$?" in \
  361. 18) $$curl -C -;; \
  362. esac \
  363. )
  364. testdata:: $(LIBVPX_TEST_DATA)
  365. $(qexec)[ -x "$$(which sha1sum)" ] && sha1sum=sha1sum;\
  366. [ -x "$$(which shasum)" ] && sha1sum=shasum;\
  367. [ -x "$$(which sha1)" ] && sha1sum=sha1;\
  368. if [ -n "$${sha1sum}" ]; then\
  369. set -e;\
  370. echo "Checking test data:";\
  371. for f in $(call enabled,LIBVPX_TEST_DATA); do\
  372. grep $$f $(SRC_PATH_BARE)/test/test-data.sha1 |\
  373. (cd $(LIBVPX_TEST_DATA_PATH); $${sha1sum} -c);\
  374. done; \
  375. else\
  376. echo "Skipping test data integrity check, sha1sum not found.";\
  377. fi
  378. ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
  379. ifeq ($(CONFIG_MSVS),yes)
  380. gtest.$(VCPROJ_SFX): $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc
  381. @echo " [CREATE] $@"
  382. $(qexec)$(GEN_VCPROJ) \
  383. --lib \
  384. --target=$(TOOLCHAIN) \
  385. $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
  386. --name=gtest \
  387. --proj-guid=EC00E1EC-AF68-4D92-A255-181690D1C9B1 \
  388. --ver=$(CONFIG_VS_VERSION) \
  389. --src-path-bare="$(SRC_PATH_BARE)" \
  390. -D_VARIADIC_MAX=10 \
  391. --out=gtest.$(VCPROJ_SFX) $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc \
  392. -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" -I"$(SRC_PATH_BARE)/third_party/googletest/src"
  393. PROJECTS-$(CONFIG_MSVS) += gtest.$(VCPROJ_SFX)
  394. test_libvpx.$(VCPROJ_SFX): $(LIBVPX_TEST_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX)
  395. @echo " [CREATE] $@"
  396. $(qexec)$(GEN_VCPROJ) \
  397. --exe \
  398. --target=$(TOOLCHAIN) \
  399. --name=test_libvpx \
  400. -D_VARIADIC_MAX=10 \
  401. --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \
  402. --ver=$(CONFIG_VS_VERSION) \
  403. --src-path-bare="$(SRC_PATH_BARE)" \
  404. $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
  405. --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \
  406. -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
  407. $(if $(CONFIG_WEBM_IO),-I"$(SRC_PATH_BARE)/third_party/libwebm") \
  408. -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^
  409. PROJECTS-$(CONFIG_MSVS) += test_libvpx.$(VCPROJ_SFX)
  410. LIBVPX_TEST_BIN := $(addprefix $(TGT_OS:win64=x64)/Release/,$(notdir $(LIBVPX_TEST_BIN)))
  411. ifneq ($(strip $(TEST_INTRA_PRED_SPEED_OBJS)),)
  412. PROJECTS-$(CONFIG_MSVS) += test_intra_pred_speed.$(VCPROJ_SFX)
  413. test_intra_pred_speed.$(VCPROJ_SFX): $(TEST_INTRA_PRED_SPEED_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX)
  414. @echo " [CREATE] $@"
  415. $(qexec)$(GEN_VCPROJ) \
  416. --exe \
  417. --target=$(TOOLCHAIN) \
  418. --name=test_intra_pred_speed \
  419. -D_VARIADIC_MAX=10 \
  420. --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \
  421. --ver=$(CONFIG_VS_VERSION) \
  422. --src-path-bare="$(SRC_PATH_BARE)" \
  423. $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
  424. --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \
  425. -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
  426. -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^
  427. endif # TEST_INTRA_PRED_SPEED
  428. endif
  429. else
  430. include $(SRC_PATH_BARE)/third_party/googletest/gtest.mk
  431. GTEST_SRCS := $(addprefix third_party/googletest/src/,$(call enabled,GTEST_SRCS))
  432. GTEST_OBJS=$(call objs,$(GTEST_SRCS))
  433. ifeq ($(filter win%,$(TGT_OS)),$(TGT_OS))
  434. # Disabling pthreads globally will cause issues on darwin and possibly elsewhere
  435. $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -DGTEST_HAS_PTHREAD=0
  436. endif
  437. GTEST_INCLUDES := -I$(SRC_PATH_BARE)/third_party/googletest/src
  438. GTEST_INCLUDES += -I$(SRC_PATH_BARE)/third_party/googletest/src/include
  439. $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += $(GTEST_INCLUDES)
  440. OBJS-yes += $(GTEST_OBJS)
  441. LIBS-yes += $(BUILD_PFX)libgtest.a $(BUILD_PFX)libgtest_g.a
  442. $(BUILD_PFX)libgtest_g.a: $(GTEST_OBJS)
  443. LIBVPX_TEST_OBJS=$(sort $(call objs,$(LIBVPX_TEST_SRCS)))
  444. $(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += $(GTEST_INCLUDES)
  445. OBJS-yes += $(LIBVPX_TEST_OBJS)
  446. BINS-yes += $(LIBVPX_TEST_BIN)
  447. CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx)
  448. CODEC_LIB_SUF=$(if $(CONFIG_SHARED),$(SHARED_LIB_SUF),.a)
  449. TEST_LIBS := lib$(CODEC_LIB)$(CODEC_LIB_SUF) libgtest.a
  450. $(LIBVPX_TEST_BIN): $(TEST_LIBS)
  451. $(eval $(call linkerxx_template,$(LIBVPX_TEST_BIN), \
  452. $(LIBVPX_TEST_OBJS) \
  453. -L. -lvpx -lgtest $(extralibs) -lm))
  454. ifneq ($(strip $(TEST_INTRA_PRED_SPEED_OBJS)),)
  455. $(TEST_INTRA_PRED_SPEED_OBJS) $(TEST_INTRA_PRED_SPEED_OBJS:.o=.d): CXXFLAGS += $(GTEST_INCLUDES)
  456. OBJS-yes += $(TEST_INTRA_PRED_SPEED_OBJS)
  457. BINS-yes += $(TEST_INTRA_PRED_SPEED_BIN)
  458. $(TEST_INTRA_PRED_SPEED_BIN): $(TEST_LIBS)
  459. $(eval $(call linkerxx_template,$(TEST_INTRA_PRED_SPEED_BIN), \
  460. $(TEST_INTRA_PRED_SPEED_OBJS) \
  461. -L. -lvpx -lgtest $(extralibs) -lm))
  462. endif # TEST_INTRA_PRED_SPEED
  463. endif # CONFIG_UNIT_TESTS
  464. # Install test sources only if codec source is included
  465. INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(patsubst $(SRC_PATH_BARE)/%,%,\
  466. $(shell find $(SRC_PATH_BARE)/third_party/googletest -type f))
  467. INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(LIBVPX_TEST_SRCS)
  468. INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(TEST_INTRA_PRED_SPEED_SRCS)
  469. define test_shard_template
  470. test:: test_shard.$(1)
  471. test-no-data-check:: test_shard_ndc.$(1)
  472. test_shard.$(1) test_shard_ndc.$(1): $(LIBVPX_TEST_BIN)
  473. @set -e; \
  474. export GTEST_SHARD_INDEX=$(1); \
  475. export GTEST_TOTAL_SHARDS=$(2); \
  476. $(LIBVPX_TEST_BIN)
  477. test_shard.$(1): testdata
  478. .PHONY: test_shard.$(1)
  479. endef
  480. NUM_SHARDS := 10
  481. SHARDS := 0 1 2 3 4 5 6 7 8 9
  482. $(foreach s,$(SHARDS),$(eval $(call test_shard_template,$(s),$(NUM_SHARDS))))
  483. endif
  484. ##
  485. ## documentation directives
  486. ##
  487. CLEAN-OBJS += libs.doxy
  488. DOCS-yes += libs.doxy
  489. libs.doxy: $(CODEC_DOC_SRCS)
  490. @echo " [CREATE] $@"
  491. @rm -f $@
  492. @echo "INPUT += $^" >> $@
  493. @echo "INCLUDE_PATH += ." >> $@;
  494. @echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@
  495. ## Generate rtcd.h for all objects
  496. ifeq ($(CONFIG_DEPENDENCY_TRACKING),yes)
  497. $(OBJS-yes:.o=.d): $(RTCD)
  498. else
  499. $(OBJS-yes): $(RTCD)
  500. endif
  501. ## Update the global src list
  502. SRCS += $(CODEC_SRCS) $(LIBVPX_TEST_SRCS) $(GTEST_SRCS)
  503. ##
  504. ## vpxdec/vpxenc tests.
  505. ##
  506. ifeq ($(CONFIG_UNIT_TESTS),yes)
  507. TEST_BIN_PATH = .
  508. ifeq ($(CONFIG_MSVS),yes)
  509. # MSVC will build both Debug and Release configurations of tools in a
  510. # sub directory named for the current target. Assume the user wants to
  511. # run the Release tools, and assign TEST_BIN_PATH accordingly.
  512. # TODO(tomfinegan): Is this adequate for ARM?
  513. # TODO(tomfinegan): Support running the debug versions of tools?
  514. TEST_BIN_PATH := $(addsuffix /$(TGT_OS:win64=x64)/Release, $(TEST_BIN_PATH))
  515. endif
  516. utiltest utiltest-no-data-check:
  517. $(qexec)$(SRC_PATH_BARE)/test/vpxdec.sh \
  518. --test-data-path $(LIBVPX_TEST_DATA_PATH) \
  519. --bin-path $(TEST_BIN_PATH)
  520. $(qexec)$(SRC_PATH_BARE)/test/vpxenc.sh \
  521. --test-data-path $(LIBVPX_TEST_DATA_PATH) \
  522. --bin-path $(TEST_BIN_PATH)
  523. utiltest: testdata
  524. else
  525. utiltest utiltest-no-data-check:
  526. @echo Unit tests must be enabled to make the utiltest target.
  527. endif
  528. ##
  529. ## Example tests.
  530. ##
  531. ifeq ($(CONFIG_UNIT_TESTS),yes)
  532. # All non-MSVC targets output example targets in a sub dir named examples.
  533. EXAMPLES_BIN_PATH = examples
  534. ifeq ($(CONFIG_MSVS),yes)
  535. # MSVC will build both Debug and Release configurations of the examples in a
  536. # sub directory named for the current target. Assume the user wants to
  537. # run the Release tools, and assign EXAMPLES_BIN_PATH accordingly.
  538. # TODO(tomfinegan): Is this adequate for ARM?
  539. # TODO(tomfinegan): Support running the debug versions of tools?
  540. EXAMPLES_BIN_PATH := $(TGT_OS:win64=x64)/Release
  541. endif
  542. exampletest exampletest-no-data-check: examples
  543. $(qexec)$(SRC_PATH_BARE)/test/examples.sh \
  544. --test-data-path $(LIBVPX_TEST_DATA_PATH) \
  545. --bin-path $(EXAMPLES_BIN_PATH)
  546. exampletest: testdata
  547. else
  548. exampletest exampletest-no-data-check:
  549. @echo Unit tests must be enabled to make the exampletest target.
  550. endif