tools.mk 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. ##
  2. ## Copyright (c) 2016 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. # List of tools to build.
  11. TOOLS-yes += tiny_ssim.c
  12. tiny_ssim.SRCS += vpx/vpx_integer.h y4minput.c y4minput.h \
  13. vpx/vpx_codec.h vpx/src/vpx_image.c
  14. tiny_ssim.SRCS += vpx_mem/vpx_mem.c vpx_mem/vpx_mem.h
  15. tiny_ssim.SRCS += vpx_mem/include/vpx_mem_intrnl.h
  16. tiny_ssim.GUID = 3afa9b05-940b-4d68-b5aa-55157d8ed7b4
  17. tiny_ssim.DESCRIPTION = Generate SSIM/PSNR from raw .yuv files
  18. #
  19. # End of specified files. The rest of the build rules should happen
  20. # automagically from here.
  21. #
  22. # Expand list of selected tools to build (as specified above)
  23. TOOLS = $(addprefix tools/,$(call enabled,TOOLS))
  24. ALL_SRCS = $(foreach ex,$(TOOLS),$($(notdir $(ex:.c=)).SRCS))
  25. CFLAGS += -I../include
  26. ifneq ($(CONFIG_CODEC_SRCS), yes)
  27. CFLAGS += -I../include/vpx
  28. endif
  29. # Expand all tools sources into a variable containing all sources
  30. # for that tools (not just them main one specified in TOOLS)
  31. # and add this file to the list (for MSVS workspace generation)
  32. $(foreach ex,$(TOOLS),$(eval $(notdir $(ex:.c=)).SRCS += $(ex) tools.mk))
  33. # Create build/install dependencies for all tools. The common case
  34. # is handled here. The MSVS case is handled below.
  35. NOT_MSVS = $(if $(CONFIG_MSVS),,yes)
  36. DIST-BINS-$(NOT_MSVS) += $(addprefix bin/,$(TOOLS:.c=$(EXE_SFX)))
  37. DIST-SRCS-yes += $(ALL_SRCS)
  38. OBJS-$(NOT_MSVS) += $(call objs,$(ALL_SRCS))
  39. BINS-$(NOT_MSVS) += $(addprefix $(BUILD_PFX),$(TOOLS:.c=$(EXE_SFX)))
  40. # Instantiate linker template for all tools.
  41. $(foreach bin,$(BINS-yes),\
  42. $(eval $(bin):)\
  43. $(eval $(call linker_template,$(bin),\
  44. $(call objs,$($(notdir $(bin:$(EXE_SFX)=)).SRCS)) -lm)))
  45. # The following pairs define a mapping of locations in the distribution
  46. # tree to locations in the source/build trees.
  47. INSTALL_MAPS += src/%.c %.c
  48. INSTALL_MAPS += src/% $(SRC_PATH_BARE)/%
  49. INSTALL_MAPS += bin/% %
  50. INSTALL_MAPS += % %
  51. # Build Visual Studio Projects. We use a template here to instantiate
  52. # explicit rules rather than using an implicit rule because we want to
  53. # leverage make's VPATH searching rather than specifying the paths on
  54. # each file in TOOLS. This has the unfortunate side effect that
  55. # touching the source files trigger a rebuild of the project files
  56. # even though there is no real dependency there (the dependency is on
  57. # the makefiles). We may want to revisit this.
  58. define vcproj_template
  59. $(1): $($(1:.$(VCPROJ_SFX)=).SRCS) vpx.$(VCPROJ_SFX)
  60. $(if $(quiet),@echo " [vcproj] $$@")
  61. $(qexec)$$(GEN_VCPROJ)\
  62. --exe\
  63. --target=$$(TOOLCHAIN)\
  64. --name=$$(@:.$(VCPROJ_SFX)=)\
  65. --ver=$$(CONFIG_VS_VERSION)\
  66. --proj-guid=$$($$(@:.$(VCPROJ_SFX)=).GUID)\
  67. --src-path-bare="$(SRC_PATH_BARE)" \
  68. $$(if $$(CONFIG_STATIC_MSVCRT),--static-crt) \
  69. --out=$$@ $$(INTERNAL_CFLAGS) $$(CFLAGS) \
  70. $$(INTERNAL_LDFLAGS) $$(LDFLAGS) $$^
  71. endef
  72. TOOLS_BASENAME := $(notdir $(TOOLS))
  73. PROJECTS-$(CONFIG_MSVS) += $(TOOLS_BASENAME:.c=.$(VCPROJ_SFX))
  74. INSTALL-BINS-$(CONFIG_MSVS) += $(foreach p,$(VS_PLATFORMS),\
  75. $(addprefix bin/$(p)/,$(TOOLS_BASENAME:.c=.exe)))
  76. $(foreach proj,$(call enabled,PROJECTS),\
  77. $(eval $(call vcproj_template,$(proj))))
  78. #
  79. # Documentation Rules
  80. #
  81. %.dox: %.c
  82. @echo " [DOXY] $@"
  83. @mkdir -p $(dir $@)
  84. @echo "/*!\page tools_$(@F:.dox=) $(@F:.dox=)" > $@
  85. @echo " \includelineno $(<F)" >> $@
  86. @echo "*/" >> $@
  87. tools.dox: tools.mk
  88. @echo " [DOXY] $@"
  89. @echo "/*!\page tools Tools" > $@
  90. @echo " This SDK includes a number of tools/utilities."\
  91. "The following tools are included: ">>$@
  92. @$(foreach ex,$(sort $(notdir $(TOOLS:.c=))),\
  93. echo " - \subpage tools_$(ex) $($(ex).DESCRIPTION)" >> $@;)
  94. @echo "*/" >> $@
  95. CLEAN-OBJS += tools.doxy tools.dox $(TOOLS:.c=.dox)
  96. DOCS-yes += tools.doxy tools.dox
  97. tools.doxy: tools.dox $(TOOLS:.c=.dox)
  98. @echo "INPUT += $^" > $@