libs.mk 22 KB

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