blob: 90913e67e87a1800f4266ef7c27ffed92893eef6 [file] [log] [blame]
John Koleszar0ea50ce2010-05-18 11:58:33 -04001##
John Koleszarc2140b82010-09-09 08:16:39 -04002## Copyright (c) 2010 The WebM project authors. All Rights Reserved.
John Koleszar0ea50ce2010-05-18 11:58:33 -04003##
John Koleszar94c52e42010-06-18 12:39:21 -04004## Use of this source code is governed by a BSD-style license
John Koleszar09202d82010-06-04 16:19:40 -04005## 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
John Koleszar94c52e42010-06-18 12:39:21 -04007## in the file PATENTS. All contributing project authors may
John Koleszar09202d82010-06-04 16:19:40 -04008## be found in the AUTHORS file in the root of the source tree.
John Koleszar0ea50ce2010-05-18 11:58:33 -04009##
10
11
12# List of examples to build. UTILS are files that are taken from the source
13# tree directly, and GEN_EXAMPLES are files that are created from the
14# examples folder.
John Koleszarea68ee02010-10-21 15:02:10 -040015UTILS-$(CONFIG_DECODERS) += vpxdec.c
16vpxdec.SRCS += md5_utils.c md5_utils.h
17vpxdec.SRCS += vpx_ports/vpx_timer.h
18vpxdec.SRCS += vpx/vpx_integer.h
Attila Nagy1a7d25a2011-09-15 15:34:12 +030019vpxdec.SRCS += args.c args.h
John Koleszarc377bf02010-11-02 09:11:57 -040020vpxdec.SRCS += tools_common.c tools_common.h
John Koleszarea68ee02010-10-21 15:02:10 -040021vpxdec.SRCS += nestegg/halloc/halloc.h
22vpxdec.SRCS += nestegg/halloc/src/align.h
23vpxdec.SRCS += nestegg/halloc/src/halloc.c
24vpxdec.SRCS += nestegg/halloc/src/hlist.h
25vpxdec.SRCS += nestegg/halloc/src/macros.h
26vpxdec.SRCS += nestegg/include/nestegg/nestegg.h
27vpxdec.SRCS += nestegg/src/nestegg.c
28vpxdec.GUID = BA5FE66F-38DD-E034-F542-B1578C5FB950
29vpxdec.DESCRIPTION = Full featured decoder
30UTILS-$(CONFIG_ENCODERS) += vpxenc.c
31vpxenc.SRCS += args.c args.h y4minput.c y4minput.h
John Koleszarc377bf02010-11-02 09:11:57 -040032vpxenc.SRCS += tools_common.c tools_common.h
Attila Nagy1a7d25a2011-09-15 15:34:12 +030033vpxenc.SRCS += vpx_ports/mem_ops.h
John Koleszarea68ee02010-10-21 15:02:10 -040034vpxenc.SRCS += vpx_ports/mem_ops_aligned.h
Johannc459d372012-04-02 15:08:18 -070035vpxenc.SRCS += vpx_ports/vpx_timer.h
John Koleszarea68ee02010-10-21 15:02:10 -040036vpxenc.SRCS += libmkv/EbmlIDs.h
37vpxenc.SRCS += libmkv/EbmlWriter.c
38vpxenc.SRCS += libmkv/EbmlWriter.h
39vpxenc.GUID = 548DEC74-7A15-4B2B-AFC3-AA102E7C25C1
40vpxenc.DESCRIPTION = Full featured encoder
Adrian Grange217591f2011-10-06 15:49:11 -070041UTILS-$(CONFIG_ENCODERS) += vp8_scalable_patterns.c
42vp8_scalable_patterns.GUID = 0D6A210B-F482-4D6F-8570-4A9C01ACC88C
43vp8_scalable_patterns.DESCRIPTION = Temporal Scalability Encoder
John Koleszarea68ee02010-10-21 15:02:10 -040044
45# Clean up old ivfenc, ivfdec binaries.
46ifeq ($(CONFIG_MSVS),yes)
47CLEAN-OBJS += $(foreach p,$(VS_PLATFORMS),$(p)/Release/ivfenc.exe)
48CLEAN-OBJS += $(foreach p,$(VS_PLATFORMS),$(p)/Release/ivfdec.exe)
49else
John Koleszar3427e1d2010-10-27 10:06:45 -040050CLEAN-OBJS += ivfenc{.c.o,.c.d,.dox,.exe,}
51CLEAN-OBJS += ivfdec{.c.o,.c.d,.dox,.exe,}
John Koleszarea68ee02010-10-21 15:02:10 -040052endif
John Koleszaree8bcb12010-05-24 10:16:44 -040053
54# XMA example disabled for now, not used in VP8
55#UTILS-$(CONFIG_DECODERS) += example_xma.c
56#example_xma.GUID = A955FC4A-73F1-44F7-135E-30D84D32F022
57#example_xma.DESCRIPTION = External Memory Allocation mode usage
John Koleszar0ea50ce2010-05-18 11:58:33 -040058
59GEN_EXAMPLES-$(CONFIG_DECODERS) += simple_decoder.c
60simple_decoder.GUID = D3BBF1E9-2427-450D-BBFF-B2843C1D44CC
61simple_decoder.DESCRIPTION = Simplified decoder loop
62GEN_EXAMPLES-$(CONFIG_DECODERS) += postproc.c
63postproc.GUID = 65E33355-F35E-4088-884D-3FD4905881D7
64postproc.DESCRIPTION = Decoder postprocessor control
65GEN_EXAMPLES-$(CONFIG_DECODERS) += decode_to_md5.c
66decode_to_md5.SRCS += md5_utils.h md5_utils.c
67decode_to_md5.GUID = 59120B9B-2735-4BFE-B022-146CA340FE42
68decode_to_md5.DESCRIPTION = Frame by frame MD5 checksum
69
70GEN_EXAMPLES-$(CONFIG_ENCODERS) += simple_encoder.c
71simple_encoder.GUID = 4607D299-8A71-4D2C-9B1D-071899B6FBFD
72simple_encoder.DESCRIPTION = Simplified encoder loop
73GEN_EXAMPLES-$(CONFIG_ENCODERS) += twopass_encoder.c
74twopass_encoder.GUID = 73494FA6-4AF9-4763-8FBB-265C92402FD8
75twopass_encoder.DESCRIPTION = Two-pass encoder loop
76GEN_EXAMPLES-$(CONFIG_ENCODERS) += force_keyframe.c
77force_keyframe.GUID = 3C67CADF-029F-4C86-81F5-D6D4F51177F0
78force_keyframe.DESCRIPTION = Force generation of keyframes
79ifeq ($(CONFIG_DECODERS),yes)
80GEN_EXAMPLES-$(CONFIG_ENCODERS) += decode_with_drops.c
81endif
82decode_with_drops.GUID = CE5C53C4-8DDA-438A-86ED-0DDD3CDB8D26
83decode_with_drops.DESCRIPTION = Drops frames while decoding
Stefan Holmerd04f8522011-05-02 15:30:51 +020084ifeq ($(CONFIG_DECODERS),yes)
85GEN_EXAMPLES-$(CONFIG_ERROR_CONCEALMENT) += decode_with_partial_drops.c
86endif
87decode_with_partial_drops.GUID = 61C2D026-5754-46AC-916F-1343ECC5537E
88decode_with_partial_drops.DESCRIPTION = Drops parts of frames while decoding
John Koleszar0ea50ce2010-05-18 11:58:33 -040089GEN_EXAMPLES-$(CONFIG_ENCODERS) += error_resilient.c
90error_resilient.GUID = DF5837B9-4145-4F92-A031-44E4F832E00C
91error_resilient.DESCRIPTION = Error Resiliency Feature
92
John Koleszar0ea50ce2010-05-18 11:58:33 -040093GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += vp8_set_maps.c
94vp8_set_maps.GUID = ECB2D24D-98B8-4015-A465-A4AF3DCC145F
95vp8_set_maps.DESCRIPTION = VP8 set active and ROI maps
96GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += vp8cx_set_ref.c
97vp8cx_set_ref.GUID = C5E31F7F-96F6-48BD-BD3E-10EBF6E8057A
98vp8cx_set_ref.DESCRIPTION = VP8 set encoder reference frame
99
Yunqing Wangaa7335e2011-10-25 15:14:16 -0400100# C file is provided, not generated automatically.
Attila Nagyef8ba4f2012-05-03 13:06:19 +0300101UTILS-$(CONFIG_MULTI_RES_ENCODING) += vp8_multi_resolution_encoder.c
Yunqing Wangaa7335e2011-10-25 15:14:16 -0400102vp8_multi_resolution_encoder.SRCS \
103 += third_party/libyuv/include/libyuv/basic_types.h \
104 third_party/libyuv/include/libyuv/cpu_id.h \
105 third_party/libyuv/include/libyuv/scale.h \
John Koleszar09080d42011-12-22 10:26:45 -0800106 third_party/libyuv/source/row.h \
Yunqing Wangaa7335e2011-10-25 15:14:16 -0400107 third_party/libyuv/source/scale.c \
108 third_party/libyuv/source/cpu_id.c
109vp8_multi_resolution_encoder.GUID = 04f8738e-63c8-423b-90fa-7c2703a374de
110vp8_multi_resolution_encoder.DESCRIPTION = VP8 Multiple-resolution Encoding
John Koleszar0ea50ce2010-05-18 11:58:33 -0400111
112# Handle extra library flags depending on codec configuration
John Koleszar0ea50ce2010-05-18 11:58:33 -0400113
Tero Rintaluoma11a222f2011-01-24 11:21:40 +0200114# We should not link to math library (libm) on RVCT
115# when building for bare-metal targets
116ifeq ($(CONFIG_OS_SUPPORT), yes)
117CODEC_EXTRA_LIBS-$(CONFIG_VP8) += m
118else
119 ifeq ($(CONFIG_GCC), yes)
120 CODEC_EXTRA_LIBS-$(CONFIG_VP8) += m
121 endif
122endif
John Koleszar0ea50ce2010-05-18 11:58:33 -0400123#
124# End of specified files. The rest of the build rules should happen
125# automagically from here.
126#
127
128
129# Examples need different flags based on whether we're building
130# from an installed tree or a version controlled tree. Determine
131# the proper paths.
132ifeq ($(HAVE_ALT_TREE_LAYOUT),yes)
133 LIB_PATH := $(SRC_PATH_BARE)/../lib
134 INC_PATH := $(SRC_PATH_BARE)/../include
135else
136 LIB_PATH-yes += $(if $(BUILD_PFX),$(BUILD_PFX),.)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400137 INC_PATH-$(CONFIG_VP8_DECODER) += $(SRC_PATH_BARE)/vp8
138 INC_PATH-$(CONFIG_VP8_ENCODER) += $(SRC_PATH_BARE)/vp8
139 LIB_PATH := $(call enabled,LIB_PATH)
140 INC_PATH := $(call enabled,INC_PATH)
141endif
Ronald S. Bultjebbf890f2011-05-02 13:56:41 -0400142INTERNAL_CFLAGS = $(addprefix -I,$(INC_PATH))
143INTERNAL_LDFLAGS += $(addprefix -L,$(LIB_PATH))
John Koleszar0ea50ce2010-05-18 11:58:33 -0400144
145
146# Expand list of selected examples to build (as specified above)
147UTILS = $(call enabled,UTILS)
148GEN_EXAMPLES = $(call enabled,GEN_EXAMPLES)
149ALL_EXAMPLES = $(UTILS) $(GEN_EXAMPLES)
John Koleszaree8bcb12010-05-24 10:16:44 -0400150UTIL_SRCS = $(foreach ex,$(UTILS),$($(ex:.c=).SRCS))
John Koleszar0ea50ce2010-05-18 11:58:33 -0400151ALL_SRCS = $(foreach ex,$(ALL_EXAMPLES),$($(ex:.c=).SRCS))
152CODEC_EXTRA_LIBS=$(sort $(call enabled,CODEC_EXTRA_LIBS))
153
154
155# Expand all example sources into a variable containing all sources
156# for that example (not just them main one specified in UTILS/GEN_EXAMPLES)
157# and add this file to the list (for MSVS workspace generation)
158$(foreach ex,$(ALL_EXAMPLES),$(eval $(ex:.c=).SRCS += $(ex) examples.mk))
159
160
161# If this is a universal (fat) binary, then all the subarchitectures have
162# already been built and our job is to stitch them together. The
163# BUILD_OBJS variable indicates whether we should be building
164# (compiling, linking) the library. The LIPO_OBJS variable indicates
165# that we're stitching.
166$(eval $(if $(filter universal%,$(TOOLCHAIN)),LIPO_OBJS,BUILD_OBJS):=yes)
167
168
169# Create build/install dependencies for all examples. The common case
170# is handled here. The MSVS case is handled below.
171NOT_MSVS = $(if $(CONFIG_MSVS),,yes)
KO Myung-Hun2dad8d62012-02-03 13:31:11 +0900172DIST-BINS-$(NOT_MSVS) += $(addprefix bin/,$(ALL_EXAMPLES:.c=$(EXE_SFX)))
173INSTALL-BINS-$(NOT_MSVS) += $(addprefix bin/,$(UTILS:.c=$(EXE_SFX)))
John Koleszaree8bcb12010-05-24 10:16:44 -0400174DIST-SRCS-yes += $(ALL_SRCS)
175INSTALL-SRCS-yes += $(UTIL_SRCS)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400176OBJS-$(NOT_MSVS) += $(if $(BUILD_OBJS),$(call objs,$(ALL_SRCS)))
KO Myung-Hun2dad8d62012-02-03 13:31:11 +0900177BINS-$(NOT_MSVS) += $(addprefix $(BUILD_PFX),$(ALL_EXAMPLES:.c=$(EXE_SFX)))
John Koleszar0ea50ce2010-05-18 11:58:33 -0400178
179
180# Instantiate linker template for all examples.
181CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx)
James Zern495b2412011-07-25 15:40:36 -0700182CODEC_LIB_SUF=$(if $(CONFIG_SHARED),.so,.a)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400183$(foreach bin,$(BINS-yes),\
James Zern495b2412011-07-25 15:40:36 -0700184 $(if $(BUILD_OBJS),$(eval $(bin):\
185 $(LIB_PATH)/lib$(CODEC_LIB)$(CODEC_LIB_SUF)))\
John Koleszar0ea50ce2010-05-18 11:58:33 -0400186 $(if $(BUILD_OBJS),$(eval $(call linker_template,$(bin),\
KO Myung-Hun2dad8d62012-02-03 13:31:11 +0900187 $(call objs,$($(notdir $(bin:$(EXE_SFX)=)).SRCS)) \
John Koleszar0ea50ce2010-05-18 11:58:33 -0400188 -l$(CODEC_LIB) $(addprefix -l,$(CODEC_EXTRA_LIBS))\
189 )))\
190 $(if $(LIPO_OBJS),$(eval $(call lipo_bin_template,$(bin))))\
191 )
192
193
194# Rules to generate the GEN_EXAMPLES sources
195.PRECIOUS: %.c
196CLEAN-OBJS += $(GEN_EXAMPLES)
197%.c: examples/%.txt
198 @echo " [EXAMPLE] $@"
199 @$(SRC_PATH_BARE)/examples/gen_example_code.sh $< > $@
200
201
202# The following pairs define a mapping of locations in the distribution
203# tree to locations in the source/build trees.
204INSTALL_MAPS += src/%.c %.c
205INSTALL_MAPS += src/% $(SRC_PATH_BARE)/%
206INSTALL_MAPS += bin/% %
207INSTALL_MAPS += % %
208
209
210# Set up additional MSVS environment
211ifeq ($(CONFIG_MSVS),yes)
212CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd)
213# This variable uses deferred expansion intentionally, since the results of
214# $(wildcard) may change during the course of the Make.
215VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))
216INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),bin/$(p)/% $(p)/Release/%)
217endif
218
219# Build Visual Studio Projects. We use a template here to instantiate
220# explicit rules rather than using an implicit rule because we want to
221# leverage make's VPATH searching rather than specifying the paths on
222# each file in ALL_EXAMPLES. This has the unfortunate side effect that
223# touching the source files trigger a rebuild of the project files
224# even though there is no real dependency there (the dependency is on
225# the makefiles). We may want to revisit this.
226define vcproj_template
227$(1): $($(1:.vcproj=).SRCS)
228 @echo " [vcproj] $$@"
229 $$(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh\
230 --exe\
231 --target=$$(TOOLCHAIN)\
232 --name=$$(@:.vcproj=)\
233 --ver=$$(CONFIG_VS_VERSION)\
234 --proj-guid=$$($$(@:.vcproj=).GUID)\
235 $$(if $$(CONFIG_STATIC_MSVCRT),--static-crt) \
Ronald S. Bultjebbf890f2011-05-02 13:56:41 -0400236 --out=$$@ $$(INTERNAL_CFLAGS) $$(CFLAGS) \
237 $$(INTERNAL_LDFLAGS) $$(LDFLAGS) -l$$(CODEC_LIB) -lwinmm $$^
John Koleszar0ea50ce2010-05-18 11:58:33 -0400238endef
239PROJECTS-$(CONFIG_MSVS) += $(ALL_EXAMPLES:.c=.vcproj)
240INSTALL-BINS-$(CONFIG_MSVS) += $(foreach p,$(VS_PLATFORMS),\
241 $(addprefix bin/$(p)/,$(ALL_EXAMPLES:.c=.exe)))
242$(foreach proj,$(call enabled,PROJECTS),\
243 $(eval $(call vcproj_template,$(proj))))
244
245
246
247#
248# Documentation Rules
249#
250%.dox: examples/%.txt
251 @echo " [DOXY] $@"
252 @$(SRC_PATH_BARE)/examples/gen_example_text.sh $< | \
253 $(SRC_PATH_BARE)/examples/gen_example_doxy.php \
254 example_$(@:.dox=) $(@:.dox=.c) > $@
255
256%.dox: %.c
257 @echo " [DOXY] $@"
258 @echo "/*!\page example_$(@:.dox=) $(@:.dox=)" > $@
259 @echo " \includelineno $(notdir $<)" >> $@
260 @echo "*/" >> $@
261
262samples.dox: examples.mk
263 @echo " [DOXY] $@"
264 @echo "/*!\page samples Sample Code" > $@
265 @echo " This SDK includes a number of sample applications."\
266 "each sample documents a feature of the SDK in both prose"\
267 "and the associated C code. In general, later samples"\
268 "build upon prior samples, so it is best to work through the"\
269 "list in order. The following samples are included: ">>$@
270 @$(foreach ex,$(GEN_EXAMPLES:.c=),\
271 echo " - \subpage example_$(ex) $($(ex).DESCRIPTION)" >> $@;)
272 @echo >> $@
273 @echo " In addition, the SDK contains a number of utilities."\
274 "Since these utilities are built upon the concepts described"\
275 "in the sample code listed above, they are not documented in"\
276 "pieces like the samples are. Thir sourcre is included here"\
277 "for reference. The following utilities are included:" >> $@
278 @$(foreach ex,$(UTILS:.c=),\
279 echo " - \subpage example_$(ex) $($(ex).DESCRIPTION)" >> $@;)
280 @echo "*/" >> $@
281
282CLEAN-OBJS += examples.doxy samples.dox $(ALL_EXAMPLES:.c=.dox)
283DOCS-yes += examples.doxy samples.dox $(ALL_EXAMPLES:.c=.dox)
284examples.doxy: samples.dox $(ALL_EXAMPLES:.c=.dox)
285 @echo "INPUT += $^" > $@