Merge "configure: support --enable-pic for generic-gnu"
[profile/ivi/libvpx.git] / examples.mk
1 ##
2 ##  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
3 ##
4 ##  Use of this source code is governed by a BSD-style license and patent
5 ##  grant that can be found in the LICENSE file in the root of the source
6 ##  tree. All contributing project authors may be found in the AUTHORS
7 ##  file in the root of the source tree.
8 ##
9
10
11 # List of examples to build. UTILS are files that are taken from the source
12 # tree directly, and GEN_EXAMPLES are files that are created from the
13 # examples folder.
14 UTILS-$(CONFIG_DECODERS)    += ivfdec.c
15 ivfdec.SRCS                 += md5_utils.c md5_utils.h
16 ivfdec.SRCS                 += vpx_ports/vpx_timer.h
17 ivfdec.SRCS                 += vpx/vpx_integer.h
18 ivfdec.SRCS                 += args.c args.h vpx_ports/config.h
19 ivfdec.GUID                  = BA5FE66F-38DD-E034-F542-B1578C5FB950
20 ivfdec.DESCRIPTION           = Full featured decoder
21 UTILS-$(CONFIG_ENCODERS)    += ivfenc.c
22 ivfenc.SRCS                 += args.c args.h vpx_ports/config.h
23 ivfenc.SRCS                 += vpx_ports/mem_ops.h vpx_ports/mem_ops_aligned.h
24 ivfenc.GUID                  = 548DEC74-7A15-4B2B-AFC3-AA102E7C25C1
25 ivfenc.DESCRIPTION           = Full featured encoder
26
27 # XMA example disabled for now, not used in VP8
28 #UTILS-$(CONFIG_DECODERS)    += example_xma.c
29 #example_xma.GUID             = A955FC4A-73F1-44F7-135E-30D84D32F022
30 #example_xma.DESCRIPTION      = External Memory Allocation mode usage
31
32 GEN_EXAMPLES-$(CONFIG_DECODERS) += simple_decoder.c
33 simple_decoder.GUID              = D3BBF1E9-2427-450D-BBFF-B2843C1D44CC
34 simple_decoder.DESCRIPTION       = Simplified decoder loop
35 GEN_EXAMPLES-$(CONFIG_DECODERS) += postproc.c
36 postproc.GUID                    = 65E33355-F35E-4088-884D-3FD4905881D7
37 postproc.DESCRIPTION             = Decoder postprocessor control
38 GEN_EXAMPLES-$(CONFIG_DECODERS) += decode_to_md5.c
39 decode_to_md5.SRCS              += md5_utils.h md5_utils.c
40 decode_to_md5.GUID               = 59120B9B-2735-4BFE-B022-146CA340FE42
41 decode_to_md5.DESCRIPTION        = Frame by frame MD5 checksum
42
43 GEN_EXAMPLES-$(CONFIG_ENCODERS) += simple_encoder.c
44 simple_encoder.GUID              = 4607D299-8A71-4D2C-9B1D-071899B6FBFD
45 simple_encoder.DESCRIPTION       = Simplified encoder loop
46 GEN_EXAMPLES-$(CONFIG_ENCODERS) += twopass_encoder.c
47 twopass_encoder.GUID             = 73494FA6-4AF9-4763-8FBB-265C92402FD8
48 twopass_encoder.DESCRIPTION      = Two-pass encoder loop
49 GEN_EXAMPLES-$(CONFIG_ENCODERS) += force_keyframe.c
50 force_keyframe.GUID              = 3C67CADF-029F-4C86-81F5-D6D4F51177F0
51 force_keyframe.DESCRIPTION       = Force generation of keyframes
52 ifeq ($(CONFIG_DECODERS),yes)
53 GEN_EXAMPLES-$(CONFIG_ENCODERS) += decode_with_drops.c
54 endif
55 decode_with_drops.GUID           = CE5C53C4-8DDA-438A-86ED-0DDD3CDB8D26
56 decode_with_drops.DESCRIPTION    = Drops frames while decoding
57 GEN_EXAMPLES-$(CONFIG_ENCODERS) += error_resilient.c
58 error_resilient.GUID             = DF5837B9-4145-4F92-A031-44E4F832E00C
59 error_resilient.DESCRIPTION      = Error Resiliency Feature
60
61 GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += vp8_scalable_patterns.c
62 vp8_scalable_patterns.GUID          = 0D6A210B-F482-4D6F-8570-4A9C01ACC88C
63 vp8_scalable_patterns.DESCRIPTION   = VP8 Scalable Bitstream Patterns
64 GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += vp8_set_maps.c
65 vp8_set_maps.GUID                   = ECB2D24D-98B8-4015-A465-A4AF3DCC145F
66 vp8_set_maps.DESCRIPTION            = VP8 set active and ROI maps
67 GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += vp8cx_set_ref.c
68 vp8cx_set_ref.GUID                  = C5E31F7F-96F6-48BD-BD3E-10EBF6E8057A
69 vp8cx_set_ref.DESCRIPTION           = VP8 set encoder reference frame
70
71
72 # Handle extra library flags depending on codec configuration
73 CODEC_EXTRA_LIBS-$(CONFIG_VP8)         += m
74
75 #
76 # End of specified files. The rest of the build rules should happen
77 # automagically from here.
78 #
79
80
81 # Examples need different flags based on whether we're building
82 # from an installed tree or a version controlled tree. Determine
83 # the proper paths.
84 ifeq ($(HAVE_ALT_TREE_LAYOUT),yes)
85     LIB_PATH := $(SRC_PATH_BARE)/../lib
86     INC_PATH := $(SRC_PATH_BARE)/../include
87 else
88     LIB_PATH-yes                     += $(if $(BUILD_PFX),$(BUILD_PFX),.)
89     INC_PATH-$(CONFIG_VP8_DECODER)   += $(SRC_PATH_BARE)/vp8
90     INC_PATH-$(CONFIG_VP8_ENCODER)   += $(SRC_PATH_BARE)/vp8
91     LIB_PATH := $(call enabled,LIB_PATH)
92     INC_PATH := $(call enabled,INC_PATH)
93 endif
94 CFLAGS += $(addprefix -I,$(INC_PATH))
95 LDFLAGS += $(addprefix -L,$(LIB_PATH))
96
97
98 # Expand list of selected examples to build (as specified above)
99 UTILS           = $(call enabled,UTILS)
100 GEN_EXAMPLES    = $(call enabled,GEN_EXAMPLES)
101 ALL_EXAMPLES    = $(UTILS) $(GEN_EXAMPLES)
102 UTIL_SRCS       = $(foreach ex,$(UTILS),$($(ex:.c=).SRCS))
103 ALL_SRCS        = $(foreach ex,$(ALL_EXAMPLES),$($(ex:.c=).SRCS))
104 CODEC_EXTRA_LIBS=$(sort $(call enabled,CODEC_EXTRA_LIBS))
105
106
107 # Expand all example sources into a variable containing all sources
108 # for that example (not just them main one specified in UTILS/GEN_EXAMPLES)
109 # and add this file to the list (for MSVS workspace generation)
110 $(foreach ex,$(ALL_EXAMPLES),$(eval $(ex:.c=).SRCS += $(ex) examples.mk))
111
112
113 # If this is a universal (fat) binary, then all the subarchitectures have
114 # already been built and our job is to stitch them together. The
115 # BUILD_OBJS variable indicates whether we should be building
116 # (compiling, linking) the library. The LIPO_OBJS variable indicates
117 # that we're stitching.
118 $(eval $(if $(filter universal%,$(TOOLCHAIN)),LIPO_OBJS,BUILD_OBJS):=yes)
119
120
121 # Create build/install dependencies for all examples. The common case
122 # is handled here. The MSVS case is handled below.
123 NOT_MSVS = $(if $(CONFIG_MSVS),,yes)
124 DIST-BINS-$(NOT_MSVS)      += $(addprefix bin/,$(ALL_EXAMPLES:.c=))
125 INSTALL-BINS-$(NOT_MSVS)   += $(addprefix bin/,$(UTILS:.c=))
126 DIST-SRCS-yes              += $(ALL_SRCS)
127 INSTALL-SRCS-yes           += $(UTIL_SRCS)
128 OBJS-$(NOT_MSVS)           += $(if $(BUILD_OBJS),$(call objs,$(ALL_SRCS)))
129 BINS-$(NOT_MSVS)           += $(addprefix $(BUILD_PFX),$(ALL_EXAMPLES:.c=))
130
131
132 # Instantiate linker template for all examples.
133 CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx)
134 $(foreach bin,$(BINS-yes),\
135     $(if $(BUILD_OBJS),$(eval $(bin): $(LIB_PATH)/lib$(CODEC_LIB).a))\
136     $(if $(BUILD_OBJS),$(eval $(call linker_template,$(bin),\
137         $(call objs,$($(notdir $(bin)).SRCS)) \
138         -l$(CODEC_LIB) $(addprefix -l,$(CODEC_EXTRA_LIBS))\
139         )))\
140     $(if $(LIPO_OBJS),$(eval $(call lipo_bin_template,$(bin))))\
141     )
142
143
144 # Rules to generate the GEN_EXAMPLES sources
145 .PRECIOUS: %.c
146 CLEAN-OBJS += $(GEN_EXAMPLES)
147 %.c: examples/%.txt
148         @echo "    [EXAMPLE] $@"
149         @$(SRC_PATH_BARE)/examples/gen_example_code.sh $< > $@
150
151
152 # The following pairs define a mapping of locations in the distribution
153 # tree to locations in the source/build trees.
154 INSTALL_MAPS += src/%.c   %.c
155 INSTALL_MAPS += src/%     $(SRC_PATH_BARE)/%
156 INSTALL_MAPS += bin/%     %
157 INSTALL_MAPS += %         %
158
159
160 # Set up additional MSVS environment
161 ifeq ($(CONFIG_MSVS),yes)
162 CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd)
163 # This variable uses deferred expansion intentionally, since the results of
164 # $(wildcard) may change during the course of the Make.
165 VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))
166 INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),bin/$(p)/%  $(p)/Release/%)
167 endif
168
169 # Build Visual Studio Projects. We use a template here to instantiate
170 # explicit rules rather than using an implicit rule because we want to
171 # leverage make's VPATH searching rather than specifying the paths on
172 # each file in ALL_EXAMPLES. This has the unfortunate side effect that
173 # touching the source files trigger a rebuild of the project files
174 # even though there is no real dependency there (the dependency is on
175 # the makefiles). We may want to revisit this.
176 define vcproj_template
177 $(1): $($(1:.vcproj=).SRCS)
178         @echo "    [vcproj] $$@"
179         $$(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh\
180             --exe\
181             --target=$$(TOOLCHAIN)\
182             --name=$$(@:.vcproj=)\
183             --ver=$$(CONFIG_VS_VERSION)\
184             --proj-guid=$$($$(@:.vcproj=).GUID)\
185             $$(if $$(CONFIG_STATIC_MSVCRT),--static-crt) \
186             --out=$$@ $$(CFLAGS) $$(LDFLAGS) -l$$(CODEC_LIB) -lwinmm $$^
187 endef
188 PROJECTS-$(CONFIG_MSVS) += $(ALL_EXAMPLES:.c=.vcproj)
189 INSTALL-BINS-$(CONFIG_MSVS) += $(foreach p,$(VS_PLATFORMS),\
190                                $(addprefix bin/$(p)/,$(ALL_EXAMPLES:.c=.exe)))
191 $(foreach proj,$(call enabled,PROJECTS),\
192     $(eval $(call vcproj_template,$(proj))))
193
194
195
196 #
197 # Documentation Rules
198 #
199 %.dox: examples/%.txt
200         @echo "    [DOXY] $@"
201         @$(SRC_PATH_BARE)/examples/gen_example_text.sh $< | \
202          $(SRC_PATH_BARE)/examples/gen_example_doxy.php \
203              example_$(@:.dox=)  $(@:.dox=.c) > $@
204
205 %.dox: %.c
206         @echo "    [DOXY] $@"
207         @echo "/*!\page example_$(@:.dox=) $(@:.dox=)" > $@
208         @echo "   \includelineno $(notdir $<)" >> $@
209         @echo "*/" >> $@
210
211 samples.dox: examples.mk
212         @echo "    [DOXY] $@"
213         @echo "/*!\page samples Sample Code" > $@
214         @echo "    This SDK includes a number of sample applications."\
215               "each sample documents a feature of the SDK in both prose"\
216               "and the associated C code. In general, later samples"\
217               "build upon prior samples, so it is best to work through the"\
218               "list in order. The following samples are included: ">>$@
219         @$(foreach ex,$(GEN_EXAMPLES:.c=),\
220            echo "     - \subpage example_$(ex) $($(ex).DESCRIPTION)" >> $@;)
221         @echo >> $@
222         @echo "    In addition, the SDK contains a number of utilities."\
223               "Since these utilities are built upon the concepts described"\
224               "in the sample code listed above, they are not documented in"\
225               "pieces like the samples are. Thir sourcre is included here"\
226               "for reference. The following utilities are included:" >> $@
227         @$(foreach ex,$(UTILS:.c=),\
228            echo "     - \subpage example_$(ex) $($(ex).DESCRIPTION)" >> $@;)
229         @echo "*/" >> $@
230
231 CLEAN-OBJS += examples.doxy samples.dox $(ALL_EXAMPLES:.c=.dox)
232 DOCS-yes += examples.doxy samples.dox $(ALL_EXAMPLES:.c=.dox)
233 examples.doxy: samples.dox $(ALL_EXAMPLES:.c=.dox)
234         @echo "INPUT += $^" > $@