]> granicus.if.org Git - libvpx/blob - build/make/Makefile
Merge "vp10: merge keyframe/interframe uvintramode/partition probabilities."
[libvpx] / build / make / Makefile
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 include config.mk
13 quiet?=true
14 ifeq ($(target),)
15 # If a target wasn't specified, invoke for all enabled targets.
16 .DEFAULT:
17         @for t in $(ALL_TARGETS); do \
18              $(MAKE) --no-print-directory target=$$t $(MAKECMDGOALS) || exit $$?;\
19         done
20 all: .DEFAULT
21 clean:: .DEFAULT
22 exampletest: .DEFAULT
23 install:: .DEFAULT
24 test:: .DEFAULT
25 test-no-data-check:: .DEFAULT
26 testdata:: .DEFAULT
27 utiltest: .DEFAULT
28 exampletest-no-data-check utiltest-no-data-check: .DEFAULT
29
30
31 # Note: md5sum is not installed on OS X, but openssl is. Openssl may not be
32 # installed on cygwin, so we need to autodetect here.
33 md5sum := $(firstword $(wildcard \
34           $(foreach e,md5sum openssl,\
35           $(foreach p,$(subst :, ,$(PATH)),$(p)/$(e)*))\
36           ))
37 md5sum := $(if $(filter %openssl,$(md5sum)),$(md5sum) dgst -md5,$(md5sum))
38
39 TGT_CC:=$(word 3, $(subst -, ,$(TOOLCHAIN)))
40 dist:
41         @for t in $(ALL_TARGETS); do \
42              $(MAKE) --no-print-directory target=$$t $(MAKECMDGOALS) || exit $$?;\
43         done
44         # Run configure for the user with the current toolchain.
45         @if [ -d "$(DIST_DIR)/src" ]; then \
46             mkdir -p "$(DIST_DIR)/build"; \
47             cd "$(DIST_DIR)/build"; \
48             echo "Rerunning configure $(CONFIGURE_ARGS)"; \
49             ../src/configure $(CONFIGURE_ARGS); \
50             $(if $(filter vs%,$(TGT_CC)),make NO_LAUNCH_DEVENV=1;) \
51         fi
52         @if [ -d "$(DIST_DIR)" ]; then \
53             echo "    [MD5SUM] $(DIST_DIR)"; \
54             cd $(DIST_DIR) && \
55             $(md5sum) `find . -name md5sums.txt -prune -o -type f -print` \
56                 | sed -e 's/MD5(\(.*\))= \([0-9a-f]\{32\}\)/\2  \1/' \
57                 > md5sums.txt;\
58         fi
59 endif
60
61 # Since we invoke make recursively for multiple targets we need to include the
62 # .mk file for the correct target, but only when $(target) is non-empty.
63 ifneq ($(target),)
64 include $(target)-$(TOOLCHAIN).mk
65 endif
66 BUILD_ROOT?=.
67 VPATH=$(SRC_PATH_BARE)
68 CFLAGS+=-I$(BUILD_PFX)$(BUILD_ROOT) -I$(SRC_PATH)
69 CXXFLAGS+=-I$(BUILD_PFX)$(BUILD_ROOT) -I$(SRC_PATH)
70 ASFLAGS+=-I$(BUILD_PFX)$(BUILD_ROOT)/ -I$(SRC_PATH)/
71 DIST_DIR?=dist
72 HOSTCC?=gcc
73 TGT_ISA:=$(word 1, $(subst -, ,$(TOOLCHAIN)))
74 TGT_OS:=$(word 2, $(subst -, ,$(TOOLCHAIN)))
75 TGT_CC:=$(word 3, $(subst -, ,$(TOOLCHAIN)))
76 quiet:=$(if $(or $(verbose), $(V)),, yes)
77 qexec=$(if $(quiet),@)
78
79 # Cancel built-in implicit rules
80 %: %.o
81 %.asm:
82 %.a:
83 %: %.cc
84
85 #
86 # Common rules"
87 #
88 .PHONY: all
89 all:
90
91 .PHONY: clean
92 clean::
93         rm -f $(OBJS-yes) $(OBJS-yes:.o=.d) $(OBJS-yes:.asm.s.o=.asm.s)
94         rm -f $(CLEAN-OBJS)
95
96 .PHONY: clean
97 distclean: clean
98         if [ -z "$(target)" ]; then \
99       rm -f Makefile; \
100       rm -f config.log config.mk; \
101       rm -f vpx_config.[hc] vpx_config.asm; \
102     else \
103       rm -f $(target)-$(TOOLCHAIN).mk; \
104     fi
105
106 .PHONY: dist
107 dist:
108 .PHONY: exampletest
109 exampletest:
110 .PHONY: install
111 install::
112 .PHONY: test
113 test::
114 .PHONY: testdata
115 testdata::
116 .PHONY: utiltest
117 utiltest:
118 .PHONY: test-no-data-check exampletest-no-data-check utiltest-no-data-check
119 test-no-data-check::
120 exampletest-no-data-check utiltest-no-data-check:
121
122 # Add compiler flags for intrinsic files
123 ifeq ($(TOOLCHAIN), x86-os2-gcc)
124 STACKREALIGN=-mstackrealign
125 else
126 STACKREALIGN=
127 endif
128
129 $(BUILD_PFX)%_mmx.c.d: CFLAGS += -mmmx
130 $(BUILD_PFX)%_mmx.c.o: CFLAGS += -mmmx
131 $(BUILD_PFX)%_sse2.c.d: CFLAGS += -msse2 $(STACKREALIGN)
132 $(BUILD_PFX)%_sse2.c.o: CFLAGS += -msse2 $(STACKREALIGN)
133 $(BUILD_PFX)%_sse3.c.d: CFLAGS += -msse3 $(STACKREALIGN)
134 $(BUILD_PFX)%_sse3.c.o: CFLAGS += -msse3 $(STACKREALIGN)
135 $(BUILD_PFX)%_ssse3.c.d: CFLAGS += -mssse3 $(STACKREALIGN)
136 $(BUILD_PFX)%_ssse3.c.o: CFLAGS += -mssse3 $(STACKREALIGN)
137 $(BUILD_PFX)%_sse4.c.d: CFLAGS += -msse4.1 $(STACKREALIGN)
138 $(BUILD_PFX)%_sse4.c.o: CFLAGS += -msse4.1 $(STACKREALIGN)
139 $(BUILD_PFX)%_avx.c.d: CFLAGS += -mavx $(STACKREALIGN)
140 $(BUILD_PFX)%_avx.c.o: CFLAGS += -mavx $(STACKREALIGN)
141 $(BUILD_PFX)%_avx2.c.d: CFLAGS += -mavx2 $(STACKREALIGN)
142 $(BUILD_PFX)%_avx2.c.o: CFLAGS += -mavx2 $(STACKREALIGN)
143 $(BUILD_PFX)%vp9_reconintra.c.d: CFLAGS += $(STACKREALIGN)
144 $(BUILD_PFX)%vp9_reconintra.c.o: CFLAGS += $(STACKREALIGN)
145
146 $(BUILD_PFX)%.c.d: %.c
147         $(if $(quiet),@echo "    [DEP] $@")
148         $(qexec)mkdir -p $(dir $@)
149         $(qexec)$(CC) $(INTERNAL_CFLAGS) $(CFLAGS) -M $< | $(fmt_deps) > $@
150
151 $(BUILD_PFX)%.c.o: %.c
152         $(if $(quiet),@echo "    [CC] $@")
153         $(qexec)$(if $(CONFIG_DEPENDENCY_TRACKING),,mkdir -p $(dir $@))
154         $(qexec)$(CC) $(INTERNAL_CFLAGS) $(CFLAGS) -c -o $@ $<
155
156 $(BUILD_PFX)%.cc.d: %.cc
157         $(if $(quiet),@echo "    [DEP] $@")
158         $(qexec)mkdir -p $(dir $@)
159         $(qexec)$(CXX) $(INTERNAL_CFLAGS) $(CXXFLAGS) -M $< | $(fmt_deps) > $@
160
161 $(BUILD_PFX)%.cc.o: %.cc
162         $(if $(quiet),@echo "    [CXX] $@")
163         $(qexec)$(if $(CONFIG_DEPENDENCY_TRACKING),,mkdir -p $(dir $@))
164         $(qexec)$(CXX) $(INTERNAL_CFLAGS) $(CXXFLAGS) -c -o $@ $<
165
166 $(BUILD_PFX)%.cpp.d: %.cpp
167         $(if $(quiet),@echo "    [DEP] $@")
168         $(qexec)mkdir -p $(dir $@)
169         $(qexec)$(CXX) $(INTERNAL_CFLAGS) $(CXXFLAGS) -M $< | $(fmt_deps) > $@
170
171 $(BUILD_PFX)%.cpp.o: %.cpp
172         $(if $(quiet),@echo "    [CXX] $@")
173         $(qexec)$(if $(CONFIG_DEPENDENCY_TRACKING),,mkdir -p $(dir $@))
174         $(qexec)$(CXX) $(INTERNAL_CFLAGS) $(CXXFLAGS) -c -o $@ $<
175
176 $(BUILD_PFX)%.asm.d: %.asm
177         $(if $(quiet),@echo "    [DEP] $@")
178         $(qexec)mkdir -p $(dir $@)
179         $(qexec)$(SRC_PATH_BARE)/build/make/gen_asm_deps.sh \
180             --build-pfx=$(BUILD_PFX) --depfile=$@ $(ASFLAGS) $< > $@
181
182 $(BUILD_PFX)%.asm.o: %.asm
183         $(if $(quiet),@echo "    [AS] $@")
184         $(qexec)$(if $(CONFIG_DEPENDENCY_TRACKING),,mkdir -p $(dir $@))
185         $(qexec)$(AS) $(ASFLAGS) -o $@ $<
186
187 $(BUILD_PFX)%.s.d: %.s
188         $(if $(quiet),@echo "    [DEP] $@")
189         $(qexec)mkdir -p $(dir $@)
190         $(qexec)$(SRC_PATH_BARE)/build/make/gen_asm_deps.sh \
191             --build-pfx=$(BUILD_PFX) --depfile=$@ $(ASFLAGS) $< > $@
192
193 $(BUILD_PFX)%.s.o: %.s
194         $(if $(quiet),@echo "    [AS] $@")
195         $(qexec)$(if $(CONFIG_DEPENDENCY_TRACKING),,mkdir -p $(dir $@))
196         $(qexec)$(AS) $(ASFLAGS) -o $@ $<
197
198 .PRECIOUS: %.c.S
199 %.c.S: CFLAGS += -DINLINE_ASM
200 $(BUILD_PFX)%.c.S: %.c
201         $(if $(quiet),@echo "    [GEN] $@")
202         $(qexec)$(if $(CONFIG_DEPENDENCY_TRACKING),,mkdir -p $(dir $@))
203         $(qexec)$(CC) -S $(CFLAGS) -o $@ $<
204
205 .PRECIOUS: %.asm.s
206 $(BUILD_PFX)%.asm.s: %.asm
207         $(if $(quiet),@echo "    [ASM CONVERSION] $@")
208         $(qexec)mkdir -p $(dir $@)
209         $(qexec)$(ASM_CONVERSION) <$< >$@
210
211 # If we're in debug mode, pretend we don't have GNU strip, to fall back to
212 # the copy implementation
213 HAVE_GNU_STRIP := $(if $(CONFIG_DEBUG),,$(HAVE_GNU_STRIP))
214 ifeq ($(HAVE_GNU_STRIP),yes)
215 # Older binutils strip global symbols not needed for relocation processing
216 # when given --strip-unneeded. Using nm and awk to identify globals and
217 # keep them caused command line length issues under mingw and segfaults in
218 # test_libvpx were observed under OS/2: simply use --strip-debug.
219 %.a: %_g.a
220         $(if $(quiet),@echo "    [STRIP] $@ < $<")
221         $(qexec)$(STRIP) --strip-debug \
222           -o $@ $<
223 else
224 %.a: %_g.a
225         $(if $(quiet),@echo "    [CP] $@ < $<")
226         $(qexec)cp $< $@
227 endif
228
229 #
230 # Utility functions
231 #
232 pairmap=$(if $(strip $(2)),\
233     $(call $(1),$(word 1,$(2)),$(word 2,$(2)))\
234     $(call pairmap,$(1),$(wordlist 3,$(words $(2)),$(2)))\
235 )
236
237 enabled=$(filter-out $($(1)-no),$($(1)-yes))
238 cond_enabled=$(if $(filter yes,$($(1))), $(call enabled,$(2)))
239
240 find_file1=$(word 1,$(wildcard $(subst //,/,$(addsuffix /$(1),$(2)))))
241 find_file=$(foreach f,$(1),$(call find_file1,$(strip $(f)),$(strip $(2))) )
242 obj_pats=.c=.c.o $(AS_SFX)=$(AS_SFX).o .cc=.cc.o .cpp=.cpp.o
243 objs=$(addprefix $(BUILD_PFX),$(foreach p,$(obj_pats),$(filter %.o,$(1:$(p))) ))
244
245 install_map_templates=$(eval $(call install_map_template,$(1),$(2)))
246
247 not=$(subst yes,no,$(1))
248
249 ifeq ($(CONFIG_MSVS),yes)
250 lib_file_name=$(1).lib
251 else
252 lib_file_name=lib$(1).a
253 endif
254 #
255 # Rule Templates
256 #
257 define linker_template
258 $(1): $(filter-out -%,$(2))
259 $(1):
260         $(if $(quiet),@echo    "    [LD] $$@")
261         $(qexec)$$(LD) $$(strip $$(INTERNAL_LDFLAGS) $$(LDFLAGS) -o $$@ $(2) $(3) $$(extralibs))
262 endef
263 define linkerxx_template
264 $(1): $(filter-out -%,$(2))
265 $(1):
266         $(if $(quiet),@echo    "    [LD] $$@")
267         $(qexec)$$(CXX) $$(strip $$(INTERNAL_LDFLAGS) $$(LDFLAGS) -o $$@ $(2) $(3) $$(extralibs))
268 endef
269 # make-3.80 has a bug with expanding large input strings to the eval function,
270 # which was triggered in some cases by the following component of
271 # linker_template:
272 #   $(1): $$(call find_file, $(patsubst -l%,lib%.a,$(filter -l%,$(2))),\
273 #                           $$(patsubst -L%,%,$$(filter -L%,$$(LDFLAGS) $(2))))
274 # This may be useful to revisit in the future (it tries to locate libraries
275 # in a search path and add them as prerequisites
276
277 define install_map_template
278 $(DIST_DIR)/$(1): $(2)
279         $(if $(quiet),@echo "    [INSTALL] $$@")
280         $(qexec)mkdir -p $$(dir $$@)
281         $(qexec)cp -p $$< $$@
282 endef
283
284 define archive_template
285 # Not using a pattern rule here because we don't want to generate empty
286 # archives when they are listed as a dependency in files not responsible
287 # for creating them.
288 $(1):
289         $(if $(quiet),@echo "    [AR] $$@")
290         $(qexec)$$(AR) $$(ARFLAGS) $$@ $$^
291 endef
292
293 define so_template
294 # Not using a pattern rule here because we don't want to generate empty
295 # archives when they are listed as a dependency in files not responsible
296 # for creating them.
297 #
298 # This needs further abstraction for dealing with non-GNU linkers.
299 $(1):
300         $(if $(quiet),@echo "    [LD] $$@")
301         $(qexec)$$(LD) -shared $$(LDFLAGS) \
302             -Wl,--no-undefined -Wl,-soname,$$(SONAME) \
303             -Wl,--version-script,$$(EXPORTS_FILE) -o $$@ \
304             $$(filter %.o,$$^) $$(extralibs)
305 endef
306
307 define dl_template
308 # Not using a pattern rule here because we don't want to generate empty
309 # archives when they are listed as a dependency in files not responsible
310 # for creating them.
311 $(1):
312         $(if $(quiet),@echo "    [LD] $$@")
313         $(qexec)$$(LD) -dynamiclib $$(LDFLAGS) \
314             -exported_symbols_list $$(EXPORTS_FILE) \
315         -Wl,-headerpad_max_install_names,-compatibility_version,1.0,-current_version,$$(VERSION_MAJOR) \
316         -o $$@ \
317         $$(filter %.o,$$^) $$(extralibs)
318 endef
319
320 define dll_template
321 # Not using a pattern rule here because we don't want to generate empty
322 # archives when they are listed as a dependency in files not responsible
323 # for creating them.
324 $(1):
325         $(if $(quiet),@echo "    [LD] $$@")
326         $(qexec)$$(LD) -Zdll $$(LDFLAGS) \
327         -o $$@ \
328         $$(filter %.o,$$^) $$(extralibs) $$(EXPORTS_FILE)
329 endef
330
331
332 #
333 # Get current configuration
334 #
335 ifneq ($(target),)
336 include $(SRC_PATH_BARE)/$(target:-$(TOOLCHAIN)=).mk
337 endif
338
339 skip_deps := $(filter %clean,$(MAKECMDGOALS))
340 skip_deps += $(findstring testdata,$(MAKECMDGOALS))
341 ifeq ($(strip $(skip_deps)),)
342   ifeq ($(CONFIG_DEPENDENCY_TRACKING),yes)
343     # Older versions of make don't like -include directives with no arguments
344     ifneq ($(filter %.d,$(OBJS-yes:.o=.d)),)
345       -include $(filter %.d,$(OBJS-yes:.o=.d))
346     endif
347   endif
348 endif
349
350 #
351 # Configuration dependent rules
352 #
353 $(call pairmap,install_map_templates,$(INSTALL_MAPS))
354
355 DOCS=$(call cond_enabled,CONFIG_INSTALL_DOCS,DOCS)
356 .docs: $(DOCS)
357         @touch $@
358
359 INSTALL-DOCS=$(call cond_enabled,CONFIG_INSTALL_DOCS,INSTALL-DOCS)
360 ifeq ($(MAKECMDGOALS),dist)
361 INSTALL-DOCS+=$(call cond_enabled,CONFIG_INSTALL_DOCS,DIST-DOCS)
362 endif
363 .install-docs: .docs $(addprefix $(DIST_DIR)/,$(INSTALL-DOCS))
364         @touch $@
365
366 clean::
367         rm -f .docs .install-docs $(DOCS)
368
369 BINS=$(call enabled,BINS)
370 .bins: $(BINS)
371         @touch $@
372
373 INSTALL-BINS=$(call cond_enabled,CONFIG_INSTALL_BINS,INSTALL-BINS)
374 ifeq ($(MAKECMDGOALS),dist)
375 INSTALL-BINS+=$(call cond_enabled,CONFIG_INSTALL_BINS,DIST-BINS)
376 endif
377 .install-bins: .bins $(addprefix $(DIST_DIR)/,$(INSTALL-BINS))
378         @touch $@
379
380 clean::
381         rm -f .bins .install-bins $(BINS)
382
383 LIBS=$(call enabled,LIBS)
384 .libs: $(LIBS)
385         @touch $@
386 $(foreach lib,$(filter %_g.a,$(LIBS)),$(eval $(call archive_template,$(lib))))
387 $(foreach lib,$(filter %so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR).$(SO_VERSION_PATCH),$(LIBS)),$(eval $(call so_template,$(lib))))
388 $(foreach lib,$(filter %$(SO_VERSION_MAJOR).dylib,$(LIBS)),$(eval $(call dl_template,$(lib))))
389 $(foreach lib,$(filter %$(SO_VERSION_MAJOR).dll,$(LIBS)),$(eval $(call dll_template,$(lib))))
390
391 INSTALL-LIBS=$(call cond_enabled,CONFIG_INSTALL_LIBS,INSTALL-LIBS)
392 ifeq ($(MAKECMDGOALS),dist)
393 INSTALL-LIBS+=$(call cond_enabled,CONFIG_INSTALL_LIBS,DIST-LIBS)
394 endif
395 .install-libs: .libs $(addprefix $(DIST_DIR)/,$(INSTALL-LIBS))
396         @touch $@
397
398 clean::
399         rm -f .libs .install-libs $(LIBS)
400
401 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
402 PROJECTS=$(call enabled,PROJECTS)
403 .projects: $(PROJECTS)
404         @touch $@
405
406 INSTALL-PROJECTS=$(call cond_enabled,CONFIG_INSTALL_PROJECTS,INSTALL-PROJECTS)
407 ifeq ($(MAKECMDGOALS),dist)
408 INSTALL-PROJECTS+=$(call cond_enabled,CONFIG_INSTALL_PROJECTS,DIST-PROJECTS)
409 endif
410 .install-projects: .projects $(addprefix $(DIST_DIR)/,$(INSTALL-PROJECTS))
411         @touch $@
412
413 clean::
414         rm -f .projects .install-projects $(PROJECTS)
415 endif
416
417 # If there are any source files to be distributed, then include the build
418 # system too.
419 ifneq ($(call enabled,DIST-SRCS),)
420     DIST-SRCS-yes            += configure
421     DIST-SRCS-yes            += build/make/configure.sh
422     DIST-SRCS-yes            += build/make/gen_asm_deps.sh
423     DIST-SRCS-yes            += build/make/Makefile
424     DIST-SRCS-$(CONFIG_MSVS)  += build/make/gen_msvs_def.sh
425     DIST-SRCS-$(CONFIG_MSVS)  += build/make/gen_msvs_proj.sh
426     DIST-SRCS-$(CONFIG_MSVS)  += build/make/gen_msvs_sln.sh
427     DIST-SRCS-$(CONFIG_MSVS)  += build/make/gen_msvs_vcxproj.sh
428     DIST-SRCS-$(CONFIG_MSVS)  += build/make/msvs_common.sh
429     DIST-SRCS-$(CONFIG_RVCT) += build/make/armlink_adapter.sh
430     DIST-SRCS-$(ARCH_ARM)    += build/make/ads2gas.pl
431     DIST-SRCS-$(ARCH_ARM)    += build/make/ads2gas_apple.pl
432     DIST-SRCS-$(ARCH_ARM)    += build/make/ads2armasm_ms.pl
433     DIST-SRCS-$(ARCH_ARM)    += build/make/thumb.pm
434     DIST-SRCS-yes            += $(target:-$(TOOLCHAIN)=).mk
435 endif
436 INSTALL-SRCS := $(call cond_enabled,CONFIG_INSTALL_SRCS,INSTALL-SRCS)
437 ifeq ($(MAKECMDGOALS),dist)
438 INSTALL-SRCS += $(call cond_enabled,CONFIG_INSTALL_SRCS,DIST-SRCS)
439 endif
440 .install-srcs: $(addprefix $(DIST_DIR)/src/,$(INSTALL-SRCS))
441         @touch $@
442
443 clean::
444         rm -f .install-srcs
445
446 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
447     BUILD_TARGETS += .projects
448     INSTALL_TARGETS += .install-projects
449 endif
450 BUILD_TARGETS += .docs .libs .bins
451 INSTALL_TARGETS += .install-docs .install-srcs .install-libs .install-bins
452 all: $(BUILD_TARGETS)
453 install:: $(INSTALL_TARGETS)
454 dist: $(INSTALL_TARGETS)
455 test::