2
0

libs.mk 22 KB

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