blob: 4ebb035d91bbdffb94ca119ed1fbf153facff073 [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
19vpxdec.SRCS += args.c args.h vpx_ports/config.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
John Koleszarea68ee02010-10-21 15:02:10 -040033vpxenc.SRCS += vpx_ports/config.h vpx_ports/mem_ops.h
34vpxenc.SRCS += vpx_ports/mem_ops_aligned.h
35vpxenc.SRCS += libmkv/EbmlIDs.h
36vpxenc.SRCS += libmkv/EbmlWriter.c
37vpxenc.SRCS += libmkv/EbmlWriter.h
38vpxenc.GUID = 548DEC74-7A15-4B2B-AFC3-AA102E7C25C1
39vpxenc.DESCRIPTION = Full featured encoder
40
41# Clean up old ivfenc, ivfdec binaries.
42ifeq ($(CONFIG_MSVS),yes)
43CLEAN-OBJS += $(foreach p,$(VS_PLATFORMS),$(p)/Release/ivfenc.exe)
44CLEAN-OBJS += $(foreach p,$(VS_PLATFORMS),$(p)/Release/ivfdec.exe)
45else
John Koleszar3427e1d2010-10-27 10:06:45 -040046CLEAN-OBJS += ivfenc{.c.o,.c.d,.dox,.exe,}
47CLEAN-OBJS += ivfdec{.c.o,.c.d,.dox,.exe,}
John Koleszarea68ee02010-10-21 15:02:10 -040048endif
John Koleszaree8bcb12010-05-24 10:16:44 -040049
50# XMA example disabled for now, not used in VP8
51#UTILS-$(CONFIG_DECODERS) += example_xma.c
52#example_xma.GUID = A955FC4A-73F1-44F7-135E-30D84D32F022
53#example_xma.DESCRIPTION = External Memory Allocation mode usage
John Koleszar0ea50ce2010-05-18 11:58:33 -040054
55GEN_EXAMPLES-$(CONFIG_DECODERS) += simple_decoder.c
56simple_decoder.GUID = D3BBF1E9-2427-450D-BBFF-B2843C1D44CC
57simple_decoder.DESCRIPTION = Simplified decoder loop
58GEN_EXAMPLES-$(CONFIG_DECODERS) += postproc.c
59postproc.GUID = 65E33355-F35E-4088-884D-3FD4905881D7
60postproc.DESCRIPTION = Decoder postprocessor control
61GEN_EXAMPLES-$(CONFIG_DECODERS) += decode_to_md5.c
62decode_to_md5.SRCS += md5_utils.h md5_utils.c
63decode_to_md5.GUID = 59120B9B-2735-4BFE-B022-146CA340FE42
64decode_to_md5.DESCRIPTION = Frame by frame MD5 checksum
65
66GEN_EXAMPLES-$(CONFIG_ENCODERS) += simple_encoder.c
67simple_encoder.GUID = 4607D299-8A71-4D2C-9B1D-071899B6FBFD
68simple_encoder.DESCRIPTION = Simplified encoder loop
69GEN_EXAMPLES-$(CONFIG_ENCODERS) += twopass_encoder.c
70twopass_encoder.GUID = 73494FA6-4AF9-4763-8FBB-265C92402FD8
71twopass_encoder.DESCRIPTION = Two-pass encoder loop
72GEN_EXAMPLES-$(CONFIG_ENCODERS) += force_keyframe.c
73force_keyframe.GUID = 3C67CADF-029F-4C86-81F5-D6D4F51177F0
74force_keyframe.DESCRIPTION = Force generation of keyframes
75ifeq ($(CONFIG_DECODERS),yes)
76GEN_EXAMPLES-$(CONFIG_ENCODERS) += decode_with_drops.c
77endif
78decode_with_drops.GUID = CE5C53C4-8DDA-438A-86ED-0DDD3CDB8D26
79decode_with_drops.DESCRIPTION = Drops frames while decoding
Stefan Holmerd04f8522011-05-02 15:30:51 +020080ifeq ($(CONFIG_DECODERS),yes)
81GEN_EXAMPLES-$(CONFIG_ERROR_CONCEALMENT) += decode_with_partial_drops.c
82endif
83decode_with_partial_drops.GUID = 61C2D026-5754-46AC-916F-1343ECC5537E
84decode_with_partial_drops.DESCRIPTION = Drops parts of frames while decoding
John Koleszar0ea50ce2010-05-18 11:58:33 -040085GEN_EXAMPLES-$(CONFIG_ENCODERS) += error_resilient.c
86error_resilient.GUID = DF5837B9-4145-4F92-A031-44E4F832E00C
87error_resilient.DESCRIPTION = Error Resiliency Feature
88
89GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += vp8_scalable_patterns.c
90vp8_scalable_patterns.GUID = 0D6A210B-F482-4D6F-8570-4A9C01ACC88C
91vp8_scalable_patterns.DESCRIPTION = VP8 Scalable Bitstream Patterns
92GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += vp8_set_maps.c
93vp8_set_maps.GUID = ECB2D24D-98B8-4015-A465-A4AF3DCC145F
94vp8_set_maps.DESCRIPTION = VP8 set active and ROI maps
95GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += vp8cx_set_ref.c
96vp8cx_set_ref.GUID = C5E31F7F-96F6-48BD-BD3E-10EBF6E8057A
97vp8cx_set_ref.DESCRIPTION = VP8 set encoder reference frame
98
99
100# Handle extra library flags depending on codec configuration
John Koleszar0ea50ce2010-05-18 11:58:33 -0400101
Tero Rintaluoma11a222f2011-01-24 11:21:40 +0200102# We should not link to math library (libm) on RVCT
103# when building for bare-metal targets
104ifeq ($(CONFIG_OS_SUPPORT), yes)
105CODEC_EXTRA_LIBS-$(CONFIG_VP8) += m
106else
107 ifeq ($(CONFIG_GCC), yes)
108 CODEC_EXTRA_LIBS-$(CONFIG_VP8) += m
109 endif
110endif
John Koleszar0ea50ce2010-05-18 11:58:33 -0400111#
112# End of specified files. The rest of the build rules should happen
113# automagically from here.
114#
115
116
117# Examples need different flags based on whether we're building
118# from an installed tree or a version controlled tree. Determine
119# the proper paths.
120ifeq ($(HAVE_ALT_TREE_LAYOUT),yes)
121 LIB_PATH := $(SRC_PATH_BARE)/../lib
122 INC_PATH := $(SRC_PATH_BARE)/../include
123else
124 LIB_PATH-yes += $(if $(BUILD_PFX),$(BUILD_PFX),.)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400125 INC_PATH-$(CONFIG_VP8_DECODER) += $(SRC_PATH_BARE)/vp8
126 INC_PATH-$(CONFIG_VP8_ENCODER) += $(SRC_PATH_BARE)/vp8
127 LIB_PATH := $(call enabled,LIB_PATH)
128 INC_PATH := $(call enabled,INC_PATH)
129endif
Ronald S. Bultjebbf890f2011-05-02 13:56:41 -0400130INTERNAL_CFLAGS = $(addprefix -I,$(INC_PATH))
131INTERNAL_LDFLAGS += $(addprefix -L,$(LIB_PATH))
John Koleszar0ea50ce2010-05-18 11:58:33 -0400132
133
134# Expand list of selected examples to build (as specified above)
135UTILS = $(call enabled,UTILS)
136GEN_EXAMPLES = $(call enabled,GEN_EXAMPLES)
137ALL_EXAMPLES = $(UTILS) $(GEN_EXAMPLES)
John Koleszaree8bcb12010-05-24 10:16:44 -0400138UTIL_SRCS = $(foreach ex,$(UTILS),$($(ex:.c=).SRCS))
John Koleszar0ea50ce2010-05-18 11:58:33 -0400139ALL_SRCS = $(foreach ex,$(ALL_EXAMPLES),$($(ex:.c=).SRCS))
140CODEC_EXTRA_LIBS=$(sort $(call enabled,CODEC_EXTRA_LIBS))
141
142
143# Expand all example sources into a variable containing all sources
144# for that example (not just them main one specified in UTILS/GEN_EXAMPLES)
145# and add this file to the list (for MSVS workspace generation)
146$(foreach ex,$(ALL_EXAMPLES),$(eval $(ex:.c=).SRCS += $(ex) examples.mk))
147
148
149# If this is a universal (fat) binary, then all the subarchitectures have
150# already been built and our job is to stitch them together. The
151# BUILD_OBJS variable indicates whether we should be building
152# (compiling, linking) the library. The LIPO_OBJS variable indicates
153# that we're stitching.
154$(eval $(if $(filter universal%,$(TOOLCHAIN)),LIPO_OBJS,BUILD_OBJS):=yes)
155
156
157# Create build/install dependencies for all examples. The common case
158# is handled here. The MSVS case is handled below.
159NOT_MSVS = $(if $(CONFIG_MSVS),,yes)
John Koleszaree8bcb12010-05-24 10:16:44 -0400160DIST-BINS-$(NOT_MSVS) += $(addprefix bin/,$(ALL_EXAMPLES:.c=))
161INSTALL-BINS-$(NOT_MSVS) += $(addprefix bin/,$(UTILS:.c=))
162DIST-SRCS-yes += $(ALL_SRCS)
163INSTALL-SRCS-yes += $(UTIL_SRCS)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400164OBJS-$(NOT_MSVS) += $(if $(BUILD_OBJS),$(call objs,$(ALL_SRCS)))
165BINS-$(NOT_MSVS) += $(addprefix $(BUILD_PFX),$(ALL_EXAMPLES:.c=))
166
167
168# Instantiate linker template for all examples.
169CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx)
James Zern495b2412011-07-25 15:40:36 -0700170CODEC_LIB_SUF=$(if $(CONFIG_SHARED),.so,.a)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400171$(foreach bin,$(BINS-yes),\
James Zern495b2412011-07-25 15:40:36 -0700172 $(if $(BUILD_OBJS),$(eval $(bin):\
173 $(LIB_PATH)/lib$(CODEC_LIB)$(CODEC_LIB_SUF)))\
John Koleszar0ea50ce2010-05-18 11:58:33 -0400174 $(if $(BUILD_OBJS),$(eval $(call linker_template,$(bin),\
175 $(call objs,$($(notdir $(bin)).SRCS)) \
176 -l$(CODEC_LIB) $(addprefix -l,$(CODEC_EXTRA_LIBS))\
177 )))\
178 $(if $(LIPO_OBJS),$(eval $(call lipo_bin_template,$(bin))))\
179 )
180
181
182# Rules to generate the GEN_EXAMPLES sources
183.PRECIOUS: %.c
184CLEAN-OBJS += $(GEN_EXAMPLES)
185%.c: examples/%.txt
186 @echo " [EXAMPLE] $@"
187 @$(SRC_PATH_BARE)/examples/gen_example_code.sh $< > $@
188
189
190# The following pairs define a mapping of locations in the distribution
191# tree to locations in the source/build trees.
192INSTALL_MAPS += src/%.c %.c
193INSTALL_MAPS += src/% $(SRC_PATH_BARE)/%
194INSTALL_MAPS += bin/% %
195INSTALL_MAPS += % %
196
197
198# Set up additional MSVS environment
199ifeq ($(CONFIG_MSVS),yes)
200CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd)
201# This variable uses deferred expansion intentionally, since the results of
202# $(wildcard) may change during the course of the Make.
203VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))
204INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),bin/$(p)/% $(p)/Release/%)
205endif
206
207# Build Visual Studio Projects. We use a template here to instantiate
208# explicit rules rather than using an implicit rule because we want to
209# leverage make's VPATH searching rather than specifying the paths on
210# each file in ALL_EXAMPLES. This has the unfortunate side effect that
211# touching the source files trigger a rebuild of the project files
212# even though there is no real dependency there (the dependency is on
213# the makefiles). We may want to revisit this.
214define vcproj_template
215$(1): $($(1:.vcproj=).SRCS)
216 @echo " [vcproj] $$@"
217 $$(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh\
218 --exe\
219 --target=$$(TOOLCHAIN)\
220 --name=$$(@:.vcproj=)\
221 --ver=$$(CONFIG_VS_VERSION)\
222 --proj-guid=$$($$(@:.vcproj=).GUID)\
223 $$(if $$(CONFIG_STATIC_MSVCRT),--static-crt) \
Ronald S. Bultjebbf890f2011-05-02 13:56:41 -0400224 --out=$$@ $$(INTERNAL_CFLAGS) $$(CFLAGS) \
225 $$(INTERNAL_LDFLAGS) $$(LDFLAGS) -l$$(CODEC_LIB) -lwinmm $$^
John Koleszar0ea50ce2010-05-18 11:58:33 -0400226endef
227PROJECTS-$(CONFIG_MSVS) += $(ALL_EXAMPLES:.c=.vcproj)
228INSTALL-BINS-$(CONFIG_MSVS) += $(foreach p,$(VS_PLATFORMS),\
229 $(addprefix bin/$(p)/,$(ALL_EXAMPLES:.c=.exe)))
230$(foreach proj,$(call enabled,PROJECTS),\
231 $(eval $(call vcproj_template,$(proj))))
232
233
234
235#
236# Documentation Rules
237#
238%.dox: examples/%.txt
239 @echo " [DOXY] $@"
240 @$(SRC_PATH_BARE)/examples/gen_example_text.sh $< | \
241 $(SRC_PATH_BARE)/examples/gen_example_doxy.php \
242 example_$(@:.dox=) $(@:.dox=.c) > $@
243
244%.dox: %.c
245 @echo " [DOXY] $@"
246 @echo "/*!\page example_$(@:.dox=) $(@:.dox=)" > $@
247 @echo " \includelineno $(notdir $<)" >> $@
248 @echo "*/" >> $@
249
250samples.dox: examples.mk
251 @echo " [DOXY] $@"
252 @echo "/*!\page samples Sample Code" > $@
253 @echo " This SDK includes a number of sample applications."\
254 "each sample documents a feature of the SDK in both prose"\
255 "and the associated C code. In general, later samples"\
256 "build upon prior samples, so it is best to work through the"\
257 "list in order. The following samples are included: ">>$@
258 @$(foreach ex,$(GEN_EXAMPLES:.c=),\
259 echo " - \subpage example_$(ex) $($(ex).DESCRIPTION)" >> $@;)
260 @echo >> $@
261 @echo " In addition, the SDK contains a number of utilities."\
262 "Since these utilities are built upon the concepts described"\
263 "in the sample code listed above, they are not documented in"\
264 "pieces like the samples are. Thir sourcre is included here"\
265 "for reference. The following utilities are included:" >> $@
266 @$(foreach ex,$(UTILS:.c=),\
267 echo " - \subpage example_$(ex) $($(ex).DESCRIPTION)" >> $@;)
268 @echo "*/" >> $@
269
270CLEAN-OBJS += examples.doxy samples.dox $(ALL_EXAMPLES:.c=.dox)
271DOCS-yes += examples.doxy samples.dox $(ALL_EXAMPLES:.c=.dox)
272examples.doxy: samples.dox $(ALL_EXAMPLES:.c=.dox)
273 @echo "INPUT += $^" > $@