1## 2## Copyright (c) 2010 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 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. 15UTILS-$(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 20vpxdec.SRCS += tools_common.c tools_common.h 21vpxdec.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 32vpxenc.SRCS += tools_common.c tools_common.h 33vpxenc.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 46CLEAN-OBJS += ivfenc{.c.o,.c.d,.dox,.exe,} 47CLEAN-OBJS += ivfdec{.c.o,.c.d,.dox,.exe,} 48endif 49 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 54 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 80GEN_EXAMPLES-$(CONFIG_ENCODERS) += error_resilient.c 81error_resilient.GUID = DF5837B9-4145-4F92-A031-44E4F832E00C 82error_resilient.DESCRIPTION = Error Resiliency Feature 83 84GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += vp8_scalable_patterns.c 85vp8_scalable_patterns.GUID = 0D6A210B-F482-4D6F-8570-4A9C01ACC88C 86vp8_scalable_patterns.DESCRIPTION = VP8 Scalable Bitstream Patterns 87GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += vp8_set_maps.c 88vp8_set_maps.GUID = ECB2D24D-98B8-4015-A465-A4AF3DCC145F 89vp8_set_maps.DESCRIPTION = VP8 set active and ROI maps 90GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += vp8cx_set_ref.c 91vp8cx_set_ref.GUID = C5E31F7F-96F6-48BD-BD3E-10EBF6E8057A 92vp8cx_set_ref.DESCRIPTION = VP8 set encoder reference frame 93 94 95# Handle extra library flags depending on codec configuration 96 97# We should not link to math library (libm) on RVCT 98# when building for bare-metal targets 99ifeq ($(CONFIG_OS_SUPPORT), yes) 100CODEC_EXTRA_LIBS-$(CONFIG_VP8) += m 101else 102 ifeq ($(CONFIG_GCC), yes) 103 CODEC_EXTRA_LIBS-$(CONFIG_VP8) += m 104 endif 105endif 106# 107# End of specified files. The rest of the build rules should happen 108# automagically from here. 109# 110 111 112# Examples need different flags based on whether we're building 113# from an installed tree or a version controlled tree. Determine 114# the proper paths. 115ifeq ($(HAVE_ALT_TREE_LAYOUT),yes) 116 LIB_PATH := $(SRC_PATH_BARE)/../lib 117 INC_PATH := $(SRC_PATH_BARE)/../include 118else 119 LIB_PATH-yes += $(if $(BUILD_PFX),$(BUILD_PFX),.) 120 INC_PATH-$(CONFIG_VP8_DECODER) += $(SRC_PATH_BARE)/vp8 121 INC_PATH-$(CONFIG_VP8_ENCODER) += $(SRC_PATH_BARE)/vp8 122 LIB_PATH := $(call enabled,LIB_PATH) 123 INC_PATH := $(call enabled,INC_PATH) 124endif 125CFLAGS += $(addprefix -I,$(INC_PATH)) 126LDFLAGS += $(addprefix -L,$(LIB_PATH)) 127 128 129# Expand list of selected examples to build (as specified above) 130UTILS = $(call enabled,UTILS) 131GEN_EXAMPLES = $(call enabled,GEN_EXAMPLES) 132ALL_EXAMPLES = $(UTILS) $(GEN_EXAMPLES) 133UTIL_SRCS = $(foreach ex,$(UTILS),$($(ex:.c=).SRCS)) 134ALL_SRCS = $(foreach ex,$(ALL_EXAMPLES),$($(ex:.c=).SRCS)) 135CODEC_EXTRA_LIBS=$(sort $(call enabled,CODEC_EXTRA_LIBS)) 136 137 138# Expand all example sources into a variable containing all sources 139# for that example (not just them main one specified in UTILS/GEN_EXAMPLES) 140# and add this file to the list (for MSVS workspace generation) 141$(foreach ex,$(ALL_EXAMPLES),$(eval $(ex:.c=).SRCS += $(ex) examples.mk)) 142 143 144# If this is a universal (fat) binary, then all the subarchitectures have 145# already been built and our job is to stitch them together. The 146# BUILD_OBJS variable indicates whether we should be building 147# (compiling, linking) the library. The LIPO_OBJS variable indicates 148# that we're stitching. 149$(eval $(if $(filter universal%,$(TOOLCHAIN)),LIPO_OBJS,BUILD_OBJS):=yes) 150 151 152# Create build/install dependencies for all examples. The common case 153# is handled here. The MSVS case is handled below. 154NOT_MSVS = $(if $(CONFIG_MSVS),,yes) 155DIST-BINS-$(NOT_MSVS) += $(addprefix bin/,$(ALL_EXAMPLES:.c=)) 156INSTALL-BINS-$(NOT_MSVS) += $(addprefix bin/,$(UTILS:.c=)) 157DIST-SRCS-yes += $(ALL_SRCS) 158INSTALL-SRCS-yes += $(UTIL_SRCS) 159OBJS-$(NOT_MSVS) += $(if $(BUILD_OBJS),$(call objs,$(ALL_SRCS))) 160BINS-$(NOT_MSVS) += $(addprefix $(BUILD_PFX),$(ALL_EXAMPLES:.c=)) 161 162 163# Instantiate linker template for all examples. 164CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx) 165$(foreach bin,$(BINS-yes),\ 166 $(if $(BUILD_OBJS),$(eval $(bin): $(LIB_PATH)/lib$(CODEC_LIB).a))\ 167 $(if $(BUILD_OBJS),$(eval $(call linker_template,$(bin),\ 168 $(call objs,$($(notdir $(bin)).SRCS)) \ 169 -l$(CODEC_LIB) $(addprefix -l,$(CODEC_EXTRA_LIBS))\ 170 )))\ 171 $(if $(LIPO_OBJS),$(eval $(call lipo_bin_template,$(bin))))\ 172 ) 173 174 175# Rules to generate the GEN_EXAMPLES sources 176.PRECIOUS: %.c 177CLEAN-OBJS += $(GEN_EXAMPLES) 178%.c: examples/%.txt 179 @echo " [EXAMPLE] $@" 180 @$(SRC_PATH_BARE)/examples/gen_example_code.sh $< > $@ 181 182 183# The following pairs define a mapping of locations in the distribution 184# tree to locations in the source/build trees. 185INSTALL_MAPS += src/%.c %.c 186INSTALL_MAPS += src/% $(SRC_PATH_BARE)/% 187INSTALL_MAPS += bin/% % 188INSTALL_MAPS += % % 189 190 191# Set up additional MSVS environment 192ifeq ($(CONFIG_MSVS),yes) 193CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd) 194# This variable uses deferred expansion intentionally, since the results of 195# $(wildcard) may change during the course of the Make. 196VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d)))) 197INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),bin/$(p)/% $(p)/Release/%) 198endif 199 200# Build Visual Studio Projects. We use a template here to instantiate 201# explicit rules rather than using an implicit rule because we want to 202# leverage make's VPATH searching rather than specifying the paths on 203# each file in ALL_EXAMPLES. This has the unfortunate side effect that 204# touching the source files trigger a rebuild of the project files 205# even though there is no real dependency there (the dependency is on 206# the makefiles). We may want to revisit this. 207define vcproj_template 208$(1): $($(1:.vcproj=).SRCS) 209 @echo " [vcproj] $$@" 210 $$(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh\ 211 --exe\ 212 --target=$$(TOOLCHAIN)\ 213 --name=$$(@:.vcproj=)\ 214 --ver=$$(CONFIG_VS_VERSION)\ 215 --proj-guid=$$($$(@:.vcproj=).GUID)\ 216 $$(if $$(CONFIG_STATIC_MSVCRT),--static-crt) \ 217 --out=$$@ $$(CFLAGS) $$(LDFLAGS) -l$$(CODEC_LIB) -lwinmm $$^ 218endef 219PROJECTS-$(CONFIG_MSVS) += $(ALL_EXAMPLES:.c=.vcproj) 220INSTALL-BINS-$(CONFIG_MSVS) += $(foreach p,$(VS_PLATFORMS),\ 221 $(addprefix bin/$(p)/,$(ALL_EXAMPLES:.c=.exe))) 222$(foreach proj,$(call enabled,PROJECTS),\ 223 $(eval $(call vcproj_template,$(proj)))) 224 225 226 227# 228# Documentation Rules 229# 230%.dox: examples/%.txt 231 @echo " [DOXY] $@" 232 @$(SRC_PATH_BARE)/examples/gen_example_text.sh $< | \ 233 $(SRC_PATH_BARE)/examples/gen_example_doxy.php \ 234 example_$(@:.dox=) $(@:.dox=.c) > $@ 235 236%.dox: %.c 237 @echo " [DOXY] $@" 238 @echo "/*!\page example_$(@:.dox=) $(@:.dox=)" > $@ 239 @echo " \includelineno $(notdir $<)" >> $@ 240 @echo "*/" >> $@ 241 242samples.dox: examples.mk 243 @echo " [DOXY] $@" 244 @echo "/*!\page samples Sample Code" > $@ 245 @echo " This SDK includes a number of sample applications."\ 246 "each sample documents a feature of the SDK in both prose"\ 247 "and the associated C code. In general, later samples"\ 248 "build upon prior samples, so it is best to work through the"\ 249 "list in order. The following samples are included: ">>$@ 250 @$(foreach ex,$(GEN_EXAMPLES:.c=),\ 251 echo " - \subpage example_$(ex) $($(ex).DESCRIPTION)" >> $@;) 252 @echo >> $@ 253 @echo " In addition, the SDK contains a number of utilities."\ 254 "Since these utilities are built upon the concepts described"\ 255 "in the sample code listed above, they are not documented in"\ 256 "pieces like the samples are. Thir sourcre is included here"\ 257 "for reference. The following utilities are included:" >> $@ 258 @$(foreach ex,$(UTILS:.c=),\ 259 echo " - \subpage example_$(ex) $($(ex).DESCRIPTION)" >> $@;) 260 @echo "*/" >> $@ 261 262CLEAN-OBJS += examples.doxy samples.dox $(ALL_EXAMPLES:.c=.dox) 263DOCS-yes += examples.doxy samples.dox $(ALL_EXAMPLES:.c=.dox) 264examples.doxy: samples.dox $(ALL_EXAMPLES:.c=.dox) 265 @echo "INPUT += $^" > $@ 266