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