2 ## Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
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.
15 # If a target wasn't specified, invoke for all enabled targets.
17 @for t in $(ALL_TARGETS); do \
18 $(MAKE) --no-print-directory target=$$t $(MAKECMDGOALS) || exit $$?;\
25 # Note: md5sum is not installed on OS X, but openssl is. Openssl may not be
26 # installed on cygwin, so we need to autodetect here.
27 md5sum := $(firstword $(wildcard \
28 $(foreach e,md5sum openssl,\
29 $(foreach p,$(subst :, ,$(PATH)),$(p)/$(e)*))\
31 md5sum := $(if $(filter %openssl,$(md5sum)),$(md5sum) dgst -md5,$(md5sum))
33 TGT_CC:=$(word 3, $(subst -, ,$(TOOLCHAIN)))
35 @for t in $(ALL_TARGETS); do \
36 $(MAKE) --no-print-directory target=$$t $(MAKECMDGOALS) || exit $$?;\
38 # Run configure for the user with the current toolchain.
39 @if [ -d "$(DIST_DIR)/src" ]; then \
40 mkdir -p "$(DIST_DIR)/build"; \
41 cd "$(DIST_DIR)/build"; \
42 if [ "$(TGT_CC)" = "rvct" ] ; then \
43 echo "../src/configure --target=$(TOOLCHAIN) --libc=$(ALT_LIBC)"; \
44 ../src/configure --target=$(TOOLCHAIN) --libc=$(ALT_LIBC); \
46 echo "../src/configure --target=$(TOOLCHAIN)"; \
47 ../src/configure --target=$(TOOLCHAIN); \
49 $(if $(filter vs%,$(TGT_CC)),make NO_LAUNCH_DEVENV=1;) \
51 @if [ -d "$(DIST_DIR)" ]; then \
52 echo " [MD5SUM] $(DIST_DIR)"; \
54 $(md5sum) `find . -name md5sums.txt -prune -o -type f -print` \
55 | sed -e 's/MD5(\(.*\))= \([0-9a-f]\{32\}\)/\2 \1/' \
60 svnstat: ALL_TARGETS:=$(firstword $(ALL_TARGETS))
64 # Normally, we want to build the filename from the target and the toolchain.
65 # This disambiguates from the $(target).mk file that exists in the source tree.
66 # However, the toolchain is part of the target in universal builds, so we
67 # don't want to include TOOLCHAIN in that case. FAT_ARCHS is used to test
68 # if we're in the universal case.
69 include $(target)$(if $(FAT_ARCHS),,-$(TOOLCHAIN)).mk
72 VPATH=$(SRC_PATH_BARE)
73 CFLAGS+=-I$(BUILD_PFX)$(BUILD_ROOT) -I$(SRC_PATH)
74 ASFLAGS+=-I$(BUILD_PFX)$(BUILD_ROOT) -I$(SRC_PATH)
77 TGT_ISA:=$(word 1, $(subst -, ,$(TOOLCHAIN)))
78 TGT_OS:=$(word 2, $(subst -, ,$(TOOLCHAIN)))
79 TGT_CC:=$(word 3, $(subst -, ,$(TOOLCHAIN)))
80 quiet:=$(if $(verbose),,yes)
81 qexec=$(if $(quiet),@)
83 # Cancel built-in implicit rules
96 rm -f $(OBJS-yes) $(OBJS-yes:.o=.d) $(OBJS-yes:.asm.s.o=.asm.s)
104 $(BUILD_PFX)%.c.d: %.c
105 $(if $(quiet),@echo " [DEP] $@")
106 $(qexec)mkdir -p $(dir $@)
107 $(qexec)$(CC) $(CFLAGS) -M $< | $(fmt_deps) > $@
109 $(BUILD_PFX)%.c.o: %.c
110 $(if $(quiet),@echo " [CC] $@")
111 $(qexec)$(CC) $(CFLAGS) -c -o $@ $<
113 $(BUILD_PFX)%.asm.d: %.asm
114 $(if $(quiet),@echo " [DEP] $@")
115 $(qexec)mkdir -p $(dir $@)
116 $(qexec)$(SRC_PATH_BARE)/build/make/gen_asm_deps.sh \
117 --build-pfx=$(BUILD_PFX) --depfile=$@ $(ASFLAGS) $< > $@
119 $(BUILD_PFX)%.asm.o: %.asm
120 $(if $(quiet),@echo " [AS] $@")
121 $(qexec)$(AS) $(ASFLAGS) -o $@ $<
123 $(BUILD_PFX)%.s.d: %.s
124 $(if $(quiet),@echo " [DEP] $@")
125 $(qexec)mkdir -p $(dir $@)
126 $(qexec)$(SRC_PATH_BARE)/build/make/gen_asm_deps.sh \
127 --build-pfx=$(BUILD_PFX) --depfile=$@ $(ASFLAGS) $< > $@
129 $(BUILD_PFX)%.s.o: %.s
130 $(if $(quiet),@echo " [AS] $@")
131 $(qexec)$(AS) $(ASFLAGS) -o $@ $<
134 $(BUILD_PFX)%.asm.s: %.asm
135 $(if $(quiet),@echo " [ASM CONVERSION] $@")
136 $(qexec)mkdir -p $(dir $@)
137 $(qexec)$(ASM_CONVERSION) <$< >$@
139 # If we're in debug mode, pretend we don't have GNU strip, to fall back to
140 # the copy implementation
141 HAVE_GNU_STRIP := $(if $(CONFIG_DEBUG),,$(HAVE_GNU_STRIP))
142 ifeq ($(HAVE_GNU_STRIP),yes)
143 # Older binutils strip global sybols not needed for relocation processing
144 # when given --strip-unneeded. Use nm and awk to identify globals and
147 $(if $(quiet),@echo " [STRIP] $@ < $<")
148 $(qexec)$(STRIP) --strip-unneeded \
149 `$(NM) $< | grep ' [A-TV-Z] ' | awk '{print "-K"$$3'}`\
153 $(if $(quiet),@echo " [CP] $@ < $<")
158 # Rule to extract assembly constants from C sources
160 obj_int_extract: build/make/obj_int_extract.c
161 $(if $(quiet),echo " [HOSTCC] $@")
162 $(qexec)$(HOSTCC) -I. -o $@ $<
163 CLEAN-OBJS += obj_int_extract
168 pairmap=$(if $(strip $(2)),\
169 $(call $(1),$(word 1,$(2)),$(word 2,$(2)))\
170 $(call pairmap,$(1),$(wordlist 3,$(words $(2)),$(2)))\
173 enabled=$(filter-out $($(1)-no),$($(1)-yes))
174 cond_enabled=$(if $(filter yes,$($(1))), $(call enabled,$(2)))
176 find_file1=$(word 1,$(wildcard $(subst //,/,$(addsuffix /$(1),$(2)))))
177 find_file=$(foreach f,$(1),$(call find_file1,$(strip $(f)),$(strip $(2))) )
178 obj_pats=.c=.c.o $(AS_SFX)=$(AS_SFX).o
179 objs=$(addprefix $(BUILD_PFX),$(foreach p,$(obj_pats),$(filter %.o,$(1:$(p))) ))
181 install_map_templates=$(eval $(call install_map_template,$(1),$(2)))
183 not=$(subst yes,no,$(1))
185 ifeq ($(CONFIG_MSVS),yes)
186 lib_file_name=$(1).lib
188 lib_file_name=lib$(1).a
193 define linker_template
194 $(1): $(filter-out -%,$(2))
196 $(if $(quiet),@echo " [LD] $$@")
197 $(qexec)$$(LD) $$(strip $$(LDFLAGS) -o $$@ $(2) $(3) $$(extralibs))
199 # make-3.80 has a bug with expanding large input strings to the eval function,
200 # which was triggered in some cases by the following component of
202 # $(1): $$(call find_file, $(patsubst -l%,lib%.a,$(filter -l%,$(2))),\
203 # $$(patsubst -L%,%,$$(filter -L%,$$(LDFLAGS) $(2))))
204 # This may be useful to revisit in the future (it tries to locate libraries
205 # in a search path and add them as prerequisites
207 define install_map_template
208 $(DIST_DIR)/$(1): $(2)
209 $(if $(quiet),@echo " [INSTALL] $$@")
210 $(qexec)mkdir -p $$(dir $$@)
211 $(qexec)cp -p $$< $$@
214 define archive_template
215 # Not using a pattern rule here because we don't want to generate empty
216 # archives when they are listed as a dependency in files not responsible
219 $(if $(quiet),@echo " [AR] $$@")
220 $(qexec)$$(AR) $$(ARFLAGS) $$@ $$?
224 # Not using a pattern rule here because we don't want to generate empty
225 # archives when they are listed as a dependency in files not responsible
228 # This needs further abstraction for dealing with non-GNU linkers.
230 $(if $(quiet),@echo " [LD] $$@")
231 $(qexec)$$(LD) -shared $$(LDFLAGS) \
232 -Wl,--no-undefined -Wl,-soname,$$(SONAME) \
233 -Wl,--version-script,$$(SO_VERSION_SCRIPT) -o $$@ \
234 $$(filter %.o,$$?) $$(extralibs)
237 define lipo_lib_template
238 $(1): $(addsuffix /$(1),$(FAT_ARCHS))
239 $(if $(quiet),@echo " [LIPO] $$@")
240 $(qexec)libtool -static -o $$@ $$?
243 define lipo_bin_template
244 $(1): $(addsuffix /$(1),$(FAT_ARCHS))
245 $(if $(quiet),@echo " [LIPO] $$@")
246 $(qexec)lipo -output $$@ -create $$?
251 # Get current configuration
254 include $(SRC_PATH_BARE)/$(target:-$(TOOLCHAIN)=).mk
256 ifeq ($(filter clean,$(MAKECMDGOALS)),)
257 # Older versions of make don't like -include directives with no arguments
258 ifneq ($(filter %.d,$(OBJS-yes:.o=.d)),)
259 -include $(filter %.d,$(OBJS-yes:.o=.d))
264 # Configuration dependant rules
266 $(call pairmap,install_map_templates,$(INSTALL_MAPS))
268 DOCS=$(call cond_enabled,CONFIG_INSTALL_DOCS,DOCS)
272 INSTALL-DOCS=$(call cond_enabled,CONFIG_INSTALL_DOCS,INSTALL-DOCS)
273 ifeq ($(MAKECMDGOALS),dist)
274 INSTALL-DOCS+=$(call cond_enabled,CONFIG_INSTALL_DOCS,DIST-DOCS)
276 .install-docs: .docs $(addprefix $(DIST_DIR)/,$(INSTALL-DOCS))
280 rm -f .docs .install-docs $(DOCS)
282 BINS=$(call enabled,BINS)
286 INSTALL-BINS=$(call cond_enabled,CONFIG_INSTALL_BINS,INSTALL-BINS)
287 ifeq ($(MAKECMDGOALS),dist)
288 INSTALL-BINS+=$(call cond_enabled,CONFIG_INSTALL_BINS,DIST-BINS)
290 .install-bins: .bins $(addprefix $(DIST_DIR)/,$(INSTALL-BINS))
294 rm -f .bins .install-bins $(BINS)
296 LIBS=$(call enabled,LIBS)
299 $(foreach lib,$(filter %_g.a,$(LIBS)),$(eval $(call archive_template,$(lib))))
300 $(foreach lib,$(filter %so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH),$(LIBS)),$(eval $(call so_template,$(lib))))
302 INSTALL-LIBS=$(call cond_enabled,CONFIG_INSTALL_LIBS,INSTALL-LIBS)
303 ifeq ($(MAKECMDGOALS),dist)
304 INSTALL-LIBS+=$(call cond_enabled,CONFIG_INSTALL_LIBS,DIST-LIBS)
306 .install-libs: .libs $(addprefix $(DIST_DIR)/,$(INSTALL-LIBS))
310 rm -f .libs .install-libs $(LIBS)
312 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
313 PROJECTS=$(call enabled,PROJECTS)
314 .projects: $(PROJECTS)
317 INSTALL-PROJECTS=$(call cond_enabled,CONFIG_INSTALL_PROJECTS,INSTALL-PROJECTS)
318 ifeq ($(MAKECMDGOALS),dist)
319 INSTALL-PROJECTS+=$(call cond_enabled,CONFIG_INSTALL_PROJECTS,DIST-PROJECTS)
321 .install-projects: .projects $(addprefix $(DIST_DIR)/,$(INSTALL-PROJECTS))
325 rm -f .projects .install-projects $(PROJECTS)
328 # If there are any source files to be distributed, then include the build
330 ifneq ($(call enabled,DIST-SRCS),)
331 DIST-SRCS-yes += configure
332 DIST-SRCS-yes += build/make/configure.sh
333 DIST-SRCS-yes += build/make/gen_asm_deps.sh
334 DIST-SRCS-yes += build/make/Makefile
335 DIST-SRCS-$(CONFIG_MSVS) += build/make/gen_msvs_def.sh
336 DIST-SRCS-$(CONFIG_MSVS) += build/make/gen_msvs_proj.sh
337 DIST-SRCS-$(CONFIG_MSVS) += build/make/gen_msvs_sln.sh
338 DIST-SRCS-$(CONFIG_RVCT) += build/make/armlink_adapter.sh
340 # This isn't really ARCH_ARM dependent, it's dependant on whether we're
341 # using assembly code or not (CONFIG_OPTIMIZATIONS maybe). Just use
343 DIST-SRCS-$(ARCH_ARM) += build/make/obj_int_extract.c
344 DIST-SRCS-$(ARCH_ARM) += build/make/ads2gas.pl
345 DIST-SRCS-yes += $(target:-$(TOOLCHAIN)=).mk
347 INSTALL-SRCS := $(call cond_enabled,CONFIG_INSTALL_SRCS,INSTALL-SRCS)
348 ifeq ($(MAKECMDGOALS),dist)
349 INSTALL-SRCS += $(call cond_enabled,CONFIG_INSTALL_SRCS,DIST-SRCS)
351 .install-srcs: $(addprefix $(DIST_DIR)/src/,$(INSTALL-SRCS))
357 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
358 BUILD_TARGETS += .projects
359 INSTALL_TARGETS += .install-projects
361 BUILD_TARGETS += .docs .libs .bins
362 INSTALL_TARGETS += .install-docs .install-srcs .install-libs .install-bins
363 all-$(target): $(BUILD_TARGETS)
364 install:: $(INSTALL_TARGETS)
365 dist: $(INSTALL_TARGETS)
368 # Development helper targets
370 ifneq ($(SRC_PATH_BARE),)
373 svn stat $(SRC_PATH_BARE)