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