blob: 26c20d433a8fd2c98744bd5df5d58302d67a6670 [file] [log] [blame]
Yue Chenc8b38b02017-01-05 11:58:32 -08001##
2## Copyright (c) 2017, Alliance for Open Media. All rights reserved
3##
4## This source code is subject to the terms of the BSD 2 Clause License and
5## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6## was not distributed with this source code in the LICENSE file, you can
7## obtain it at www.aomedia.org/license/software. If the Alliance for Open
8## Media Patent License 1.0 was not distributed with this source code in the
9## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10##
11
12# List of tools to build.
13ifeq ($(CONFIG_ENTROPY_STATS), yes)
14TOOLS-$(CONFIG_AV1_ENCODER) += aom_entropy_optimizer.c
15aom_entropy_optimizer.GUID = 3afa9b05-940b-4d68-b5aa-55157d8ed7b4
16aom_entropy_optimizer.DESCRIPTION = Offline default probability optimizer
17endif
18
19#
20# End of specified files. The rest of the build rules should happen
21# automagically from here.
22#
23
24# Tools need different flags based on whether we're building
25# from an installed tree or a version controlled tree. Determine
26# the proper paths.
27ifeq ($(HAVE_ALT_TREE_LAYOUT),yes)
28 LIB_PATH-yes := $(SRC_PATH_BARE)/../lib
29 INC_PATH-yes := $(SRC_PATH_BARE)/../include
30else
31 LIB_PATH-yes += $(if $(BUILD_PFX),$(BUILD_PFX),.)
32 INC_PATH-$(CONFIG_AV1_DECODER) += $(SRC_PATH_BARE)/av1
33 INC_PATH-$(CONFIG_AV1_ENCODER) += $(SRC_PATH_BARE)/av1
34endif
35INC_PATH-$(CONFIG_LIBYUV) += $(SRC_PATH_BARE)/third_party/libyuv/include
36LIB_PATH := $(call enabled,LIB_PATH)
37INC_PATH := $(call enabled,INC_PATH)
38INTERNAL_CFLAGS = $(addprefix -I,$(INC_PATH))
39INTERNAL_LDFLAGS += $(addprefix -L,$(LIB_PATH))
40
41# Expand list of selected tools to build (as specified above)
42TOOLS = $(addprefix tools/,$(call enabled,TOOLS))
43ALL_SRCS = $(foreach ex,$(TOOLS),$($(notdir $(ex:.c=)).SRCS))
44CFLAGS += -I../include
45CODEC_EXTRA_LIBS=$(sort $(call enabled,CODEC_EXTRA_LIBS))
46
47ifneq ($(CONFIG_CODEC_SRCS), yes)
48 CFLAGS += -I../include/vpx
49endif
50
51# Expand all tools sources into a variable containing all sources
52# for that tools (not just them main one specified in TOOLS)
53# and add this file to the list (for MSVS workspace generation)
54$(foreach ex,$(TOOLS),$(eval $(notdir $(ex:.c=)).SRCS += $(ex) tools.mk))
55
56
57# Create build/install dependencies for all tools. The common case
58# is handled here. The MSVS case is handled below.
59NOT_MSVS = $(if $(CONFIG_MSVS),,yes)
60DIST-BINS-$(NOT_MSVS) += $(addprefix bin/,$(TOOLS:.c=$(EXE_SFX)))
61DIST-SRCS-yes += $(ALL_SRCS)
62OBJS-$(NOT_MSVS) += $(call objs,$(ALL_SRCS))
63BINS-$(NOT_MSVS) += $(addprefix $(BUILD_PFX),$(TOOLS:.c=$(EXE_SFX)))
64
65# Instantiate linker template for all tools.
66ifeq ($(CONFIG_OS_SUPPORT), yes)
67CODEC_EXTRA_LIBS-$(CONFIG_AV1) += m
68else
69 ifeq ($(CONFIG_GCC), yes)
70 CODEC_EXTRA_LIBS-$(CONFIG_AV1) += m
71 endif
72endif
73
74CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),aom_g,aom)
75ifneq ($(filter darwin%,$(TGT_OS)),)
76SHARED_LIB_SUF=.dylib
77else
78ifneq ($(filter os2%,$(TGT_OS)),)
79SHARED_LIB_SUF=_dll.a
80else
81SHARED_LIB_SUF=.so
82endif
83endif
84CODEC_LIB_SUF=$(if $(CONFIG_SHARED),$(SHARED_LIB_SUF),.a)
85$(foreach bin,$(BINS-yes),\
86 $(eval $(bin):$(LIB_PATH)/lib$(CODEC_LIB)$(CODEC_LIB_SUF))\
87 $(eval $(call linker_template,$(bin),\
88 $(call objs,$($(notdir $(bin:$(EXE_SFX)=)).SRCS)) \
89 -l$(CODEC_LIB) $(addprefix -l,$(CODEC_EXTRA_LIBS))\
90 )))
91
92# The following pairs define a mapping of locations in the distribution
93# tree to locations in the source/build trees.
94INSTALL_MAPS += src/%.c %.c
95INSTALL_MAPS += src/% $(SRC_PATH_BARE)/%
96INSTALL_MAPS += bin/% %
97INSTALL_MAPS += % %
98
99
100# Build Visual Studio Projects. We use a template here to instantiate
101# explicit rules rather than using an implicit rule because we want to
102# leverage make's VPATH searching rather than specifying the paths on
103# each file in TOOLS. This has the unfortunate side effect that
104# touching the source files trigger a rebuild of the project files
105# even though there is no real dependency there (the dependency is on
106# the makefiles). We may want to revisit this.
107define vcproj_template
108$(1): $($(1:.$(VCPROJ_SFX)=).SRCS) vpx.$(VCPROJ_SFX)
109 $(if $(quiet),@echo " [vcproj] $$@")
110 $(qexec)$$(GEN_VCPROJ)\
111 --exe\
112 --target=$$(TOOLCHAIN)\
113 --name=$$(@:.$(VCPROJ_SFX)=)\
114 --ver=$$(CONFIG_VS_VERSION)\
115 --proj-guid=$$($$(@:.$(VCPROJ_SFX)=).GUID)\
116 --src-path-bare="$(SRC_PATH_BARE)" \
117 $$(if $$(CONFIG_STATIC_MSVCRT),--static-crt) \
118 --out=$$@ $$(INTERNAL_CFLAGS) $$(CFLAGS) \
119 $$(INTERNAL_LDFLAGS) $$(LDFLAGS) $$^
120endef
121TOOLS_BASENAME := $(notdir $(TOOLS))
122PROJECTS-$(CONFIG_MSVS) += $(TOOLS_BASENAME:.c=.$(VCPROJ_SFX))
123INSTALL-BINS-$(CONFIG_MSVS) += $(foreach p,$(VS_PLATFORMS),\
124 $(addprefix bin/$(p)/,$(TOOLS_BASENAME:.c=.exe)))
125$(foreach proj,$(call enabled,PROJECTS),\
126 $(eval $(call vcproj_template,$(proj))))