libs.mk 20.3 KB
Newer Older
John Koleszar's avatar
John Koleszar committed
1
##
2
##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
John Koleszar's avatar
John Koleszar committed
3
##
4
##  Use of this source code is governed by a BSD-style license
5 6
##  that can be found in the LICENSE file in the root of the source
##  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.
John Koleszar's avatar
John Koleszar committed
9 10 11
##


Johann's avatar
Johann committed
12 13 14
# ARM assembly files are written in RVCT-style. We use some make magic to
# filter those files to allow GCC compilation
ifeq ($(ARCH_ARM),yes)
15
  ASM:=$(if $(filter yes,$(CONFIG_GCC)$(CONFIG_MSVS)),.asm.s,.asm)
Johann's avatar
Johann committed
16 17 18
else
  ASM:=.asm
endif
John Koleszar's avatar
John Koleszar committed
19

20 21 22 23 24 25
#
# Rule to generate runtime cpu detection files
#
define rtcd_h_template
$$(BUILD_PFX)$(1).h: $$(SRC_PATH_BARE)/$(2)
	@echo "    [CREATE] $$@"
James Zern's avatar
James Zern committed
26
	$$(qexec)$$(SRC_PATH_BARE)/build/make/rtcd.pl --arch=$$(TGT_ISA) \
27
          --sym=$(1) \
28
          --config=$$(CONFIG_DIR)$$(target)-$$(TOOLCHAIN).mk \
29 30 31 32
          $$(RTCD_OPTIONS) $$^ > $$@
CLEAN-OBJS += $$(BUILD_PFX)$(1).h
RTCD += $$(BUILD_PFX)$(1).h
endef
33

Johann's avatar
Johann committed
34
CODEC_SRCS-yes += CHANGELOG
35 36
CODEC_SRCS-yes += libs.mk

Adrian Grange's avatar
Adrian Grange committed
37
include $(SRC_PATH_BARE)/aom/aom_codec.mk
Yaowu Xu's avatar
Yaowu Xu committed
38 39
CODEC_SRCS-yes += $(addprefix aom/,$(call enabled,API_SRCS))
CODEC_DOC_SRCS += $(addprefix aom/,$(call enabled,API_DOC_SRCS))
John Koleszar's avatar
John Koleszar committed
40

Adrian Grange's avatar
Adrian Grange committed
41
include $(SRC_PATH_BARE)/aom_mem/aom_mem.mk
Yaowu Xu's avatar
Yaowu Xu committed
42
CODEC_SRCS-yes += $(addprefix aom_mem/,$(call enabled,MEM_SRCS))
John Koleszar's avatar
John Koleszar committed
43

Adrian Grange's avatar
Adrian Grange committed
44
include $(SRC_PATH_BARE)/aom_scale/aom_scale.mk
Yaowu Xu's avatar
Yaowu Xu committed
45
CODEC_SRCS-yes += $(addprefix aom_scale/,$(call enabled,SCALE_SRCS))
John Koleszar's avatar
John Koleszar committed
46

Adrian Grange's avatar
Adrian Grange committed
47
include $(SRC_PATH_BARE)/aom_ports/aom_ports.mk
Yaowu Xu's avatar
Yaowu Xu committed
48
CODEC_SRCS-yes += $(addprefix aom_ports/,$(call enabled,PORTS_SRCS))
Johann's avatar
Johann committed
49

Adrian Grange's avatar
Adrian Grange committed
50
include $(SRC_PATH_BARE)/aom_dsp/aom_dsp.mk
Yaowu Xu's avatar
Yaowu Xu committed
51
CODEC_SRCS-yes += $(addprefix aom_dsp/,$(call enabled,DSP_SRCS))
Johann's avatar
Johann committed
52

Adrian Grange's avatar
Adrian Grange committed
53
include $(SRC_PATH_BARE)/aom_util/aom_util.mk
Yaowu Xu's avatar
Yaowu Xu committed
54
CODEC_SRCS-yes += $(addprefix aom_util/,$(call enabled,UTIL_SRCS))
55

56 57 58 59
#  AV1 make file
ifeq ($(CONFIG_AV1),yes)
  AV1_PREFIX=av1/
  include $(SRC_PATH_BARE)/$(AV1_PREFIX)av1_common.mk
Jingning Han's avatar
Jingning Han committed
60 61
endif

62 63 64 65 66 67
ifeq ($(CONFIG_AV1_ENCODER),yes)
  AV1_PREFIX=av1/
  include $(SRC_PATH_BARE)/$(AV1_PREFIX)av1_cx.mk
  CODEC_SRCS-yes += $(addprefix $(AV1_PREFIX),$(call enabled,AV1_CX_SRCS))
  CODEC_EXPORTS-yes += $(addprefix $(AV1_PREFIX),$(AV1_CX_EXPORTS))
  CODEC_SRCS-yes += $(AV1_PREFIX)av1_cx.mk aom/vp8.h aom/vp8cx.h
Yaowu Xu's avatar
Yaowu Xu committed
68 69
  INSTALL-LIBS-yes += include/aom/vp8.h include/aom/vp8cx.h
  INSTALL-LIBS-$(CONFIG_SPATIAL_SVC) += include/aom/svc_context.h
70
  INSTALL_MAPS += include/aom/% $(SRC_PATH_BARE)/$(AV1_PREFIX)/%
Yaowu Xu's avatar
Yaowu Xu committed
71
  CODEC_DOC_SRCS += aom/vp8.h aom/vp8cx.h
72
  CODEC_DOC_SECTIONS += av1 av1_encoder
Jingning Han's avatar
Jingning Han committed
73 74
endif

75 76 77 78 79 80
ifeq ($(CONFIG_AV1_DECODER),yes)
  AV1_PREFIX=av1/
  include $(SRC_PATH_BARE)/$(AV1_PREFIX)av1_dx.mk
  CODEC_SRCS-yes += $(addprefix $(AV1_PREFIX),$(call enabled,AV1_DX_SRCS))
  CODEC_EXPORTS-yes += $(addprefix $(AV1_PREFIX),$(AV1_DX_EXPORTS))
  CODEC_SRCS-yes += $(AV1_PREFIX)av1_dx.mk aom/vp8.h aom/vp8dx.h
Yaowu Xu's avatar
Yaowu Xu committed
81
  INSTALL-LIBS-yes += include/aom/vp8.h include/aom/vp8dx.h
82
  INSTALL_MAPS += include/aom/% $(SRC_PATH_BARE)/$(AV1_PREFIX)/%
Yaowu Xu's avatar
Yaowu Xu committed
83
  CODEC_DOC_SRCS += aom/vp8.h aom/vp8dx.h
84
  CODEC_DOC_SECTIONS += av1 av1_decoder
Jingning Han's avatar
Jingning Han committed
85 86
endif

87 88
AV1_PREFIX=av1/
$(BUILD_PFX)$(AV1_PREFIX)%.c.o: CFLAGS += -Wextra
Jingning Han's avatar
Jingning Han committed
89

John Koleszar's avatar
John Koleszar committed
90 91 92 93 94 95 96 97 98
ifeq ($(CONFIG_ENCODERS),yes)
  CODEC_DOC_SECTIONS += encoder
endif
ifeq ($(CONFIG_DECODERS),yes)
  CODEC_DOC_SECTIONS += decoder
endif


ifeq ($(CONFIG_MSVS),yes)
Adrian Grange's avatar
Adrian Grange committed
99
CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),aommt,aommd)
100
GTEST_LIB=$(if $(CONFIG_STATIC_MSVCRT),gtestmt,gtestmd)
John Koleszar's avatar
John Koleszar committed
101 102 103 104 105 106 107
# This variable uses deferred expansion intentionally, since the results of
# $(wildcard) may change during the course of the Make.
VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))
endif

# The following pairs define a mapping of locations in the distribution
# tree to locations in the source/build trees.
Yaowu Xu's avatar
Yaowu Xu committed
108 109
INSTALL_MAPS += include/aom/% $(SRC_PATH_BARE)/aom/%
INSTALL_MAPS += include/aom/% $(SRC_PATH_BARE)/aom_ports/%
110
INSTALL_MAPS += $(LIBSUBDIR)/%     %
John Koleszar's avatar
John Koleszar committed
111 112
INSTALL_MAPS += src/%     $(SRC_PATH_BARE)/%
ifeq ($(CONFIG_MSVS),yes)
113 114
INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/%  $(p)/Release/%)
INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/%  $(p)/Debug/%)
John Koleszar's avatar
John Koleszar committed
115 116
endif

117 118
CODEC_SRCS-yes += build/make/version.sh
CODEC_SRCS-yes += build/make/rtcd.pl
Yaowu Xu's avatar
Yaowu Xu committed
119 120 121
CODEC_SRCS-yes += aom_ports/emmintrin_compat.h
CODEC_SRCS-yes += aom_ports/mem_ops.h
CODEC_SRCS-yes += aom_ports/mem_ops_aligned.h
Adrian Grange's avatar
Adrian Grange committed
122 123 124
CODEC_SRCS-yes += aom_ports/aom_once.h
CODEC_SRCS-yes += $(BUILD_PFX)aom_config.c
INSTALL-SRCS-no += $(BUILD_PFX)aom_config.c
125
ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
126
INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += third_party/x86inc/x86inc.asm
127
endif
Yaowu Xu's avatar
Yaowu Xu committed
128 129 130 131
CODEC_EXPORTS-yes += aom/exports_com
CODEC_EXPORTS-$(CONFIG_ENCODERS) += aom/exports_enc
CODEC_EXPORTS-$(CONFIG_DECODERS) += aom/exports_dec

Adrian Grange's avatar
Adrian Grange committed
132 133 134 135 136 137
INSTALL-LIBS-yes += include/aom/aom_codec.h
INSTALL-LIBS-yes += include/aom/aom_frame_buffer.h
INSTALL-LIBS-yes += include/aom/aom_image.h
INSTALL-LIBS-yes += include/aom/aom_integer.h
INSTALL-LIBS-$(CONFIG_DECODERS) += include/aom/aom_decoder.h
INSTALL-LIBS-$(CONFIG_ENCODERS) += include/aom/aom_encoder.h
John Koleszar's avatar
John Koleszar committed
138 139
ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
ifeq ($(CONFIG_MSVS),yes)
140 141
INSTALL-LIBS-yes                  += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB).lib)
INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB)d.lib)
Adrian Grange's avatar
Adrian Grange committed
142 143
INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/aom.dll)
INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/aom.exp)
John Koleszar's avatar
John Koleszar committed
144 145
endif
else
Yaowu Xu's avatar
Yaowu Xu committed
146 147
INSTALL-LIBS-$(CONFIG_STATIC) += $(LIBSUBDIR)/libaom.a
INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(LIBSUBDIR)/libaom_g.a
John Koleszar's avatar
John Koleszar committed
148 149
endif

150
CODEC_SRCS=$(call enabled,CODEC_SRCS)
John Koleszar's avatar
John Koleszar committed
151 152 153
INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(CODEC_SRCS)
INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS)

154 155 156

# Generate a list of all enabled sources, in particular for exporting to gyp
# based build systems.
Yaowu Xu's avatar
Yaowu Xu committed
157
libaom_srcs.txt:
158
	@echo "    [CREATE] $@"
159
	@echo $(CODEC_SRCS) | xargs -n1 echo | LC_ALL=C sort -u > $@
Yaowu Xu's avatar
Yaowu Xu committed
160
CLEAN-OBJS += libaom_srcs.txt
161 162


John Koleszar's avatar
John Koleszar committed
163 164 165
ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
ifeq ($(CONFIG_MSVS),yes)

Adrian Grange's avatar
Adrian Grange committed
166
aom.def: $(call enabled,CODEC_EXPORTS)
John Koleszar's avatar
John Koleszar committed
167
	@echo "    [CREATE] $@"
168
	$(qexec)$(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\
Adrian Grange's avatar
Adrian Grange committed
169
            --name=aom\
John Koleszar's avatar
John Koleszar committed
170
            --out=$@ $^
Adrian Grange's avatar
Adrian Grange committed
171
CLEAN-OBJS += aom.def
John Koleszar's avatar
John Koleszar committed
172

173 174 175 176
# Assembly files that are included, but don't define symbols themselves.
# Filtered out to avoid Visual Studio build warnings.
ASM_INCLUDES := \
    third_party/x86inc/x86inc.asm \
Adrian Grange's avatar
Adrian Grange committed
177 178
    aom_config.asm \
    aom_ports/x86_abi_support.asm \
179

Adrian Grange's avatar
Adrian Grange committed
180
aom.$(VCPROJ_SFX): $(CODEC_SRCS) aom.def
John Koleszar's avatar
John Koleszar committed
181
	@echo "    [CREATE] $@"
182
	$(qexec)$(GEN_VCPROJ) \
Jim Bankoski's avatar
Jim Bankoski committed
183 184
            $(if $(CONFIG_SHARED),--dll,--lib) \
            --target=$(TOOLCHAIN) \
John Koleszar's avatar
John Koleszar committed
185
            $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
Adrian Grange's avatar
Adrian Grange committed
186
            --name=aom \
Johann's avatar
Johann committed
187
            --proj-guid=DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74 \
Adrian Grange's avatar
Adrian Grange committed
188
            --module-def=aom.def \
Johann's avatar
Johann committed
189
            --ver=$(CONFIG_VS_VERSION) \
190
            --src-path-bare="$(SRC_PATH_BARE)" \
191 192
            --out=$@ $(CFLAGS) \
            $(filter-out $(addprefix %, $(ASM_INCLUDES)), $^) \
Johann's avatar
Johann committed
193
            --src-path-bare="$(SRC_PATH_BARE)" \
John Koleszar's avatar
John Koleszar committed
194

Adrian Grange's avatar
Adrian Grange committed
195
PROJECTS-yes += aom.$(VCPROJ_SFX)
John Koleszar's avatar
John Koleszar committed
196

Adrian Grange's avatar
Adrian Grange committed
197 198
aom.$(VCPROJ_SFX): aom_config.asm
aom.$(VCPROJ_SFX): $(RTCD)
John Koleszar's avatar
John Koleszar committed
199 200 201

endif
else
Yaowu Xu's avatar
Yaowu Xu committed
202 203 204 205
LIBAOM_OBJS=$(call objs,$(CODEC_SRCS))
OBJS-yes += $(LIBAOM_OBJS)
LIBS-$(if yes,$(CONFIG_STATIC)) += $(BUILD_PFX)libaom.a $(BUILD_PFX)libaom_g.a
$(BUILD_PFX)libaom_g.a: $(LIBAOM_OBJS)
John Koleszar's avatar
John Koleszar committed
206

Johann's avatar
Johann committed
207
SO_VERSION_MAJOR := 3
208 209
SO_VERSION_MINOR := 0
SO_VERSION_PATCH := 0
jimbankoski's avatar
jimbankoski committed
210
ifeq ($(filter darwin%,$(TGT_OS)),$(TGT_OS))
Yaowu Xu's avatar
Yaowu Xu committed
211
LIBAOM_SO               := libaom.$(SO_VERSION_MAJOR).dylib
212
SHARED_LIB_SUF          := .dylib
Yaowu Xu's avatar
Yaowu Xu committed
213 214 215
EXPORT_FILE             := libaom.syms
LIBAOM_SO_SYMLINKS      := $(addprefix $(LIBSUBDIR)/, \
                             libaom.dylib  )
jimbankoski's avatar
jimbankoski committed
216
else
217
ifeq ($(filter os2%,$(TGT_OS)),$(TGT_OS))
Yaowu Xu's avatar
Yaowu Xu committed
218
LIBAOM_SO               := libaom$(SO_VERSION_MAJOR).dll
219
SHARED_LIB_SUF          := _dll.a
Yaowu Xu's avatar
Yaowu Xu committed
220 221 222
EXPORT_FILE             := libaom.def
LIBAOM_SO_SYMLINKS      :=
LIBAOM_SO_IMPLIB        := libaom_dll.a
223
else
Yaowu Xu's avatar
Yaowu Xu committed
224
LIBAOM_SO               := libaom.so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR).$(SO_VERSION_PATCH)
225
SHARED_LIB_SUF          := .so
Yaowu Xu's avatar
Yaowu Xu committed
226 227 228 229
EXPORT_FILE             := libaom.ver
LIBAOM_SO_SYMLINKS      := $(addprefix $(LIBSUBDIR)/, \
                             libaom.so libaom.so.$(SO_VERSION_MAJOR) \
                             libaom.so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR))
jimbankoski's avatar
jimbankoski committed
230
endif
231
endif
jimbankoski's avatar
jimbankoski committed
232

Yaowu Xu's avatar
Yaowu Xu committed
233 234 235 236 237 238 239
LIBS-$(CONFIG_SHARED) += $(BUILD_PFX)$(LIBAOM_SO)\
                           $(notdir $(LIBAOM_SO_SYMLINKS)) \
                           $(if $(LIBAOM_SO_IMPLIB), $(BUILD_PFX)$(LIBAOM_SO_IMPLIB))
$(BUILD_PFX)$(LIBAOM_SO): $(LIBAOM_OBJS) $(EXPORT_FILE)
$(BUILD_PFX)$(LIBAOM_SO): extralibs += -lm
$(BUILD_PFX)$(LIBAOM_SO): SONAME = libaom.so.$(SO_VERSION_MAJOR)
$(BUILD_PFX)$(LIBAOM_SO): EXPORTS_FILE = $(EXPORT_FILE)
John Koleszar's avatar
John Koleszar committed
240

Yaowu Xu's avatar
Yaowu Xu committed
241
libaom.ver: $(call enabled,CODEC_EXPORTS)
John Koleszar's avatar
John Koleszar committed
242 243 244 245
	@echo "    [CREATE] $@"
	$(qexec)echo "{ global:" > $@
	$(qexec)for f in $?; do awk '{print $$2";"}' < $$f >>$@; done
	$(qexec)echo "local: *; };" >> $@
Yaowu Xu's avatar
Yaowu Xu committed
246
CLEAN-OBJS += libaom.ver
John Koleszar's avatar
John Koleszar committed
247

Yaowu Xu's avatar
Yaowu Xu committed
248
libaom.syms: $(call enabled,CODEC_EXPORTS)
jimbankoski's avatar
jimbankoski committed
249 250
	@echo "    [CREATE] $@"
	$(qexec)awk '{print "_"$$2}' $^ >$@
Yaowu Xu's avatar
Yaowu Xu committed
251
CLEAN-OBJS += libaom.syms
jimbankoski's avatar
jimbankoski committed
252

Yaowu Xu's avatar
Yaowu Xu committed
253
libaom.def: $(call enabled,CODEC_EXPORTS)
254
	@echo "    [CREATE] $@"
Yaowu Xu's avatar
Yaowu Xu committed
255
	$(qexec)echo LIBRARY $(LIBAOM_SO:.dll=) INITINSTANCE TERMINSTANCE > $@
256 257
	$(qexec)echo "DATA MULTIPLE NONSHARED" >> $@
	$(qexec)echo "EXPORTS" >> $@
Adrian Grange's avatar
Adrian Grange committed
258
	$(qexec)awk '!/aom_svc_*/ {print "_"$$2}' $^ >>$@
Yaowu Xu's avatar
Yaowu Xu committed
259
CLEAN-OBJS += libaom.def
260

Yaowu Xu's avatar
Yaowu Xu committed
261
libaom_dll.a: $(LIBAOM_SO)
262 263
	@echo "    [IMPLIB] $@"
	$(qexec)emximp -o $@ $<
Yaowu Xu's avatar
Yaowu Xu committed
264
CLEAN-OBJS += libaom_dll.a
265

Yaowu Xu's avatar
Yaowu Xu committed
266
define libaom_symlink_template
267
$(1): $(2)
jimbankoski's avatar
jimbankoski committed
268
	@echo "    [LN]     $(2) $$@"
269
	$(qexec)mkdir -p $$(dir $$@)
jimbankoski's avatar
jimbankoski committed
270
	$(qexec)ln -sf $(2) $$@
271 272
endef

Yaowu Xu's avatar
Yaowu Xu committed
273 274 275 276 277 278
$(eval $(call libaom_symlink_template,\
    $(addprefix $(BUILD_PFX),$(notdir $(LIBAOM_SO_SYMLINKS))),\
    $(BUILD_PFX)$(LIBAOM_SO)))
$(eval $(call libaom_symlink_template,\
    $(addprefix $(DIST_DIR)/,$(LIBAOM_SO_SYMLINKS)),\
    $(LIBAOM_SO)))
John Koleszar's avatar
John Koleszar committed
279

jimbankoski's avatar
jimbankoski committed
280

Yaowu Xu's avatar
Yaowu Xu committed
281 282 283
INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBAOM_SO_SYMLINKS)
INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBSUBDIR)/$(LIBAOM_SO)
INSTALL-LIBS-$(CONFIG_SHARED) += $(if $(LIBAOM_SO_IMPLIB),$(LIBSUBDIR)/$(LIBAOM_SO_IMPLIB))
John Koleszar's avatar
John Koleszar committed
284

285

Adrian Grange's avatar
Adrian Grange committed
286 287
LIBS-yes += aom.pc
aom.pc: config.mk libs.mk
288
	@echo "    [CREATE] $@"
Yaowu Xu's avatar
Yaowu Xu committed
289
	$(qexec)echo '# pkg-config file from libaom $(VERSION_STRING)' > $@
290 291
	$(qexec)echo 'prefix=$(PREFIX)' >> $@
	$(qexec)echo 'exec_prefix=$${prefix}' >> $@
Takanori MATSUURA's avatar
Takanori MATSUURA committed
292
	$(qexec)echo 'libdir=$${prefix}/$(LIBSUBDIR)' >> $@
293 294
	$(qexec)echo 'includedir=$${prefix}/include' >> $@
	$(qexec)echo '' >> $@
Adrian Grange's avatar
Adrian Grange committed
295
	$(qexec)echo 'Name: aom' >> $@
296 297 298 299
	$(qexec)echo 'Description: WebM Project VPx codec implementation' >> $@
	$(qexec)echo 'Version: $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)' >> $@
	$(qexec)echo 'Requires:' >> $@
	$(qexec)echo 'Conflicts:' >> $@
Yaowu Xu's avatar
Yaowu Xu committed
300
	$(qexec)echo 'Libs: -L$${libdir} -laom -lm' >> $@
Johann's avatar
Johann committed
301
ifeq ($(HAVE_PTHREAD_H),yes)
302
	$(qexec)echo 'Libs.private: -lm -lpthread' >> $@
Johann's avatar
Johann committed
303 304 305
else
	$(qexec)echo 'Libs.private: -lm' >> $@
endif
306
	$(qexec)echo 'Cflags: -I$${includedir}' >> $@
Adrian Grange's avatar
Adrian Grange committed
307
INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/aom.pc
308
INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc
Adrian Grange's avatar
Adrian Grange committed
309
CLEAN-OBJS += aom.pc
John Koleszar's avatar
John Koleszar committed
310 311 312 313 314 315 316
endif

#
# Rule to make assembler configuration file from C configuration file
#
ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
# YASM
Adrian Grange's avatar
Adrian Grange committed
317
$(BUILD_PFX)aom_config.asm: $(BUILD_PFX)aom_config.h
John Koleszar's avatar
John Koleszar committed
318 319 320 321 322
	@echo "    [CREATE] $@"
	@egrep "#define [A-Z0-9_]+ [01]" $< \
	    | awk '{print $$2 " equ " $$3}' > $@
else
ADS2GAS=$(if $(filter yes,$(CONFIG_GCC)),| $(ASM_CONVERSION))
Adrian Grange's avatar
Adrian Grange committed
323
$(BUILD_PFX)aom_config.asm: $(BUILD_PFX)aom_config.h
John Koleszar's avatar
John Koleszar committed
324 325 326 327
	@echo "    [CREATE] $@"
	@egrep "#define [A-Z0-9_]+ [01]" $< \
	    | awk '{print $$2 " EQU " $$3}' $(ADS2GAS) > $@
	@echo "        END" $(ADS2GAS) >> $@
Adrian Grange's avatar
Adrian Grange committed
328
CLEAN-OBJS += $(BUILD_PFX)aom_config.asm
John Koleszar's avatar
John Koleszar committed
329 330 331
endif

#
Johann's avatar
Johann committed
332
# Add assembler dependencies for configuration.
John Koleszar's avatar
John Koleszar committed
333
#
Adrian Grange's avatar
Adrian Grange committed
334 335
$(filter %.s.o,$(OBJS-yes)):     $(BUILD_PFX)aom_config.asm
$(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)aom_config.asm
John Koleszar's avatar
John Koleszar committed
336

Johann's avatar
Johann committed
337

Adrian Grange's avatar
Adrian Grange committed
338 339
$(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)aom_version.h)
CLEAN-OBJS += $(BUILD_PFX)aom_version.h
John Koleszar's avatar
John Koleszar committed
340

John Koleszar's avatar
John Koleszar committed
341

342
##
Yaowu Xu's avatar
Yaowu Xu committed
343
## libaom test directives
344 345
##
ifeq ($(CONFIG_UNIT_TESTS),yes)
Adrian Grange's avatar
Adrian Grange committed
346
LIBAOM_TEST_DATA_PATH ?= .
347 348

include $(SRC_PATH_BARE)/test/test.mk
Yaowu Xu's avatar
Yaowu Xu committed
349 350 351 352
LIBAOM_TEST_SRCS=$(addprefix test/,$(call enabled,LIBAOM_TEST_SRCS))
LIBAOM_TEST_BIN=./test_libaom$(EXE_SFX)
LIBAOM_TEST_DATA=$(addprefix $(LIBAOM_TEST_DATA_PATH)/,\
                     $(call enabled,LIBAOM_TEST_DATA))
Adrian Grange's avatar
Adrian Grange committed
353
libaom_test_data_url=http://downloads.webmproject.org/test_data/libvpx/$(1)
354

James Zern's avatar
James Zern committed
355 356
TEST_INTRA_PRED_SPEED_BIN=./test_intra_pred_speed$(EXE_SFX)
TEST_INTRA_PRED_SPEED_SRCS=$(addprefix test/,$(call enabled,TEST_INTRA_PRED_SPEED_SRCS))
357
TEST_INTRA_PRED_SPEED_OBJS := $(sort $(call objs,$(TEST_INTRA_PRED_SPEED_SRCS)))
James Zern's avatar
James Zern committed
358

Yaowu Xu's avatar
Yaowu Xu committed
359
libaom_test_srcs.txt:
360
	@echo "    [CREATE] $@"
Yaowu Xu's avatar
Yaowu Xu committed
361 362
	@echo $(LIBAOM_TEST_SRCS) | xargs -n1 echo | LC_ALL=C sort -u > $@
CLEAN-OBJS += libaom_test_srcs.txt
363

Yaowu Xu's avatar
Yaowu Xu committed
364
$(LIBAOM_TEST_DATA): $(SRC_PATH_BARE)/test/test-data.sha1
365 366
	@echo "    [DOWNLOAD] $@"
	$(qexec)trap 'rm -f $@' INT TERM &&\
Yaowu Xu's avatar
Yaowu Xu committed
367
            curl -L -o $@ $(call libaom_test_data_url,$(@F))
368

Yaowu Xu's avatar
Yaowu Xu committed
369
testdata:: $(LIBAOM_TEST_DATA)
370 371 372 373
	$(qexec)[ -x "$$(which sha1sum)" ] && sha1sum=sha1sum;\
          [ -x "$$(which shasum)" ] && sha1sum=shasum;\
          [ -x "$$(which sha1)" ] && sha1sum=sha1;\
          if [ -n "$${sha1sum}" ]; then\
374
            set -e;\
375
            echo "Checking test data:";\
Yaowu Xu's avatar
Yaowu Xu committed
376
            for f in $(call enabled,LIBAOM_TEST_DATA); do\
377
                grep $$f $(SRC_PATH_BARE)/test/test-data.sha1 |\
Adrian Grange's avatar
Adrian Grange committed
378
                    (cd $(LIBAOM_TEST_DATA_PATH); $${sha1sum} -c);\
379
            done; \
380 381 382
        else\
            echo "Skipping test data integrity check, sha1sum not found.";\
        fi
383

384 385 386
ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
ifeq ($(CONFIG_MSVS),yes)

387
gtest.$(VCPROJ_SFX): $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc
388
	@echo "    [CREATE] $@"
389
	$(qexec)$(GEN_VCPROJ) \
390 391 392 393 394 395 396
            --lib \
            --target=$(TOOLCHAIN) \
            $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
            --name=gtest \
            --proj-guid=EC00E1EC-AF68-4D92-A255-181690D1C9B1 \
            --ver=$(CONFIG_VS_VERSION) \
            --src-path-bare="$(SRC_PATH_BARE)" \
397
            -D_VARIADIC_MAX=10 \
398
            --out=gtest.$(VCPROJ_SFX) $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc \
399 400
            -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" -I"$(SRC_PATH_BARE)/third_party/googletest/src"

401
PROJECTS-$(CONFIG_MSVS) += gtest.$(VCPROJ_SFX)
402

Adrian Grange's avatar
Adrian Grange committed
403
test_libaom.$(VCPROJ_SFX): $(LIBAOM_TEST_SRCS) aom.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX)
404
	@echo "    [CREATE] $@"
405
	$(qexec)$(GEN_VCPROJ) \
406 407
            --exe \
            --target=$(TOOLCHAIN) \
Yaowu Xu's avatar
Yaowu Xu committed
408
            --name=test_libaom \
409
            -D_VARIADIC_MAX=10 \
410 411
            --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \
            --ver=$(CONFIG_VS_VERSION) \
412
            --src-path-bare="$(SRC_PATH_BARE)" \
413 414
            $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
            --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \
415
            -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
Martin Storsjo's avatar
Martin Storsjo committed
416
            -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^
417

Yaowu Xu's avatar
Yaowu Xu committed
418
PROJECTS-$(CONFIG_MSVS) += test_libaom.$(VCPROJ_SFX)
419

Yaowu Xu's avatar
Yaowu Xu committed
420
LIBAOM_TEST_BIN := $(addprefix $(TGT_OS:win64=x64)/Release/,$(notdir $(LIBAOM_TEST_BIN)))
James Zern's avatar
James Zern committed
421 422 423

ifneq ($(strip $(TEST_INTRA_PRED_SPEED_OBJS)),)
PROJECTS-$(CONFIG_MSVS) += test_intra_pred_speed.$(VCPROJ_SFX)
Adrian Grange's avatar
Adrian Grange committed
424
test_intra_pred_speed.$(VCPROJ_SFX): $(TEST_INTRA_PRED_SPEED_SRCS) aom.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX)
James Zern's avatar
James Zern committed
425 426 427 428 429 430 431 432 433 434 435 436 437 438
	@echo "    [CREATE] $@"
	$(qexec)$(GEN_VCPROJ) \
            --exe \
            --target=$(TOOLCHAIN) \
            --name=test_intra_pred_speed \
            -D_VARIADIC_MAX=10 \
            --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \
            --ver=$(CONFIG_VS_VERSION) \
            --src-path-bare="$(SRC_PATH_BARE)" \
            $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
            --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \
            -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
            -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^
endif  # TEST_INTRA_PRED_SPEED
439 440 441 442 443 444
endif
else

include $(SRC_PATH_BARE)/third_party/googletest/gtest.mk
GTEST_SRCS := $(addprefix third_party/googletest/src/,$(call enabled,GTEST_SRCS))
GTEST_OBJS=$(call objs,$(GTEST_SRCS))
445 446 447 448
ifeq ($(filter win%,$(TGT_OS)),$(TGT_OS))
# Disabling pthreads globally will cause issues on darwin and possibly elsewhere
$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -DGTEST_HAS_PTHREAD=0
endif
James Zern's avatar
James Zern committed
449 450 451
GTEST_INCLUDES := -I$(SRC_PATH_BARE)/third_party/googletest/src
GTEST_INCLUDES += -I$(SRC_PATH_BARE)/third_party/googletest/src/include
$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += $(GTEST_INCLUDES)
452 453
OBJS-yes += $(GTEST_OBJS)
LIBS-yes += $(BUILD_PFX)libgtest.a $(BUILD_PFX)libgtest_g.a
454 455
$(BUILD_PFX)libgtest_g.a: $(GTEST_OBJS)

Yaowu Xu's avatar
Yaowu Xu committed
456 457 458 459
LIBAOM_TEST_OBJS=$(sort $(call objs,$(LIBAOM_TEST_SRCS)))
$(LIBAOM_TEST_OBJS) $(LIBAOM_TEST_OBJS:.o=.d): CXXFLAGS += $(GTEST_INCLUDES)
OBJS-yes += $(LIBAOM_TEST_OBJS)
BINS-yes += $(LIBAOM_TEST_BIN)
460

Yaowu Xu's avatar
Yaowu Xu committed
461
CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),aom_g,aom)
462
CODEC_LIB_SUF=$(if $(CONFIG_SHARED),$(SHARED_LIB_SUF),.a)
James Zern's avatar
James Zern committed
463
TEST_LIBS := lib$(CODEC_LIB)$(CODEC_LIB_SUF) libgtest.a
Yaowu Xu's avatar
Yaowu Xu committed
464 465 466
$(LIBAOM_TEST_BIN): $(TEST_LIBS)
$(eval $(call linkerxx_template,$(LIBAOM_TEST_BIN), \
              $(LIBAOM_TEST_OBJS) \
Yaowu Xu's avatar
Yaowu Xu committed
467
              -L. -laom -lgtest $(extralibs) -lm))
468

James Zern's avatar
James Zern committed
469 470 471 472 473 474 475 476
ifneq ($(strip $(TEST_INTRA_PRED_SPEED_OBJS)),)
$(TEST_INTRA_PRED_SPEED_OBJS) $(TEST_INTRA_PRED_SPEED_OBJS:.o=.d): CXXFLAGS += $(GTEST_INCLUDES)
OBJS-yes += $(TEST_INTRA_PRED_SPEED_OBJS)
BINS-yes += $(TEST_INTRA_PRED_SPEED_BIN)

$(TEST_INTRA_PRED_SPEED_BIN): $(TEST_LIBS)
$(eval $(call linkerxx_template,$(TEST_INTRA_PRED_SPEED_BIN), \
              $(TEST_INTRA_PRED_SPEED_OBJS) \
Yaowu Xu's avatar
Yaowu Xu committed
477
              -L. -laom -lgtest $(extralibs) -lm))
James Zern's avatar
James Zern committed
478 479
endif  # TEST_INTRA_PRED_SPEED

480
endif  # CONFIG_UNIT_TESTS
481

Johann's avatar
Johann committed
482 483 484
# Install test sources only if codec source is included
INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(patsubst $(SRC_PATH_BARE)/%,%,\
    $(shell find $(SRC_PATH_BARE)/third_party/googletest -type f))
Yaowu Xu's avatar
Yaowu Xu committed
485
INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(LIBAOM_TEST_SRCS)
James Zern's avatar
James Zern committed
486
INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(TEST_INTRA_PRED_SPEED_SRCS)
Johann's avatar
Johann committed
487

488 489
define test_shard_template
test:: test_shard.$(1)
490
test-no-data-check:: test_shard_ndc.$(1)
Yaowu Xu's avatar
Yaowu Xu committed
491
test_shard.$(1) test_shard_ndc.$(1): $(LIBAOM_TEST_BIN)
492
	@set -e; \
493 494
	 export GTEST_SHARD_INDEX=$(1); \
	 export GTEST_TOTAL_SHARDS=$(2); \
Yaowu Xu's avatar
Yaowu Xu committed
495
	 $(LIBAOM_TEST_BIN)
496
test_shard.$(1): testdata
497 498 499 500 501 502 503
.PHONY: test_shard.$(1)
endef

NUM_SHARDS := 10
SHARDS := 0 1 2 3 4 5 6 7 8 9
$(foreach s,$(SHARDS),$(eval $(call test_shard_template,$(s),$(NUM_SHARDS))))

504 505 506 507 508
endif

##
## documentation directives
##
John Koleszar's avatar
John Koleszar committed
509 510 511 512 513 514 515 516
CLEAN-OBJS += libs.doxy
DOCS-yes += libs.doxy
libs.doxy: $(CODEC_DOC_SRCS)
	@echo "    [CREATE] $@"
	@rm -f $@
	@echo "INPUT += $^" >> $@
	@echo "INCLUDE_PATH += ." >> $@;
	@echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@
517

518
## Generate rtcd.h for all objects
519
ifeq ($(CONFIG_DEPENDENCY_TRACKING),yes)
520
$(OBJS-yes:.o=.d): $(RTCD)
521 522 523
else
$(OBJS-yes): $(RTCD)
endif
524 525

## Update the global src list
Yaowu Xu's avatar
Yaowu Xu committed
526
SRCS += $(CODEC_SRCS) $(LIBAOM_TEST_SRCS) $(GTEST_SRCS)
Tom Finegan's avatar
Tom Finegan committed
527 528

##
Adrian Grange's avatar
Adrian Grange committed
529
## aomdec/aomenc tests.
Tom Finegan's avatar
Tom Finegan committed
530 531 532 533 534 535 536 537 538 539 540
##
ifeq ($(CONFIG_UNIT_TESTS),yes)
TEST_BIN_PATH = .
ifeq ($(CONFIG_MSVS),yes)
# MSVC will build both Debug and Release configurations of tools in a
# sub directory named for the current target. Assume the user wants to
# run the Release tools, and assign TEST_BIN_PATH accordingly.
# TODO(tomfinegan): Is this adequate for ARM?
# TODO(tomfinegan): Support running the debug versions of tools?
TEST_BIN_PATH := $(addsuffix /$(TGT_OS:win64=x64)/Release, $(TEST_BIN_PATH))
endif
541
utiltest utiltest-no-data-check:
Adrian Grange's avatar
Adrian Grange committed
542
	$(qexec)$(SRC_PATH_BARE)/test/aomdec.sh \
Adrian Grange's avatar
Adrian Grange committed
543
		--test-data-path $(LIBAOM_TEST_DATA_PATH) \
Tom Finegan's avatar
Tom Finegan committed
544
		--bin-path $(TEST_BIN_PATH)
Adrian Grange's avatar
Adrian Grange committed
545
	$(qexec)$(SRC_PATH_BARE)/test/aomenc.sh \
Adrian Grange's avatar
Adrian Grange committed
546
		--test-data-path $(LIBAOM_TEST_DATA_PATH) \
Tom Finegan's avatar
Tom Finegan committed
547
		--bin-path $(TEST_BIN_PATH)
548
utiltest: testdata
Tom Finegan's avatar
Tom Finegan committed
549
else
550
utiltest utiltest-no-data-check:
Tom Finegan's avatar
Tom Finegan committed
551 552
	@echo Unit tests must be enabled to make the utiltest target.
endif
553 554 555 556 557 558 559 560 561 562 563 564 565 566 567

##
## Example tests.
##
ifeq ($(CONFIG_UNIT_TESTS),yes)
# All non-MSVC targets output example targets in a sub dir named examples.
EXAMPLES_BIN_PATH = examples
ifeq ($(CONFIG_MSVS),yes)
# MSVC will build both Debug and Release configurations of the examples in a
# sub directory named for the current target. Assume the user wants to
# run the Release tools, and assign EXAMPLES_BIN_PATH accordingly.
# TODO(tomfinegan): Is this adequate for ARM?
# TODO(tomfinegan): Support running the debug versions of tools?
EXAMPLES_BIN_PATH := $(TGT_OS:win64=x64)/Release
endif
568
exampletest exampletest-no-data-check: examples
569
	$(qexec)$(SRC_PATH_BARE)/test/examples.sh \
Adrian Grange's avatar
Adrian Grange committed
570
		--test-data-path $(LIBAOM_TEST_DATA_PATH) \
571
		--bin-path $(EXAMPLES_BIN_PATH)
572
exampletest: testdata
573
else
574
exampletest exampletest-no-data-check:
575 576
	@echo Unit tests must be enabled to make the exampletest target.
endif