Use -fno-common for mingw
[libvpx.git] / libs.mk
blob32f8a34bc1a5f442cfc226b003740dad920ce6a6
1 ##
2 ## Copyright (c) 2010 The VP8 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 ##
12 ASM:=$(if $(filter yes,$(CONFIG_GCC)),.asm.s,.asm)
14 CODEC_SRCS-yes += libs.mk
16 include $(SRC_PATH_BARE)/vpx/vpx_codec.mk
17 CODEC_SRCS-yes += $(addprefix vpx/,$(call enabled,API_SRCS))
19 include $(SRC_PATH_BARE)/vpx_mem/vpx_mem.mk
20 CODEC_SRCS-yes += $(addprefix vpx_mem/,$(call enabled,MEM_SRCS))
22 include $(SRC_PATH_BARE)/vpx_scale/vpx_scale.mk
23 CODEC_SRCS-yes += $(addprefix vpx_scale/,$(call enabled,SCALE_SRCS))
26 ifeq ($(CONFIG_VP8_ENCODER),yes)
27 VP8_PREFIX=vp8/
28 include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8cx.mk
29 CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_CX_SRCS))
30 CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_CX_EXPORTS))
31 CODEC_SRCS-yes += $(VP8_PREFIX)vp8cx.mk vpx/vp8.h vpx/vp8cx.h vpx/vp8e.h
32 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8e.h include/vpx/vp8cx.h
33 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/%
34 CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8cx.h
35 CODEC_DOC_SECTIONS += vp8 vp8_encoder
36 endif
38 ifeq ($(CONFIG_VP8_DECODER),yes)
39 VP8_PREFIX=vp8/
40 include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8dx.mk
41 CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_DX_SRCS))
42 CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_DX_EXPORTS))
43 CODEC_SRCS-yes += $(VP8_PREFIX)vp8dx.mk vpx/vp8.h vpx/vp8dx.h
44 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h
45 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/%
46 CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8dx.h
47 CODEC_DOC_SECTIONS += vp8 vp8_decoder
48 endif
51 ifeq ($(CONFIG_ENCODERS),yes)
52 CODEC_DOC_SECTIONS += encoder
53 endif
54 ifeq ($(CONFIG_DECODERS),yes)
55 CODEC_DOC_SECTIONS += decoder
56 endif
59 ifeq ($(CONFIG_MSVS),yes)
60 CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd)
61 # This variable uses deferred expansion intentionally, since the results of
62 # $(wildcard) may change during the course of the Make.
63 VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))
64 endif
66 # The following pairs define a mapping of locations in the distribution
67 # tree to locations in the source/build trees.
68 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx/%
69 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx_ports/%
70 INSTALL_MAPS += $(LIBSUBDIR)/% %
71 INSTALL_MAPS += src/% $(SRC_PATH_BARE)/%
72 ifeq ($(CONFIG_MSVS),yes)
73 INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Release/%)
74 INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Debug/%)
75 endif
77 # If this is a universal (fat) binary, then all the subarchitectures have
78 # already been built and our job is to stitch them together. The
79 # BUILD_LIBVPX variable indicates whether we should be building
80 # (compiling, linking) the library. The LIPO_LIBVPX variable indicates
81 # that we're stitching.
82 $(eval $(if $(filter universal%,$(TOOLCHAIN)),LIPO_LIBVPX,BUILD_LIBVPX):=yes)
84 CODEC_SRCS-$(BUILD_LIBVPX) += build/make/version.sh
85 CODEC_SRCS-$(BUILD_LIBVPX) += vpx/vpx_integer.h
86 CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/vpx_timer.h
87 CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/mem.h
88 CODEC_SRCS-$(BUILD_LIBVPX) += $(BUILD_PFX)vpx_config.c
89 INSTALL-SRCS-no += $(BUILD_PFX)vpx_config.c
90 ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
91 CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/emms.asm
92 CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/x86.h
93 CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/x86_abi_support.asm
94 endif
95 CODEC_SRCS-$(ARCH_ARM) += $(BUILD_PFX)vpx_config.asm
96 CODEC_EXPORTS-$(BUILD_LIBVPX) += vpx/exports_com
97 CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc
98 CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec
100 INSTALL-LIBS-yes += include/vpx/vpx_codec.h
101 INSTALL-LIBS-yes += include/vpx/vpx_image.h
102 INSTALL-LIBS-yes += include/vpx/vpx_integer.h
103 INSTALL-LIBS-yes += include/vpx/vpx_codec_impl_top.h
104 INSTALL-LIBS-yes += include/vpx/vpx_codec_impl_bottom.h
105 INSTALL-LIBS-$(CONFIG_DECODERS) += include/vpx/vpx_decoder.h
106 INSTALL-LIBS-$(CONFIG_DECODERS) += include/vpx/vpx_decoder_compat.h
107 INSTALL-LIBS-$(CONFIG_ENCODERS) += include/vpx/vpx_encoder.h
108 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
109 ifeq ($(CONFIG_MSVS),yes)
110 INSTALL-LIBS-yes += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB).lib)
111 INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB)d.lib)
112 INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.dll)
113 INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.exp)
114 endif
115 else
116 INSTALL-LIBS-yes += $(LIBSUBDIR)/libvpx.a
117 INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(LIBSUBDIR)/libvpx_g.a
118 endif
120 CODEC_SRCS=$(call enabled,CODEC_SRCS)
121 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(CODEC_SRCS)
122 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS)
124 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
125 ifeq ($(CONFIG_MSVS),yes)
127 ifeq ($(ARCH_ARM),yes)
128 ifeq ($(HAVE_ARMV5TE),yes)
129 ARM_ARCH=v5
130 endif
131 ifeq ($(HAVE_ARMV6),yes)
132 ARM_ARCH=v6
133 endif
134 obj_int_extract.vcproj: $(SRC_PATH_BARE)/build/make/obj_int_extract.c
135 @cp $(SRC_PATH_BARE)/build/arm-wince-vs8/obj_int_extract.bat .
136 @echo " [CREATE] $@"
137 $(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh\
138 --exe\
139 --target=$(TOOLCHAIN)\
140 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
141 --name=obj_int_extract\
142 --proj-guid=E1360C65-D375-4335-8057-7ED99CC3F9B2\
143 --out=$@ $^\
144 -I".";"$(SRC_PATH_BARE)"
146 PROJECTS-$(BUILD_LIBVPX) += obj_int_extract.vcproj
147 PROJECTS-$(BUILD_LIBVPX) += obj_int_extract.bat
148 endif
150 vpx.def: $(call enabled,CODEC_EXPORTS)
151 @echo " [CREATE] $@"
152 $(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\
153 --name=vpx\
154 --out=$@ $^
155 CLEAN-OBJS += vpx.def
157 vpx.vcproj: $(CODEC_SRCS) vpx.def
158 @echo " [CREATE] $@"
159 $(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh\
160 --lib\
161 --target=$(TOOLCHAIN)\
162 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
163 --name=vpx\
164 --proj-guid=DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74\
165 --module-def=vpx.def\
166 --ver=$(CONFIG_VS_VERSION)\
167 --out=$@ $(CFLAGS) $^\
169 PROJECTS-$(BUILD_LIBVPX) += vpx.vcproj
171 vpx.vcproj: vpx_config.asm
173 endif
174 else
175 LIBVPX_OBJS=$(call objs,$(CODEC_SRCS))
176 OBJS-$(BUILD_LIBVPX) += $(LIBVPX_OBJS)
177 LIBS-$(BUILD_LIBVPX) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a
178 $(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS)
180 BUILD_LIBVPX_SO := $(if $(BUILD_LIBVPX),$(CONFIG_SHARED))
181 LIBVPX_SO := libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
182 LIBS-$(BUILD_LIBVPX_SO) += $(BUILD_PFX)$(LIBVPX_SO)
183 $(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) libvpx.ver
184 $(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm -pthread
185 $(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(VERSION_MAJOR)
186 $(BUILD_PFX)$(LIBVPX_SO): SO_VERSION_SCRIPT = libvpx.ver
187 LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
188 libvpx.so libvpx.so.$(VERSION_MAJOR) \
189 libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR))
191 libvpx.ver: $(call enabled,CODEC_EXPORTS)
192 @echo " [CREATE] $@"
193 $(qexec)echo "{ global:" > $@
194 $(qexec)for f in $?; do awk '{print $$2";"}' < $$f >>$@; done
195 $(qexec)echo "local: *; };" >> $@
196 CLEAN-OBJS += libvpx.ver
198 $(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)):
199 @echo " [LN] $@"
200 $(qexec)ln -sf $(LIBVPX_SO) $@
202 INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBVPX_SO_SYMLINKS)
203 INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBSUBDIR)/$(LIBVPX_SO)
204 endif
206 LIBS-$(LIPO_LIBVPX) += libvpx.a
207 $(eval $(if $(LIPO_LIBVPX),$(call lipo_lib_template,libvpx.a)))
210 # Rule to make assembler configuration file from C configuration file
212 ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
213 # YASM
214 $(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
215 @echo " [CREATE] $@"
216 @egrep "#define [A-Z0-9_]+ [01]" $< \
217 | awk '{print $$2 " equ " $$3}' > $@
218 else
219 ADS2GAS=$(if $(filter yes,$(CONFIG_GCC)),| $(ASM_CONVERSION))
220 $(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
221 @echo " [CREATE] $@"
222 @egrep "#define [A-Z0-9_]+ [01]" $< \
223 | awk '{print $$2 " EQU " $$3}' $(ADS2GAS) > $@
224 @echo " END" $(ADS2GAS) >> $@
225 CLEAN-OBJS += $(BUILD_PFX)vpx_config.asm
226 endif
229 # Add assembler dependencies for configuration and offsets
231 #$(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm $(BUILD_PFX)vpx_asm_offsets.asm
232 $(filter %.s.o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
233 $(filter %.asm.o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
235 $(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h)
236 CLEAN-OBJS += $(BUILD_PFX)vpx_version.h
238 CODEC_DOC_SRCS += vpx/vpx_codec.h \
239 vpx/vpx_decoder.h \
240 vpx/vpx_encoder.h \
241 vpx/vpx_image.h
243 CLEAN-OBJS += libs.doxy
244 DOCS-yes += libs.doxy
245 libs.doxy: $(CODEC_DOC_SRCS)
246 @echo " [CREATE] $@"
247 @rm -f $@
248 @echo "INPUT += $^" >> $@
249 @echo "PREDEFINED = VPX_CODEC_DISABLE_COMPAT" >> $@
250 @echo "INCLUDE_PATH += ." >> $@;
251 @echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@