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